|
16 | 16 | #include <linux/compat.h> /* compat_ptr() */ |
17 | 17 | #include <linux/mount.h> /* mnt_want_write_file(), mnt_drop_write_file() */ |
18 | 18 | #include <linux/buffer_head.h> |
| 19 | +#include <linux/fileattr.h> |
19 | 20 | #include "nilfs.h" |
20 | 21 | #include "segment.h" |
21 | 22 | #include "bmap.h" |
@@ -113,63 +114,47 @@ static int nilfs_ioctl_wrap_copy(struct the_nilfs *nilfs, |
113 | 114 | } |
114 | 115 |
|
115 | 116 | /** |
116 | | - * nilfs_ioctl_getflags - ioctl to support lsattr |
| 117 | + * nilfs_fileattr_get - ioctl to support lsattr |
117 | 118 | */ |
118 | | -static int nilfs_ioctl_getflags(struct inode *inode, void __user *argp) |
| 119 | +int nilfs_fileattr_get(struct dentry *dentry, struct fileattr *fa) |
119 | 120 | { |
120 | | - unsigned int flags = NILFS_I(inode)->i_flags & FS_FL_USER_VISIBLE; |
| 121 | + struct inode *inode = d_inode(dentry); |
121 | 122 |
|
122 | | - return put_user(flags, (int __user *)argp); |
| 123 | + fileattr_fill_flags(fa, NILFS_I(inode)->i_flags & FS_FL_USER_VISIBLE); |
| 124 | + |
| 125 | + return 0; |
123 | 126 | } |
124 | 127 |
|
125 | 128 | /** |
126 | | - * nilfs_ioctl_setflags - ioctl to support chattr |
| 129 | + * nilfs_fileattr_set - ioctl to support chattr |
127 | 130 | */ |
128 | | -static int nilfs_ioctl_setflags(struct inode *inode, struct file *filp, |
129 | | - void __user *argp) |
| 131 | +int nilfs_fileattr_set(struct user_namespace *mnt_userns, |
| 132 | + struct dentry *dentry, struct fileattr *fa) |
130 | 133 | { |
| 134 | + struct inode *inode = d_inode(dentry); |
131 | 135 | struct nilfs_transaction_info ti; |
132 | 136 | unsigned int flags, oldflags; |
133 | 137 | int ret; |
134 | 138 |
|
135 | | - if (!inode_owner_or_capable(&init_user_ns, inode)) |
136 | | - return -EACCES; |
137 | | - |
138 | | - if (get_user(flags, (int __user *)argp)) |
139 | | - return -EFAULT; |
140 | | - |
141 | | - ret = mnt_want_write_file(filp); |
142 | | - if (ret) |
143 | | - return ret; |
144 | | - |
145 | | - flags = nilfs_mask_flags(inode->i_mode, flags); |
146 | | - |
147 | | - inode_lock(inode); |
148 | | - |
149 | | - oldflags = NILFS_I(inode)->i_flags; |
| 139 | + if (fileattr_has_fsx(fa)) |
| 140 | + return -EOPNOTSUPP; |
150 | 141 |
|
151 | | - ret = vfs_ioc_setflags_prepare(inode, oldflags, flags); |
152 | | - if (ret) |
153 | | - goto out; |
| 142 | + flags = nilfs_mask_flags(inode->i_mode, fa->flags); |
154 | 143 |
|
155 | 144 | ret = nilfs_transaction_begin(inode->i_sb, &ti, 0); |
156 | 145 | if (ret) |
157 | | - goto out; |
| 146 | + return ret; |
158 | 147 |
|
159 | | - NILFS_I(inode)->i_flags = (oldflags & ~FS_FL_USER_MODIFIABLE) | |
160 | | - (flags & FS_FL_USER_MODIFIABLE); |
| 148 | + oldflags = NILFS_I(inode)->i_flags & ~FS_FL_USER_MODIFIABLE; |
| 149 | + NILFS_I(inode)->i_flags = oldflags | (flags & FS_FL_USER_MODIFIABLE); |
161 | 150 |
|
162 | 151 | nilfs_set_inode_flags(inode); |
163 | 152 | inode->i_ctime = current_time(inode); |
164 | 153 | if (IS_SYNC(inode)) |
165 | 154 | nilfs_set_transaction_flag(NILFS_TI_SYNC); |
166 | 155 |
|
167 | 156 | nilfs_mark_inode_dirty(inode); |
168 | | - ret = nilfs_transaction_commit(inode->i_sb); |
169 | | -out: |
170 | | - inode_unlock(inode); |
171 | | - mnt_drop_write_file(filp); |
172 | | - return ret; |
| 157 | + return nilfs_transaction_commit(inode->i_sb); |
173 | 158 | } |
174 | 159 |
|
175 | 160 | /** |
@@ -1282,10 +1267,6 @@ long nilfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) |
1282 | 1267 | void __user *argp = (void __user *)arg; |
1283 | 1268 |
|
1284 | 1269 | switch (cmd) { |
1285 | | - case FS_IOC_GETFLAGS: |
1286 | | - return nilfs_ioctl_getflags(inode, argp); |
1287 | | - case FS_IOC_SETFLAGS: |
1288 | | - return nilfs_ioctl_setflags(inode, filp, argp); |
1289 | 1270 | case FS_IOC_GETVERSION: |
1290 | 1271 | return nilfs_ioctl_getversion(inode, argp); |
1291 | 1272 | case NILFS_IOCTL_CHANGE_CPMODE: |
@@ -1331,12 +1312,6 @@ long nilfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) |
1331 | 1312 | long nilfs_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) |
1332 | 1313 | { |
1333 | 1314 | switch (cmd) { |
1334 | | - case FS_IOC32_GETFLAGS: |
1335 | | - cmd = FS_IOC_GETFLAGS; |
1336 | | - break; |
1337 | | - case FS_IOC32_SETFLAGS: |
1338 | | - cmd = FS_IOC_SETFLAGS; |
1339 | | - break; |
1340 | 1315 | case FS_IOC32_GETVERSION: |
1341 | 1316 | cmd = FS_IOC_GETVERSION; |
1342 | 1317 | break; |
|
0 commit comments