diff options
author | OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> | 2008-04-28 05:16:26 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-04-28 11:58:47 -0400 |
commit | 1ae43f826b6cb951fc5b0f9c92372a8d5b63c7f9 (patch) | |
tree | aea00f01d74a40e026974182006e8af903b0b241 /fs/fat/file.c | |
parent | e97e8de388723f9491514fa0434ddf1fd713a188 (diff) |
fat: Add allow_utime option
Normally utime(2) checks current process is owner of the file, or it
has CAP_FOWNER capability. But FAT filesystem doesn't have uid/gid as
on disk info, so normal check is too unflexible.
With this option you can relax it.
Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/fat/file.c')
-rw-r--r-- | fs/fat/file.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/fs/fat/file.c b/fs/fat/file.c index e73f13a13792..d604bb132422 100644 --- a/fs/fat/file.c +++ b/fs/fat/file.c | |||
@@ -280,11 +280,27 @@ static int fat_check_mode(const struct msdos_sb_info *sbi, struct inode *inode, | |||
280 | return 0; | 280 | return 0; |
281 | } | 281 | } |
282 | 282 | ||
283 | static int fat_allow_set_time(struct msdos_sb_info *sbi, struct inode *inode) | ||
284 | { | ||
285 | mode_t allow_utime = sbi->options.allow_utime; | ||
286 | |||
287 | if (current->fsuid != inode->i_uid) { | ||
288 | if (in_group_p(inode->i_gid)) | ||
289 | allow_utime >>= 3; | ||
290 | if (allow_utime & MAY_WRITE) | ||
291 | return 1; | ||
292 | } | ||
293 | |||
294 | /* use a default check */ | ||
295 | return 0; | ||
296 | } | ||
297 | |||
283 | int fat_setattr(struct dentry *dentry, struct iattr *attr) | 298 | int fat_setattr(struct dentry *dentry, struct iattr *attr) |
284 | { | 299 | { |
285 | struct msdos_sb_info *sbi = MSDOS_SB(dentry->d_sb); | 300 | struct msdos_sb_info *sbi = MSDOS_SB(dentry->d_sb); |
286 | struct inode *inode = dentry->d_inode; | 301 | struct inode *inode = dentry->d_inode; |
287 | int mask, error = 0; | 302 | int mask, error = 0; |
303 | unsigned int ia_valid; | ||
288 | 304 | ||
289 | lock_kernel(); | 305 | lock_kernel(); |
290 | 306 | ||
@@ -302,7 +318,15 @@ int fat_setattr(struct dentry *dentry, struct iattr *attr) | |||
302 | } | 318 | } |
303 | } | 319 | } |
304 | 320 | ||
321 | /* Check for setting the inode time. */ | ||
322 | ia_valid = attr->ia_valid; | ||
323 | if (ia_valid & (ATTR_MTIME_SET | ATTR_ATIME_SET)) { | ||
324 | if (fat_allow_set_time(sbi, inode)) | ||
325 | attr->ia_valid &= ~(ATTR_MTIME_SET | ATTR_ATIME_SET); | ||
326 | } | ||
327 | |||
305 | error = inode_change_ok(inode, attr); | 328 | error = inode_change_ok(inode, attr); |
329 | attr->ia_valid = ia_valid; | ||
306 | if (error) { | 330 | if (error) { |
307 | if (sbi->options.quiet) | 331 | if (sbi->options.quiet) |
308 | error = 0; | 332 | error = 0; |