return result;
}
-/****************************************************************************
- Change a unix mode to a dos mode.
- May also read the create timespec into the stat struct in smb_fname
- if "store dos attributes" is true.
-****************************************************************************/
-
-uint32_t dos_mode(connection_struct *conn, struct smb_filename *smb_fname)
+static uint32_t dos_mode_post(uint32_t dosmode,
+ connection_struct *conn,
+ struct smb_filename *smb_fname,
+ const char *func)
{
- uint32_t result = 0;
- NTSTATUS status = NT_STATUS_OK;
-
- DEBUG(8,("dos_mode: %s\n", smb_fname_str_dbg(smb_fname)));
-
- if (!VALID_STAT(smb_fname->st)) {
- return 0;
- }
-
- /* Get the DOS attributes via the VFS if we can */
- status = SMB_VFS_GET_DOS_ATTRIBUTES(conn, smb_fname, &result);
- if (!NT_STATUS_IS_OK(status)) {
- /*
- * Only fall back to using UNIX modes if we get NOT_IMPLEMENTED.
- */
- if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_IMPLEMENTED)) {
- result |= dos_mode_from_sbuf(conn, smb_fname);
- }
- }
+ NTSTATUS status;
/*
* According to MS-FSA a stream name does not have
/*
* Non-default stream name, not a posix path.
*/
- result &= ~(FILE_ATTRIBUTE_DIRECTORY);
+ dosmode &= ~(FILE_ATTRIBUTE_DIRECTORY);
}
}
if (conn->fs_capabilities & FILE_FILE_COMPRESSION) {
bool compressed = false;
+
status = dos_mode_check_compressed(conn, smb_fname,
&compressed);
if (NT_STATUS_IS_OK(status) && compressed) {
- result |= FILE_ATTRIBUTE_COMPRESSED;
+ dosmode |= FILE_ATTRIBUTE_COMPRESSED;
}
}
- result |= dos_mode_from_name(conn, smb_fname, result);
+ dosmode |= dos_mode_from_name(conn, smb_fname, dosmode);
if (S_ISDIR(smb_fname->st.st_ex_mode)) {
- result |= FILE_ATTRIBUTE_DIRECTORY;
- } else if (result == 0) {
- result = FILE_ATTRIBUTE_NORMAL;
+ dosmode |= FILE_ATTRIBUTE_DIRECTORY;
+ } else if (dosmode == 0) {
+ dosmode = FILE_ATTRIBUTE_NORMAL;
}
- result = filter_mode_by_protocol(result);
+ dosmode = filter_mode_by_protocol(dosmode);
- dos_mode_debug_print(__func__, result);
+ dos_mode_debug_print(func, dosmode);
+ return dosmode;
+}
+
+/****************************************************************************
+ Change a unix mode to a dos mode.
+ May also read the create timespec into the stat struct in smb_fname
+ if "store dos attributes" is true.
+****************************************************************************/
+
+uint32_t dos_mode(connection_struct *conn, struct smb_filename *smb_fname)
+{
+ uint32_t result = 0;
+ NTSTATUS status = NT_STATUS_OK;
+
+ DEBUG(8,("dos_mode: %s\n", smb_fname_str_dbg(smb_fname)));
+
+ if (!VALID_STAT(smb_fname->st)) {
+ return 0;
+ }
+
+ /* Get the DOS attributes via the VFS if we can */
+ status = SMB_VFS_GET_DOS_ATTRIBUTES(conn, smb_fname, &result);
+ if (!NT_STATUS_IS_OK(status)) {
+ /*
+ * Only fall back to using UNIX modes if we get NOT_IMPLEMENTED.
+ */
+ if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_IMPLEMENTED)) {
+ result |= dos_mode_from_sbuf(conn, smb_fname);
+ }
+ }
+ result = dos_mode_post(result, conn, smb_fname, __func__);
return result;
}