linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RESENT] Fix previously extX_ioctl() patches
@ 2008-01-22 13:09 Mathieu Segaud
  2008-01-22 13:09 ` [PATCH] Convert ext4_ioctl to an unlocked_ioctl Mathieu Segaud
  0 siblings, 1 reply; 7+ messages in thread
From: Mathieu Segaud @ 2008-01-22 13:09 UTC (permalink / raw)
  To: linux-ext4; +Cc: linux-kernel, akpm, sct

This two patches discards and replaces 2 previously sent patches
they convert ext3/4_ioctl()s to unlocked_ioctl's



^ permalink raw reply	[flat|nested] 7+ messages in thread
* [PATCH] Convert EXT2 to use unlocked_ioctl
@ 2008-01-17 12:37 Mathieu Segaud
  2008-01-17 12:37 ` [PATCH] Convert ext3_ioctl() to an unlocked_ioctl Mathieu Segaud
  0 siblings, 1 reply; 7+ messages in thread
From: Mathieu Segaud @ 2008-01-17 12:37 UTC (permalink / raw)
  To: linux-ext4; +Cc: linux-kernel, akpm, sct, Mathieu Segaud

Change ext_ioctl() to be an unlocked_ioctl(), explicitly
exposing BKL's uses.

Signed-off-by: Mathieu Segaud <mathieu.segaud@regala.cx>
---
 fs/ext2/dir.c   |    2 +-
 fs/ext2/ext2.h  |    3 +-
 fs/ext2/file.c  |    4 +-
 fs/ext2/ioctl.c |  103 +++++++++++++++++++++++++++++++++++++------------------
 4 files changed, 73 insertions(+), 39 deletions(-)

