diff options
author | OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> | 2008-11-06 15:53:54 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-11-06 18:41:21 -0500 |
commit | 9c0aa1b87bf541affef519eb4879ce7c5a5941ae (patch) | |
tree | 3bd583d8331c630b59fc01b68ab9cb34bb953d6e /fs/fat/file.c | |
parent | 45cfbe354785a5bc9a38354754d6f7322f598001 (diff) |
fat: Cleanup FAT attribute stuff
This adds three helpers:
fat_make_attrs() - makes FAT attributes from inode.
fat_make_mode() - makes mode_t from FAT attributes.
fat_save_attrs() - saves FAT attributes to inode.
Then this replaces: MSDOS_MKMODE() by fat_make_mode(), fat_attr() by
fat_make_attrs(), ->i_attrs = attr & ATTR_UNUSED by fat_save_attrs().
And for root inode, those is used with ATTR_DIR instead of bogus
ATTR_NONE.
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 | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/fs/fat/file.c b/fs/fat/file.c index b21973f266a1..f5a7e907a8fa 100644 --- a/fs/fat/file.c +++ b/fs/fat/file.c | |||
@@ -27,13 +27,7 @@ int fat_generic_ioctl(struct inode *inode, struct file *filp, | |||
27 | switch (cmd) { | 27 | switch (cmd) { |
28 | case FAT_IOCTL_GET_ATTRIBUTES: | 28 | case FAT_IOCTL_GET_ATTRIBUTES: |
29 | { | 29 | { |
30 | u32 attr; | 30 | u32 attr = fat_make_attrs(inode); |
31 | |||
32 | if (inode->i_ino == MSDOS_ROOT_INO) | ||
33 | attr = ATTR_DIR; | ||
34 | else | ||
35 | attr = fat_attr(inode); | ||
36 | |||
37 | return put_user(attr, user_attr); | 31 | return put_user(attr, user_attr); |
38 | } | 32 | } |
39 | case FAT_IOCTL_SET_ATTRIBUTES: | 33 | case FAT_IOCTL_SET_ATTRIBUTES: |
@@ -62,20 +56,16 @@ int fat_generic_ioctl(struct inode *inode, struct file *filp, | |||
62 | /* Merge in ATTR_VOLUME and ATTR_DIR */ | 56 | /* Merge in ATTR_VOLUME and ATTR_DIR */ |
63 | attr |= (MSDOS_I(inode)->i_attrs & ATTR_VOLUME) | | 57 | attr |= (MSDOS_I(inode)->i_attrs & ATTR_VOLUME) | |
64 | (is_dir ? ATTR_DIR : 0); | 58 | (is_dir ? ATTR_DIR : 0); |
65 | oldattr = fat_attr(inode); | 59 | oldattr = fat_make_attrs(inode); |
66 | 60 | ||
67 | /* Equivalent to a chmod() */ | 61 | /* Equivalent to a chmod() */ |
68 | ia.ia_valid = ATTR_MODE | ATTR_CTIME; | 62 | ia.ia_valid = ATTR_MODE | ATTR_CTIME; |
69 | ia.ia_ctime = current_fs_time(inode->i_sb); | 63 | ia.ia_ctime = current_fs_time(inode->i_sb); |
70 | if (is_dir) { | 64 | if (is_dir) |
71 | ia.ia_mode = MSDOS_MKMODE(attr, | 65 | ia.ia_mode = fat_make_mode(sbi, attr, S_IRWXUGO); |
72 | S_IRWXUGO & ~sbi->options.fs_dmask) | 66 | else { |
73 | | S_IFDIR; | 67 | ia.ia_mode = fat_make_mode(sbi, attr, |
74 | } else { | 68 | S_IRUGO | S_IWUGO | (inode->i_mode & S_IXUGO)); |
75 | ia.ia_mode = MSDOS_MKMODE(attr, | ||
76 | (S_IRUGO | S_IWUGO | (inode->i_mode & S_IXUGO)) | ||
77 | & ~sbi->options.fs_fmask) | ||
78 | | S_IFREG; | ||
79 | } | 69 | } |
80 | 70 | ||
81 | /* The root directory has no attributes */ | 71 | /* The root directory has no attributes */ |
@@ -115,7 +105,7 @@ int fat_generic_ioctl(struct inode *inode, struct file *filp, | |||
115 | inode->i_flags &= S_IMMUTABLE; | 105 | inode->i_flags &= S_IMMUTABLE; |
116 | } | 106 | } |
117 | 107 | ||
118 | MSDOS_I(inode)->i_attrs = attr & ATTR_UNUSED; | 108 | fat_save_attrs(inode, attr); |
119 | mark_inode_dirty(inode); | 109 | mark_inode_dirty(inode); |
120 | up: | 110 | up: |
121 | mnt_drop_write(filp->f_path.mnt); | 111 | mnt_drop_write(filp->f_path.mnt); |
@@ -274,7 +264,7 @@ static int fat_sanitize_mode(const struct msdos_sb_info *sbi, | |||
274 | 264 | ||
275 | /* | 265 | /* |
276 | * Note, the basic check is already done by a caller of | 266 | * Note, the basic check is already done by a caller of |
277 | * (attr->ia_mode & ~MSDOS_VALID_MODE) | 267 | * (attr->ia_mode & ~FAT_VALID_MODE) |
278 | */ | 268 | */ |
279 | 269 | ||
280 | if (S_ISREG(inode->i_mode)) | 270 | if (S_ISREG(inode->i_mode)) |
@@ -314,6 +304,8 @@ static int fat_allow_set_time(struct msdos_sb_info *sbi, struct inode *inode) | |||
314 | } | 304 | } |
315 | 305 | ||
316 | #define TIMES_SET_FLAGS (ATTR_MTIME_SET | ATTR_ATIME_SET | ATTR_TIMES_SET) | 306 | #define TIMES_SET_FLAGS (ATTR_MTIME_SET | ATTR_ATIME_SET | ATTR_TIMES_SET) |
307 | /* valid file mode bits */ | ||
308 | #define FAT_VALID_MODE (S_IFREG | S_IFDIR | S_IRWXUGO) | ||
317 | 309 | ||
318 | int fat_setattr(struct dentry *dentry, struct iattr *attr) | 310 | int fat_setattr(struct dentry *dentry, struct iattr *attr) |
319 | { | 311 | { |
@@ -356,7 +348,7 @@ int fat_setattr(struct dentry *dentry, struct iattr *attr) | |||
356 | ((attr->ia_valid & ATTR_GID) && | 348 | ((attr->ia_valid & ATTR_GID) && |
357 | (attr->ia_gid != sbi->options.fs_gid)) || | 349 | (attr->ia_gid != sbi->options.fs_gid)) || |
358 | ((attr->ia_valid & ATTR_MODE) && | 350 | ((attr->ia_valid & ATTR_MODE) && |
359 | (attr->ia_mode & ~MSDOS_VALID_MODE))) | 351 | (attr->ia_mode & ~FAT_VALID_MODE))) |
360 | error = -EPERM; | 352 | error = -EPERM; |
361 | 353 | ||
362 | if (error) { | 354 | if (error) { |