예제 #1
0
static void
cifs_put_super(struct super_block *sb)
{
	int rc = 0;
	struct cifs_sb_info *cifs_sb;

	cFYI(1, ("In cifs_put_super"));
	cifs_sb = CIFS_SB(sb);
	if (cifs_sb == NULL) {
		cFYI(1, ("Empty cifs superblock info passed to unmount"));
		return;
	}

	lock_kernel();

	rc = cifs_umount(sb, cifs_sb);
	if (rc)
		cERROR(1, ("cifs_umount failed with return code %d", rc));
#ifdef CONFIG_CIFS_DFS_UPCALL
	if (cifs_sb->mountdata) {
		kfree(cifs_sb->mountdata);
		cifs_sb->mountdata = NULL;
	}
#endif

	unload_nls(cifs_sb->local_nls);
	kfree(cifs_sb);

	unlock_kernel();
}
예제 #2
0
static void
cifs_put_super(struct super_block *sb)
{
	int rc = 0;
	struct cifs_sb_info *cifs_sb;

	cFYI(1, "In cifs_put_super");
	cifs_sb = CIFS_SB(sb);
	if (cifs_sb == NULL) {
		cFYI(1, "Empty cifs superblock info passed to unmount");
		return;
	}

	rc = cifs_umount(sb, cifs_sb);
	if (rc)
		cERROR(1, "cifs_umount failed with return code %d", rc);
	if (cifs_sb->mountdata) {
		kfree(cifs_sb->mountdata);
		cifs_sb->mountdata = NULL;
	}

	unload_nls(cifs_sb->local_nls);
	bdi_destroy(&cifs_sb->bdi);
	kfree(cifs_sb);
}
예제 #3
0
static int
cifs_read_super(struct super_block *sb, struct smb_vol *volume_info,
		const char *devname, int silent)
{
	struct inode *inode;
	struct cifs_sb_info *cifs_sb;
	int rc = 0;

	cifs_sb = CIFS_SB(sb);

	spin_lock_init(&cifs_sb->tlink_tree_lock);
	cifs_sb->tlink_tree = RB_ROOT;

	rc = bdi_setup_and_register(&cifs_sb->bdi, "cifs", BDI_CAP_MAP_COPY);
	if (rc)
		return rc;

	cifs_sb->bdi.ra_pages = default_backing_dev_info.ra_pages;

	rc = cifs_mount(sb, cifs_sb, volume_info, devname);

	if (rc) {
		if (!silent)
			cERROR(1, "cifs_mount failed w/return code = %d", rc);
		goto out_mount_failed;
	}

	sb->s_magic = CIFS_MAGIC_NUMBER;
	sb->s_op = &cifs_super_ops;
	sb->s_bdi = &cifs_sb->bdi;
	sb->s_blocksize = CIFS_MAX_MSGSIZE;
	sb->s_blocksize_bits = 14;	/* default 2**14 = CIFS_MAX_MSGSIZE */
	inode = cifs_root_iget(sb);

	if (IS_ERR(inode)) {
		rc = PTR_ERR(inode);
		inode = NULL;
		goto out_no_root;
	}

	sb->s_root = d_alloc_root(inode);

	if (!sb->s_root) {
		rc = -ENOMEM;
		goto out_no_root;
	}

	/* do that *after* d_alloc_root() - we want NULL ->d_op for root here */
	if (cifs_sb_master_tcon(cifs_sb)->nocase)
		sb->s_d_op = &cifs_ci_dentry_ops;
	else
		sb->s_d_op = &cifs_dentry_ops;

#ifdef CIFS_NFSD_EXPORT
	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) {
		cFYI(1, "export ops supported");
		sb->s_export_op = &cifs_export_ops;
	}
#endif /* CIFS_NFSD_EXPORT */

	return 0;

out_no_root:
	cERROR(1, "cifs_read_super: get root inode failed");
	if (inode)
		iput(inode);

	cifs_umount(sb, cifs_sb);