diff --git a/fs/ext2/dir.c b/fs/ext2/dir.c
index d868e26..dbee3c9 100644
--- a/fs/ext2/dir.c
+++ b/fs/ext2/dir.c
@@ -703,7 +703,7 @@ const struct file_operations ext2_dir_operations = {
 	.llseek		= generic_file_llseek,
 	.read		= generic_read_dir,
 	.readdir	= ext2_readdir,
-	.ioctl		= ext2_ioctl,
+	.unlocked_ioctl	= ext2_ioctl,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl	= ext2_compat_ioctl,
 #endif
diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h
index c87ae29..bb9948c 100644
--- a/fs/ext2/ext2.h
+++ b/fs/ext2/ext2.h
@@ -139,8 +139,7 @@ int __ext2_write_begin(struct file *file, struct address_space *mapping,
 		struct page **pagep, void **fsdata);
 
 /* ioctl.c */
-extern int ext2_ioctl (struct inode *, struct file *, unsigned int,
-		       unsigned long);
+extern long ext2_ioctl(struct file *, unsigned int, unsigned long);
 extern long ext2_compat_ioctl(struct file *, unsigned int, unsigned long);
 
 /* namei.c */
diff --git a/fs/ext2/file.c b/fs/ext2/file.c
index c051798..17fe628 100644
--- a/fs/ext2/file.c
+++ b/fs/ext2/file.c
@@ -48,7 +48,7 @@ const struct file_operations ext2_file_operations = {
 	.write		= do_sync_write,
 	.aio_read	= generic_file_aio_read,
 	.aio_write	= generic_file_aio_write,
-	.ioctl		= ext2_ioctl,
+	.unlocked_ioctl	= ext2_ioctl,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl	= ext2_compat_ioctl,
 #endif
@@ -65,7 +65,7 @@ const struct file_operations ext2_xip_file_operations = {
 	.llseek		= generic_file_llseek,
 	.read		= xip_file_read,
 	.write		= xip_file_write,
-	.ioctl		= ext2_ioctl,
+	.unlocked_ioctl	= ext2_ioctl,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl	= ext2_compat_ioctl,
 #endif
diff --git a/fs/ext2/ioctl.c b/fs/ext2/ioctl.c
index 320b2cb..0f18ac5 100644
--- a/fs/ext2/ioctl.c
+++ b/fs/ext2/ioctl.c
@@ -17,12 +17,18 @@
 #include <asm/uaccess.h>
 
 
-int ext2_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
+long ext2_ioctl(struct file *filp, unsigned int cmd,
 		unsigned long arg)
 {
-	struct ext2_inode_info *ei = EXT2_I(inode);
+	struct ext2_inode_info *ei;
+	struct inode *inode;
 	unsigned int flags;
 	unsigned short rsv_window_size;
+	long retval = 0;
+
+	lock_kernel();
+	inode = filp->f_path.dentry->d_inode;
+	ei = EXT2_I(inode);
 
 	ext2_debug ("cmd = %u, arg = %lu\n", cmd, arg);
 
@@ -30,18 +36,25 @@ int ext2_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
 	case EXT2_IOC_GETFLAGS:
 		ext2_get_inode_flags(ei);
 		flags = ei->i_flags & EXT2_FL_USER_VISIBLE;
-		return put_user(flags, (int __user *) arg);
+		retval = put_user(flags, (int __user *) arg);
+		goto out;
 	case EXT2_IOC_SETFLAGS: {
 		unsigned int oldflags;
 
-		if (IS_RDONLY(inode))
-			return -EROFS;
+		if (IS_RDONLY(inode)) {
+			retval = -EROFS;
+			goto out;
+		}
 
-		if (!is_owner_or_cap(inode))
-			return -EACCES;
+		if (!is_owner_or_cap(inode)) {
+			retval = -EACCES;
+			goto out;
+		}
 
-		if (get_user(flags, (int __user *) arg))
-			return -EFAULT;
+		if (get_user(flags, (int __user *) arg)) {
+			retval = -EFAULT;
+			goto out;
+		}
 
 		if (!S_ISDIR(inode->i_mode))
 			flags &= ~EXT2_DIRSYNC_FL;
@@ -50,7 +63,8 @@ int ext2_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
 		/* Is it quota file? Do not allow user to mess with it */
 		if (IS_NOQUOTA(inode)) {
 			mutex_unlock(&inode->i_mutex);
-			return -EPERM;
+			retval = -EPERM;
+			goto out;
 		}
 		oldflags = ei->i_flags;
 
@@ -63,7 +77,8 @@ int ext2_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
 		if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) {
 			if (!capable(CAP_LINUX_IMMUTABLE)) {
 				mutex_unlock(&inode->i_mutex);
-				return -EPERM;
+				retval = -EPERM;
+				goto out;
 			}
 		}
 
@@ -75,41 +90,59 @@ int ext2_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
 		ext2_set_inode_flags(inode);
 		inode->i_ctime = CURRENT_TIME_SEC;
 		mark_inode_dirty(inode);
-		return 0;
+		goto out;
 	}
 	case EXT2_IOC_GETVERSION:
-		return put_user(inode->i_generation, (int __user *) arg);
+		retval = put_user(inode->i_generation, (int __user *) arg);
+		goto out;
 	case EXT2_IOC_SETVERSION:
-		if (!is_owner_or_cap(inode))
-			return -EPERM;
-		if (IS_RDONLY(inode))
-			return -EROFS;
-		if (get_user(inode->i_generation, (int __user *) arg))
-			return -EFAULT;	
+		if (!is_owner_or_cap(inode)) {
+			retval = -EPERM;
+			goto out;
+		}
+		if (IS_RDONLY(inode)) {
+			retval = -EROFS;
+			goto out;
+		}
+		if (get_user(inode->i_generation, (int __user *) arg)) {
+			retval = -EFAULT;
+			goto out;
+		}
 		inode->i_ctime = CURRENT_TIME_SEC;
 		mark_inode_dirty(inode);
-		return 0;
+		goto out;
 	case EXT2_IOC_GETRSVSZ:
 		if (test_opt(inode->i_sb, RESERVATION)
 			&& S_ISREG(inode->i_mode)
 			&& ei->i_block_alloc_info) {
 			rsv_window_size = ei->i_block_alloc_info->rsv_window_node.rsv_goal_size;
-			return put_user(rsv_window_size, (int __user *)arg);
+			retval = put_user(rsv_window_size, (int __user *)arg);
+			goto out;
 		}
-		return -ENOTTY;
+		retval = -ENOTTY;
+		goto out;
 	case EXT2_IOC_SETRSVSZ: {
 
-		if (!test_opt(inode->i_sb, RESERVATION) ||!S_ISREG(inode->i_mode))
-			return -ENOTTY;
+		if (!test_opt(inode->i_sb, RESERVATION) ||
+				!S_ISREG(inode->i_mode)) {
+			retval = -ENOTTY;
+			goto out;
+		}
 
-		if (IS_RDONLY(inode))
-			return -EROFS;
+		if (IS_RDONLY(inode)) {
+			retval = -EROFS;
+			goto out;
+		}
 
-		if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
-			return -EACCES;
+		if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER)) {
+			retval = -EACCES;
+			goto out;
+		}
 
-		if (get_user(rsv_window_size, (int __user *)arg))
-			return -EFAULT;
+		if (get_user(rsv_window_size, (int __user *)arg)) {
+			retval = -EFAULT;
+			goto out;
+		}
 
 		if (rsv_window_size > EXT2_MAX_RESERVE_BLOCKS)
 			rsv_window_size = EXT2_MAX_RESERVE_BLOCKS;
@@ -131,11 +164,15 @@ int ext2_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
 			rsv->rsv_goal_size = rsv_window_size;
 		}
 		mutex_unlock(&ei->truncate_mutex);
-		return 0;
+		goto out;
 	}
 	default:
