1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-26 18:50:30 +03:00

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 <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
Ralph Boehme 2016-06-23 12:23:33 +02:00
parent 030fd72b32
commit c8c67c9a2a

View File

@ -562,6 +562,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
@ -580,22 +605,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 via the VFS if we can */
status = SMB_VFS_GET_DOS_ATTRIBUTES(conn, smb_fname, &result);