s3:smbd: set file_id in fetch_dos_mode_done()
authorRalph Boehme <slow@samba.org>
Thu, 27 Jun 2019 12:47:57 +0000 (14:47 +0200)
committerJeremy Allison <jra@samba.org>
Mon, 1 Jul 2019 21:43:24 +0000 (21:43 +0000)
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/smb2_query_directory.c

index 13fb820ce6cf5f10a7d6623b0d2dd464d9ea9625..d433f2bee42d085fb2686481452afb6f023f7638 100644 (file)
@@ -1021,8 +1021,11 @@ static void fetch_dos_mode_done(struct tevent_req *subreq)
        uint32_t dfs_dosmode;
        uint32_t dosmode;
        struct timespec btime_ts = {0};
+       bool need_file_id = false;
+       uint64_t file_id;
        off_t dosmode_off;
        off_t btime_off;
+       off_t file_id_off;
        NTSTATUS status;
 
        status = dos_mode_at_recv(subreq, &dosmode);
@@ -1074,6 +1077,30 @@ static void fetch_dos_mode_done(struct tevent_req *subreq)
                               (char *)state->entry_marshall_buf + btime_off,
                               btime_ts);
 
+       switch (state->info_level) {
+       case SMB_FIND_ID_BOTH_DIRECTORY_INFO:
+               file_id_off = 96;
+               need_file_id = true;
+               break;
+       case SMB_FIND_ID_FULL_DIRECTORY_INFO:
+               file_id_off = 72;
+               need_file_id = true;
+               break;
+       default:
+               break;
+       }
+
+       if (need_file_id) {
+               /*
+                * File-ID might have been updated from calculated (based on
+                * inode) to storage based, fetch via DOS attributes in
+                * vfs_default.
+                */
+               file_id = SMB_VFS_FS_FILE_ID(state->dir_fsp->conn,
+                                            &state->smb_fname->st);
+               SBVAL(state->entry_marshall_buf, file_id_off, file_id);
+       }
+
        tevent_req_done(req);
        return;
 }