out_mount_failed:
	bdi_destroy(&cifs_sb->bdi);
	return rc;
}
예제 #4
0
static int
cifs_read_super(struct super_block *sb, void *data,
                const char *devname, int silent)
{
    struct inode *inode;
    struct cifs_sb_info *cifs_sb;
    int rc = 0;

    /* BB should we make this contingent on mount parm? */
    sb->s_flags |= MS_NODIRATIME | MS_NOATIME;
    sb->s_fs_info = kzalloc(sizeof(struct cifs_sb_info), GFP_KERNEL);
    cifs_sb = CIFS_SB(sb);
    if (cifs_sb == NULL)
        return -ENOMEM;

    spin_lock_init(&cifs_sb->tlink_tree_lock);
    cifs_sb->tlink_tree = RB_ROOT;

    rc = bdi_setup_and_register(&cifs_sb->bdi, "cifs", BDI_CAP_MAP_COPY);
    if (rc) {
        kfree(cifs_sb);
        return rc;
    }
    cifs_sb->bdi.ra_pages = default_backing_dev_info.ra_pages;

#ifdef CONFIG_CIFS_DFS_UPCALL
    /* copy mount params to sb for use in submounts */
    /* BB: should we move this after the mount so we
     * do not have to do the copy on failed mounts?
     * BB: May be it is better to do simple copy before
     * complex operation (mount), and in case of fail
     * just exit instead of doing mount and attempting
     * undo it if this copy fails?*/
    if (data) {
        int len = strlen(data);
        cifs_sb->mountdata = kzalloc(len + 1, GFP_KERNEL);
        if (cifs_sb->mountdata == NULL) {
            bdi_destroy(&cifs_sb->bdi);
            kfree(sb->s_fs_info);
            sb->s_fs_info = NULL;
            return -ENOMEM;
        }
        strncpy(cifs_sb->mountdata, data, len + 1);
        cifs_sb->mountdata[len] = '\0';
    }
#endif

    rc = cifs_mount(sb, cifs_sb, data, devname);

    if (rc) {
        if (!silent)
            cERROR(1, "cifs_mount failed w/return code = %d", rc);
        goto out_mount_failed;
    }

    sb->s_magic = CIFS_MAGIC_NUMBER;
    sb->s_op = &cifs_super_ops;
    sb->s_bdi = &cifs_sb->bdi;
    sb->s_blocksize = CIFS_MAX_MSGSIZE;
    sb->s_blocksize_bits = 14;	/* default 2**14 = CIFS_MAX_MSGSIZE */
    inode = cifs_root_iget(sb, ROOT_I);

    if (IS_ERR(inode)) {
        rc = PTR_ERR(inode);
        inode = NULL;
        goto out_no_root;
    }

    sb->s_root = d_alloc_root(inode);

    if (!sb->s_root) {
        rc = -ENOMEM;
        goto out_no_root;
    }

    /* do that *after* d_alloc_root() - we want NULL ->d_op for root here */
    if (cifs_sb_master_tcon(cifs_sb)->nocase)
        sb->s_d_op = &cifs_ci_dentry_ops;
    else
        sb->s_d_op = &cifs_dentry_ops;

#ifdef CONFIG_CIFS_EXPERIMENTAL
    if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) {
        cFYI(1, "export ops supported");
        sb->s_export_op = &cifs_export_ops;
    }
#endif /* EXPERIMENTAL */

    return 0;

out_no_root:
    cERROR(1, "cifs_read_super: get root inode failed");
    if (inode)
        iput(inode);

    cifs_umount(sb, cifs_sb);

