struct dentry *wrapfs_mount(struct file_system_type *fs_type, int flags, const char *dev_name, void *raw_data) { void *lower_path_name = (void *) dev_name; wrapfs_debug("wrapfs_mount"); parse_wrapfs_options(raw_data); return mount_nodev(fs_type, flags, lower_path_name, wrapfs_read_super); }
struct dentry *wrapfs_mount(struct file_system_type *fs_type, int flags, const char *dev_name, void *raw_data) { struct dentry *dentry; dentry = mount_nodev(fs_type, flags, raw_data, wrapfs_read_super); if (!IS_ERR(dentry)) WRAPFS_SB(dentry->d_sb)->dev_name = kstrdup(dev_name, GFP_KERNEL); return dentry; }
static struct dentry * proxyfs_fs_mount(struct file_system_type *fs_type, int flags, const char *devname, void *data) { struct proxyfs_task *task; mdbg(INFO3, "Mounting ProxyFS, server is on %s", devname); if ( (task = proxyfs_task_run( proxyfs_client_thread, devname )) == NULL ) return (void *)-EINVAL; //Convert to void* for remove warning by Jiri Rakosnik // return get_sb_single(fs_type, flags, task, proxyfs_fs_fill_super, mnt); return mount_nodev(fs_type, flags, task, proxyfs_fs_fill_super); //Replaced function get_sb_nodev to mount_nodev and remove mnt parameter | by Jiri Rakosnik }
static struct dentry *rootfs_mount(struct file_system_type *fs_type, int flags, const char *dev_name, void *data) { static unsigned long once; void *fill = ramfs_fill_super; if (test_and_set_bit(0, &once)) return ERR_PTR(-ENODEV); if (IS_ENABLED(CONFIG_TMPFS) && is_tmpfs) fill = shmem_fill_super; return mount_nodev(fs_type, flags, data, fill); }
static struct dentry * zpl_mount(struct file_system_type *fs_type, int flags, const char *osname, void *data) { zfs_mntopts_t *zmo = zfs_mntopts_alloc(); int error; error = zpl_parse_options((char *)osname, (char *)data, zmo, B_FALSE); if (error) { zfs_mntopts_free(zmo); return (ERR_PTR(error)); } return (mount_nodev(fs_type, flags, zmo, zpl_fill_super)); }
struct dentry *wrapfs_mount(struct file_system_type *fs_type, int flags, const char *dev_name, void *raw_data) { void *lower_path_name = (void *) dev_name; struct dentry *d = NULL; d = mount_nodev(fs_type, flags, lower_path_name, wrapfs_read_super); if (d) { wrapfs_parse_mount_options((char *)raw_data, d->d_sb); #ifdef WRAPFS_CRYPTO wrapfs_set_enc_key(d->d_sb , NULL); #endif } return d; }
struct dentry *wrapfs_mount(struct file_system_type *fs_type, int flags, const char *dev_name, void *raw_data) { void *lower_path_name = (void *) dev_name; struct dentry *sb_dentry; struct wrapfs_mnt_opt mount_options; int retval=0; DEBUG_MESG("Enter"); retval = wrapfs_parse_options(raw_data, &mount_options); if(retval<0) { printk("wrapfs_mount: Error parsing options\n"); goto out; } sb_dentry = mount_nodev(fs_type, flags, lower_path_name, wrapfs_read_super); if(!sb_dentry) printk(KERN_ERR "sb_dentry is null\n"); printk("**********************************************\n"); wrapfs_set_mount_options(sb_dentry->d_sb, mount_options); #ifdef WRAPFS_CRYPTO WRAPFS_SB(sb_dentry->d_sb)->has_key = FALSE; // make sure to set it to FALSE ??? #endif // printk("%d\n", wrapfs_get_debug(sb_dentry->d_sb)); //memset(((struct wrapfs_sb_info *)(sb)->s_fs_info)->key, '0', KEYLEN + 1); //((struct wrapfs_sb_info *)(sb)->s_fs_info)->key[KEYLEN] = '\0'; DEBUG_MESG("Exit"); return sb_dentry; out: return ERR_PTR(retval); }
static int axfs_get_sb_address(struct file_system_type *fs_type, int flags, struct axfs_super *sbi, struct vfsmount *mnt, int *err) #endif { #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,36) struct dentry *dp = NULL; #else int mtdnr; #endif char *sd = sbi->second_dev; if (sbi->phys_start_addr == 0) return false; if (sbi->phys_start_addr & (PAGE_SIZE - 1)) { printk(KERN_ERR "axfs: address 0x%lx for axfs image isn't aligned " "to a page boundary\n", sbi->phys_start_addr); #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,36) return ERR_PTR(-EINVAL); } dp = axfs_mount_mtd(fs_type, flags, sd, sbi); if (!IS_ERR_OR_NULL(dp)) return dp; dp = axfs_mount_bdev(fs_type, flags, sd, sbi); if (!IS_ERR_OR_NULL(dp)) return dp; return mount_nodev(fs_type, flags, sbi, axfs_fill_super); #else *err = -EINVAL; return true; }
struct dentry *ramfs_mount(struct file_system_type *fs_type, int flags, const char *dev_name, void *data) { return mount_nodev(fs_type, flags, data, ramfs_fill_super); }
struct dentry *rbfs_mount(struct file_system_type *type, int flags, const char *dev, void *data) { printk("mounting\n"); return mount_nodev(type, flags, data, rbfs_fill_super); }
static struct dentry *sf_mount(struct file_system_type *fs_type, int flags, const char *dev_name, void *data) { TRACE(); return mount_nodev(fs_type, flags, data, sf_read_super_26); }
static struct dentry *bpf_mount(struct file_system_type *type, int flags, const char *dev_name, void *data) { return mount_nodev(type, flags, data, bpf_fill_super); }
static struct dentry* samplefs_get_sb(struct file_system_type *fs_type, int flags, const char *dev_name, void *data) { return mount_nodev(fs_type, flags, data, samplefs_fill_super); }
static struct dentry *myfs_mount(struct file_system_type *fs_type, int flags, const char *dev_name, void *data) { /* TODO 1: call superblock initialization method */ return mount_nodev(fs_type, flags, data, myfs_fill_super); }
//----------------------------------------------------------------------------- // Mount the filesystem // From docs: the mount() method must return the root dentry of the tree // requested by caller. An active reference to its superblock must be // grabbed and the superblock must be locked. On failure it should return // ERR_PTR(error). //----------------------------------------------------------------------------- struct dentry *janfs_mount(struct file_system_type *fs_type, int flags, const char *dev_name, void *data) { int ret = 0, remote_port = 0; char remote_address[32]; char* token = NULL; char* data_buf = NULL; printk("Janfs mounting filesystem: data[%s], dev_name[%s].\n", (char*)data, dev_name); data_buf = kstrdup(dev_name, GFP_KERNEL); if (!data_buf) { printk(" Error duplicating string [%s].\n", dev_name); goto out_err_ret; } // Remote address token = strsep(&data_buf, ":"); if (!token) { printk(" Error spliting string [%s].\n", data_buf); goto out_err; } strncpy(remote_address, token, sizeof(remote_address)); // Remote port token = strsep(&data_buf, ":"); if (!token) { printk(" Error spliting string [%s].\n", data_buf); goto out_err; } if (kstrtoint(token, 10, &remote_port) != 0) { printk(" Error parsing integer from string [%s].\n", token); goto out_err; } // Copy remote mount path token = strsep(&data_buf, ":"); if (!token) { printk(" Error spliting string [%s].\n", data_buf); goto out_err; } strncpy(mount_path, token, sizeof(mount_path)); // Free duplicated string kfree(data_buf); printk("Mounting janfs with remote addr=%s, port=%d and path=%s.\n", remote_address, remote_port, token); ret = create_client_socket(); if (ret) { printk(KERN_ERR " Could not create client socket.\n"); goto out_err; } // Connect to specified address ret = connect_server(remote_address, remote_port); if (ret) { printk(KERN_ERR " Could not connect to remote host.\n"); goto out_err; } return mount_nodev(fs_type, flags, data, janfs_fill_super); out_err: kfree(data_buf); out_err_ret: return ERR_PTR(-ENOMEM); }
static int dazukofs_fill_super(struct super_block *sb, void *data, int silent) { struct dazukofs_sb_info *sbi; struct dentry *root; static const struct qstr name = { .name = "/", .len = 1 }; struct dazukofs_dentry_info *di; sbi = kmem_cache_zalloc(dazukofs_sb_info_cachep, GFP_KERNEL); if (!sbi) return -ENOMEM; sb->s_op = &dazukofs_sops; root = d_alloc(NULL, &name); if (!root) { kmem_cache_free(dazukofs_sb_info_cachep, sbi); return -ENOMEM; } sb->s_root = root; sb->s_root->d_op = &dazukofs_dops; sb->s_root->d_sb = sb; sb->s_root->d_parent = sb->s_root; di = kmem_cache_zalloc(dazukofs_dentry_info_cachep, GFP_KERNEL); if (!di) { kmem_cache_free(dazukofs_sb_info_cachep, sbi); dput(sb->s_root); return -ENOMEM; } set_dentry_private(sb->s_root, di); set_sb_private(sb, sbi); return 0; } static int dazukofs_read_super(struct super_block *sb, const char *dev_name) { struct nameidata nd; struct dentry *lower_root; struct vfsmount *lower_mnt; int err; memset(&nd, 0, sizeof(struct nameidata)); #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39) err = kern_path(dev_name, LOOKUP_FOLLOW | LOOKUP_DIRECTORY, &nd.path); #else err = path_lookup(dev_name, LOOKUP_FOLLOW | LOOKUP_DIRECTORY, &nd); #endif if (err) return err; lower_root = dget(nd.path.dentry); lower_mnt = mntget(nd.path.mnt); if (IS_ERR(lower_root)) { err = PTR_ERR(lower_root); goto out_put; } if (!lower_root->d_inode) { err = -ENOENT; goto out_put; } if (!S_ISDIR(lower_root->d_inode->i_mode)) { err = -EINVAL; goto out_put; } set_lower_sb(sb, lower_root->d_sb); sb->s_maxbytes = lower_root->d_sb->s_maxbytes; set_lower_dentry(sb->s_root, lower_root, lower_mnt); err = dazukofs_interpose(lower_root, sb->s_root, sb, 0); if (err) goto out_put; goto out; out_put: dput(lower_root); mntput(lower_mnt); out: path_put(&nd.path); return err; } // FIXME! #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39) static struct dentry* dazukofs_get_sb(struct file_system_type *fs_type, int flags, const char *dev_name, void *data) { return mount_nodev(fs_type, flags, data, dazukofs_fill_super); } #else static int dazukofs_get_sb(struct file_system_type *fs_type, int flags, const char *dev_name, void *data, struct vfsmount *mnt) { struct super_block *sb; int err; err = get_sb_nodev(fs_type, flags, data, dazukofs_fill_super, mnt); if (err) goto out; sb = mnt->mnt_sb; err = dazukofs_parse_mount_options(data, sb); if (err) goto out_abort; err = dazukofs_read_super(sb, dev_name); if (err) goto out_abort; goto out; out_abort: dput(sb->s_root); up_write(&sb->s_umount); deactivate_super(sb); out: return err; } #endif static void init_once(void *data) { struct dazukofs_inode_info *inode_info = (struct dazukofs_inode_info *)data; memset(inode_info, 0, sizeof(struct dazukofs_inode_info)); inode_init_once(&(inode_info->vfs_inode)); } static void destroy_caches(void) { if (dazukofs_inode_info_cachep) { kmem_cache_destroy(dazukofs_inode_info_cachep); dazukofs_inode_info_cachep = NULL; } if (dazukofs_sb_info_cachep) { kmem_cache_destroy(dazukofs_sb_info_cachep); dazukofs_sb_info_cachep = NULL; } if (dazukofs_dentry_info_cachep) { kmem_cache_destroy(dazukofs_dentry_info_cachep); dazukofs_dentry_info_cachep = NULL; } if (dazukofs_file_info_cachep) { kmem_cache_destroy(dazukofs_file_info_cachep); dazukofs_file_info_cachep = NULL; } } static int init_caches(void) { dazukofs_inode_info_cachep = kmem_cache_create("dazukofs_inode_info_cache", sizeof(struct dazukofs_inode_info), 0, SLAB_HWCACHE_ALIGN, init_once); if (!dazukofs_inode_info_cachep) goto out_nomem; dazukofs_sb_info_cachep = kmem_cache_create("dazukofs_sb_info_cache", sizeof(struct dazukofs_sb_info), 0, SLAB_HWCACHE_ALIGN, NULL); if (!dazukofs_sb_info_cachep) goto out_nomem; dazukofs_dentry_info_cachep = kmem_cache_create("dazukofs_dentry_info_cache", sizeof(struct dazukofs_dentry_info), 0, SLAB_HWCACHE_ALIGN, NULL); if (!dazukofs_dentry_info_cachep) goto out_nomem; dazukofs_file_info_cachep = kmem_cache_create("dazukofs_file_info_cache", sizeof(struct dazukofs_file_info), 0, SLAB_HWCACHE_ALIGN, NULL); if (!dazukofs_file_info_cachep) goto out_nomem; return 0; out_nomem: destroy_caches(); return -ENOMEM; }
static int exofs_read_lookup_dev_table(struct exofs_sb_info **psbi, unsigned table_count) { struct exofs_sb_info *sbi = *psbi; struct osd_dev *fscb_od; struct osd_obj_id obj = {.partition = sbi->layout.s_pid, .id = EXOFS_DEVTABLE_ID}; struct exofs_device_table *dt; unsigned table_bytes = table_count * sizeof(dt->dt_dev_table[0]) + sizeof(*dt); unsigned numdevs, i; int ret; dt = kmalloc(table_bytes, GFP_KERNEL); if (unlikely(!dt)) { EXOFS_ERR("ERROR: allocating %x bytes for device table\n", table_bytes); return -ENOMEM; } fscb_od = sbi->layout.s_ods[0]; sbi->layout.s_ods[0] = NULL; sbi->layout.s_numdevs = 0; ret = exofs_read_kern(fscb_od, sbi->s_cred, &obj, 0, dt, table_bytes); if (unlikely(ret)) { EXOFS_ERR("ERROR: reading device table\n"); goto out; } numdevs = le64_to_cpu(dt->dt_num_devices); if (unlikely(!numdevs)) { ret = -EINVAL; goto out; } WARN_ON(table_count != numdevs); ret = _read_and_match_data_map(sbi, numdevs, dt); if (unlikely(ret)) goto out; if (likely(numdevs > 1)) { unsigned size = numdevs * sizeof(sbi->layout.s_ods[0]); sbi = krealloc(sbi, sizeof(*sbi) + size, GFP_KERNEL); if (unlikely(!sbi)) { ret = -ENOMEM; goto out; } memset(&sbi->layout.s_ods[1], 0, size - sizeof(sbi->layout.s_ods[0])); *psbi = sbi; } for (i = 0; i < numdevs; i++) { struct exofs_fscb fscb; struct osd_dev_info odi; struct osd_dev *od; if (exofs_devs_2_odi(&dt->dt_dev_table[i], &odi)) { EXOFS_ERR("ERROR: Read all-zeros device entry\n"); ret = -EINVAL; goto out; } printk(KERN_NOTICE "Add device[%d]: osd_name-%s\n", i, odi.osdname); /* On all devices the device table is identical. The user can * specify any one of the participating devices on the command * line. We always keep them in device-table order. */ if (fscb_od && osduld_device_same(fscb_od, &odi)) { sbi->layout.s_ods[i] = fscb_od; ++sbi->layout.s_numdevs; fscb_od = NULL; continue; } od = osduld_info_lookup(&odi); if (unlikely(IS_ERR(od))) { ret = PTR_ERR(od); EXOFS_ERR("ERROR: device requested is not found " "osd_name-%s =>%d\n", odi.osdname, ret); goto out; } sbi->layout.s_ods[i] = od; ++sbi->layout.s_numdevs; /* Read the fscb of the other devices to make sure the FS * partition is there. */ ret = exofs_read_kern(od, sbi->s_cred, &obj, 0, &fscb, sizeof(fscb)); if (unlikely(ret)) { EXOFS_ERR("ERROR: Malformed participating device " "error reading fscb osd_name-%s\n", odi.osdname); goto out; } /* TODO: verify other information is correct and FS-uuid * matches. Benny what did you say about device table * generation and old devices? */ } out: kfree(dt); if (unlikely(!ret && fscb_od)) { EXOFS_ERR( "ERROR: Bad device-table container device not present\n"); osduld_put_device(fscb_od); ret = -EINVAL; } return ret; } /* * Read the superblock from the OSD and fill in the fields */ static int exofs_fill_super(struct super_block *sb, void *data, int silent) { struct inode *root; struct exofs_mountopt *opts = data; struct exofs_sb_info *sbi; /*extended info */ struct osd_dev *od; /* Master device */ struct exofs_fscb fscb; /*on-disk superblock info */ struct osd_obj_id obj; unsigned table_count; int ret; sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); if (!sbi) return -ENOMEM; ret = bdi_setup_and_register(&sbi->bdi, "exofs", BDI_CAP_MAP_COPY); if (ret) goto free_bdi; /* use mount options to fill superblock */ od = osduld_path_lookup(opts->dev_name); if (IS_ERR(od)) { ret = PTR_ERR(od); goto free_sbi; } /* Default layout in case we do not have a device-table */ sbi->layout.stripe_unit = PAGE_SIZE; sbi->layout.mirrors_p1 = 1; sbi->layout.group_width = 1; sbi->layout.group_depth = -1; sbi->layout.group_count = 1; sbi->layout.s_ods[0] = od; sbi->layout.s_numdevs = 1; sbi->layout.s_pid = opts->pid; sbi->s_timeout = opts->timeout; /* fill in some other data by hand */ memset(sb->s_id, 0, sizeof(sb->s_id)); strcpy(sb->s_id, "exofs"); sb->s_blocksize = EXOFS_BLKSIZE; sb->s_blocksize_bits = EXOFS_BLKSHIFT; sb->s_maxbytes = MAX_LFS_FILESIZE; atomic_set(&sbi->s_curr_pending, 0); sb->s_bdev = NULL; sb->s_dev = 0; obj.partition = sbi->layout.s_pid; obj.id = EXOFS_SUPER_ID; exofs_make_credential(sbi->s_cred, &obj); ret = exofs_read_kern(od, sbi->s_cred, &obj, 0, &fscb, sizeof(fscb)); if (unlikely(ret)) goto free_sbi; sb->s_magic = le16_to_cpu(fscb.s_magic); sbi->s_nextid = le64_to_cpu(fscb.s_nextid); sbi->s_numfiles = le32_to_cpu(fscb.s_numfiles); /* make sure what we read from the object store is correct */ if (sb->s_magic != EXOFS_SUPER_MAGIC) { if (!silent) EXOFS_ERR("ERROR: Bad magic value\n"); ret = -EINVAL; goto free_sbi; } if (le32_to_cpu(fscb.s_version) != EXOFS_FSCB_VER) { EXOFS_ERR("ERROR: Bad FSCB version expected-%d got-%d\n", EXOFS_FSCB_VER, le32_to_cpu(fscb.s_version)); ret = -EINVAL; goto free_sbi; } /* start generation numbers from a random point */ get_random_bytes(&sbi->s_next_generation, sizeof(u32)); spin_lock_init(&sbi->s_next_gen_lock); table_count = le64_to_cpu(fscb.s_dev_table_count); if (table_count) { ret = exofs_read_lookup_dev_table(&sbi, table_count); if (unlikely(ret)) goto free_sbi; } /* set up operation vectors */ sb->s_bdi = &sbi->bdi; sb->s_fs_info = sbi; sb->s_op = &exofs_sops; sb->s_export_op = &exofs_export_ops; root = exofs_iget(sb, EXOFS_ROOT_ID - EXOFS_OBJ_OFF); if (IS_ERR(root)) { EXOFS_ERR("ERROR: exofs_iget failed\n"); ret = PTR_ERR(root); goto free_sbi; } sb->s_root = d_alloc_root(root); if (!sb->s_root) { iput(root); EXOFS_ERR("ERROR: get root inode failed\n"); ret = -ENOMEM; goto free_sbi; } if (!S_ISDIR(root->i_mode)) { dput(sb->s_root); sb->s_root = NULL; EXOFS_ERR("ERROR: corrupt root inode (mode = %hd)\n", root->i_mode); ret = -EINVAL; goto free_sbi; } _exofs_print_device("Mounting", opts->dev_name, sbi->layout.s_ods[0], sbi->layout.s_pid); return 0; free_sbi: bdi_destroy(&sbi->bdi); free_bdi: EXOFS_ERR("Unable to mount exofs on %s pid=0x%llx err=%d\n", opts->dev_name, sbi->layout.s_pid, ret); exofs_free_sbi(sbi); return ret; } /* * Set up the superblock (calls exofs_fill_super eventually) */ static struct dentry *exofs_mount(struct file_system_type *type, int flags, const char *dev_name, void *data) { struct exofs_mountopt opts; int ret; ret = parse_options(data, &opts); if (ret) return ERR_PTR(ret); opts.dev_name = dev_name; return mount_nodev(type, flags, &opts, exofs_fill_super); } /* * Return information about the file system state in the buffer. This is used * by the 'df' command, for example. */ static int exofs_statfs(struct dentry *dentry, struct kstatfs *buf) { struct super_block *sb = dentry->d_sb; struct exofs_sb_info *sbi = sb->s_fs_info; struct exofs_io_state *ios; struct osd_attr attrs[] = { ATTR_DEF(OSD_APAGE_PARTITION_QUOTAS, OSD_ATTR_PQ_CAPACITY_QUOTA, sizeof(__be64)), ATTR_DEF(OSD_APAGE_PARTITION_INFORMATION, OSD_ATTR_PI_USED_CAPACITY, sizeof(__be64)), }; uint64_t capacity = ULLONG_MAX; uint64_t used = ULLONG_MAX; uint8_t cred_a[OSD_CAP_LEN]; int ret; ret = exofs_get_io_state(&sbi->layout, &ios); if (ret) { EXOFS_DBGMSG("exofs_get_io_state failed.\n"); return ret; } exofs_make_credential(cred_a, &ios->obj); ios->cred = sbi->s_cred; ios->in_attr = attrs; ios->in_attr_len = ARRAY_SIZE(attrs); ret = exofs_sbi_read(ios); if (unlikely(ret)) goto out; ret = extract_attr_from_ios(ios, &attrs[0]); if (likely(!ret)) { capacity = get_unaligned_be64(attrs[0].val_ptr); if (unlikely(!capacity)) capacity = ULLONG_MAX; } else EXOFS_DBGMSG("exofs_statfs: get capacity failed.\n"); ret = extract_attr_from_ios(ios, &attrs[1]); if (likely(!ret)) used = get_unaligned_be64(attrs[1].val_ptr); else EXOFS_DBGMSG("exofs_statfs: get used-space failed.\n"); /* fill in the stats buffer */ buf->f_type = EXOFS_SUPER_MAGIC; buf->f_bsize = EXOFS_BLKSIZE; buf->f_blocks = capacity >> 9; buf->f_bfree = (capacity - used) >> 9; buf->f_bavail = buf->f_bfree; buf->f_files = sbi->s_numfiles; buf->f_ffree = EXOFS_MAX_ID - sbi->s_numfiles; buf->f_namelen = EXOFS_NAME_LEN; out: exofs_put_io_state(ios); return ret; } static const struct super_operations exofs_sops = { .alloc_inode = exofs_alloc_inode, .destroy_inode = exofs_destroy_inode, .write_inode = exofs_write_inode, .evict_inode = exofs_evict_inode, .put_super = exofs_put_super, .write_super = exofs_write_super, .sync_fs = exofs_sync_fs, .statfs = exofs_statfs, }; /****************************************************************************** * EXPORT OPERATIONS *****************************************************************************/ struct dentry *exofs_get_parent(struct dentry *child) { unsigned long ino = exofs_parent_ino(child); if (!ino) return NULL; return d_obtain_alias(exofs_iget(child->d_inode->i_sb, ino)); }
static struct dentry *ovl_mount(struct file_system_type *fs_type, int flags, const char *dev_name, void *raw_data) { return mount_nodev(fs_type, flags, raw_data, ovl_fill_super); }
static struct dentry *hostfs_mount(struct file_system_type *fs_type, int flags, const char *dev_name, void *data) { return mount_nodev(fs_type, flags, data, hostfs_read_super);}