]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Move dos_mode_from_name() up in dosmode.c
authorVolker Lendecke <vl@samba.org>
Tue, 20 Jun 2023 13:31:34 +0000 (15:31 +0200)
committerVolker Lendecke <vl@samba.org>
Fri, 30 Jun 2023 10:42:36 +0000 (10:42 +0000)
Is useful in dos_mode_msdfs() as well.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/smbd/dosmode.c

index 5a88cd059b040a7f3fb53fb9b6cda12d0e7d5c6c..57746e821b2086f95ce580df8f7265fc94878cf5 100644 (file)
@@ -525,6 +525,38 @@ NTSTATUS set_ea_dos_attribute(connection_struct *conn,
        return NT_STATUS_OK;
 }
 
+static uint32_t dos_mode_from_name(connection_struct *conn,
+                                  const struct smb_filename *smb_fname,
+                                  uint32_t dosmode)
+{
+       const char *p = NULL;
+       uint32_t result = dosmode;
+
+       if (!(result & FILE_ATTRIBUTE_HIDDEN) &&
+           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] == '.') && !(ISDOT(p) || ISDOTDOT(p))) {
+                       result |= FILE_ATTRIBUTE_HIDDEN;
+               }
+       }
+
+       if (!(result & FILE_ATTRIBUTE_HIDDEN) &&
+           IS_HIDDEN_PATH(conn, smb_fname->base_name))
+       {
+               result |= FILE_ATTRIBUTE_HIDDEN;
+       }
+
+       return result;
+}
+
 /****************************************************************************
  Change a unix mode to a dos mode for an ms dfs link.
 ****************************************************************************/
@@ -604,38 +636,6 @@ static NTSTATUS dos_mode_check_compressed(struct files_struct *fsp,
        return NT_STATUS_OK;
 }
 
-static uint32_t dos_mode_from_name(connection_struct *conn,
-                                  const struct smb_filename *smb_fname,
-                                  uint32_t dosmode)
-{
-       const char *p = NULL;
-       uint32_t result = dosmode;
-
-       if (!(result & FILE_ATTRIBUTE_HIDDEN) &&
-           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] == '.') && !(ISDOT(p) || ISDOTDOT(p))) {
-                       result |= FILE_ATTRIBUTE_HIDDEN;
-               }
-       }
-
-       if (!(result & FILE_ATTRIBUTE_HIDDEN) &&
-           IS_HIDDEN_PATH(conn, smb_fname->base_name))
-       {
-               result |= FILE_ATTRIBUTE_HIDDEN;
-       }
-
-       return result;
-}
-
 static uint32_t dos_mode_post(uint32_t dosmode,
                              struct files_struct *fsp,
                              const char *func)