summaryrefslogtreecommitdiff
path: root/fs/fat/fat.h
diff options
context:
space:
mode:
authorOGAWA Hirofumi <hirofumi@mail.parknet.co.jp>2008-11-06 12:53:54 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2008-11-06 15:41:21 -0800
commit9c0aa1b87bf541affef519eb4879ce7c5a5941ae (patch)
tree3bd583d8331c630b59fc01b68ab9cb34bb953d6e /fs/fat/fat.h
parent45cfbe354785a5bc9a38354754d6f7322f598001 (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/fat.h')
-rw-r--r--fs/fat/fat.h20
1 files changed, 19 insertions, 1 deletions
diff --git a/fs/fat/fat.h b/fs/fat/fat.h
index 2b8e94c3eef4..3b4753a024e3 100644
--- a/fs/fat/fat.h
+++ b/fs/fat/fat.h
@@ -117,14 +117,32 @@ static inline struct msdos_inode_info *MSDOS_I(struct inode *inode)
return container_of(inode, struct msdos_inode_info, vfs_inode);
}
+/* Convert attribute bits and a mask to the UNIX mode. */
+static inline mode_t fat_make_mode(struct msdos_sb_info *sbi,
+ u8 attrs, mode_t mode)
+{
+ if (attrs & ATTR_RO)
+ mode &= ~S_IWUGO;
+
+ if (attrs & ATTR_DIR)
+ return (mode & ~sbi->options.fs_dmask) | S_IFDIR;
+ else
+ return (mode & ~sbi->options.fs_fmask) | S_IFREG;
+}
+
/* Return the FAT attribute byte for this inode */
-static inline u8 fat_attr(struct inode *inode)
+static inline u8 fat_make_attrs(struct inode *inode)
{
return ((inode->i_mode & S_IWUGO) ? ATTR_NONE : ATTR_RO) |
(S_ISDIR(inode->i_mode) ? ATTR_DIR : ATTR_NONE) |
MSDOS_I(inode)->i_attrs;
}
+static inline void fat_save_attrs(struct inode *inode, u8 attrs)
+{
+ MSDOS_I(inode)->i_attrs = attrs & ATTR_UNUSED;
+}
+
static inline unsigned char fat_checksum(const __u8 *name)
{
unsigned char s = name[0];