Commit 24e0a1ef authored by Ronnie Sahlberg's avatar Ronnie Sahlberg Committed by Steve French
Browse files

cifs: switch to new mount api



See Documentation/filesystems/mount_api.rst for details on new mount API

Signed-off-by: default avatarRonnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
parent 66e7b09c
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -275,6 +275,10 @@ static struct vfsmount *cifs_dfs_do_mount(struct dentry *mntpt,

	convert_delimiter(devname, '/');

	/* TODO: change to call fs_context_for_mount(), fill in context directly, call fc_mount */

	/* See afs_mntpt_do_automount in fs/afs/mntpt.c for an example */

	/* strip first '\' from fullpath */
	mountdata = cifs_compose_mount_options(cifs_sb->mountdata,
					       fullpath + 1, NULL, NULL);
+5 −0
Original line number Diff line number Diff line
@@ -661,6 +661,11 @@ setup_ntlmv2_rsp(struct cifs_ses *ses, const struct nls_table *nls_cp)
	unsigned char *tiblob = NULL; /* target info blob */
	__le64 rsp_timestamp;

	if (nls_cp == NULL) {
		cifs_dbg(VFS, "%s called with nls_cp==NULL\n", __func__);
		return -EINVAL;
	}

	if (ses->server->negflavor == CIFS_NEGFLAVOR_EXTENDED) {
		if (!ses->domainName) {
			if (ses->domainAuto) {
+23 −31
Original line number Diff line number Diff line
@@ -682,13 +682,6 @@ static int cifs_show_stats(struct seq_file *s, struct dentry *root)
}
#endif

static int cifs_remount(struct super_block *sb, int *flags, char *data)
{
	sync_filesystem(sb);
	*flags |= SB_NODIRATIME;
	return 0;
}

static int cifs_drop_inode(struct inode *inode)
{
	struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
@@ -710,7 +703,6 @@ static const struct super_operations cifs_super_ops = {
	as opens */
	.show_options = cifs_show_options,
	.umount_begin   = cifs_umount_begin,
	.remount_fs = cifs_remount,
#ifdef CONFIG_CIFS_STATS2
	.show_stats = cifs_show_stats,
#endif
@@ -778,9 +770,9 @@ static int cifs_set_super(struct super_block *sb, void *data)
	return set_anon_super(sb, NULL);
}

static struct dentry *
struct dentry *
cifs_smb3_do_mount(struct file_system_type *fs_type,
	      int flags, const char *dev_name, void *data, bool is_smb3)
	      int flags, struct smb3_fs_context *old_ctx)
{
	int rc;
	struct super_block *sb;
@@ -794,13 +786,24 @@ cifs_smb3_do_mount(struct file_system_type *fs_type,
	 *	If CIFS_DEBUG && cifs_FYI
	 */
	if (cifsFYI)
		cifs_dbg(FYI, "Devname: %s flags: %d\n", dev_name, flags);
		cifs_dbg(FYI, "Devname: %s flags: %d\n", old_ctx->UNC, flags);
	else
		cifs_info("Attempting to mount %s\n", dev_name);
		cifs_info("Attempting to mount %s\n", old_ctx->UNC);

	ctx = kzalloc(sizeof(struct smb3_fs_context), GFP_KERNEL);
	if (!ctx)
		return ERR_PTR(-ENOMEM);
	rc = smb3_fs_context_dup(ctx, old_ctx);
	if (rc) {
		root = ERR_PTR(rc);
		goto out;
	}

	ctx = cifs_get_volume_info((char *)data, dev_name, is_smb3);
	if (IS_ERR(ctx))
		return ERR_CAST(ctx);
	rc = cifs_setup_volume_info(ctx);
	if (rc) {
		root = ERR_PTR(rc);
		goto out;
	}

	cifs_sb = kzalloc(sizeof(struct cifs_sb_info), GFP_KERNEL);
	if (cifs_sb == NULL) {
@@ -808,7 +811,7 @@ cifs_smb3_do_mount(struct file_system_type *fs_type,
		goto out_nls;
	}

	cifs_sb->mountdata = kstrndup(data, PAGE_SIZE, GFP_KERNEL);
	cifs_sb->mountdata = kstrndup(ctx->mount_options, PAGE_SIZE, GFP_KERNEL);
	if (cifs_sb->mountdata == NULL) {
		root = ERR_PTR(-ENOMEM);
		goto out_free;
@@ -878,19 +881,6 @@ cifs_smb3_do_mount(struct file_system_type *fs_type,
	goto out;
}

static struct dentry *
smb3_do_mount(struct file_system_type *fs_type,
	      int flags, const char *dev_name, void *data)
{
	return cifs_smb3_do_mount(fs_type, flags, dev_name, data, true);
}

static struct dentry *
cifs_do_mount(struct file_system_type *fs_type,
	      int flags, const char *dev_name, void *data)
{
	return cifs_smb3_do_mount(fs_type, flags, dev_name, data, false);
}

static ssize_t
cifs_loose_read_iter(struct kiocb *iocb, struct iov_iter *iter)
@@ -1027,7 +1017,8 @@ cifs_setlease(struct file *file, long arg, struct file_lock **lease, void **priv
struct file_system_type cifs_fs_type = {
	.owner = THIS_MODULE,
	.name = "cifs",
	.mount = cifs_do_mount,
	.init_fs_context = smb3_init_fs_context,
	.parameters = smb3_fs_parameters,
	.kill_sb = cifs_kill_sb,
	.fs_flags = FS_RENAME_DOES_D_MOVE,
};
@@ -1036,7 +1027,8 @@ MODULE_ALIAS_FS("cifs");
static struct file_system_type smb3_fs_type = {
	.owner = THIS_MODULE,
	.name = "smb3",
	.mount = smb3_do_mount,
	.init_fs_context = smb3_init_fs_context,
	.parameters = smb3_fs_parameters,
	.kill_sb = cifs_kill_sb,
	.fs_flags = FS_RENAME_DOES_D_MOVE,
};
+4 −0
Original line number Diff line number Diff line
@@ -152,6 +152,10 @@ extern long cifs_ioctl(struct file *filep, unsigned int cmd, unsigned long arg);
extern void cifs_setsize(struct inode *inode, loff_t offset);
extern int cifs_truncate_page(struct address_space *mapping, loff_t from);

struct smb3_fs_context;
extern struct dentry *cifs_smb3_do_mount(struct file_system_type *fs_type,
					 int flags, struct smb3_fs_context *ctx);

#ifdef CONFIG_CIFS_NFSD_EXPORT
extern const struct export_operations cifs_export_ops;
#endif /* CONFIG_CIFS_NFSD_EXPORT */
+1 −4
Original line number Diff line number Diff line
@@ -239,8 +239,6 @@ extern int cifs_setup_cifs_sb(struct smb3_fs_context *ctx,
			       struct cifs_sb_info *cifs_sb);
extern int cifs_match_super(struct super_block *, void *);
extern void cifs_cleanup_volume_info(struct smb3_fs_context *ctx);
extern struct smb3_fs_context *cifs_get_volume_info(char *mount_data,
					    const char *devname, bool is_smb3);
extern int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb3_fs_context *ctx);
extern void cifs_umount(struct cifs_sb_info *);
extern void cifs_mark_open_files_invalid(struct cifs_tcon *tcon);
@@ -554,8 +552,7 @@ extern int SMBencrypt(unsigned char *passwd, const unsigned char *c8,
			unsigned char *p24);

extern int
cifs_setup_volume_info(struct smb3_fs_context *ctx, char *mount_data,
		       const char *devname, bool is_smb3);
cifs_setup_volume_info(struct smb3_fs_context *ctx);
extern void
cifs_cleanup_volume_info_contents(struct smb3_fs_context *ctx);

Loading