aboutsummaryrefslogtreecommitdiffstats
path: root/fs/hpfs/super.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/hpfs/super.c')
-rw-r--r--fs/hpfs/super.c151
1 files changed, 71 insertions, 80 deletions
diff --git a/fs/hpfs/super.c b/fs/hpfs/super.c
index 2607010be2fe..98580a3b5005 100644
--- a/fs/hpfs/super.c
+++ b/fs/hpfs/super.c
@@ -13,21 +13,21 @@
13#include <linux/statfs.h> 13#include <linux/statfs.h>
14#include <linux/magic.h> 14#include <linux/magic.h>
15#include <linux/sched.h> 15#include <linux/sched.h>
16#include <linux/smp_lock.h>
17#include <linux/bitmap.h> 16#include <linux/bitmap.h>
18#include <linux/slab.h> 17#include <linux/slab.h>
19 18
20/* Mark the filesystem dirty, so that chkdsk checks it when os/2 booted */ 19/* Mark the filesystem dirty, so that chkdsk checks it when os/2 booted */
21 20
22static void mark_dirty(struct super_block *s) 21static void mark_dirty(struct super_block *s, int remount)
23{ 22{
24 if (hpfs_sb(s)->sb_chkdsk && !(s->s_flags & MS_RDONLY)) { 23 if (hpfs_sb(s)->sb_chkdsk && (remount || !(s->s_flags & MS_RDONLY))) {
25 struct buffer_head *bh; 24 struct buffer_head *bh;
26 struct hpfs_spare_block *sb; 25 struct hpfs_spare_block *sb;
27 if ((sb = hpfs_map_sector(s, 17, &bh, 0))) { 26 if ((sb = hpfs_map_sector(s, 17, &bh, 0))) {
28 sb->dirty = 1; 27 sb->dirty = 1;
29 sb->old_wrote = 0; 28 sb->old_wrote = 0;
30 mark_buffer_dirty(bh); 29 mark_buffer_dirty(bh);
30 sync_dirty_buffer(bh);
31 brelse(bh); 31 brelse(bh);
32 } 32 }
33 } 33 }
@@ -41,10 +41,12 @@ static void unmark_dirty(struct super_block *s)
41 struct buffer_head *bh; 41 struct buffer_head *bh;
42 struct hpfs_spare_block *sb; 42 struct hpfs_spare_block *sb;
43 if (s->s_flags & MS_RDONLY) return; 43 if (s->s_flags & MS_RDONLY) return;
44 sync_blockdev(s->s_bdev);
44 if ((sb = hpfs_map_sector(s, 17, &bh, 0))) { 45 if ((sb = hpfs_map_sector(s, 17, &bh, 0))) {
45 sb->dirty = hpfs_sb(s)->sb_chkdsk > 1 - hpfs_sb(s)->sb_was_error; 46 sb->dirty = hpfs_sb(s)->sb_chkdsk > 1 - hpfs_sb(s)->sb_was_error;
46 sb->old_wrote = hpfs_sb(s)->sb_chkdsk >= 2 && !hpfs_sb(s)->sb_was_error; 47 sb->old_wrote = hpfs_sb(s)->sb_chkdsk >= 2 && !hpfs_sb(s)->sb_was_error;
47 mark_buffer_dirty(bh); 48 mark_buffer_dirty(bh);
49 sync_dirty_buffer(bh);
48 brelse(bh); 50 brelse(bh);
49 } 51 }
50} 52}
@@ -64,13 +66,13 @@ void hpfs_error(struct super_block *s, const char *fmt, ...)
64 if (!hpfs_sb(s)->sb_was_error) { 66 if (!hpfs_sb(s)->sb_was_error) {
65 if (hpfs_sb(s)->sb_err == 2) { 67 if (hpfs_sb(s)->sb_err == 2) {
66 printk("; crashing the system because you wanted it\n"); 68 printk("; crashing the system because you wanted it\n");
67 mark_dirty(s); 69 mark_dirty(s, 0);
68 panic("HPFS panic"); 70 panic("HPFS panic");
69 } else if (hpfs_sb(s)->sb_err == 1) { 71 } else if (hpfs_sb(s)->sb_err == 1) {
70 if (s->s_flags & MS_RDONLY) printk("; already mounted read-only\n"); 72 if (s->s_flags & MS_RDONLY) printk("; already mounted read-only\n");
71 else { 73 else {
72 printk("; remounting read-only\n"); 74 printk("; remounting read-only\n");
73 mark_dirty(s); 75 mark_dirty(s, 0);
74 s->s_flags |= MS_RDONLY; 76 s->s_flags |= MS_RDONLY;
75 } 77 }
76 } else if (s->s_flags & MS_RDONLY) printk("; going on - but anything won't be destroyed because it's read-only\n"); 78 } else if (s->s_flags & MS_RDONLY) printk("; going on - but anything won't be destroyed because it's read-only\n");
@@ -103,15 +105,14 @@ static void hpfs_put_super(struct super_block *s)
103{ 105{
104 struct hpfs_sb_info *sbi = hpfs_sb(s); 106 struct hpfs_sb_info *sbi = hpfs_sb(s);
105 107
106 lock_kernel(); 108 hpfs_lock(s);
109 unmark_dirty(s);
110 hpfs_unlock(s);
107 111
108 kfree(sbi->sb_cp_table); 112 kfree(sbi->sb_cp_table);
109 kfree(sbi->sb_bmp_dir); 113 kfree(sbi->sb_bmp_dir);
110 unmark_dirty(s);
111 s->s_fs_info = NULL; 114 s->s_fs_info = NULL;
112 kfree(sbi); 115 kfree(sbi);
113
114 unlock_kernel();
115} 116}
116 117
117unsigned hpfs_count_one_bitmap(struct super_block *s, secno secno) 118unsigned hpfs_count_one_bitmap(struct super_block *s, secno secno)
@@ -134,7 +135,7 @@ static unsigned count_bitmaps(struct super_block *s)
134 n_bands = (hpfs_sb(s)->sb_fs_size + 0x3fff) >> 14; 135 n_bands = (hpfs_sb(s)->sb_fs_size + 0x3fff) >> 14;
135 count = 0; 136 count = 0;
136 for (n = 0; n < n_bands; n++) 137 for (n = 0; n < n_bands; n++)
137 count += hpfs_count_one_bitmap(s, hpfs_sb(s)->sb_bmp_dir[n]); 138 count += hpfs_count_one_bitmap(s, le32_to_cpu(hpfs_sb(s)->sb_bmp_dir[n]));
138 return count; 139 return count;
139} 140}
140 141
@@ -143,7 +144,7 @@ static int hpfs_statfs(struct dentry *dentry, struct kstatfs *buf)
143 struct super_block *s = dentry->d_sb; 144 struct super_block *s = dentry->d_sb;
144 struct hpfs_sb_info *sbi = hpfs_sb(s); 145 struct hpfs_sb_info *sbi = hpfs_sb(s);
145 u64 id = huge_encode_dev(s->s_bdev->bd_dev); 146 u64 id = huge_encode_dev(s->s_bdev->bd_dev);
146 lock_kernel(); 147 hpfs_lock(s);
147 148
148 /*if (sbi->sb_n_free == -1) {*/ 149 /*if (sbi->sb_n_free == -1) {*/
149 sbi->sb_n_free = count_bitmaps(s); 150 sbi->sb_n_free = count_bitmaps(s);
@@ -160,7 +161,7 @@ static int hpfs_statfs(struct dentry *dentry, struct kstatfs *buf)
160 buf->f_fsid.val[1] = (u32)(id >> 32); 161 buf->f_fsid.val[1] = (u32)(id >> 32);
161 buf->f_namelen = 254; 162 buf->f_namelen = 254;
162 163
163 unlock_kernel(); 164 hpfs_unlock(s);
164 165
165 return 0; 166 return 0;
166} 167}
@@ -177,17 +178,22 @@ static struct inode *hpfs_alloc_inode(struct super_block *sb)
177 return &ei->vfs_inode; 178 return &ei->vfs_inode;
178} 179}
179 180
180static void hpfs_destroy_inode(struct inode *inode) 181static void hpfs_i_callback(struct rcu_head *head)
181{ 182{
183 struct inode *inode = container_of(head, struct inode, i_rcu);
184 INIT_LIST_HEAD(&inode->i_dentry);
182 kmem_cache_free(hpfs_inode_cachep, hpfs_i(inode)); 185 kmem_cache_free(hpfs_inode_cachep, hpfs_i(inode));
183} 186}
184 187
188static void hpfs_destroy_inode(struct inode *inode)
189{
190 call_rcu(&inode->i_rcu, hpfs_i_callback);
191}
192
185static void init_once(void *foo) 193static void init_once(void *foo)
186{ 194{
187 struct hpfs_inode_info *ei = (struct hpfs_inode_info *) foo; 195 struct hpfs_inode_info *ei = (struct hpfs_inode_info *) foo;
188 196
189 mutex_init(&ei->i_mutex);
190 mutex_init(&ei->i_parent_mutex);
191 inode_init_once(&ei->vfs_inode); 197 inode_init_once(&ei->vfs_inode);
192} 198}
193 199
@@ -216,7 +222,6 @@ static void destroy_inodecache(void)
216 222
217enum { 223enum {
218 Opt_help, Opt_uid, Opt_gid, Opt_umask, Opt_case_lower, Opt_case_asis, 224 Opt_help, Opt_uid, Opt_gid, Opt_umask, Opt_case_lower, Opt_case_asis,
219 Opt_conv_binary, Opt_conv_text, Opt_conv_auto,
220 Opt_check_none, Opt_check_normal, Opt_check_strict, 225 Opt_check_none, Opt_check_normal, Opt_check_strict,
221 Opt_err_cont, Opt_err_ro, Opt_err_panic, 226 Opt_err_cont, Opt_err_ro, Opt_err_panic,
222 Opt_eas_no, Opt_eas_ro, Opt_eas_rw, 227 Opt_eas_no, Opt_eas_ro, Opt_eas_rw,
@@ -231,9 +236,6 @@ static const match_table_t tokens = {
231 {Opt_umask, "umask=%o"}, 236 {Opt_umask, "umask=%o"},
232 {Opt_case_lower, "case=lower"}, 237 {Opt_case_lower, "case=lower"},
233 {Opt_case_asis, "case=asis"}, 238 {Opt_case_asis, "case=asis"},
234 {Opt_conv_binary, "conv=binary"},
235 {Opt_conv_text, "conv=text"},
236 {Opt_conv_auto, "conv=auto"},
237 {Opt_check_none, "check=none"}, 239 {Opt_check_none, "check=none"},
238 {Opt_check_normal, "check=normal"}, 240 {Opt_check_normal, "check=normal"},
239 {Opt_check_strict, "check=strict"}, 241 {Opt_check_strict, "check=strict"},
@@ -251,7 +253,7 @@ static const match_table_t tokens = {
251}; 253};
252 254
253static int parse_opts(char *opts, uid_t *uid, gid_t *gid, umode_t *umask, 255static int parse_opts(char *opts, uid_t *uid, gid_t *gid, umode_t *umask,
254 int *lowercase, int *conv, int *eas, int *chk, int *errs, 256 int *lowercase, int *eas, int *chk, int *errs,
255 int *chkdsk, int *timeshift) 257 int *chkdsk, int *timeshift)
256{ 258{
257 char *p; 259 char *p;
@@ -293,15 +295,6 @@ static int parse_opts(char *opts, uid_t *uid, gid_t *gid, umode_t *umask,
293 case Opt_case_asis: 295 case Opt_case_asis:
294 *lowercase = 0; 296 *lowercase = 0;
295 break; 297 break;
296 case Opt_conv_binary:
297 *conv = CONV_BINARY;
298 break;
299 case Opt_conv_text:
300 *conv = CONV_TEXT;
301 break;
302 case Opt_conv_auto:
303 *conv = CONV_AUTO;
304 break;
305 case Opt_check_none: 298 case Opt_check_none:
306 *chk = 0; 299 *chk = 0;
307 break; 300 break;
@@ -368,9 +361,6 @@ HPFS filesystem options:\n\
368 umask=xxx set mode of files that don't have mode specified in eas\n\ 361 umask=xxx set mode of files that don't have mode specified in eas\n\
369 case=lower lowercase all files\n\ 362 case=lower lowercase all files\n\
370 case=asis do not lowercase files (default)\n\ 363 case=asis do not lowercase files (default)\n\
371 conv=binary do not convert CR/LF -> LF (default)\n\
372 conv=auto convert only files with known text extensions\n\
373 conv=text convert all files\n\
374 check=none no fs checks - kernel may crash on corrupted filesystem\n\ 364 check=none no fs checks - kernel may crash on corrupted filesystem\n\
375 check=normal do some checks - it should not crash (default)\n\ 365 check=normal do some checks - it should not crash (default)\n\
376 check=strict do extra time-consuming checks, used for debugging\n\ 366 check=strict do extra time-consuming checks, used for debugging\n\
@@ -392,22 +382,22 @@ static int hpfs_remount_fs(struct super_block *s, int *flags, char *data)
392 uid_t uid; 382 uid_t uid;
393 gid_t gid; 383 gid_t gid;
394 umode_t umask; 384 umode_t umask;
395 int lowercase, conv, eas, chk, errs, chkdsk, timeshift; 385 int lowercase, eas, chk, errs, chkdsk, timeshift;
396 int o; 386 int o;
397 struct hpfs_sb_info *sbi = hpfs_sb(s); 387 struct hpfs_sb_info *sbi = hpfs_sb(s);
398 char *new_opts = kstrdup(data, GFP_KERNEL); 388 char *new_opts = kstrdup(data, GFP_KERNEL);
399 389
400 *flags |= MS_NOATIME; 390 *flags |= MS_NOATIME;
401 391
402 lock_kernel(); 392 hpfs_lock(s);
403 lock_super(s); 393 lock_super(s);
404 uid = sbi->sb_uid; gid = sbi->sb_gid; 394 uid = sbi->sb_uid; gid = sbi->sb_gid;
405 umask = 0777 & ~sbi->sb_mode; 395 umask = 0777 & ~sbi->sb_mode;
406 lowercase = sbi->sb_lowercase; conv = sbi->sb_conv; 396 lowercase = sbi->sb_lowercase;
407 eas = sbi->sb_eas; chk = sbi->sb_chk; chkdsk = sbi->sb_chkdsk; 397 eas = sbi->sb_eas; chk = sbi->sb_chk; chkdsk = sbi->sb_chkdsk;
408 errs = sbi->sb_err; timeshift = sbi->sb_timeshift; 398 errs = sbi->sb_err; timeshift = sbi->sb_timeshift;
409 399
410 if (!(o = parse_opts(data, &uid, &gid, &umask, &lowercase, &conv, 400 if (!(o = parse_opts(data, &uid, &gid, &umask, &lowercase,
411 &eas, &chk, &errs, &chkdsk, &timeshift))) { 401 &eas, &chk, &errs, &chkdsk, &timeshift))) {
412 printk("HPFS: bad mount options.\n"); 402 printk("HPFS: bad mount options.\n");
413 goto out_err; 403 goto out_err;
@@ -425,21 +415,21 @@ static int hpfs_remount_fs(struct super_block *s, int *flags, char *data)
425 415
426 sbi->sb_uid = uid; sbi->sb_gid = gid; 416 sbi->sb_uid = uid; sbi->sb_gid = gid;
427 sbi->sb_mode = 0777 & ~umask; 417 sbi->sb_mode = 0777 & ~umask;
428 sbi->sb_lowercase = lowercase; sbi->sb_conv = conv; 418 sbi->sb_lowercase = lowercase;
429 sbi->sb_eas = eas; sbi->sb_chk = chk; sbi->sb_chkdsk = chkdsk; 419 sbi->sb_eas = eas; sbi->sb_chk = chk; sbi->sb_chkdsk = chkdsk;
430 sbi->sb_err = errs; sbi->sb_timeshift = timeshift; 420 sbi->sb_err = errs; sbi->sb_timeshift = timeshift;
431 421
432 if (!(*flags & MS_RDONLY)) mark_dirty(s); 422 if (!(*flags & MS_RDONLY)) mark_dirty(s, 1);
433 423
434 replace_mount_options(s, new_opts); 424 replace_mount_options(s, new_opts);
435 425
436 unlock_super(s); 426 unlock_super(s);
437 unlock_kernel(); 427 hpfs_unlock(s);
438 return 0; 428 return 0;
439 429
440out_err: 430out_err:
441 unlock_super(s); 431 unlock_super(s);
442 unlock_kernel(); 432 hpfs_unlock(s);
443 kfree(new_opts); 433 kfree(new_opts);
444 return -EINVAL; 434 return -EINVAL;
445} 435}
@@ -469,7 +459,7 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent)
469 uid_t uid; 459 uid_t uid;
470 gid_t gid; 460 gid_t gid;
471 umode_t umask; 461 umode_t umask;
472 int lowercase, conv, eas, chk, errs, chkdsk, timeshift; 462 int lowercase, eas, chk, errs, chkdsk, timeshift;
473 463
474 dnode_secno root_dno; 464 dnode_secno root_dno;
475 struct hpfs_dirent *de = NULL; 465 struct hpfs_dirent *de = NULL;
@@ -480,27 +470,28 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent)
480 save_mount_options(s, options); 470 save_mount_options(s, options);
481 471
482 sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); 472 sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
483 if (!sbi) 473 if (!sbi) {
484 return -ENOMEM; 474 return -ENOMEM;
475 }
485 s->s_fs_info = sbi; 476 s->s_fs_info = sbi;
486 477
487 sbi->sb_bmp_dir = NULL; 478 sbi->sb_bmp_dir = NULL;
488 sbi->sb_cp_table = NULL; 479 sbi->sb_cp_table = NULL;
489 480
490 init_MUTEX(&sbi->hpfs_creation_de); 481 mutex_init(&sbi->hpfs_mutex);
482 hpfs_lock(s);
491 483
492 uid = current_uid(); 484 uid = current_uid();
493 gid = current_gid(); 485 gid = current_gid();
494 umask = current_umask(); 486 umask = current_umask();
495 lowercase = 0; 487 lowercase = 0;
496 conv = CONV_BINARY;
497 eas = 2; 488 eas = 2;
498 chk = 1; 489 chk = 1;
499 errs = 1; 490 errs = 1;
500 chkdsk = 1; 491 chkdsk = 1;
501 timeshift = 0; 492 timeshift = 0;
502 493
503 if (!(o = parse_opts(options, &uid, &gid, &umask, &lowercase, &conv, 494 if (!(o = parse_opts(options, &uid, &gid, &umask, &lowercase,
504 &eas, &chk, &errs, &chkdsk, &timeshift))) { 495 &eas, &chk, &errs, &chkdsk, &timeshift))) {
505 printk("HPFS: bad mount options.\n"); 496 printk("HPFS: bad mount options.\n");
506 goto bail0; 497 goto bail0;
@@ -518,9 +509,9 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent)
518 if (!(spareblock = hpfs_map_sector(s, 17, &bh2, 0))) goto bail3; 509 if (!(spareblock = hpfs_map_sector(s, 17, &bh2, 0))) goto bail3;
519 510
520 /* Check magics */ 511 /* Check magics */
521 if (/*bootblock->magic != BB_MAGIC 512 if (/*le16_to_cpu(bootblock->magic) != BB_MAGIC
522 ||*/ superblock->magic != SB_MAGIC 513 ||*/ le32_to_cpu(superblock->magic) != SB_MAGIC
523 || spareblock->magic != SP_MAGIC) { 514 || le32_to_cpu(spareblock->magic) != SP_MAGIC) {
524 if (!silent) printk("HPFS: Bad magic ... probably not HPFS\n"); 515 if (!silent) printk("HPFS: Bad magic ... probably not HPFS\n");
525 goto bail4; 516 goto bail4;
526 } 517 }
@@ -539,20 +530,20 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent)
539 /* Fill superblock stuff */ 530 /* Fill superblock stuff */
540 s->s_magic = HPFS_SUPER_MAGIC; 531 s->s_magic = HPFS_SUPER_MAGIC;
541 s->s_op = &hpfs_sops; 532 s->s_op = &hpfs_sops;
542 533 s->s_d_op = &hpfs_dentry_operations;
543 sbi->sb_root = superblock->root; 534
544 sbi->sb_fs_size = superblock->n_sectors; 535 sbi->sb_root = le32_to_cpu(superblock->root);
545 sbi->sb_bitmaps = superblock->bitmaps; 536 sbi->sb_fs_size = le32_to_cpu(superblock->n_sectors);
546 sbi->sb_dirband_start = superblock->dir_band_start; 537 sbi->sb_bitmaps = le32_to_cpu(superblock->bitmaps);
547 sbi->sb_dirband_size = superblock->n_dir_band; 538 sbi->sb_dirband_start = le32_to_cpu(superblock->dir_band_start);
548 sbi->sb_dmap = superblock->dir_band_bitmap; 539 sbi->sb_dirband_size = le32_to_cpu(superblock->n_dir_band);
540 sbi->sb_dmap = le32_to_cpu(superblock->dir_band_bitmap);
549 sbi->sb_uid = uid; 541 sbi->sb_uid = uid;
550 sbi->sb_gid = gid; 542 sbi->sb_gid = gid;
551 sbi->sb_mode = 0777 & ~umask; 543 sbi->sb_mode = 0777 & ~umask;
552 sbi->sb_n_free = -1; 544 sbi->sb_n_free = -1;
553 sbi->sb_n_free_dnodes = -1; 545 sbi->sb_n_free_dnodes = -1;
554 sbi->sb_lowercase = lowercase; 546 sbi->sb_lowercase = lowercase;
555 sbi->sb_conv = conv;
556 sbi->sb_eas = eas; 547 sbi->sb_eas = eas;
557 sbi->sb_chk = chk; 548 sbi->sb_chk = chk;
558 sbi->sb_chkdsk = chkdsk; 549 sbi->sb_chkdsk = chkdsk;
@@ -564,7 +555,7 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent)
564 sbi->sb_max_fwd_alloc = 0xffffff; 555 sbi->sb_max_fwd_alloc = 0xffffff;
565 556
566 /* Load bitmap directory */ 557 /* Load bitmap directory */
567 if (!(sbi->sb_bmp_dir = hpfs_load_bitmap_directory(s, superblock->bitmaps))) 558 if (!(sbi->sb_bmp_dir = hpfs_load_bitmap_directory(s, le32_to_cpu(superblock->bitmaps))))
568 goto bail4; 559 goto bail4;
569 560
570 /* Check for general fs errors*/ 561 /* Check for general fs errors*/
@@ -582,20 +573,20 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent)
582 mark_buffer_dirty(bh2); 573 mark_buffer_dirty(bh2);
583 } 574 }
584 575
585 if (spareblock->hotfixes_used || spareblock->n_spares_used) { 576 if (le32_to_cpu(spareblock->hotfixes_used) || le32_to_cpu(spareblock->n_spares_used)) {
586 if (errs >= 2) { 577 if (errs >= 2) {
587 printk("HPFS: Hotfixes not supported here, try chkdsk\n"); 578 printk("HPFS: Hotfixes not supported here, try chkdsk\n");
588 mark_dirty(s); 579 mark_dirty(s, 0);
589 goto bail4; 580 goto bail4;
590 } 581 }
591 hpfs_error(s, "hotfixes not supported here, try chkdsk"); 582 hpfs_error(s, "hotfixes not supported here, try chkdsk");
592 if (errs == 0) printk("HPFS: Proceeding, but your filesystem will be probably corrupted by this driver...\n"); 583 if (errs == 0) printk("HPFS: Proceeding, but your filesystem will be probably corrupted by this driver...\n");
593 else printk("HPFS: This driver may read bad files or crash when operating on disk with hotfixes.\n"); 584 else printk("HPFS: This driver may read bad files or crash when operating on disk with hotfixes.\n");
594 } 585 }
595 if (spareblock->n_dnode_spares != spareblock->n_dnode_spares_free) { 586 if (le32_to_cpu(spareblock->n_dnode_spares) != le32_to_cpu(spareblock->n_dnode_spares_free)) {
596 if (errs >= 2) { 587 if (errs >= 2) {
597 printk("HPFS: Spare dnodes used, try chkdsk\n"); 588 printk("HPFS: Spare dnodes used, try chkdsk\n");
598 mark_dirty(s); 589 mark_dirty(s, 0);
599 goto bail4; 590 goto bail4;
600 } 591 }
601 hpfs_error(s, "warning: spare dnodes used, try chkdsk"); 592 hpfs_error(s, "warning: spare dnodes used, try chkdsk");
@@ -603,26 +594,26 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent)
603 } 594 }
604 if (chk) { 595 if (chk) {
605 unsigned a; 596 unsigned a;
606 if (superblock->dir_band_end - superblock->dir_band_start + 1 != superblock->n_dir_band || 597 if (le32_to_cpu(superblock->dir_band_end) - le32_to_cpu(superblock->dir_band_start) + 1 != le32_to_cpu(superblock->n_dir_band) ||
607 superblock->dir_band_end < superblock->dir_band_start || superblock->n_dir_band > 0x4000) { 598 le32_to_cpu(superblock->dir_band_end) < le32_to_cpu(superblock->dir_band_start) || le32_to_cpu(superblock->n_dir_band) > 0x4000) {
608 hpfs_error(s, "dir band size mismatch: dir_band_start==%08x, dir_band_end==%08x, n_dir_band==%08x", 599 hpfs_error(s, "dir band size mismatch: dir_band_start==%08x, dir_band_end==%08x, n_dir_band==%08x",
609 superblock->dir_band_start, superblock->dir_band_end, superblock->n_dir_band); 600 le32_to_cpu(superblock->dir_band_start), le32_to_cpu(superblock->dir_band_end), le32_to_cpu(superblock->n_dir_band));
610 goto bail4; 601 goto bail4;
611 } 602 }
612 a = sbi->sb_dirband_size; 603 a = sbi->sb_dirband_size;
613 sbi->sb_dirband_size = 0; 604 sbi->sb_dirband_size = 0;
614 if (hpfs_chk_sectors(s, superblock->dir_band_start, superblock->n_dir_band, "dir_band") || 605 if (hpfs_chk_sectors(s, le32_to_cpu(superblock->dir_band_start), le32_to_cpu(superblock->n_dir_band), "dir_band") ||
615 hpfs_chk_sectors(s, superblock->dir_band_bitmap, 4, "dir_band_bitmap") || 606 hpfs_chk_sectors(s, le32_to_cpu(superblock->dir_band_bitmap), 4, "dir_band_bitmap") ||
616 hpfs_chk_sectors(s, superblock->bitmaps, 4, "bitmaps")) { 607 hpfs_chk_sectors(s, le32_to_cpu(superblock->bitmaps), 4, "bitmaps")) {
617 mark_dirty(s); 608 mark_dirty(s, 0);
618 goto bail4; 609 goto bail4;
619 } 610 }
620 sbi->sb_dirband_size = a; 611 sbi->sb_dirband_size = a;
621 } else printk("HPFS: You really don't want any checks? You are crazy...\n"); 612 } else printk("HPFS: You really don't want any checks? You are crazy...\n");
622 613
623 /* Load code page table */ 614 /* Load code page table */
624 if (spareblock->n_code_pages) 615 if (le32_to_cpu(spareblock->n_code_pages))
625 if (!(sbi->sb_cp_table = hpfs_load_code_page(s, spareblock->code_page_dir))) 616 if (!(sbi->sb_cp_table = hpfs_load_code_page(s, le32_to_cpu(spareblock->code_page_dir))))
626 printk("HPFS: Warning: code page support is disabled\n"); 617 printk("HPFS: Warning: code page support is disabled\n");
627 618
628 brelse(bh2); 619 brelse(bh2);
@@ -640,7 +631,6 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent)
640 iput(root); 631 iput(root);
641 goto bail0; 632 goto bail0;
642 } 633 }
643 hpfs_set_dentry_operations(s->s_root);
644 634
645 /* 635 /*
646 * find the root directory's . pointer & finish filling in the inode 636 * find the root directory's . pointer & finish filling in the inode
@@ -652,13 +642,13 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent)
652 if (!de) 642 if (!de)
653 hpfs_error(s, "unable to find root dir"); 643 hpfs_error(s, "unable to find root dir");
654 else { 644 else {
655 root->i_atime.tv_sec = local_to_gmt(s, de->read_date); 645 root->i_atime.tv_sec = local_to_gmt(s, le32_to_cpu(de->read_date));
656 root->i_atime.tv_nsec = 0; 646 root->i_atime.tv_nsec = 0;
657 root->i_mtime.tv_sec = local_to_gmt(s, de->write_date); 647 root->i_mtime.tv_sec = local_to_gmt(s, le32_to_cpu(de->write_date));
658 root->i_mtime.tv_nsec = 0; 648 root->i_mtime.tv_nsec = 0;
659 root->i_ctime.tv_sec = local_to_gmt(s, de->creation_date); 649 root->i_ctime.tv_sec = local_to_gmt(s, le32_to_cpu(de->creation_date));
660 root->i_ctime.tv_nsec = 0; 650 root->i_ctime.tv_nsec = 0;
661 hpfs_i(root)->i_ea_size = de->ea_size; 651 hpfs_i(root)->i_ea_size = le16_to_cpu(de->ea_size);
662 hpfs_i(root)->i_parent_dir = root->i_ino; 652 hpfs_i(root)->i_parent_dir = root->i_ino;
663 if (root->i_size == -1) 653 if (root->i_size == -1)
664 root->i_size = 2048; 654 root->i_size = 2048;
@@ -666,6 +656,7 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent)
666 root->i_blocks = 5; 656 root->i_blocks = 5;
667 hpfs_brelse4(&qbh); 657 hpfs_brelse4(&qbh);
668 } 658 }
659 hpfs_unlock(s);
669 return 0; 660 return 0;
670 661
671bail4: brelse(bh2); 662bail4: brelse(bh2);
@@ -673,6 +664,7 @@ bail3: brelse(bh1);
673bail2: brelse(bh0); 664bail2: brelse(bh0);
674bail1: 665bail1:
675bail0: 666bail0:
667 hpfs_unlock(s);
676 kfree(sbi->sb_bmp_dir); 668 kfree(sbi->sb_bmp_dir);
677 kfree(sbi->sb_cp_table); 669 kfree(sbi->sb_cp_table);
678 s->s_fs_info = NULL; 670 s->s_fs_info = NULL;
@@ -680,17 +672,16 @@ bail0:
680 return -EINVAL; 672 return -EINVAL;
681} 673}
682 674
683static int hpfs_get_sb(struct file_system_type *fs_type, 675static struct dentry *hpfs_mount(struct file_system_type *fs_type,
684 int flags, const char *dev_name, void *data, struct vfsmount *mnt) 676 int flags, const char *dev_name, void *data)
685{ 677{
686 return get_sb_bdev(fs_type, flags, dev_name, data, hpfs_fill_super, 678 return mount_bdev(fs_type, flags, dev_name, data, hpfs_fill_super);
687 mnt);
688} 679}
689 680
690static struct file_system_type hpfs_fs_type = { 681static struct file_system_type hpfs_fs_type = {
691 .owner = THIS_MODULE, 682 .owner = THIS_MODULE,
692 .name = "hpfs", 683 .name = "hpfs",
693 .get_sb = hpfs_get_sb, 684 .mount = hpfs_mount,
694 .kill_sb = kill_block_super, 685 .kill_sb = kill_block_super,
695 .fs_flags = FS_REQUIRES_DEV, 686 .fs_flags = FS_REQUIRES_DEV,
696}; 687};