-		return -ENOTTY;
+		retval = -ENOTTY;
+		goto out;
 	}
+out:
+	unlock_kernel();
+	return retval;
 }
 
 #ifdef CONFIG_COMPAT
@@ -161,9 +198,7 @@ long ext2_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 	default:
 		return -ENOIOCTLCMD;
 	}
-	lock_kernel();
 	ret = ext2_ioctl(inode, file, cmd, (unsigned long) compat_ptr(arg));
-	unlock_kernel();
 	return ret;
 }
 #endif
-- 
1.5.3.8


^ permalink raw reply related	[flat|nested] 7+ messages in thread
* [PATCH] Convert EXT2 to use unlocked_ioctl
@ 2008-01-17 10:30 Mathieu Segaud
  2008-01-17 10:30 ` [PATCH] Convert ext3_ioctl() to an unlocked_ioctl Mathieu Segaud
  0 siblings, 1 reply; 7+ messages in thread
From: Mathieu Segaud @ 2008-01-17 10:30 UTC (permalink / raw)
  To: linux-ext4; +Cc: linux-kernel, akpm, sct, Mathieu Segaud

Change ext_ioctl() to be an unlocked_ioctl(), explicitly
exposing BKL's uses.

Signed-off-by: Mathieu Segaud <mathieu.segaud@regala.cx>
---
 fs/ext2/dir.c   |    2 +-
 fs/ext2/ext2.h  |    3 +-
 fs/ext2/file.c  |    4 +-
 fs/ext2/ioctl.c |  101 +++++++++++++++++++++++++++++++++++++-----------------
 4 files changed, 73 insertions(+), 37 deletions(-)

diff --git a/fs/ext2/dir.c b/fs/ext2/dir.c
index d868e26..dbee3c9 100644
--- a/fs/ext2/dir.c
+++ b/fs/ext2/dir.c
@@ -703,7 +703,7 @@ const struct file_operations ext2_dir_operations = {
 	.llseek		= generic_file_llseek,
 	.read		= generic_read_dir,
 	.readdir	= ext2_readdir,
-	.ioctl		= ext2_ioctl,
+	.unlocked_ioctl	= ext2_ioctl,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl	= ext2_compat_ioctl,
 #endif
diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h
index c87ae29..bb9948c 100644
--- a/fs/ext2/ext2.h
+++ b/fs/ext2/ext2.h
@@ -139,8 +139,7 @@ int __ext2_write_begin(struct file *file, struct address_space *mapping,
 		struct page **pagep, void **fsdata);
 
 /* ioctl.c */
-extern int ext2_ioctl (struct inode *, struct file *, unsigned int,
-		       unsigned long);
+extern long ext2_ioctl(struct file *, unsigned int, unsigned long);
 extern long ext2_compat_ioctl(struct file *, unsigned int, unsigned long);
 
 /* namei.c */
diff --git a/fs/ext2/file.c b/fs/ext2/file.c
index c051798..17fe628 100644
--- a/fs/ext2/file.c
+++ b/fs/ext2/file.c
@@ -48,7 +48,7 @@ const struct file_operations ext2_file_operations = {
 	.write		= do_sync_write,
 	.aio_read	= generic_file_aio_read,
 	.aio_write	= generic_file_aio_write,
-	.ioctl		= ext2_ioctl,
+	.unlocked_ioctl	= ext2_ioctl,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl	= ext2_compat_ioctl,
 #endif
@@ -65,7 +65,7 @@ const struct file_operations ext2_xip_file_operations = {
 	.llseek		= generic_file_llseek,
 	.read		= xip_file_read,
 	.write		= xip_file_write,
-	.ioctl		= ext2_ioctl,
+	.unlocked_ioctl	= ext2_ioctl,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl	= ext2_compat_ioctl,
 #endif
diff --git a/fs/ext2/ioctl.c b/fs/ext2/ioctl.c
index 320b2cb..02ba8e4 100644
--- a/fs/ext2/ioctl.c
+++ b/fs/ext2/ioctl.c
@@ -17,12 +17,18 @@
 #include <asm/uaccess.h>
 
 
-int ext2_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
+long ext2_ioctl(struct file *filp, unsigned int cmd,
 		unsigned long arg)
 {
-	struct ext2_inode_info *ei = EXT2_I(inode);
+	struct ext2_inode_info *ei;
+	struct inode *inode;
 	unsigned int flags;
 	unsigned short rsv_window_size;
+	long retval = 0;
+
+	lock_kernel();
+	inode = filp->f_dentry->d_inode;
+	ei = EXT2_I(inode);
 
 	ext2_debug ("cmd = %u, arg = %lu\n", cmd, arg);
 
@@ -30,18 +36,25 @@ int ext2_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
 	case EXT2_IOC_GETFLAGS:
 		ext2_get_inode_flags(ei);
 		flags = ei->i_flags & EXT2_FL_USER_VISIBLE;
-		return put_user(flags, (int __user *) arg);
+		retval = put_user(flags, (int __user *) arg);
+		goto out;
 	case EXT2_IOC_SETFLAGS: {
 		unsigned int oldflags;
 
-		if (IS_RDONLY(inode))
-			return -EROFS;
+		if (IS_RDONLY(inode)) {
+			retval = -EROFS;
+			goto out;
+		}
 
-		if (!is_owner_or_cap(inode))
-			return -EACCES;
+		if (!is_owner_or_cap(inode)) {
+			retval = -EACCES;
+			goto out;
+		}
 
-		if (get_user(flags, (int __user *) arg))
-			return -EFAULT;
+		if (get_user(flags, (int __user *) arg)) {
+			retval = -EFAULT;
+			goto out;
+		}
 
 		if (!S_ISDIR(inode->i_mode))
 			flags &= ~EXT2_DIRSYNC_FL;
@@ -50,7 +63,8 @@ int ext2_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
 		/* Is it quota file? Do not allow user to mess with it */
 		if (IS_NOQUOTA(inode)) {
 			mutex_unlock(&inode->i_mutex);
-			return -EPERM;
+			retval = -EPERM;
+			goto out;
 		}
 		oldflags = ei->i_flags;
 
@@ -63,7 +77,8 @@ int ext2_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
 		if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) {
 			if (!capable(CAP_LINUX_IMMUTABLE)) {
 				mutex_unlock(&inode->i_mutex);
-				return -EPERM;
+				retval = -EPERM;
+				goto out;
 			}
 		}
 
@@ -75,41 +90,59 @@ int ext2_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
 		ext2_set_inode_flags(inode);
 		inode->i_ctime = CURRENT_TIME_SEC;
 		mark_inode_dirty(inode);
-		return 0;
+		goto out;
 	}
 	case EXT2_IOC_GETVERSION:
-		return put_user(inode->i_generation, (int __user *) arg);
+		retval = put_user(inode->i_generation, (int __user *) arg);
+		goto out;
 	case EXT2_IOC_SETVERSION:
-		if (!is_owner_or_cap(inode))
-			return -EPERM;
-		if (IS_RDONLY(inode))
-			return -EROFS;
-		if (get_user(inode->i_generation, (int __user *) arg))
-			return -EFAULT;	
+		if (!is_owner_or_cap(inode)) {
+			retval = -EPERM;
+			goto out;
+		}
+		if (IS_RDONLY(inode)) {
+			retval = -EROFS;
+			goto out;
+		}
+		if (get_user(inode->i_generation, (int __user *) arg)) {
+			retval = -EFAULT;
+			goto out;
+		}
 		inode->i_ctime = CURRENT_TIME_SEC;
 		mark_inode_dirty(inode);
-		return 0;
+		goto out;
 	case EXT2_IOC_GETRSVSZ:
 		if (test_opt(inode->i_sb, RESERVATION)
 			&& S_ISREG(inode->i_mode)
 			&& ei->i_block_alloc_info) {
 			rsv_window_size = ei->i_block_alloc_info->rsv_window_node.rsv_goal_size;
-			return put_user(rsv_window_size, (int __user *)arg);
+			retval = put_user(rsv_window_size, (int __user *)arg);
+			goto out;
 		}
-		return -ENOTTY;
+		retval = -ENOTTY;
+		goto out;
 	case EXT2_IOC_SETRSVSZ: {
 
-		if (!test_opt(inode->i_sb, RESERVATION) ||!S_ISREG(inode->i_mode))
-			return -ENOTTY;
+		if (!test_opt(inode->i_sb, RESERVATION) ||
+				!S_ISREG(inode->i_mode)) {
+			retval = -ENOTTY;
+			goto out;
+		}
 
-		if (IS_RDONLY(inode))
-			return -EROFS;
+		if (IS_RDONLY(inode)) {
+			retval = -EROFS;
+			goto out;
+		}
 
-		if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
-			return -EACCES;
+		if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER)) {
+			retval = -EACCES;
+			goto out;
+		}
 
-		if (get_user(rsv_window_size, (int __user *)arg))
-			return -EFAULT;
+		if (get_user(rsv_window_size, (int __user *)arg)) {
+			retval = -EFAULT;
+			goto out;
+		}
 
 		if (rsv_window_size > EXT2_MAX_RESERVE_BLOCKS)
 			rsv_window_size = EXT2_MAX_RESERVE_BLOCKS;
@@ -131,11 +164,15 @@ int ext2_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
 			rsv->rsv_goal_size = rsv_window_size;
 		}
 		mutex_unlock(&ei->truncate_mutex);
-		return 0;
+		goto out;
 	}
 	default:
-		return -ENOTTY;
+		retval = -ENOTTY;
+		goto out;
 	}
+out:
+	unlock_kernel();
+	return retval;
 }
 
 #ifdef CONFIG_COMPAT
-- 
1.5.3.8


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2008-01-25  6:35 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-22 13:09 [RESENT] Fix previously extX_ioctl() patches Mathieu Segaud
2008-01-22 13:09 ` [PATCH] Convert ext4_ioctl to an unlocked_ioctl Mathieu Segaud
2008-01-22 13:09   ` [PATCH] Convert ext3_ioctl() " Mathieu Segaud
2008-01-25  6:35   ` [PATCH] Convert ext4_ioctl " Junio C Hamano
  -- strict thread matches above, loose matches on Subject: below --
2008-01-17 12:37 [PATCH] Convert EXT2 to use unlocked_ioctl Mathieu Segaud
2008-01-17 12:37 ` [PATCH] Convert ext3_ioctl() to an unlocked_ioctl Mathieu Segaud
2008-01-17 12:37   ` [PATCH] Convert ext4_ioctl " Mathieu Segaud
2008-01-17 23:50     ` Mathieu SEGAUD
2008-01-17 10:30 [PATCH] Convert EXT2 to use unlocked_ioctl Mathieu Segaud
2008-01-17 10:30 ` [PATCH] Convert ext3_ioctl() to an unlocked_ioctl Mathieu Segaud
2008-01-17 10:30   ` [PATCH] Convert ext4_ioctl " Mathieu Segaud

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).