X-Git-Url: http://ftp.safe.ca/?a=blobdiff_plain;f=fs%2Fhpfs%2Fsuper.c;h=0d049b8919c42ed1c62871f26815994a5f00e254;hb=084f71ae5ceeb16734d8ac47559d3c718456a865;hp=f798480a363f1bf0b5cdd989e0cb354a13561284;hpb=726c334223180e3c0197cc980a432681370d4baf;p=safe%2Fjmp%2Flinux-2.6 diff --git a/fs/hpfs/super.c b/fs/hpfs/super.c index f798480..0d049b8 100644 --- a/fs/hpfs/super.c +++ b/fs/hpfs/super.c @@ -11,6 +11,8 @@ #include #include #include +#include +#include /* Mark the filesystem dirty, so that chkdsk checks it when os/2 booted */ @@ -45,21 +47,17 @@ static void unmark_dirty(struct super_block *s) } /* Filesystem error... */ +static char err_buf[1024]; -#define ERR_BUF_SIZE 1024 - -void hpfs_error(struct super_block *s, char *m,...) +void hpfs_error(struct super_block *s, const char *fmt, ...) { - char *buf; - va_list l; - va_start(l, m); - if (!(buf = kmalloc(ERR_BUF_SIZE, GFP_KERNEL))) - printk("HPFS: No memory for error message '%s'\n",m); - else if (vsprintf(buf, m, l) >= ERR_BUF_SIZE) - printk("HPFS: Grrrr... Kernel memory corrupted ... going on, but it'll crash very soon :-(\n"); - printk("HPFS: filesystem error: "); - if (buf) printk("%s", buf); - else printk("%s\n",m); + va_list args; + + va_start(args, fmt); + vsnprintf(err_buf, sizeof(err_buf), fmt, args); + va_end(args); + + printk("HPFS: filesystem error: %s", err_buf); if (!hpfs_sb(s)->sb_was_error) { if (hpfs_sb(s)->sb_err == 2) { printk("; crashing the system because you wanted it\n"); @@ -75,7 +73,6 @@ void hpfs_error(struct super_block *s, char *m,...) } else if (s->s_flags & MS_RDONLY) printk("; going on - but anything won't be destroyed because it's read-only\n"); else printk("; corrupted filesystem mounted read/write - your computer will explode within 20 seconds ... but you wanted it so!\n"); } else printk("\n"); - kfree(buf); hpfs_sb(s)->sb_was_error = 1; } @@ -159,12 +156,12 @@ static int hpfs_statfs(struct dentry *dentry, struct kstatfs *buf) return 0; } -static kmem_cache_t * hpfs_inode_cachep; +static struct kmem_cache * hpfs_inode_cachep; static struct inode *hpfs_alloc_inode(struct super_block *sb) { struct hpfs_inode_info *ei; - ei = (struct hpfs_inode_info *)kmem_cache_alloc(hpfs_inode_cachep, SLAB_NOFS); + ei = (struct hpfs_inode_info *)kmem_cache_alloc(hpfs_inode_cachep, GFP_NOFS); if (!ei) return NULL; ei->vfs_inode.i_version = 1; @@ -176,25 +173,22 @@ static void hpfs_destroy_inode(struct inode *inode) kmem_cache_free(hpfs_inode_cachep, hpfs_i(inode)); } -static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) +static void init_once(void *foo) { struct hpfs_inode_info *ei = (struct hpfs_inode_info *) foo; - if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) == - SLAB_CTOR_CONSTRUCTOR) { - mutex_init(&ei->i_mutex); - mutex_init(&ei->i_parent_mutex); - inode_init_once(&ei->vfs_inode); - } + mutex_init(&ei->i_mutex); + mutex_init(&ei->i_parent_mutex); + inode_init_once(&ei->vfs_inode); } - + static int init_inodecache(void) { hpfs_inode_cachep = kmem_cache_create("hpfs_inode_cache", sizeof(struct hpfs_inode_info), 0, (SLAB_RECLAIM_ACCOUNT| SLAB_MEM_SPREAD), - init_once, NULL); + init_once); if (hpfs_inode_cachep == NULL) return -ENOMEM; return 0; @@ -202,8 +196,7 @@ static int init_inodecache(void) static void destroy_inodecache(void) { - if (kmem_cache_destroy(hpfs_inode_cachep)) - printk(KERN_INFO "hpfs_inode_cache: not all structures were freed\n"); + kmem_cache_destroy(hpfs_inode_cachep); } /* @@ -222,7 +215,7 @@ enum { Opt_timeshift, Opt_err, }; -static match_table_t tokens = { +static const match_table_t tokens = { {Opt_help, "help"}, {Opt_uid, "uid=%u"}, {Opt_gid, "gid=%u"}, @@ -393,6 +386,7 @@ static int hpfs_remount_fs(struct super_block *s, int *flags, char *data) int lowercase, conv, eas, chk, errs, chkdsk, timeshift; int o; struct hpfs_sb_info *sbi = hpfs_sb(s); + char *new_opts = kstrdup(data, GFP_KERNEL); *flags |= MS_NOATIME; @@ -405,15 +399,15 @@ static int hpfs_remount_fs(struct super_block *s, int *flags, char *data) if (!(o = parse_opts(data, &uid, &gid, &umask, &lowercase, &conv, &eas, &chk, &errs, &chkdsk, ×hift))) { printk("HPFS: bad mount options.\n"); - return 1; + goto out_err; } if (o == 2) { hpfs_help(); - return 1; + goto out_err; } if (timeshift != sbi->sb_timeshift) { printk("HPFS: timeshift can't be changed using remount.\n"); - return 1; + goto out_err; } unmark_dirty(s); @@ -426,12 +420,19 @@ static int hpfs_remount_fs(struct super_block *s, int *flags, char *data) if (!(*flags & MS_RDONLY)) mark_dirty(s); + kfree(s->s_options); + s->s_options = new_opts; + return 0; + +out_err: + kfree(new_opts); + return -EINVAL; } /* Super operations */ -static struct super_operations hpfs_sops = +static const struct super_operations hpfs_sops = { .alloc_inode = hpfs_alloc_inode, .destroy_inode = hpfs_destroy_inode, @@ -439,6 +440,7 @@ static struct super_operations hpfs_sops = .put_super = hpfs_put_super, .statfs = hpfs_statfs, .remount_fs = hpfs_remount_fs, + .show_options = generic_show_options, }; static int hpfs_fill_super(struct super_block *s, void *options, int silent) @@ -461,19 +463,20 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent) int o; - sbi = kmalloc(sizeof(*sbi), GFP_KERNEL); + save_mount_options(s, options); + + sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); if (!sbi) return -ENOMEM; s->s_fs_info = sbi; - memset(sbi, 0, sizeof(*sbi)); sbi->sb_bmp_dir = NULL; sbi->sb_cp_table = NULL; init_MUTEX(&sbi->hpfs_creation_de); - uid = current->uid; - gid = current->gid; + uid = current_uid(); + gid = current_gid(); umask = current->fs->umask; lowercase = 0; conv = CONV_BINARY;