/* * fill in the superblock */ static int jffs2_fill_super(struct super_block *sb, void *data, int silent) { struct jffs2_sb_info *c; D1(printk(KERN_DEBUG "jffs2_get_sb_mtd():" " New superblock for device %d (\"%s\")\n", sb->s_mtd->index, sb->s_mtd->name)); c = kzalloc(sizeof(*c), GFP_KERNEL); if (!c) return -ENOMEM; c->mtd = sb->s_mtd; c->os_priv = sb; sb->s_fs_info = c; /* Initialize JFFS2 superblock locks, the further initialization will * be done later */ init_MUTEX(&c->alloc_sem); init_MUTEX(&c->erase_free_sem); init_waitqueue_head(&c->erase_wait); init_waitqueue_head(&c->inocache_wq); spin_lock_init(&c->erase_completion_lock); spin_lock_init(&c->inocache_lock); sb->s_op = &jffs2_super_operations; sb->s_flags = sb->s_flags | MS_NOATIME; sb->s_xattr = jffs2_xattr_handlers; #ifdef CONFIG_JFFS2_FS_POSIX_ACL sb->s_flags |= MS_POSIXACL; #endif return jffs2_do_fill_super(sb, data, silent); }
static struct super_block *jffs2_read_super(struct super_block *sb, void *data, int silent) { struct jffs2_sb_info *c; int ret; D1(printk(KERN_DEBUG "jffs2: read_super for device %s\n", kdevname(sb->s_dev))); if (major(sb->s_dev) != MTD_BLOCK_MAJOR) { if (!silent) printk(KERN_DEBUG "jffs2: attempt to mount non-MTD device %s\n", kdevname(sb->s_dev)); return NULL; } c = JFFS2_SB_INFO(sb); memset(c, 0, sizeof(*c)); sb->s_op = &jffs2_super_operations; c->mtd = get_mtd_device(NULL, minor(sb->s_dev)); if (!c->mtd) { D1(printk(KERN_DEBUG "jffs2: MTD device #%u doesn't appear to exist\n", minor(sb->s_dev))); return NULL; } ret = jffs2_do_fill_super(sb, data, silent); if (ret) { put_mtd_device(c->mtd); return NULL; } return sb; }
static struct super_block *jffs2_get_sb_mtd(struct file_system_type *fs_type, int flags, const char *dev_name, void *data, struct mtd_info *mtd) { struct super_block *sb; struct jffs2_sb_info *c; int ret; c = kmalloc(sizeof(*c), GFP_KERNEL); if (!c) return ERR_PTR(-ENOMEM); memset(c, 0, sizeof(*c)); c->mtd = mtd; sb = sget(fs_type, jffs2_sb_compare, jffs2_sb_set, c); if (IS_ERR(sb)) goto out_put; if (sb->s_root) { /* New mountpoint for JFFS2 which is already mounted */ D1(printk(KERN_DEBUG "jffs2_get_sb_mtd(): Device %d (\"%s\") is already mounted\n", mtd->index, mtd->name)); goto out_put; } D1(printk(KERN_DEBUG "jffs2_get_sb_mtd(): New superblock for device %d (\"%s\")\n", mtd->index, mtd->name)); /* Initialize JFFS2 superblock locks, the further initialization will be * done later */ init_MUTEX(&c->alloc_sem); init_MUTEX(&c->erase_free_sem); init_waitqueue_head(&c->erase_wait); init_waitqueue_head(&c->inocache_wq); spin_lock_init(&c->erase_completion_lock); spin_lock_init(&c->inocache_lock); sb->s_op = &jffs2_super_operations; sb->s_flags = flags | MS_NOATIME; ret = jffs2_do_fill_super(sb, data, (flags&MS_VERBOSE)?1:0); if (ret) { /* Failure case... */ up_write(&sb->s_umount); deactivate_super(sb); return ERR_PTR(ret); } sb->s_flags |= MS_ACTIVE; return sb; out_put: kfree(c); put_mtd_device(mtd); return sb; }
static struct super_block *jffs2_get_sb_mtd(struct file_system_type *fs_type, int flags, const char *dev_name, void *data, struct mtd_info *mtd) { struct super_block *sb; struct jffs2_sb_info *c; int ret; c = kmalloc(sizeof(*c), GFP_KERNEL); if (!c) return ERR_PTR(-ENOMEM); memset(c, 0, sizeof(*c)); c->mtd = mtd; sb = sget(fs_type, jffs2_sb_compare, jffs2_sb_set, c); if (IS_ERR(sb)) goto out_put; if (sb->s_root) { /* New mountpoint for JFFS2 which is already mounted */ D1(printk(KERN_DEBUG "jffs2_get_sb_mtd(): Device %d (\"%s\") is already mounted\n", mtd->index, mtd->name)); goto out_put; } D1(printk(KERN_DEBUG "jffs2_get_sb_mtd(): New superblock for device %d (\"%s\")\n", mtd->index, mtd->name)); sb->s_op = &jffs2_super_operations; ret = jffs2_do_fill_super(sb, data, (flags&MS_VERBOSE)?1:0); if (ret) { /* Failure case... */ up_write(&sb->s_umount); deactivate_super(sb); return ERR_PTR(ret); } sb->s_flags |= MS_ACTIVE; return sb; out_put: kfree(c); put_mtd_device(mtd); return sb; }
/* * fill in the superblock */ static int jffs2_fill_super(struct super_block *sb, void *data, int silent) { struct jffs2_sb_info *c; int ret; jffs2_dbg(1, "jffs2_get_sb_mtd():" " New superblock for device %d (\"%s\")\n", sb->s_mtd->index, sb->s_mtd->name); c = kzalloc(sizeof(*c), GFP_KERNEL); if (!c) return -ENOMEM; c->mtd = sb->s_mtd; c->os_priv = sb; sb->s_fs_info = c; ret = jffs2_parse_options(c, data); if (ret) return -EINVAL; /* Initialize JFFS2 superblock locks, the further initialization will * be done later */ mutex_init(&c->alloc_sem); mutex_init(&c->erase_free_sem); init_waitqueue_head(&c->erase_wait); init_waitqueue_head(&c->inocache_wq); spin_lock_init(&c->erase_completion_lock); spin_lock_init(&c->inocache_lock); sb->s_op = &jffs2_super_operations; sb->s_export_op = &jffs2_export_ops; sb->s_flags = sb->s_flags | SB_NOATIME; sb->s_xattr = jffs2_xattr_handlers; #ifdef CONFIG_JFFS2_FS_POSIX_ACL sb->s_flags |= SB_POSIXACL; #endif ret = jffs2_do_fill_super(sb, data, silent); return ret; }
static int jffs2_get_sb_mtd(struct file_system_type *fs_type, int flags, const char *dev_name, void *data, struct mtd_info *mtd, struct vfsmount *mnt) { struct super_block *sb; struct jffs2_sb_info *c; int ret; c = kzalloc(sizeof(*c), GFP_KERNEL); if (!c) return -ENOMEM; c->mtd = mtd; sb = sget(fs_type, jffs2_sb_compare, jffs2_sb_set, c); if (IS_ERR(sb)) goto out_error; if (sb->s_root) { /* New mountpoint for JFFS2 which is already mounted */ D1(printk(KERN_DEBUG "jffs2_get_sb_mtd(): Device %d (\"%s\") is already mounted\n", mtd->index, mtd->name)); ret = simple_set_mnt(mnt, sb); goto out_put; } D1(printk(KERN_DEBUG "jffs2_get_sb_mtd(): New superblock for device %d (\"%s\")\n", mtd->index, mtd->name)); /* Initialize JFFS2 superblock locks, the further initialization will be * done later */ init_MUTEX(&c->alloc_sem); init_MUTEX(&c->erase_free_sem); init_waitqueue_head(&c->erase_wait); init_waitqueue_head(&c->inocache_wq); spin_lock_init(&c->erase_completion_lock); spin_lock_init(&c->inocache_lock); sb->s_op = &jffs2_super_operations; sb->s_flags = flags | MS_NOATIME; sb->s_xattr = jffs2_xattr_handlers; #ifdef CONFIG_JFFS2_FS_POSIX_ACL sb->s_flags |= MS_POSIXACL; #endif ret = jffs2_do_fill_super(sb, data, flags & MS_SILENT ? 1 : 0); if (ret) { /* Failure case... */ up_write(&sb->s_umount); deactivate_super(sb); return ret; } sb->s_flags |= MS_ACTIVE; return simple_set_mnt(mnt, sb); out_error: ret = PTR_ERR(sb); out_put: kfree(c); put_mtd_device(mtd); return ret; }