summaryrefslogtreecommitdiffstats
path: root/fs/cifs/fs_context.c
diff options
context:
space:
mode:
authorRonnie Sahlberg <lsahlber@redhat.com>2020-11-02 00:36:24 +0100
committerSteve French <stfrench@microsoft.com>2020-12-14 02:12:07 +0100
commit837e3a1bbfdc105216972c83f693e96969c62351 (patch)
treec82bc65764b3db66cd7c7252f9fde759e0772e7f /fs/cifs/fs_context.c
parentcifs: rename smb_vol as smb3_fs_context and move it to fs_context.h (diff)
downloadlinux-837e3a1bbfdc105216972c83f693e96969c62351.tar.xz
linux-837e3a1bbfdc105216972c83f693e96969c62351.zip
cifs: rename dup_vol to smb3_fs_context_dup and move it into fs_context.c
Continue restructuring needed for support of new mount API Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com> Signed-off-by: Steve French <stfrench@microsoft.com>
Diffstat (limited to 'fs/cifs/fs_context.c')
-rw-r--r--fs/cifs/fs_context.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/fs/cifs/fs_context.c b/fs/cifs/fs_context.c
index 3d071c87353e..af6ff0192d5e 100644
--- a/fs/cifs/fs_context.c
+++ b/fs/cifs/fs_context.c
@@ -7,6 +7,7 @@
*/
#include "cifsglob.h"
+#include "cifsproto.h"
#include "cifs_debug.h"
#include "fs_context.h"
@@ -219,3 +220,43 @@ cifs_parse_cache_flavor(char *value, struct smb3_fs_context *ctx)
}
return 0;
}
+
+#define DUP_CTX_STR(field) \
+do { \
+ if (ctx->field) { \
+ new_ctx->field = kstrdup(ctx->field, GFP_ATOMIC); \
+ if (new_ctx->field == NULL) { \
+ cifs_cleanup_volume_info_contents(new_ctx); \
+ return -ENOMEM; \
+ } \
+ } \
+} while (0)
+
+int
+smb3_fs_context_dup(struct smb3_fs_context *new_ctx, struct smb3_fs_context *ctx)
+{
+ int rc = 0;
+
+ memcpy(new_ctx, ctx, sizeof(*ctx));
+ new_ctx->prepath = NULL;
+ new_ctx->local_nls = NULL;
+ new_ctx->nodename = NULL;
+ new_ctx->username = NULL;
+ new_ctx->password = NULL;
+ new_ctx->domainname = NULL;
+ new_ctx->UNC = NULL;
+ new_ctx->iocharset = NULL;
+
+ /*
+ * Make sure to stay in sync with cifs_cleanup_volume_info_contents()
+ */
+ DUP_CTX_STR(prepath);
+ DUP_CTX_STR(username);
+ DUP_CTX_STR(password);
+ DUP_CTX_STR(UNC);
+ DUP_CTX_STR(domainname);
+ DUP_CTX_STR(nodename);
+ DUP_CTX_STR(iocharset);
+
+ return rc;
+}