s3: lib: Add new utility function cp_smb_filename_nostream().
authorJeremy Allison <jra@samba.org>
Tue, 30 May 2017 18:46:49 +0000 (11:46 -0700)
committerJeremy Allison <jra@samba.org>
Wed, 31 May 2017 20:50:21 +0000 (22:50 +0200)
Will be needed when we migrate lower-level VFS functions to
take an struct smb_filename *, especially the SYS_ACL and
XATTR modification modules, as these must ignore a passed-in
stream name.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/include/proto.h
source3/lib/filename_util.c

index 4e7a431fbb784a839f94599b160500089d20ebe1..121c9eb480dc6f2ae760110bdde5344196ff2e9c 100644 (file)
@@ -1114,6 +1114,8 @@ const char *fsp_str_dbg(const struct files_struct *fsp);
 const char *fsp_fnum_dbg(const struct files_struct *fsp);
 struct smb_filename *cp_smb_filename(TALLOC_CTX *mem_ctx,
                                     const struct smb_filename *in);
+struct smb_filename *cp_smb_filename_nostream(TALLOC_CTX *mem_ctx,
+                                    const struct smb_filename *in);
 bool is_ntfs_stream_smb_fname(const struct smb_filename *smb_fname);
 bool is_ntfs_default_stream_smb_fname(const struct smb_filename *smb_fname);
 bool is_invalid_windows_ea_name(const char *name);
index 3983aaa0eca857e928d452e4e10b6c0be5873e26..8a16bacddbea52edb899ec14d88abf79b003a948 100644 (file)
@@ -71,6 +71,22 @@ struct smb_filename *synthetic_smb_fname(TALLOC_CTX *mem_ctx,
        return cp_smb_filename(mem_ctx, &smb_fname_loc);
 }
 
+/**
+ * Utility function used by VFS calls that must *NOT* operate
+ * on a stream filename, only the base_name.
+ */
+struct smb_filename *cp_smb_filename_nostream(TALLOC_CTX *mem_ctx,
+                                       const struct smb_filename *smb_fname_in)
+{
+       struct smb_filename *smb_fname = cp_smb_filename(mem_ctx,
+                                                       smb_fname_in);
+       if (smb_fname == NULL) {
+               return NULL;
+       }
+       TALLOC_FREE(smb_fname->stream_name);
+       return smb_fname;
+}
+
 /**
  * There are a few legitimate users of this.
  */