From: Ralph Boehme Date: Thu, 26 Sep 2019 17:05:40 +0000 (-0700) Subject: s3:lib: add is_named_stream() X-Git-Tag: talloc-2.3.1~526 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=091e3fdab61217251de1cf5111f070ff295d1649;p=thirdparty%2Fsamba.git s3:lib: add is_named_stream() Add a new utility functions that checks whether a struct smb_filename points to a real named stream, excluding the default stream "::$DATA". foo -> false foo::$DATA -> false foo:bar -> true foo:bar:$DATA -> true BUG: https://bugzilla.samba.org/show_bug.cgi?id=14137 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison --- diff --git a/source3/include/proto.h b/source3/include/proto.h index 0d02f38fc8b..91a7c00fef2 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -985,6 +985,7 @@ 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_named_stream(const struct smb_filename *smb_fname); bool is_invalid_windows_ea_name(const char *name); bool ea_list_has_invalid_name(struct ea_list *ea_list); bool split_stream_filename(TALLOC_CTX *ctx, diff --git a/source3/lib/filename_util.c b/source3/lib/filename_util.c index 2917481c8bf..66c07001eba 100644 --- a/source3/lib/filename_util.c +++ b/source3/lib/filename_util.c @@ -267,6 +267,32 @@ bool is_ntfs_stream_smb_fname(const struct smb_filename *smb_fname) return true; } +/**************************************************************************** + Simple check to determine if a smb_fname is pointing to a normal file or + a named stream that is not the default stream "::$DATA". + + foo -> false + foo::$DATA -> false + foo:bar -> true + foo:bar:$DATA -> true + + ***************************************************************************/ + +bool is_named_stream(const struct smb_filename *smb_fname) +{ + assert_valid_stream_smb_fname(smb_fname); + + if (smb_fname->stream_name == NULL) { + return false; + } + + if (strequal_m(smb_fname->stream_name, "::$DATA")) { + return false; + } + + return true; +} + /**************************************************************************** Returns true if the filename's stream == "::$DATA" ***************************************************************************/