diff options
-rw-r--r-- | fs/fat/cache.c | 7 | ||||
-rw-r--r-- | fs/fat/dir.c | 32 | ||||
-rw-r--r-- | fs/fat/fat.h | 15 | ||||
-rw-r--r-- | fs/fat/fatent.c | 4 | ||||
-rw-r--r-- | fs/fat/inode.c | 74 | ||||
-rw-r--r-- | fs/fat/misc.c | 44 | ||||
-rw-r--r-- | fs/fat/namei_msdos.c | 4 | ||||
-rw-r--r-- | fs/fat/namei_vfat.c | 4 |
8 files changed, 104 insertions, 80 deletions
diff --git a/fs/fat/cache.c b/fs/fat/cache.c index ae8200f84e39..1cc7038e273d 100644 --- a/fs/fat/cache.c +++ b/fs/fat/cache.c | |||
@@ -151,6 +151,13 @@ static void fat_cache_add(struct inode *inode, struct fat_cache_id *new) | |||
151 | spin_unlock(&MSDOS_I(inode)->cache_lru_lock); | 151 | spin_unlock(&MSDOS_I(inode)->cache_lru_lock); |
152 | 152 | ||
153 | tmp = fat_cache_alloc(inode); | 153 | tmp = fat_cache_alloc(inode); |
154 | if (!tmp) { | ||
155 | spin_lock(&MSDOS_I(inode)->cache_lru_lock); | ||
156 | MSDOS_I(inode)->nr_caches--; | ||
157 | spin_unlock(&MSDOS_I(inode)->cache_lru_lock); | ||
158 | return; | ||
159 | } | ||
160 | |||
154 | spin_lock(&MSDOS_I(inode)->cache_lru_lock); | 161 | spin_lock(&MSDOS_I(inode)->cache_lru_lock); |
155 | cache = fat_cache_merge(inode, new); | 162 | cache = fat_cache_merge(inode, new); |
156 | if (cache != NULL) { | 163 | if (cache != NULL) { |
diff --git a/fs/fat/dir.c b/fs/fat/dir.c index ee42b9e0b16a..4ad64732cbce 100644 --- a/fs/fat/dir.c +++ b/fs/fat/dir.c | |||
@@ -98,7 +98,7 @@ next: | |||
98 | 98 | ||
99 | *bh = sb_bread(sb, phys); | 99 | *bh = sb_bread(sb, phys); |
100 | if (*bh == NULL) { | 100 | if (*bh == NULL) { |
101 | printk(KERN_ERR "FAT: Directory bread(block %llu) failed\n", | 101 | fat_msg(sb, KERN_ERR, "Directory bread(block %llu) failed", |
102 | (llu)phys); | 102 | (llu)phys); |
103 | /* skip this block */ | 103 | /* skip this block */ |
104 | *pos = (iblock + 1) << sb->s_blocksize_bits; | 104 | *pos = (iblock + 1) << sb->s_blocksize_bits; |
@@ -136,9 +136,10 @@ static inline int fat_get_entry(struct inode *dir, loff_t *pos, | |||
136 | * but ignore that right now. | 136 | * but ignore that right now. |
137 | * Ahem... Stack smashing in ring 0 isn't fun. Fixed. | 137 | * Ahem... Stack smashing in ring 0 isn't fun. Fixed. |
138 | */ | 138 | */ |
139 | static int uni16_to_x8(unsigned char *ascii, const wchar_t *uni, int len, | 139 | static int uni16_to_x8(struct super_block *sb, unsigned char *ascii, |
140 | int uni_xlate, struct nls_table *nls) | 140 | const wchar_t *uni, int len, struct nls_table *nls) |
141 | { | 141 | { |
142 | int uni_xlate = MSDOS_SB(sb)->options.unicode_xlate; | ||
142 | const wchar_t *ip; | 143 | const wchar_t *ip; |
143 | wchar_t ec; | 144 | wchar_t ec; |
144 | unsigned char *op; | 145 | unsigned char *op; |
@@ -166,23 +167,23 @@ static int uni16_to_x8(unsigned char *ascii, const wchar_t *uni, int len, | |||
166 | } | 167 | } |
167 | 168 | ||
168 | if (unlikely(*ip)) { | 169 | if (unlikely(*ip)) { |
169 | printk(KERN_WARNING "FAT: filename was truncated while " | 170 | fat_msg(sb, KERN_WARNING, "filename was truncated while " |
170 | "converting."); | 171 | "converting."); |
171 | } | 172 | } |
172 | 173 | ||
173 | *op = 0; | 174 | *op = 0; |
174 | return (op - ascii); | 175 | return (op - ascii); |
175 | } | 176 | } |
176 | 177 | ||
177 | static inline int fat_uni_to_x8(struct msdos_sb_info *sbi, const wchar_t *uni, | 178 | static inline int fat_uni_to_x8(struct super_block *sb, const wchar_t *uni, |
178 | unsigned char *buf, int size) | 179 | unsigned char *buf, int size) |
179 | { | 180 | { |
181 | struct msdos_sb_info *sbi = MSDOS_SB(sb); | ||
180 | if (sbi->options.utf8) | 182 | if (sbi->options.utf8) |
181 | return utf16s_to_utf8s(uni, FAT_MAX_UNI_CHARS, | 183 | return utf16s_to_utf8s(uni, FAT_MAX_UNI_CHARS, |
182 | UTF16_HOST_ENDIAN, buf, size); | 184 | UTF16_HOST_ENDIAN, buf, size); |
183 | else | 185 | else |
184 | return uni16_to_x8(buf, uni, size, sbi->options.unicode_xlate, | 186 | return uni16_to_x8(sb, buf, uni, size, sbi->nls_io); |
185 | sbi->nls_io); | ||
186 | } | 187 | } |
187 | 188 | ||
188 | static inline int | 189 | static inline int |
@@ -419,7 +420,7 @@ parse_record: | |||
419 | 420 | ||
420 | /* Compare shortname */ | 421 | /* Compare shortname */ |
421 | bufuname[last_u] = 0x0000; | 422 | bufuname[last_u] = 0x0000; |
422 | len = fat_uni_to_x8(sbi, bufuname, bufname, sizeof(bufname)); | 423 | len = fat_uni_to_x8(sb, bufuname, bufname, sizeof(bufname)); |
423 | if (fat_name_match(sbi, name, name_len, bufname, len)) | 424 | if (fat_name_match(sbi, name, name_len, bufname, len)) |
424 | goto found; | 425 | goto found; |
425 | 426 | ||
@@ -428,7 +429,7 @@ parse_record: | |||
428 | int size = PATH_MAX - FAT_MAX_UNI_SIZE; | 429 | int size = PATH_MAX - FAT_MAX_UNI_SIZE; |
429 | 430 | ||
430 | /* Compare longname */ | 431 | /* Compare longname */ |
431 | len = fat_uni_to_x8(sbi, unicode, longname, size); | 432 | len = fat_uni_to_x8(sb, unicode, longname, size); |
432 | if (fat_name_match(sbi, name, name_len, longname, len)) | 433 | if (fat_name_match(sbi, name, name_len, longname, len)) |
433 | goto found; | 434 | goto found; |
434 | } | 435 | } |
@@ -545,7 +546,7 @@ parse_record: | |||
545 | if (nr_slots) { | 546 | if (nr_slots) { |
546 | void *longname = unicode + FAT_MAX_UNI_CHARS; | 547 | void *longname = unicode + FAT_MAX_UNI_CHARS; |
547 | int size = PATH_MAX - FAT_MAX_UNI_SIZE; | 548 | int size = PATH_MAX - FAT_MAX_UNI_SIZE; |
548 | int len = fat_uni_to_x8(sbi, unicode, longname, size); | 549 | int len = fat_uni_to_x8(sb, unicode, longname, size); |
549 | 550 | ||
550 | fill_name = longname; | 551 | fill_name = longname; |
551 | fill_len = len; | 552 | fill_len = len; |
@@ -621,7 +622,7 @@ parse_record: | |||
621 | 622 | ||
622 | if (isvfat) { | 623 | if (isvfat) { |
623 | bufuname[j] = 0x0000; | 624 | bufuname[j] = 0x0000; |
624 | i = fat_uni_to_x8(sbi, bufuname, bufname, sizeof(bufname)); | 625 | i = fat_uni_to_x8(sb, bufuname, bufname, sizeof(bufname)); |
625 | } | 626 | } |
626 | if (nr_slots) { | 627 | if (nr_slots) { |
627 | /* hack for fat_ioctl_filldir() */ | 628 | /* hack for fat_ioctl_filldir() */ |
@@ -979,6 +980,7 @@ static int __fat_remove_entries(struct inode *dir, loff_t pos, int nr_slots) | |||
979 | 980 | ||
980 | int fat_remove_entries(struct inode *dir, struct fat_slot_info *sinfo) | 981 | int fat_remove_entries(struct inode *dir, struct fat_slot_info *sinfo) |
981 | { | 982 | { |
983 | struct super_block *sb = dir->i_sb; | ||
982 | struct msdos_dir_entry *de; | 984 | struct msdos_dir_entry *de; |
983 | struct buffer_head *bh; | 985 | struct buffer_head *bh; |
984 | int err = 0, nr_slots; | 986 | int err = 0, nr_slots; |
@@ -1013,8 +1015,8 @@ int fat_remove_entries(struct inode *dir, struct fat_slot_info *sinfo) | |||
1013 | */ | 1015 | */ |
1014 | err = __fat_remove_entries(dir, sinfo->slot_off, nr_slots); | 1016 | err = __fat_remove_entries(dir, sinfo->slot_off, nr_slots); |
1015 | if (err) { | 1017 | if (err) { |
1016 | printk(KERN_WARNING | 1018 | fat_msg(sb, KERN_WARNING, |
1017 | "FAT: Couldn't remove the long name slots\n"); | 1019 | "Couldn't remove the long name slots"); |
1018 | } | 1020 | } |
1019 | } | 1021 | } |
1020 | 1022 | ||
@@ -1265,7 +1267,7 @@ int fat_add_entries(struct inode *dir, void *slots, int nr_slots, | |||
1265 | if (sbi->fat_bits != 32) | 1267 | if (sbi->fat_bits != 32) |
1266 | goto error; | 1268 | goto error; |
1267 | } else if (MSDOS_I(dir)->i_start == 0) { | 1269 | } else if (MSDOS_I(dir)->i_start == 0) { |
1268 | printk(KERN_ERR "FAT: Corrupted directory (i_pos %lld)\n", | 1270 | fat_msg(sb, KERN_ERR, "Corrupted directory (i_pos %lld)", |
1269 | MSDOS_I(dir)->i_pos); | 1271 | MSDOS_I(dir)->i_pos); |
1270 | err = -EIO; | 1272 | err = -EIO; |
1271 | goto error; | 1273 | goto error; |
diff --git a/fs/fat/fat.h b/fs/fat/fat.h index f50408901f7e..8276cc282dec 100644 --- a/fs/fat/fat.h +++ b/fs/fat/fat.h | |||
@@ -319,19 +319,20 @@ extern struct inode *fat_build_inode(struct super_block *sb, | |||
319 | struct msdos_dir_entry *de, loff_t i_pos); | 319 | struct msdos_dir_entry *de, loff_t i_pos); |
320 | extern int fat_sync_inode(struct inode *inode); | 320 | extern int fat_sync_inode(struct inode *inode); |
321 | extern int fat_fill_super(struct super_block *sb, void *data, int silent, | 321 | extern int fat_fill_super(struct super_block *sb, void *data, int silent, |
322 | const struct inode_operations *fs_dir_inode_ops, | 322 | int isvfat, void (*setup)(struct super_block *)); |
323 | int isvfat, void (*setup)(struct super_block *)); | ||
324 | 323 | ||
325 | extern int fat_flush_inodes(struct super_block *sb, struct inode *i1, | 324 | extern int fat_flush_inodes(struct super_block *sb, struct inode *i1, |
326 | struct inode *i2); | 325 | struct inode *i2); |
327 | /* fat/misc.c */ | 326 | /* fat/misc.c */ |
328 | extern void | 327 | extern void |
329 | __fat_fs_error(struct super_block *s, int report, const char *fmt, ...) | 328 | __fat_fs_error(struct super_block *sb, int report, const char *fmt, ...) |
329 | __attribute__ ((format (printf, 3, 4))) __cold; | ||
330 | #define fat_fs_error(sb, fmt, args...) \ | ||
331 | __fat_fs_error(sb, 1, fmt , ## args) | ||
332 | #define fat_fs_error_ratelimit(sb, fmt, args...) \ | ||
333 | __fat_fs_error(sb, __ratelimit(&MSDOS_SB(sb)->ratelimit), fmt , ## args) | ||
334 | void fat_msg(struct super_block *sb, const char *level, const char *fmt, ...) | ||
330 | __attribute__ ((format (printf, 3, 4))) __cold; | 335 | __attribute__ ((format (printf, 3, 4))) __cold; |
331 | #define fat_fs_error(s, fmt, args...) \ | ||
332 | __fat_fs_error(s, 1, fmt , ## args) | ||
333 | #define fat_fs_error_ratelimit(s, fmt, args...) \ | ||
334 | __fat_fs_error(s, __ratelimit(&MSDOS_SB(s)->ratelimit), fmt , ## args) | ||
335 | extern int fat_clusters_flush(struct super_block *sb); | 336 | extern int fat_clusters_flush(struct super_block *sb); |
336 | extern int fat_chain_add(struct inode *inode, int new_dclus, int nr_cluster); | 337 | extern int fat_chain_add(struct inode *inode, int new_dclus, int nr_cluster); |
337 | extern void fat_time_fat2unix(struct msdos_sb_info *sbi, struct timespec *ts, | 338 | extern void fat_time_fat2unix(struct msdos_sb_info *sbi, struct timespec *ts, |
diff --git a/fs/fat/fatent.c b/fs/fat/fatent.c index b47d2c9f4fa1..2e81ac0df7e2 100644 --- a/fs/fat/fatent.c +++ b/fs/fat/fatent.c | |||
@@ -95,7 +95,7 @@ static int fat12_ent_bread(struct super_block *sb, struct fat_entry *fatent, | |||
95 | err_brelse: | 95 | err_brelse: |
96 | brelse(bhs[0]); | 96 | brelse(bhs[0]); |
97 | err: | 97 | err: |
98 | printk(KERN_ERR "FAT: FAT read failed (blocknr %llu)\n", (llu)blocknr); | 98 | fat_msg(sb, KERN_ERR, "FAT read failed (blocknr %llu)", (llu)blocknr); |
99 | return -EIO; | 99 | return -EIO; |
100 | } | 100 | } |
101 | 101 | ||
@@ -108,7 +108,7 @@ static int fat_ent_bread(struct super_block *sb, struct fat_entry *fatent, | |||
108 | fatent->fat_inode = MSDOS_SB(sb)->fat_inode; | 108 | fatent->fat_inode = MSDOS_SB(sb)->fat_inode; |
109 | fatent->bhs[0] = sb_bread(sb, blocknr); | 109 | fatent->bhs[0] = sb_bread(sb, blocknr); |
110 | if (!fatent->bhs[0]) { | 110 | if (!fatent->bhs[0]) { |
111 | printk(KERN_ERR "FAT: FAT read failed (blocknr %llu)\n", | 111 | fat_msg(sb, KERN_ERR, "FAT read failed (blocknr %llu)", |
112 | (llu)blocknr); | 112 | (llu)blocknr); |
113 | return -EIO; | 113 | return -EIO; |
114 | } | 114 | } |
diff --git a/fs/fat/inode.c b/fs/fat/inode.c index 8d68690bdcf1..cb8d8391ac0b 100644 --- a/fs/fat/inode.c +++ b/fs/fat/inode.c | |||
@@ -581,7 +581,8 @@ static int fat_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
581 | buf->f_bavail = sbi->free_clusters; | 581 | buf->f_bavail = sbi->free_clusters; |
582 | buf->f_fsid.val[0] = (u32)id; | 582 | buf->f_fsid.val[0] = (u32)id; |
583 | buf->f_fsid.val[1] = (u32)(id >> 32); | 583 | buf->f_fsid.val[1] = (u32)(id >> 32); |
584 | buf->f_namelen = sbi->options.isvfat ? FAT_LFN_LEN : 12; | 584 | buf->f_namelen = |
585 | (sbi->options.isvfat ? FAT_LFN_LEN : 12) * NLS_MAX_CHARSET_SIZE; | ||
585 | 586 | ||
586 | return 0; | 587 | return 0; |
587 | } | 588 | } |
@@ -619,8 +620,8 @@ retry: | |||
619 | 620 | ||
620 | bh = sb_bread(sb, i_pos >> sbi->dir_per_block_bits); | 621 | bh = sb_bread(sb, i_pos >> sbi->dir_per_block_bits); |
621 | if (!bh) { | 622 | if (!bh) { |
622 | printk(KERN_ERR "FAT: unable to read inode block " | 623 | fat_msg(sb, KERN_ERR, "unable to read inode block " |
623 | "for updating (i_pos %lld)\n", i_pos); | 624 | "for updating (i_pos %lld)", i_pos); |
624 | return -EIO; | 625 | return -EIO; |
625 | } | 626 | } |
626 | spin_lock(&sbi->inode_hash_lock); | 627 | spin_lock(&sbi->inode_hash_lock); |
@@ -976,8 +977,8 @@ static const match_table_t vfat_tokens = { | |||
976 | {Opt_err, NULL} | 977 | {Opt_err, NULL} |
977 | }; | 978 | }; |
978 | 979 | ||
979 | static int parse_options(char *options, int is_vfat, int silent, int *debug, | 980 | static int parse_options(struct super_block *sb, char *options, int is_vfat, |
980 | struct fat_mount_options *opts) | 981 | int silent, int *debug, struct fat_mount_options *opts) |
981 | { | 982 | { |
982 | char *p; | 983 | char *p; |
983 | substring_t args[MAX_OPT_ARGS]; | 984 | substring_t args[MAX_OPT_ARGS]; |
@@ -1168,15 +1169,15 @@ static int parse_options(char *options, int is_vfat, int silent, int *debug, | |||
1168 | 1169 | ||
1169 | /* obsolete mount options */ | 1170 | /* obsolete mount options */ |
1170 | case Opt_obsolate: | 1171 | case Opt_obsolate: |
1171 | printk(KERN_INFO "FAT: \"%s\" option is obsolete, " | 1172 | fat_msg(sb, KERN_INFO, "\"%s\" option is obsolete, " |
1172 | "not supported now\n", p); | 1173 | "not supported now", p); |
1173 | break; | 1174 | break; |
1174 | /* unknown option */ | 1175 | /* unknown option */ |
1175 | default: | 1176 | default: |
1176 | if (!silent) { | 1177 | if (!silent) { |
1177 | printk(KERN_ERR | 1178 | fat_msg(sb, KERN_ERR, |
1178 | "FAT: Unrecognized mount option \"%s\" " | 1179 | "Unrecognized mount option \"%s\" " |
1179 | "or missing value\n", p); | 1180 | "or missing value", p); |
1180 | } | 1181 | } |
1181 | return -EINVAL; | 1182 | return -EINVAL; |
1182 | } | 1183 | } |
@@ -1185,7 +1186,7 @@ static int parse_options(char *options, int is_vfat, int silent, int *debug, | |||
1185 | out: | 1186 | out: |
1186 | /* UTF-8 doesn't provide FAT semantics */ | 1187 | /* UTF-8 doesn't provide FAT semantics */ |
1187 | if (!strcmp(opts->iocharset, "utf8")) { | 1188 | if (!strcmp(opts->iocharset, "utf8")) { |
1188 | printk(KERN_ERR "FAT: utf8 is not a recommended IO charset" | 1189 | fat_msg(sb, KERN_ERR, "utf8 is not a recommended IO charset" |
1189 | " for FAT filesystems, filesystem will be " | 1190 | " for FAT filesystems, filesystem will be " |
1190 | "case sensitive!\n"); | 1191 | "case sensitive!\n"); |
1191 | } | 1192 | } |
@@ -1238,8 +1239,7 @@ static int fat_read_root(struct inode *inode) | |||
1238 | /* | 1239 | /* |
1239 | * Read the super block of an MS-DOS FS. | 1240 | * Read the super block of an MS-DOS FS. |
1240 | */ | 1241 | */ |
1241 | int fat_fill_super(struct super_block *sb, void *data, int silent, | 1242 | int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat, |
1242 | const struct inode_operations *fs_dir_inode_ops, int isvfat, | ||
1243 | void (*setup)(struct super_block *)) | 1243 | void (*setup)(struct super_block *)) |
1244 | { | 1244 | { |
1245 | struct inode *root_inode = NULL, *fat_inode = NULL; | 1245 | struct inode *root_inode = NULL, *fat_inode = NULL; |
@@ -1268,11 +1268,10 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, | |||
1268 | sb->s_magic = MSDOS_SUPER_MAGIC; | 1268 | sb->s_magic = MSDOS_SUPER_MAGIC; |
1269 | sb->s_op = &fat_sops; | 1269 | sb->s_op = &fat_sops; |
1270 | sb->s_export_op = &fat_export_ops; | 1270 | sb->s_export_op = &fat_export_ops; |
1271 | sbi->dir_ops = fs_dir_inode_ops; | ||
1272 | ratelimit_state_init(&sbi->ratelimit, DEFAULT_RATELIMIT_INTERVAL, | 1271 | ratelimit_state_init(&sbi->ratelimit, DEFAULT_RATELIMIT_INTERVAL, |
1273 | DEFAULT_RATELIMIT_BURST); | 1272 | DEFAULT_RATELIMIT_BURST); |
1274 | 1273 | ||
1275 | error = parse_options(data, isvfat, silent, &debug, &sbi->options); | 1274 | error = parse_options(sb, data, isvfat, silent, &debug, &sbi->options); |
1276 | if (error) | 1275 | if (error) |
1277 | goto out_fail; | 1276 | goto out_fail; |
1278 | 1277 | ||
@@ -1282,20 +1281,20 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, | |||
1282 | sb_min_blocksize(sb, 512); | 1281 | sb_min_blocksize(sb, 512); |
1283 | bh = sb_bread(sb, 0); | 1282 | bh = sb_bread(sb, 0); |
1284 | if (bh == NULL) { | 1283 | if (bh == NULL) { |
1285 | printk(KERN_ERR "FAT: unable to read boot sector\n"); | 1284 | fat_msg(sb, KERN_ERR, "unable to read boot sector"); |
1286 | goto out_fail; | 1285 | goto out_fail; |
1287 | } | 1286 | } |
1288 | 1287 | ||
1289 | b = (struct fat_boot_sector *) bh->b_data; | 1288 | b = (struct fat_boot_sector *) bh->b_data; |
1290 | if (!b->reserved) { | 1289 | if (!b->reserved) { |
1291 | if (!silent) | 1290 | if (!silent) |
1292 | printk(KERN_ERR "FAT: bogus number of reserved sectors\n"); | 1291 | fat_msg(sb, KERN_ERR, "bogus number of reserved sectors"); |
1293 | brelse(bh); | 1292 | brelse(bh); |
1294 | goto out_invalid; | 1293 | goto out_invalid; |
1295 | } | 1294 | } |
1296 | if (!b->fats) { | 1295 | if (!b->fats) { |
1297 | if (!silent) | 1296 | if (!silent) |
1298 | printk(KERN_ERR "FAT: bogus number of FAT structure\n"); | 1297 | fat_msg(sb, KERN_ERR, "bogus number of FAT structure"); |
1299 | brelse(bh); | 1298 | brelse(bh); |
1300 | goto out_invalid; | 1299 | goto out_invalid; |
1301 | } | 1300 | } |
@@ -1308,7 +1307,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, | |||
1308 | media = b->media; | 1307 | media = b->media; |
1309 | if (!fat_valid_media(media)) { | 1308 | if (!fat_valid_media(media)) { |
1310 | if (!silent) | 1309 | if (!silent) |
1311 | printk(KERN_ERR "FAT: invalid media value (0x%02x)\n", | 1310 | fat_msg(sb, KERN_ERR, "invalid media value (0x%02x)", |
1312 | media); | 1311 | media); |
1313 | brelse(bh); | 1312 | brelse(bh); |
1314 | goto out_invalid; | 1313 | goto out_invalid; |
@@ -1318,7 +1317,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, | |||
1318 | || (logical_sector_size < 512) | 1317 | || (logical_sector_size < 512) |
1319 | || (logical_sector_size > 4096)) { | 1318 | || (logical_sector_size > 4096)) { |
1320 | if (!silent) | 1319 | if (!silent) |
1321 | printk(KERN_ERR "FAT: bogus logical sector size %u\n", | 1320 | fat_msg(sb, KERN_ERR, "bogus logical sector size %u", |
1322 | logical_sector_size); | 1321 | logical_sector_size); |
1323 | brelse(bh); | 1322 | brelse(bh); |
1324 | goto out_invalid; | 1323 | goto out_invalid; |
@@ -1326,15 +1325,15 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, | |||
1326 | sbi->sec_per_clus = b->sec_per_clus; | 1325 | sbi->sec_per_clus = b->sec_per_clus; |
1327 | if (!is_power_of_2(sbi->sec_per_clus)) { | 1326 | if (!is_power_of_2(sbi->sec_per_clus)) { |
1328 | if (!silent) | 1327 | if (!silent) |
1329 | printk(KERN_ERR "FAT: bogus sectors per cluster %u\n", | 1328 | fat_msg(sb, KERN_ERR, "bogus sectors per cluster %u", |
1330 | sbi->sec_per_clus); | 1329 | sbi->sec_per_clus); |
1331 | brelse(bh); | 1330 | brelse(bh); |
1332 | goto out_invalid; | 1331 | goto out_invalid; |
1333 | } | 1332 | } |
1334 | 1333 | ||
1335 | if (logical_sector_size < sb->s_blocksize) { | 1334 | if (logical_sector_size < sb->s_blocksize) { |
1336 | printk(KERN_ERR "FAT: logical sector size too small for device" | 1335 | fat_msg(sb, KERN_ERR, "logical sector size too small for device" |
1337 | " (logical sector size = %u)\n", logical_sector_size); | 1336 | " (logical sector size = %u)", logical_sector_size); |
1338 | brelse(bh); | 1337 | brelse(bh); |
1339 | goto out_fail; | 1338 | goto out_fail; |
1340 | } | 1339 | } |
@@ -1342,14 +1341,14 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, | |||
1342 | brelse(bh); | 1341 | brelse(bh); |
1343 | 1342 | ||
1344 | if (!sb_set_blocksize(sb, logical_sector_size)) { | 1343 | if (!sb_set_blocksize(sb, logical_sector_size)) { |
1345 | printk(KERN_ERR "FAT: unable to set blocksize %u\n", | 1344 | fat_msg(sb, KERN_ERR, "unable to set blocksize %u", |
1346 | logical_sector_size); | 1345 | logical_sector_size); |
1347 | goto out_fail; | 1346 | goto out_fail; |
1348 | } | 1347 | } |
1349 | bh = sb_bread(sb, 0); | 1348 | bh = sb_bread(sb, 0); |
1350 | if (bh == NULL) { | 1349 | if (bh == NULL) { |
1351 | printk(KERN_ERR "FAT: unable to read boot sector" | 1350 | fat_msg(sb, KERN_ERR, "unable to read boot sector" |
1352 | " (logical sector size = %lu)\n", | 1351 | " (logical sector size = %lu)", |
1353 | sb->s_blocksize); | 1352 | sb->s_blocksize); |
1354 | goto out_fail; | 1353 | goto out_fail; |
1355 | } | 1354 | } |
@@ -1385,16 +1384,16 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, | |||
1385 | 1384 | ||
1386 | fsinfo_bh = sb_bread(sb, sbi->fsinfo_sector); | 1385 | fsinfo_bh = sb_bread(sb, sbi->fsinfo_sector); |
1387 | if (fsinfo_bh == NULL) { | 1386 | if (fsinfo_bh == NULL) { |
1388 | printk(KERN_ERR "FAT: bread failed, FSINFO block" | 1387 | fat_msg(sb, KERN_ERR, "bread failed, FSINFO block" |
1389 | " (sector = %lu)\n", sbi->fsinfo_sector); | 1388 | " (sector = %lu)", sbi->fsinfo_sector); |
1390 | brelse(bh); | 1389 | brelse(bh); |
1391 | goto out_fail; | 1390 | goto out_fail; |
1392 | } | 1391 | } |
1393 | 1392 | ||
1394 | fsinfo = (struct fat_boot_fsinfo *)fsinfo_bh->b_data; | 1393 | fsinfo = (struct fat_boot_fsinfo *)fsinfo_bh->b_data; |
1395 | if (!IS_FSINFO(fsinfo)) { | 1394 | if (!IS_FSINFO(fsinfo)) { |
1396 | printk(KERN_WARNING "FAT: Invalid FSINFO signature: " | 1395 | fat_msg(sb, KERN_WARNING, "Invalid FSINFO signature: " |
1397 | "0x%08x, 0x%08x (sector = %lu)\n", | 1396 | "0x%08x, 0x%08x (sector = %lu)", |
1398 | le32_to_cpu(fsinfo->signature1), | 1397 | le32_to_cpu(fsinfo->signature1), |
1399 | le32_to_cpu(fsinfo->signature2), | 1398 | le32_to_cpu(fsinfo->signature2), |
1400 | sbi->fsinfo_sector); | 1399 | sbi->fsinfo_sector); |
@@ -1415,8 +1414,8 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, | |||
1415 | sbi->dir_entries = get_unaligned_le16(&b->dir_entries); | 1414 | sbi->dir_entries = get_unaligned_le16(&b->dir_entries); |
1416 | if (sbi->dir_entries & (sbi->dir_per_block - 1)) { | 1415 | if (sbi->dir_entries & (sbi->dir_per_block - 1)) { |
1417 | if (!silent) | 1416 | if (!silent) |
1418 | printk(KERN_ERR "FAT: bogus directroy-entries per block" | 1417 | fat_msg(sb, KERN_ERR, "bogus directroy-entries per block" |
1419 | " (%u)\n", sbi->dir_entries); | 1418 | " (%u)", sbi->dir_entries); |
1420 | brelse(bh); | 1419 | brelse(bh); |
1421 | goto out_invalid; | 1420 | goto out_invalid; |
1422 | } | 1421 | } |
@@ -1438,7 +1437,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, | |||
1438 | total_clusters = min(total_clusters, fat_clusters - FAT_START_ENT); | 1437 | total_clusters = min(total_clusters, fat_clusters - FAT_START_ENT); |
1439 | if (total_clusters > MAX_FAT(sb)) { | 1438 | if (total_clusters > MAX_FAT(sb)) { |
1440 | if (!silent) | 1439 | if (!silent) |
1441 | printk(KERN_ERR "FAT: count of clusters too big (%u)\n", | 1440 | fat_msg(sb, KERN_ERR, "count of clusters too big (%u)", |
1442 | total_clusters); | 1441 | total_clusters); |
1443 | brelse(bh); | 1442 | brelse(bh); |
1444 | goto out_invalid; | 1443 | goto out_invalid; |
@@ -1471,7 +1470,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, | |||
1471 | sprintf(buf, "cp%d", sbi->options.codepage); | 1470 | sprintf(buf, "cp%d", sbi->options.codepage); |
1472 | sbi->nls_disk = load_nls(buf); | 1471 | sbi->nls_disk = load_nls(buf); |
1473 | if (!sbi->nls_disk) { | 1472 | if (!sbi->nls_disk) { |
1474 | printk(KERN_ERR "FAT: codepage %s not found\n", buf); | 1473 | fat_msg(sb, KERN_ERR, "codepage %s not found", buf); |
1475 | goto out_fail; | 1474 | goto out_fail; |
1476 | } | 1475 | } |
1477 | 1476 | ||
@@ -1479,7 +1478,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, | |||
1479 | if (sbi->options.isvfat) { | 1478 | if (sbi->options.isvfat) { |
1480 | sbi->nls_io = load_nls(sbi->options.iocharset); | 1479 | sbi->nls_io = load_nls(sbi->options.iocharset); |
1481 | if (!sbi->nls_io) { | 1480 | if (!sbi->nls_io) { |
1482 | printk(KERN_ERR "FAT: IO charset %s not found\n", | 1481 | fat_msg(sb, KERN_ERR, "IO charset %s not found", |
1483 | sbi->options.iocharset); | 1482 | sbi->options.iocharset); |
1484 | goto out_fail; | 1483 | goto out_fail; |
1485 | } | 1484 | } |
@@ -1503,7 +1502,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, | |||
1503 | insert_inode_hash(root_inode); | 1502 | insert_inode_hash(root_inode); |
1504 | sb->s_root = d_alloc_root(root_inode); | 1503 | sb->s_root = d_alloc_root(root_inode); |
1505 | if (!sb->s_root) { | 1504 | if (!sb->s_root) { |
1506 | printk(KERN_ERR "FAT: get root inode failed\n"); | 1505 | fat_msg(sb, KERN_ERR, "get root inode failed"); |
1507 | goto out_fail; | 1506 | goto out_fail; |
1508 | } | 1507 | } |
1509 | 1508 | ||
@@ -1512,8 +1511,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, | |||
1512 | out_invalid: | 1511 | out_invalid: |
1513 | error = -EINVAL; | 1512 | error = -EINVAL; |
1514 | if (!silent) | 1513 | if (!silent) |
1515 | printk(KERN_INFO "VFS: Can't find a valid FAT filesystem" | 1514 | fat_msg(sb, KERN_INFO, "Can't find a valid FAT filesystem"); |
1516 | " on dev %s.\n", sb->s_id); | ||
1517 | 1515 | ||
1518 | out_fail: | 1516 | out_fail: |
1519 | if (fat_inode) | 1517 | if (fat_inode) |
diff --git a/fs/fat/misc.c b/fs/fat/misc.c index 970e682ea754..6d93360ca0cc 100644 --- a/fs/fat/misc.c +++ b/fs/fat/misc.c | |||
@@ -20,30 +20,46 @@ | |||
20 | * In case the file system is remounted read-only, it can be made writable | 20 | * In case the file system is remounted read-only, it can be made writable |
21 | * again by remounting it. | 21 | * again by remounting it. |
22 | */ | 22 | */ |
23 | void __fat_fs_error(struct super_block *s, int report, const char *fmt, ...) | 23 | void __fat_fs_error(struct super_block *sb, int report, const char *fmt, ...) |
24 | { | 24 | { |
25 | struct fat_mount_options *opts = &MSDOS_SB(s)->options; | 25 | struct fat_mount_options *opts = &MSDOS_SB(sb)->options; |
26 | va_list args; | 26 | va_list args; |
27 | struct va_format vaf; | ||
27 | 28 | ||
28 | if (report) { | 29 | if (report) { |
29 | printk(KERN_ERR "FAT: Filesystem error (dev %s)\n", s->s_id); | ||
30 | |||
31 | printk(KERN_ERR " "); | ||
32 | va_start(args, fmt); | 30 | va_start(args, fmt); |
33 | vprintk(fmt, args); | 31 | vaf.fmt = fmt; |
32 | vaf.va = &args; | ||
33 | printk(KERN_ERR "FAT-fs (%s): error, %pV\n", sb->s_id, &vaf); | ||
34 | va_end(args); | 34 | va_end(args); |
35 | printk("\n"); | ||
36 | } | 35 | } |
37 | 36 | ||
38 | if (opts->errors == FAT_ERRORS_PANIC) | 37 | if (opts->errors == FAT_ERRORS_PANIC) |
39 | panic("FAT: fs panic from previous error\n"); | 38 | panic("FAT-fs (%s): fs panic from previous error\n", sb->s_id); |
40 | else if (opts->errors == FAT_ERRORS_RO && !(s->s_flags & MS_RDONLY)) { | 39 | else if (opts->errors == FAT_ERRORS_RO && !(sb->s_flags & MS_RDONLY)) { |
41 | s->s_flags |= MS_RDONLY; | 40 | sb->s_flags |= MS_RDONLY; |
42 | printk(KERN_ERR "FAT: Filesystem has been set read-only\n"); | 41 | printk(KERN_ERR "FAT-fs (%s): Filesystem has been " |
42 | "set read-only\n", sb->s_id); | ||
43 | } | 43 | } |
44 | } | 44 | } |
45 | EXPORT_SYMBOL_GPL(__fat_fs_error); | 45 | EXPORT_SYMBOL_GPL(__fat_fs_error); |
46 | 46 | ||
47 | /** | ||
48 | * fat_msg() - print preformated FAT specific messages. Every thing what is | ||
49 | * not fat_fs_error() should be fat_msg(). | ||
50 | */ | ||
51 | void fat_msg(struct super_block *sb, const char *level, const char *fmt, ...) | ||
52 | { | ||
53 | struct va_format vaf; | ||
54 | va_list args; | ||
55 | |||
56 | va_start(args, fmt); | ||
57 | vaf.fmt = fmt; | ||
58 | vaf.va = &args; | ||
59 | printk("%sFAT-fs (%s): %pV\n", level, sb->s_id, &vaf); | ||
60 | va_end(args); | ||
61 | } | ||
62 | |||
47 | /* Flushes the number of free clusters on FAT32 */ | 63 | /* Flushes the number of free clusters on FAT32 */ |
48 | /* XXX: Need to write one per FSINFO block. Currently only writes 1 */ | 64 | /* XXX: Need to write one per FSINFO block. Currently only writes 1 */ |
49 | int fat_clusters_flush(struct super_block *sb) | 65 | int fat_clusters_flush(struct super_block *sb) |
@@ -57,15 +73,15 @@ int fat_clusters_flush(struct super_block *sb) | |||
57 | 73 | ||
58 | bh = sb_bread(sb, sbi->fsinfo_sector); | 74 | bh = sb_bread(sb, sbi->fsinfo_sector); |
59 | if (bh == NULL) { | 75 | if (bh == NULL) { |
60 | printk(KERN_ERR "FAT: bread failed in fat_clusters_flush\n"); | 76 | fat_msg(sb, KERN_ERR, "bread failed in fat_clusters_flush"); |
61 | return -EIO; | 77 | return -EIO; |
62 | } | 78 | } |
63 | 79 | ||
64 | fsinfo = (struct fat_boot_fsinfo *)bh->b_data; | 80 | fsinfo = (struct fat_boot_fsinfo *)bh->b_data; |
65 | /* Sanity check */ | 81 | /* Sanity check */ |
66 | if (!IS_FSINFO(fsinfo)) { | 82 | if (!IS_FSINFO(fsinfo)) { |
67 | printk(KERN_ERR "FAT: Invalid FSINFO signature: " | 83 | fat_msg(sb, KERN_ERR, "Invalid FSINFO signature: " |
68 | "0x%08x, 0x%08x (sector = %lu)\n", | 84 | "0x%08x, 0x%08x (sector = %lu)", |
69 | le32_to_cpu(fsinfo->signature1), | 85 | le32_to_cpu(fsinfo->signature1), |
70 | le32_to_cpu(fsinfo->signature2), | 86 | le32_to_cpu(fsinfo->signature2), |
71 | sbi->fsinfo_sector); | 87 | sbi->fsinfo_sector); |
diff --git a/fs/fat/namei_msdos.c b/fs/fat/namei_msdos.c index 711499040eb6..3b222dafd15b 100644 --- a/fs/fat/namei_msdos.c +++ b/fs/fat/namei_msdos.c | |||
@@ -659,14 +659,14 @@ static const struct inode_operations msdos_dir_inode_operations = { | |||
659 | 659 | ||
660 | static void setup(struct super_block *sb) | 660 | static void setup(struct super_block *sb) |
661 | { | 661 | { |
662 | MSDOS_SB(sb)->dir_ops = &msdos_dir_inode_operations; | ||
662 | sb->s_d_op = &msdos_dentry_operations; | 663 | sb->s_d_op = &msdos_dentry_operations; |
663 | sb->s_flags |= MS_NOATIME; | 664 | sb->s_flags |= MS_NOATIME; |
664 | } | 665 | } |
665 | 666 | ||
666 | static int msdos_fill_super(struct super_block *sb, void *data, int silent) | 667 | static int msdos_fill_super(struct super_block *sb, void *data, int silent) |
667 | { | 668 | { |
668 | return fat_fill_super(sb, data, silent, &msdos_dir_inode_operations, | 669 | return fat_fill_super(sb, data, silent, 0, setup); |
669 | 0, setup); | ||
670 | } | 670 | } |
671 | 671 | ||
672 | static struct dentry *msdos_mount(struct file_system_type *fs_type, | 672 | static struct dentry *msdos_mount(struct file_system_type *fs_type, |
diff --git a/fs/fat/namei_vfat.c b/fs/fat/namei_vfat.c index adae3fb7451a..20b4ea53fdc4 100644 --- a/fs/fat/namei_vfat.c +++ b/fs/fat/namei_vfat.c | |||
@@ -1065,6 +1065,7 @@ static const struct inode_operations vfat_dir_inode_operations = { | |||
1065 | 1065 | ||
1066 | static void setup(struct super_block *sb) | 1066 | static void setup(struct super_block *sb) |
1067 | { | 1067 | { |
1068 | MSDOS_SB(sb)->dir_ops = &vfat_dir_inode_operations; | ||
1068 | if (MSDOS_SB(sb)->options.name_check != 's') | 1069 | if (MSDOS_SB(sb)->options.name_check != 's') |
1069 | sb->s_d_op = &vfat_ci_dentry_ops; | 1070 | sb->s_d_op = &vfat_ci_dentry_ops; |
1070 | else | 1071 | else |
@@ -1073,8 +1074,7 @@ static void setup(struct super_block *sb) | |||
1073 | 1074 | ||
1074 | static int vfat_fill_super(struct super_block *sb, void *data, int silent) | 1075 | static int vfat_fill_super(struct super_block *sb, void *data, int silent) |
1075 | { | 1076 | { |
1076 | return fat_fill_super(sb, data, silent, &vfat_dir_inode_operations, | 1077 | return fat_fill_super(sb, data, silent, 1, setup); |
1077 | 1, setup); | ||
1078 | } | 1078 | } |
1079 | 1079 | ||
1080 | static struct dentry *vfat_mount(struct file_system_type *fs_type, | 1080 | static struct dentry *vfat_mount(struct file_system_type *fs_type, |