From: Ralph Boehme Date: Thu, 23 Jun 2016 10:23:33 +0000 (+0200) Subject: s3/smbd: add helper func dos_mode_from_name() X-Git-Tag: samba-4.3.12~112 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4683fd1f003d863af156578342ceaef5bd5d80f8;p=thirdparty%2Fsamba.git s3/smbd: add helper func dos_mode_from_name() This just moves the computation of "hide dot files" files to a helper functions without changing overall behaviour. Bug: https://bugzilla.samba.org/show_bug.cgi?id=11992 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison (cherry picked from commit c8c67c9a2a6347e36f4628e2d0260bd6c58d8c65) --- diff --git a/source3/smbd/dosmode.c b/source3/smbd/dosmode.c index 907f3f9a777..a2aaa3d384c 100644 --- a/source3/smbd/dosmode.c +++ b/source3/smbd/dosmode.c @@ -569,6 +569,31 @@ err_out: return status; } +static uint32_t dos_mode_from_name(connection_struct *conn, + const struct smb_filename *smb_fname) +{ + const char *p = NULL; + uint32_t result = 0; + + if (lp_hide_dot_files(SNUM(conn))) { + p = strrchr_m(smb_fname->base_name, '/'); + if (p) { + p++; + } else { + p = smb_fname->base_name; + } + + /* Only . and .. are not hidden. */ + if ((p[0] == '.') && + !((p[1] == '\0') || (p[1] == '.' && p[2] == '\0'))) + { + result |= FILE_ATTRIBUTE_HIDDEN; + } + } + + return result; +} + /**************************************************************************** Change a unix mode to a dos mode. May also read the create timespec into the stat struct in smb_fname @@ -586,22 +611,7 @@ uint32_t dos_mode(connection_struct *conn, struct smb_filename *smb_fname) return 0; } - /* First do any modifications that depend on the path name. */ - /* hide files with a name starting with a . */ - if (lp_hide_dot_files(SNUM(conn))) { - const char *p = strrchr_m(smb_fname->base_name,'/'); - if (p) { - p++; - } else { - p = smb_fname->base_name; - } - - /* Only . and .. are not hidden. */ - if (p[0] == '.' && !((p[1] == '\0') || - (p[1] == '.' && p[2] == '\0'))) { - result |= FILE_ATTRIBUTE_HIDDEN; - } - } + result |= dos_mode_from_name(conn, smb_fname); /* Get the DOS attributes from an EA by preference. */ if (!get_ea_dos_attribute(conn, smb_fname, &result)) {