Exemple #1
0
int axfs_fill_super(struct super_block *sb, void *data, int silent)
{
    struct axfs_super *sbi;
    struct inode *root;
    int err;
    struct axfs_super *sbi_in = (struct axfs_super *)data;

    sbi = axfs_get_sbi();
    if (IS_ERR(sbi))
        return PTR_ERR(sbi);

    sb->s_fs_info = (void *)sbi;

    memcpy(sbi, sbi_in, sizeof(*sbi));

    /* fully populate the incore superblock structures */
    err = axfs_do_fill_super(sb);
    if (err)
        goto out;

    sb->s_flags |= MS_RDONLY;

    /* Setup the VFS super block now */
    sb->s_op = &axfs_sops;
    root = axfs_create_vfs_inode(sb, 0);
    if (!root) {
        err = -EINVAL;
        goto out;
    }

#if LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0)
    sb->s_root = d_make_root(root);
#else
    sb->s_root = d_alloc_root(root);
#endif
    if (!sb->s_root) {
#if LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0)
#else
        iput(root);
#endif
        err = -EINVAL;
        goto out;
    }

    err = axfs_init_profiling(sbi);
    if (err)
        goto out;

    return 0;

out:
    axfs_put_super(sb);
    return err;
}
Exemple #2
0
/******************************************************************************
 *
 * axfs_fill_super
 *
 * Description:
 *     Populates the VFS super block Structure.
 *
 * Parameters:
 *    (OUT) sb - superblock of fs instance
 *
 *    (IN) data - used to pass a pointer to the axfs_fill_super_info
 *
 *    (IN) silent - not used
 *
 * Returns:
 *    0 or error number
 *
 *****************************************************************************/
static int axfs_fill_super(struct super_block *sb, void *data, int silent)
{
	struct axfs_super_incore *sbi;
	struct axfs_metadata_ptrs_incore *metadata = NULL;
	struct axfs_fill_super_info *fsi = NULL;
	struct inode *root;
	int err;

	fsi = (struct axfs_fill_super_info *)data;

	/*
	 * Create the space for the private super block runtime information and store it
	 * in the VFS super block structure
	 */
	sbi = vmalloc(sizeof(*sbi));
	if (!sbi) {
		err = -ENOMEM;
		goto out;
	}
	memset(sbi, 0, sizeof(*sbi));
	sb->s_fs_info = sbi;

	sb->s_flags |= MS_RDONLY;
	sbi->metadata = vmalloc(sizeof(*metadata));
	metadata = sbi->metadata;
	if (!metadata) {
		err = -ENOMEM;
		goto out;
	}
	memset(metadata, 0, sizeof(*metadata));

	sbi->phys_start_addr=fsi->physical_start_address;
	sbi->virt_start_addr=fsi->virtual_start_address;

	printk(KERN_INFO "axfs: start axfs_do_fill_super\n");
	/* fully populate the incore superblock structures */
	err = axfs_do_fill_super(sb,fsi);
	if(err != 0)
		goto out;

	printk(KERN_INFO "axfs: doned axfs_do_fill_super\n");

	err = axfs_check_super(sbi);
	if(err != 0)
		goto out;

	printk(KERN_INFO "axfs: doned axfs_check_super\n");

	/* Setup the VFS super block now */
	sb->s_op = &axfs_ops;
	root = axfs_create_vfs_inode(sb, 0);
	if(!root) {
		err = -EINVAL;
		goto out;
	}

	sb->s_root = d_alloc_root(root);
	if(!sb->s_root) {
		iput(root);
		err = -EINVAL;
		goto out;
	}

#ifdef CONFIG_AXFS_PROFILING
	init_axfs_profiling(sbi);
#endif

	sbi->cblock_buffer[0] = vmalloc(sbi->cblock_size);
	sbi->cblock_buffer[1] = vmalloc(sbi->cblock_size);
	if ((!sbi->cblock_buffer[0]) || (!sbi->cblock_buffer[1])) {
		iput(root);
		err = -ENOMEM;
		goto out;
	}

	sbi->current_cnode_index = -1;

	vfree(fsi->onmedia_super_block);
	vfree(fsi);
	return 0;

out:
	vfree(fsi->onmedia_super_block);
	vfree(fsi);
	vfree(metadata);
	vfree(sbi);
	sb->s_fs_info = NULL;
	return err;
}