summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorTim Prouty <tprouty@samba.org>2009-06-09 17:04:10 -0700
committerTim Prouty <tprouty@samba.org>2009-06-10 13:13:27 -0700
commitbddd7ad3dcc4a74fb61e09a2dd6fb7034c820046 (patch)
tree55b757c9c1e5bbeb81f25a901af84ace38fe1bca /source3
parent5b2034f9c1db7efc14bdfe1a95356833705c4057 (diff)
downloadsamba-bddd7ad3dcc4a74fb61e09a2dd6fb7034c820046.tar.gz
samba-bddd7ad3dcc4a74fb61e09a2dd6fb7034c820046.tar.bz2
samba-bddd7ad3dcc4a74fb61e09a2dd6fb7034c820046.zip
s3: Add utility function for copying an smb_filename struct
Diffstat (limited to 'source3')
-rw-r--r--source3/include/proto.h3
-rw-r--r--source3/smbd/filename.c39
2 files changed, 42 insertions, 0 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 9b297155e9..f5e44bad64 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -6362,6 +6362,9 @@ int fsp_stat(files_struct *fsp, SMB_STRUCT_STAT *pst);
NTSTATUS get_full_smb_filename(TALLOC_CTX *ctx, const struct smb_filename *smb_fname,
char **full_name);
+NTSTATUS copy_smb_filename(TALLOC_CTX *ctx,
+ const struct smb_filename *smb_fname_in,
+ struct smb_filename **smb_fname_out);
NTSTATUS unix_convert(TALLOC_CTX *ctx,
connection_struct *conn,
const char *orig_path,
diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c
index 059dca29c8..9897332607 100644
--- a/source3/smbd/filename.c
+++ b/source3/smbd/filename.c
@@ -97,6 +97,45 @@ NTSTATUS get_full_smb_filename(TALLOC_CTX *ctx, const struct smb_filename *smb_f
return NT_STATUS_OK;
}
+NTSTATUS copy_smb_filename(TALLOC_CTX *ctx,
+ const struct smb_filename *smb_fname_in,
+ struct smb_filename **smb_fname_out)
+{
+
+ *smb_fname_out = TALLOC_ZERO_P(ctx, struct smb_filename);
+ if (*smb_fname_out == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ if (smb_fname_in->base_name) {
+ (*smb_fname_out)->base_name =
+ talloc_strdup(*smb_fname_out, smb_fname_in->base_name);
+ if ((*smb_fname_out)->base_name)
+ goto no_mem_err;
+ }
+
+ if (smb_fname_in->stream_name) {
+ (*smb_fname_out)->stream_name =
+ talloc_strdup(*smb_fname_out, smb_fname_in->stream_name);
+ if ((*smb_fname_out)->stream_name)
+ goto no_mem_err;
+ }
+
+ if (smb_fname_in->original_lcomp) {
+ (*smb_fname_out)->original_lcomp =
+ talloc_strdup(*smb_fname_out, smb_fname_in->original_lcomp);
+ if ((*smb_fname_out)->original_lcomp)
+ goto no_mem_err;
+ }
+
+ (*smb_fname_out)->st = smb_fname_in->st;
+ return NT_STATUS_OK;
+
+ no_mem_err:
+ TALLOC_FREE(*smb_fname_out);
+ return NT_STATUS_NO_MEMORY;
+}
+
/****************************************************************************
This routine is called to convert names from the dos namespace to unix
namespace. It needs to handle any case conversions, mangling, format changes,