diff options
Diffstat (limited to 'fs/jfs/ioctl.c')
-rw-r--r-- | fs/jfs/ioctl.c | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/fs/jfs/ioctl.c b/fs/jfs/ioctl.c index dfda12a073e1..a1f8e375ad21 100644 --- a/fs/jfs/ioctl.c +++ b/fs/jfs/ioctl.c | |||
@@ -51,9 +51,9 @@ static long jfs_map_ext2(unsigned long flags, int from) | |||
51 | } | 51 | } |
52 | 52 | ||
53 | 53 | ||
54 | int jfs_ioctl(struct inode * inode, struct file * filp, unsigned int cmd, | 54 | long jfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) |
55 | unsigned long arg) | ||
56 | { | 55 | { |
56 | struct inode *inode = filp->f_dentry->d_inode; | ||
57 | struct jfs_inode_info *jfs_inode = JFS_IP(inode); | 57 | struct jfs_inode_info *jfs_inode = JFS_IP(inode); |
58 | unsigned int flags; | 58 | unsigned int flags; |
59 | 59 | ||
@@ -82,6 +82,10 @@ int jfs_ioctl(struct inode * inode, struct file * filp, unsigned int cmd, | |||
82 | /* Is it quota file? Do not allow user to mess with it */ | 82 | /* Is it quota file? Do not allow user to mess with it */ |
83 | if (IS_NOQUOTA(inode)) | 83 | if (IS_NOQUOTA(inode)) |
84 | return -EPERM; | 84 | return -EPERM; |
85 | |||
86 | /* Lock against other parallel changes of flags */ | ||
87 | mutex_lock(&inode->i_mutex); | ||
88 | |||
85 | jfs_get_inode_flags(jfs_inode); | 89 | jfs_get_inode_flags(jfs_inode); |
86 | oldflags = jfs_inode->mode2; | 90 | oldflags = jfs_inode->mode2; |
87 | 91 | ||
@@ -92,8 +96,10 @@ int jfs_ioctl(struct inode * inode, struct file * filp, unsigned int cmd, | |||
92 | if ((oldflags & JFS_IMMUTABLE_FL) || | 96 | if ((oldflags & JFS_IMMUTABLE_FL) || |
93 | ((flags ^ oldflags) & | 97 | ((flags ^ oldflags) & |
94 | (JFS_APPEND_FL | JFS_IMMUTABLE_FL))) { | 98 | (JFS_APPEND_FL | JFS_IMMUTABLE_FL))) { |
95 | if (!capable(CAP_LINUX_IMMUTABLE)) | 99 | if (!capable(CAP_LINUX_IMMUTABLE)) { |
100 | mutex_unlock(&inode->i_mutex); | ||
96 | return -EPERM; | 101 | return -EPERM; |
102 | } | ||
97 | } | 103 | } |
98 | 104 | ||
99 | flags = flags & JFS_FL_USER_MODIFIABLE; | 105 | flags = flags & JFS_FL_USER_MODIFIABLE; |
@@ -101,6 +107,7 @@ int jfs_ioctl(struct inode * inode, struct file * filp, unsigned int cmd, | |||
101 | jfs_inode->mode2 = flags; | 107 | jfs_inode->mode2 = flags; |
102 | 108 | ||
103 | jfs_set_inode_flags(inode); | 109 | jfs_set_inode_flags(inode); |
110 | mutex_unlock(&inode->i_mutex); | ||
104 | inode->i_ctime = CURRENT_TIME_SEC; | 111 | inode->i_ctime = CURRENT_TIME_SEC; |
105 | mark_inode_dirty(inode); | 112 | mark_inode_dirty(inode); |
106 | return 0; | 113 | return 0; |
@@ -110,3 +117,21 @@ int jfs_ioctl(struct inode * inode, struct file * filp, unsigned int cmd, | |||
110 | } | 117 | } |
111 | } | 118 | } |
112 | 119 | ||
120 | #ifdef CONFIG_COMPAT | ||
121 | long jfs_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) | ||
122 | { | ||
123 | /* While these ioctl numbers defined with 'long' and have different | ||
124 | * numbers than the 64bit ABI, | ||
125 | * the actual implementation only deals with ints and is compatible. | ||
126 | */ | ||
127 | switch (cmd) { | ||
128 | case JFS_IOC_GETFLAGS32: | ||
129 | cmd = JFS_IOC_GETFLAGS; | ||
130 | break; | ||
131 | case JFS_IOC_SETFLAGS32: | ||
132 | cmd = JFS_IOC_SETFLAGS; | ||
133 | break; | ||
134 | } | ||
135 | return jfs_ioctl(filp, cmd, arg); | ||
136 | } | ||
137 | #endif | ||