out_mount_failed:
    if (cifs_sb) {
#ifdef CONFIG_CIFS_DFS_UPCALL
        if (cifs_sb->mountdata) {
            kfree(cifs_sb->mountdata);
            cifs_sb->mountdata = NULL;
        }
#endif
        unload_nls(cifs_sb->local_nls);
        bdi_destroy(&cifs_sb->bdi);
        kfree(cifs_sb);
    }
    return rc;
}
예제 #5
0
static struct dentry *
cifs_do_mount(struct file_system_type *fs_type,
	      int flags, const char *dev_name, void *data)
{
	int rc;
	struct super_block *sb;
	struct cifs_sb_info *cifs_sb;
	struct smb_vol *volume_info;
	struct cifs_mnt_data mnt_data;
	struct dentry *root;

	cifs_dbg(FYI, "Devname: %s flags: %d\n", dev_name, flags);

	volume_info = cifs_get_volume_info((char *)data, dev_name);
	if (IS_ERR(volume_info))
		return ERR_CAST(volume_info);

	cifs_sb = kzalloc(sizeof(struct cifs_sb_info), GFP_KERNEL);
	if (cifs_sb == NULL) {
		root = ERR_PTR(-ENOMEM);
		goto out_nls;
	}

	cifs_sb->mountdata = kstrndup(data, PAGE_SIZE, GFP_KERNEL);
	if (cifs_sb->mountdata == NULL) {
		root = ERR_PTR(-ENOMEM);
		goto out_cifs_sb;
	}

	cifs_setup_cifs_sb(volume_info, cifs_sb);

	rc = cifs_mount(cifs_sb, volume_info);
	if (rc) {
		if (!(flags & MS_SILENT))
			cifs_dbg(VFS, "cifs_mount failed w/return code = %d\n",
				 rc);
		root = ERR_PTR(rc);
		goto out_mountdata;
	}

	mnt_data.vol = volume_info;
	mnt_data.cifs_sb = cifs_sb;
	mnt_data.flags = flags;

	/* BB should we make this contingent on mount parm? */
	flags |= MS_NODIRATIME | MS_NOATIME;

	sb = sget(fs_type, cifs_match_super, cifs_set_super, flags, &mnt_data);
	if (IS_ERR(sb)) {
		root = ERR_CAST(sb);
		cifs_umount(cifs_sb);
		goto out;
	}

	if (sb->s_root) {
		cifs_dbg(FYI, "Use existing superblock\n");
		cifs_umount(cifs_sb);
	} else {
		rc = cifs_read_super(sb);
		if (rc) {
			root = ERR_PTR(rc);
			goto out_super;
		}

		sb->s_flags |= MS_ACTIVE;
	}

	root = cifs_get_root(volume_info, sb);
	if (IS_ERR(root))
		goto out_super;

	cifs_dbg(FYI, "dentry root is: %p\n", root);
	goto out;

out_super:
	deactivate_locked_super(sb);
out:
	cifs_cleanup_volume_info(volume_info);
	return root;

out_mountdata:
	kfree(cifs_sb->mountdata);
out_cifs_sb:
	kfree(cifs_sb);
out_nls:
	unload_nls(volume_info->local_nls);
	goto out;
}
예제 #6
0
static void cifs_kill_sb(struct super_block *sb)
{
	struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
	kill_anon_super(sb);
	cifs_umount(cifs_sb);
}
예제 #7
0
static int
cifs_read_super(struct super_block *sb, void *data,
		const char *devname, int silent)
{
	struct inode *inode;
	struct cifs_sb_info *cifs_sb;
	int rc = 0;

	/* BB should we make this contingent on mount parm? */
	sb->s_flags |= MS_NODIRATIME | MS_NOATIME;
	sb->s_fs_info = kzalloc(sizeof(struct cifs_sb_info), GFP_KERNEL);
	cifs_sb = CIFS_SB(sb);
	if (cifs_sb == NULL)
		return -ENOMEM;

#ifdef CONFIG_CIFS_DFS_UPCALL
	/* copy mount params to sb for use in submounts */
	/* BB: should we move this after the mount so we
	 * do not have to do the copy on failed mounts?
	 * BB: May be it is better to do simple copy before
	 * complex operation (mount), and in case of fail
	 * just exit instead of doing mount and attempting
	 * undo it if this copy fails?*/
	if (data) {
		int len = strlen(data);
		cifs_sb->mountdata = kzalloc(len + 1, GFP_KERNEL);
		if (cifs_sb->mountdata == NULL) {
			kfree(sb->s_fs_info);
			sb->s_fs_info = NULL;
			return -ENOMEM;
		}
		strncpy(cifs_sb->mountdata, data, len + 1);
		cifs_sb->mountdata[len] = '\0';
	}
#endif

	rc = cifs_mount(sb, cifs_sb, data, devname);

	if (rc) {
		if (!silent)
			cERROR(1,
			       ("cifs_mount failed w/return code = %d", rc));
		goto out_mount_failed;
	}

	sb->s_magic = CIFS_MAGIC_NUMBER;
	sb->s_op = &cifs_super_ops;
/*	if (cifs_sb->tcon->ses->server->maxBuf > MAX_CIFS_HDR_SIZE + 512)
	    sb->s_blocksize =
		cifs_sb->tcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE; */
#ifdef CONFIG_CIFS_QUOTA
	sb->s_qcop = &cifs_quotactl_ops;
#endif
	sb->s_blocksize = CIFS_MAX_MSGSIZE;
	sb->s_blocksize_bits = 14;	/* default 2**14 = CIFS_MAX_MSGSIZE */
	inode = cifs_root_iget(sb, ROOT_I);

	if (IS_ERR(inode)) {
		rc = PTR_ERR(inode);
		inode = NULL;
		goto out_no_root;
	}

	sb->s_root = d_alloc_root(inode);

	if (!sb->s_root) {
		rc = -ENOMEM;
		goto out_no_root;
	}

#ifdef CONFIG_CIFS_EXPERIMENTAL
	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) {
		cFYI(1, ("export ops supported"));
		sb->s_export_op = &cifs_export_ops;
	}
#endif /* EXPERIMENTAL */

	return 0;

out_no_root:
	cERROR(1, ("cifs_read_super: get root inode failed"));
	if (inode)
		iput(inode);

	cifs_umount(sb, cifs_sb);

out_mount_failed:
	if (cifs_sb) {
#ifdef CONFIG_CIFS_DFS_UPCALL
		if (cifs_sb->mountdata) {
			kfree(cifs_sb->mountdata);
			cifs_sb->mountdata = NULL;
		}
#endif
		unload_nls(cifs_sb->local_nls);
		kfree(cifs_sb);
	}
	return rc;
}