smbd: move files_struct.is_directory to a bitfield
[samba.git] / source3 / smbd / trans2.c
index bbb894c1af37e0a8eb98692b8ea700c538ee31a1..19706d32bd5d24b4b85aae3a26066a40c79ef273 100644 (file)
@@ -2729,7 +2729,7 @@ static void call_trans2findfirst(connection_struct *conn,
        NTSTATUS ntstatus = NT_STATUS_OK;
        bool ask_sharemode = lp_smbd_search_ask_sharemode(SNUM(conn));
        struct smbd_server_connection *sconn = req->sconn;
-       uint32_t ucf_flags = UCF_SAVE_LCOMP | UCF_ALWAYS_ALLOW_WCARD_LCOMP |
+       uint32_t ucf_flags = UCF_ALWAYS_ALLOW_WCARD_LCOMP |
                        ucf_flags_from_smb_request(req);
        bool backup_priv = false;
        bool as_root = false;
@@ -5003,7 +5003,7 @@ static NTSTATUS smb_query_posix_acl(connection_struct *conn,
                 * We can only have default POSIX ACLs on
                 * directories.
                 */
-               if (!fsp->is_directory) {
+               if (!fsp->fsp_flags.is_directory) {
                        DBG_INFO("Non-directory open %s\n",
                                fsp_str_dbg(fsp));
                        status = NT_STATUS_INVALID_HANDLE;
@@ -6697,7 +6697,7 @@ static NTSTATUS smb_set_file_size(connection_struct *conn,
                if (fsp == NULL) {
                        return NT_STATUS_OK;
                }
-               if (!fsp->modified) {
+               if (!fsp->fsp_flags.modified) {
                        return NT_STATUS_OK;
                }
                trigger_write_time_update_immediate(fsp);
@@ -7083,8 +7083,8 @@ static NTSTATUS smb2_file_rename_information(connection_struct *conn,
        uint32_t len;
        char *newname = NULL;
        struct smb_filename *smb_fname_dst = NULL;
-       uint32_t ucf_flags = UCF_SAVE_LCOMP |
-               ucf_flags_from_smb_request(req);
+       const char *dst_original_lcomp = NULL;
+       uint32_t ucf_flags = ucf_flags_from_smb_request(req);
        NTSTATUS status = NT_STATUS_OK;
        TALLOC_CTX *ctx = talloc_tos();
 
@@ -7156,18 +7156,19 @@ static NTSTATUS smb2_file_rename_information(connection_struct *conn,
                        status = NT_STATUS_NO_MEMORY;
                        goto out;
                }
+       }
 
-               /*
-                * Set the original last component, since
-                * rename_internals_fsp() requires it.
-                */
-               smb_fname_dst->original_lcomp = talloc_strdup(smb_fname_dst,
-                                                             newname);
-               if (smb_fname_dst->original_lcomp == NULL) {
-                       status = NT_STATUS_NO_MEMORY;
-                       goto out;
-               }
-
+       /*
+        * Set the original last component, since
+        * rename_internals_fsp() requires it.
+        */
+       dst_original_lcomp = get_original_lcomp(smb_fname_dst,
+                                       conn,
+                                       newname,
+                                       ucf_flags);
+       if (dst_original_lcomp == NULL) {
+               status = NT_STATUS_NO_MEMORY;
+               goto out;
        }
 
        DEBUG(10,("smb2_file_rename_information: "
@@ -7177,7 +7178,7 @@ static NTSTATUS smb2_file_rename_information(connection_struct *conn,
        status = rename_internals_fsp(conn,
                                fsp,
                                smb_fname_dst,
-                               smb_fname_dst->original_lcomp,
+                               dst_original_lcomp,
                                (FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM),
                                overwrite);
 
@@ -7198,8 +7199,7 @@ static NTSTATUS smb_file_link_information(connection_struct *conn,
        char *newname = NULL;
        struct smb_filename *smb_fname_dst = NULL;
        NTSTATUS status = NT_STATUS_OK;
-       uint32_t ucf_flags = UCF_SAVE_LCOMP |
-               ucf_flags_from_smb_request(req);
+       uint32_t ucf_flags = ucf_flags_from_smb_request(req);
        TALLOC_CTX *ctx = talloc_tos();
 
        if (!fsp) {
@@ -7291,6 +7291,7 @@ static NTSTATUS smb_file_rename_information(connection_struct *conn,
        uint32_t len;
        char *newname = NULL;
        struct smb_filename *smb_fname_dst = NULL;
+       const char *dst_original_lcomp = NULL;
        bool dest_has_wcard = False;
        NTSTATUS status = NT_STATUS_OK;
        char *p;
@@ -7359,12 +7360,14 @@ static NTSTATUS smb_file_rename_information(connection_struct *conn,
                }
 
                /*
-                * Set the original last component, since
+                * Get the original last component, since
                 * rename_internals_fsp() requires it.
                 */
-               smb_fname_dst->original_lcomp = talloc_strdup(smb_fname_dst,
-                                                             newname);
-               if (smb_fname_dst->original_lcomp == NULL) {
+               dst_original_lcomp = get_original_lcomp(smb_fname_dst,
+                                       conn,
+                                       newname,
+                                       0);
+               if (dst_original_lcomp == NULL) {
                        status = NT_STATUS_NO_MEMORY;
                        goto out;
                }
@@ -7376,8 +7379,7 @@ static NTSTATUS smb_file_rename_information(connection_struct *conn,
                 * the newname instead.
                 */
                char *base_name = NULL;
-               uint32_t ucf_flags = UCF_SAVE_LCOMP |
-                       ucf_flags_from_smb_request(req);
+               uint32_t ucf_flags = ucf_flags_from_smb_request(req);
 
                if (dest_has_wcard) {
                        ucf_flags |= UCF_ALWAYS_ALLOW_WCARD_LCOMP;
@@ -7440,6 +7442,14 @@ static NTSTATUS smb_file_rename_information(connection_struct *conn,
                                goto out;
                        }
                }
+               dst_original_lcomp = get_original_lcomp(smb_fname_dst,
+                                       conn,
+                                       newname,
+                                       ucf_flags);
+               if (dst_original_lcomp == NULL) {
+                       status = NT_STATUS_NO_MEMORY;
+                       goto out;
+               }
        }
 
        if (fsp) {
@@ -7450,7 +7460,7 @@ static NTSTATUS smb_file_rename_information(connection_struct *conn,
                status = rename_internals_fsp(conn,
                                        fsp,
                                        smb_fname_dst,
-                                       smb_fname_dst->original_lcomp,
+                                       dst_original_lcomp,
                                        0,
                                        overwrite);
        } else {
@@ -7463,7 +7473,7 @@ static NTSTATUS smb_file_rename_information(connection_struct *conn,
                                        req,
                                        smb_fname_src,
                                        smb_fname_dst,
-                                       smb_fname_dst->original_lcomp,
+                                       dst_original_lcomp,
                                        0,
                                        overwrite,
                                        false,
@@ -7588,7 +7598,7 @@ static NTSTATUS smb_set_posix_acl(connection_struct *conn,
        }
 
        /* If we have a default acl, this *must* be a directory. */
-       if (valid_def_acls && !fsp->is_directory) {
+       if (valid_def_acls && !fsp->fsp_flags.is_directory) {
                DBG_INFO("Can't set default acls on "
                         "non-directory %s\n",
                         fsp_str_dbg(fsp));
@@ -7675,7 +7685,7 @@ static NTSTATUS smb_set_posix_lock(connection_struct *conn,
                        break;
                case POSIX_LOCK_TYPE_WRITE:
                        /* Return the right POSIX-mappable error code for files opened read-only. */
-                       if (!fsp->can_write) {
+                       if (!fsp->fsp_flags.can_write) {
                                return NT_STATUS_INVALID_HANDLE;
                        }
                        lock_type = WRITE_LOCK;
@@ -7855,7 +7865,7 @@ static NTSTATUS smb_set_file_basic_info(connection_struct *conn,
                return status;
        }
 
-       if (fsp != NULL && fsp->modified) {
+       if (fsp != NULL && fsp->fsp_flags.modified) {
                trigger_write_time_update_immediate(fsp);
        }
        return NT_STATUS_OK;
@@ -7900,7 +7910,7 @@ static NTSTATUS smb_set_info_standard(connection_struct *conn,
                return status;
        }
 
-       if (fsp != NULL && fsp->modified) {
+       if (fsp != NULL && fsp->fsp_flags.modified) {
                trigger_write_time_update_immediate(fsp);
        }
        return NT_STATUS_OK;
@@ -8341,7 +8351,7 @@ static NTSTATUS smb_set_file_unix_basic(connection_struct *conn,
                 * We're setting the time explicitly for UNIX.
                 * Cancel any pending changes over all handles.
                 */
-               all_fsps->update_write_time_on_close = false;
+               all_fsps->fsp_flags.update_write_time_on_close = false;
                TALLOC_FREE(all_fsps->update_write_time_event);
        }