From: Ralph Boehme Date: Sat, 29 Jun 2019 12:18:13 +0000 (+0200) Subject: s3:vfs: move get_fs_file_id to vfs_default X-Git-Tag: ldb-2.0.5~101 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=df5752ec90d2b648b221887840262acf8fe43ef6;p=thirdparty%2Fsamba.git s3:vfs: move get_fs_file_id to vfs_default This makes get_fs_file_id() the default implementation of SMB_VFS_FS_FILE_ID(). No change in behaviour. Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison --- diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index f2f2ed7f7d1..dcb53c64eef 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -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, diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index 23c59000da1..1dd1a8dbef4 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -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, diff --git a/source3/smbd/smb2_create.c b/source3/smbd/smb2_create.c index 55dfb148c8e..61ed72169fb 100644 --- a/source3/smbd/smb2_create.c +++ b/source3/smbd/smb2_create.c @@ -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); diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index a268e97218f..9a2ae9b2f47 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -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;