s3:vfs: move get_fs_file_id to vfs_default
authorRalph Boehme <slow@samba.org>
Sat, 29 Jun 2019 12:18:13 +0000 (14:18 +0200)
committerJeremy Allison <jra@samba.org>
Mon, 1 Jul 2019 21:43:24 +0000 (21:43 +0000)
This makes get_fs_file_id() the default implementation of
SMB_VFS_FS_FILE_ID(). No change in behaviour.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/modules/vfs_default.c
source3/smbd/proto.h
source3/smbd/smb2_create.c
source3/smbd/trans2.c

index f2f2ed7f7d18553357bdb62f298b7c3274663b20..dcb53c64eef45909bb8662b161a27df11f6a4ade 100644 (file)
@@ -2728,6 +2728,28 @@ static struct file_id vfswrap_file_id_create(struct vfs_handle_struct *handle,
        return key;
 }
 
+static uint64_t vfswrap_fs_file_id(struct vfs_handle_struct *handle,
+                                  const SMB_STRUCT_STAT *psbuf)
+{
+       uint64_t file_id;
+
+       if (handle->conn->sconn->aapl_zero_file_id) {
+               return 0;
+       }
+
+       if (handle->conn->base_share_dev == psbuf->st_ex_dev) {
+               return (uint64_t)psbuf->st_ex_ino;
+       }
+
+       /* FileIDLow */
+       file_id = ((psbuf->st_ex_ino) & UINT32_MAX);
+
+       /* FileIDHigh */
+       file_id |= ((uint64_t)((psbuf->st_ex_dev) & UINT32_MAX)) << 32;
+
+       return file_id;
+}
+
 static NTSTATUS vfswrap_streaminfo(vfs_handle_struct *handle,
                                   struct files_struct *fsp,
                                   const struct smb_filename *smb_fname,
@@ -3447,6 +3469,7 @@ static struct vfs_fn_pointers vfs_default_fns = {
        .realpath_fn = vfswrap_realpath,
        .chflags_fn = vfswrap_chflags,
        .file_id_create_fn = vfswrap_file_id_create,
+       .fs_file_id_fn = vfswrap_fs_file_id,
        .streaminfo_fn = vfswrap_streaminfo,
        .get_real_filename_fn = vfswrap_get_real_filename,
        .connectpath_fn = vfswrap_connectpath,
index 23c59000da15ac43bef2c390dcb5fcae33c76ebd..1dd1a8dbef4d1d6c6f3ccdddfdeb81b44388f0a7 100644 (file)
@@ -1161,7 +1161,6 @@ int sys_statvfs(const char *path, vfs_statvfs_struct *statbuf);
 NTSTATUS check_access_fsp(const struct files_struct *fsp,
                          uint32_t access_mask);
 uint64_t smb_roundup(connection_struct *conn, uint64_t val);
-uint64_t get_fs_file_id(connection_struct *conn, const SMB_STRUCT_STAT *psbuf);
 void aapl_force_zero_file_id(struct smbd_server_connection *sconn);
 bool samba_private_attr_name(const char *unix_ea_name);
 NTSTATUS get_ea_value(TALLOC_CTX *mem_ctx, connection_struct *conn,
index 55dfb148c8ef1c7dbbea32bdc6a5e5637b9b40d3..61ed72169fb4492e4e164959502b9590b7067e6a 100644 (file)
@@ -1389,8 +1389,9 @@ static void smbd_smb2_create_after_exec(struct tevent_req *req)
 
        if (state->qfid != NULL) {
                uint8_t p[32];
-               uint64_t file_id = get_fs_file_id(state->result->conn,
-                                                 &state->result->fsp_name->st);
+               uint64_t file_id = SMB_VFS_FS_FILE_ID(
+                       state->result->conn,
+                       &state->result->fsp_name->st);
                DATA_BLOB blob = data_blob_const(p, sizeof(p));
 
                ZERO_STRUCT(p);
index a268e97218f9a8055e629282669788861671a427..9a2ae9b2f47f99d8150d53b6ab3844b1b46a08f7 100644 (file)
@@ -213,27 +213,6 @@ uint64_t smb_roundup(connection_struct *conn, uint64_t val)
        return val;
 }
 
-/********************************************************************
- Create a 64 bit FileIndex. If the file is on the same device as
- the root of the share, just return the 64-bit inode. If it isn't,
- mangle as we used to do.
-********************************************************************/
-
-uint64_t get_fs_file_id(connection_struct *conn, const SMB_STRUCT_STAT *psbuf)
-{
-       uint64_t file_id;
-       if (conn->sconn->aapl_zero_file_id) {
-               return 0;
-       }
-       if (conn->base_share_dev == psbuf->st_ex_dev) {
-               return (uint64_t)psbuf->st_ex_ino;
-       }
-       file_id = ((psbuf->st_ex_ino) & UINT32_MAX); /* FileIDLow */
-       file_id |= ((uint64_t)((psbuf->st_ex_dev) & UINT32_MAX)) << 32; /* FileIDHigh */
-       return file_id;
-}
-
-
 /********************************************************************
  Globally (for this connection / multi-channel) disable file-ID
  calculation. This is required to be global because it serves
@@ -1863,7 +1842,7 @@ static NTSTATUS smbd_marshall_dir_entry(TALLOC_CTX *ctx,
                }
        }
 
-       file_id = get_fs_file_id(conn, &smb_fname->st);
+       file_id = SMB_VFS_FS_FILE_ID(conn, &smb_fname->st);
 
        mdate_ts = smb_fname->st.st_ex_mtime;
        adate_ts = smb_fname->st.st_ex_atime;
@@ -5231,7 +5210,7 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn,
 
           I think this causes us to fail the IFSKIT
           BasicFileInformationTest. -tpot */
-       file_id = get_fs_file_id(conn, psbuf);
+       file_id = SMB_VFS_FS_FILE_ID(conn, psbuf);
 
        *fixed_portion = 0;