aboutsummaryrefslogtreecommitdiffstats
path: root/fs/fat/inode.c
diff options
context:
space:
mode:
authorOGAWA Hirofumi <hirofumi@mail.parknet.co.jp>2008-11-06 15:53:54 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2008-11-06 18:41:21 -0500
commit9c0aa1b87bf541affef519eb4879ce7c5a5941ae (patch)
tree3bd583d8331c630b59fc01b68ab9cb34bb953d6e /fs/fat/inode.c
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/inode.c')
-rw-r--r--fs/fat/inode.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index 8e1b75c63c7f..7aaa21cf019a 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -337,8 +337,7 @@ static int fat_fill_inode(struct inode *inode, struct msdos_dir_entry *de)
337 337
338 if ((de->attr & ATTR_DIR) && !IS_FREE(de->name)) { 338 if ((de->attr & ATTR_DIR) && !IS_FREE(de->name)) {
339 inode->i_generation &= ~1; 339 inode->i_generation &= ~1;
340 inode->i_mode = MSDOS_MKMODE(de->attr, 340 inode->i_mode = fat_make_mode(sbi, de->attr, S_IRWXUGO);
341 S_IRWXUGO & ~sbi->options.fs_dmask) | S_IFDIR;
342 inode->i_op = sbi->dir_ops; 341 inode->i_op = sbi->dir_ops;
343 inode->i_fop = &fat_dir_operations; 342 inode->i_fop = &fat_dir_operations;
344 343
@@ -355,10 +354,9 @@ static int fat_fill_inode(struct inode *inode, struct msdos_dir_entry *de)
355 inode->i_nlink = fat_subdirs(inode); 354 inode->i_nlink = fat_subdirs(inode);
356 } else { /* not a directory */ 355 } else { /* not a directory */
357 inode->i_generation |= 1; 356 inode->i_generation |= 1;
358 inode->i_mode = MSDOS_MKMODE(de->attr, 357 inode->i_mode = fat_make_mode(sbi, de->attr,
359 ((sbi->options.showexec && !is_exec(de->name + 8)) 358 ((sbi->options.showexec && !is_exec(de->name + 8))
360 ? S_IRUGO|S_IWUGO : S_IRWXUGO) 359 ? S_IRUGO|S_IWUGO : S_IRWXUGO));
361 & ~sbi->options.fs_fmask) | S_IFREG;
362 MSDOS_I(inode)->i_start = le16_to_cpu(de->start); 360 MSDOS_I(inode)->i_start = le16_to_cpu(de->start);
363 if (sbi->fat_bits == 32) 361 if (sbi->fat_bits == 32)
364 MSDOS_I(inode)->i_start |= (le16_to_cpu(de->starthi) << 16); 362 MSDOS_I(inode)->i_start |= (le16_to_cpu(de->starthi) << 16);
@@ -374,7 +372,8 @@ static int fat_fill_inode(struct inode *inode, struct msdos_dir_entry *de)
374 if (sbi->options.sys_immutable) 372 if (sbi->options.sys_immutable)
375 inode->i_flags |= S_IMMUTABLE; 373 inode->i_flags |= S_IMMUTABLE;
376 } 374 }
377 MSDOS_I(inode)->i_attrs = de->attr & ATTR_UNUSED; 375 fat_save_attrs(inode, de->attr);
376
378 inode->i_blocks = ((inode->i_size + (sbi->cluster_size - 1)) 377 inode->i_blocks = ((inode->i_size + (sbi->cluster_size - 1))
379 & ~((loff_t)sbi->cluster_size - 1)) >> 9; 378 & ~((loff_t)sbi->cluster_size - 1)) >> 9;
380 379
@@ -569,7 +568,7 @@ retry:
569 raw_entry->size = 0; 568 raw_entry->size = 0;
570 else 569 else
571 raw_entry->size = cpu_to_le32(inode->i_size); 570 raw_entry->size = cpu_to_le32(inode->i_size);
572 raw_entry->attr = fat_attr(inode); 571 raw_entry->attr = fat_make_attrs(inode);
573 raw_entry->start = cpu_to_le16(MSDOS_I(inode)->i_logstart); 572 raw_entry->start = cpu_to_le16(MSDOS_I(inode)->i_logstart);
574 raw_entry->starthi = cpu_to_le16(MSDOS_I(inode)->i_logstart >> 16); 573 raw_entry->starthi = cpu_to_le16(MSDOS_I(inode)->i_logstart >> 16);
575 fat_time_unix2fat(sbi, &inode->i_mtime, &raw_entry->time, 574 fat_time_unix2fat(sbi, &inode->i_mtime, &raw_entry->time,
@@ -1105,7 +1104,7 @@ static int fat_read_root(struct inode *inode)
1105 inode->i_gid = sbi->options.fs_gid; 1104 inode->i_gid = sbi->options.fs_gid;
1106 inode->i_version++; 1105 inode->i_version++;
1107 inode->i_generation = 0; 1106 inode->i_generation = 0;
1108 inode->i_mode = (S_IRWXUGO & ~sbi->options.fs_dmask) | S_IFDIR; 1107 inode->i_mode = fat_make_mode(sbi, ATTR_DIR, S_IRWXUGO);
1109 inode->i_op = sbi->dir_ops; 1108 inode->i_op = sbi->dir_ops;
1110 inode->i_fop = &fat_dir_operations; 1109 inode->i_fop = &fat_dir_operations;
1111 if (sbi->fat_bits == 32) { 1110 if (sbi->fat_bits == 32) {
@@ -1122,7 +1121,7 @@ static int fat_read_root(struct inode *inode)
1122 MSDOS_I(inode)->i_logstart = 0; 1121 MSDOS_I(inode)->i_logstart = 0;
1123 MSDOS_I(inode)->mmu_private = inode->i_size; 1122 MSDOS_I(inode)->mmu_private = inode->i_size;
1124 1123
1125 MSDOS_I(inode)->i_attrs = ATTR_NONE; 1124 fat_save_attrs(inode, ATTR_DIR);
1126 inode->i_mtime.tv_sec = inode->i_atime.tv_sec = inode->i_ctime.tv_sec = 0; 1125 inode->i_mtime.tv_sec = inode->i_atime.tv_sec = inode->i_ctime.tv_sec = 0;
1127 inode->i_mtime.tv_nsec = inode->i_atime.tv_nsec = inode->i_ctime.tv_nsec = 0; 1126 inode->i_mtime.tv_nsec = inode->i_atime.tv_nsec = inode->i_ctime.tv_nsec = 0;
1128 inode->i_nlink = fat_subdirs(inode)+2; 1127 inode->i_nlink = fat_subdirs(inode)+2;