10 #include <linux/module.h>
14 #include <linux/magic.h>
15 #include <linux/sched.h>
16 #include <linux/bitmap.h>
17 #include <linux/slab.h>
21 static void mark_dirty(
struct super_block *
s,
int remount)
24 struct buffer_head *bh;
41 struct buffer_head *bh;
46 sb->
dirty = hpfs_sb(s)->sb_chkdsk > 1 - hpfs_sb(s)->sb_was_error;
47 sb->
old_wrote = hpfs_sb(s)->sb_chkdsk >= 2 && !hpfs_sb(s)->sb_was_error;
55 static char err_buf[1024];
62 vsnprintf(err_buf,
sizeof(err_buf), fmt, args);
65 printk(
"HPFS: filesystem error: %s", err_buf);
66 if (!hpfs_sb(s)->sb_was_error) {
67 if (hpfs_sb(s)->sb_err == 2) {
68 printk(
"; crashing the system because you wanted it\n");
71 }
else if (hpfs_sb(s)->sb_err == 1) {
74 printk(
"; remounting 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");
79 else printk(
"; corrupted filesystem mounted read/write - your computer will explode within 20 seconds ... but you wanted it so!\n");
81 hpfs_sb(s)->sb_was_error = 1;
95 if (*c2 && *c1 == key) {
96 hpfs_error(s,
"cycle detected on key %08x in %s", key, msg);
100 if (!((*c2 - 1) & *c2)) *c1 =
key;
132 static unsigned count_bitmaps(
struct super_block *s)
134 unsigned n,
count, n_bands;
135 n_bands = (hpfs_sb(s)->sb_fs_size + 0x3fff) >> 14;
137 for (n = 0; n < n_bands; n++)
146 u64 id = huge_encode_dev(s->
s_bdev->bd_dev);
187 static void hpfs_destroy_inode(
struct inode *inode)
192 static void init_once(
void *
foo)
199 static int init_inodecache(
void)
206 if (hpfs_inode_cachep ==
NULL)
211 static void destroy_inodecache(
void)
260 int *lowercase,
int *eas,
int *chk,
int *errs,
261 int *chkdsk,
int *timeshift)
285 if (!uid_valid(*uid))
292 if (!gid_valid(*gid))
345 char *rhs = args[0].
from;
348 if (*rhs ==
'-') m = -1;
349 if (*rhs ==
'+' || *rhs ==
'-') rhs++;
362 static inline void hpfs_help(
void)
365 HPFS filesystem options:\n\
366 help do not mount and display this text\n\
367 uid=xxx set uid of files that don't have uid specified in eas\n\
368 gid=xxx set gid of files that don't have gid specified in eas\n\
369 umask=xxx set mode of files that don't have mode specified in eas\n\
370 case=lower lowercase all files\n\
371 case=asis do not lowercase files (default)\n\
372 check=none no fs checks - kernel may crash on corrupted filesystem\n\
373 check=normal do some checks - it should not crash (default)\n\
374 check=strict do extra time-consuming checks, used for debugging\n\
375 errors=continue continue on errors\n\
376 errors=remount-ro remount read-only if errors found (default)\n\
377 errors=panic panic on errors\n\
378 chkdsk=no do not mark fs for chkdsking even if there were errors\n\
379 chkdsk=errors mark fs dirty if errors found (default)\n\
380 chkdsk=always always mark fs dirty - used for debugging\n\
381 eas=no ignore extended attributes\n\
382 eas=ro read but do not write extended attributes\n\
383 eas=rw r/w eas => enables chmod, chown, mknod, ln -s (default)\n\
384 timeshift=nnn add nnn seconds to file times\n\
393 int lowercase, eas, chk, errs, chkdsk, timeshift;
407 if (!(o = parse_opts(data, &uid, &gid, &umask, &lowercase,
408 &eas, &chk, &errs, &chkdsk, ×hift))) {
409 printk(
"HPFS: bad mount options.\n");
417 printk(
"HPFS: timeshift can't be changed using remount.\n");
429 if (!(*flags &
MS_RDONLY)) mark_dirty(s, 1);
446 .alloc_inode = hpfs_alloc_inode,
447 .destroy_inode = hpfs_destroy_inode,
449 .put_super = hpfs_put_super,
450 .statfs = hpfs_statfs,
451 .remount_fs = hpfs_remount_fs,
457 struct buffer_head *bh0, *bh1, *bh2;
467 int lowercase, eas, chk, errs, chkdsk, timeshift;
499 if (!(o = parse_opts(options, &uid, &gid, &umask, &lowercase,
500 &eas, &chk, &errs, &chkdsk, ×hift))) {
501 printk(
"HPFS: bad mount options.\n");
520 if (!silent)
printk(
"HPFS: Bad magic ... probably not HPFS\n");
527 printk(
"HPFS: Bad version %d,%d. Mount readonly to go around\n",
529 printk(
"HPFS: please try recent version of HPFS driver at http://artax.karlin.mff.cuni.cz/~mikulas/vyplody/hpfs/index-e.cgi and if it still can't understand this format, contact author - [email protected]\n");
537 s->
s_op = &hpfs_sops;
569 printk(
"HPFS: Improperly stopped, not mounted\n");
576 spareblock->
dirty = 1;
583 printk(
"HPFS: Hotfixes not supported here, try chkdsk\n");
587 hpfs_error(s,
"hotfixes not supported here, try chkdsk");
588 if (errs == 0)
printk(
"HPFS: Proceeding, but your filesystem will be probably corrupted by this driver...\n");
589 else printk(
"HPFS: This driver may read bad files or crash when operating on disk with hotfixes.\n");
593 printk(
"HPFS: Spare dnodes used, try chkdsk\n");
597 hpfs_error(s,
"warning: spare dnodes used, try chkdsk");
598 if (errs == 0)
printk(
"HPFS: Proceeding, but your filesystem could be corrupted if you delete files or directories\n");
604 hpfs_error(s,
"dir band size mismatch: dir_band_start==%08x, dir_band_end==%08x, n_dir_band==%08x",
617 }
else printk(
"HPFS: You really don't want any checks? You are crazy...\n");
622 printk(
"HPFS: Warning: code page support is disabled\n");
655 hpfs_i(root)->i_parent_dir = root->
i_ino;
679 int flags,
const char *dev_name,
void *data)
681 return mount_bdev(fs_type, flags, dev_name, data, hpfs_fill_super);
692 static int __init init_hpfs_fs(
void)
694 int err = init_inodecache();
702 destroy_inodecache();
707 static void __exit exit_hpfs_fs(
void)
710 destroy_inodecache();