From: Ralph Boehme Date: Mon, 9 Sep 2019 05:57:34 +0000 (+0200) Subject: s3: replace fsp_stat() with vfs_stat_fsp() X-Git-Tag: talloc-2.3.1~933 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ab03394969f8a4c748aea7d0d8ed37f9ced6cc30;p=thirdparty%2Fsamba.git s3: replace fsp_stat() with vfs_stat_fsp() Both functions do the same, they differ just in the type of the returned result. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14121 Signed-off-by: Ralph Boehme Reviewed-by: Stefan Metzmacher --- diff --git a/source3/modules/vfs_dirsort.c b/source3/modules/vfs_dirsort.c index c23f6f0152d..c6b5ea41c93 100644 --- a/source3/modules/vfs_dirsort.c +++ b/source3/modules/vfs_dirsort.c @@ -44,19 +44,22 @@ static bool get_sorted_dir_mtime(vfs_handle_struct *handle, { int ret; struct timespec mtime; + NTSTATUS status; if (data->fsp) { - ret = fsp_stat(data->fsp); + status = vfs_stat_fsp(data->fsp); + if (!NT_STATUS_IS_OK(status)) { + return false; + } mtime = data->fsp->fsp_name->st.st_ex_mtime; } else { ret = SMB_VFS_STAT(handle->conn, data->smb_fname); + if (ret == -1) { + return false; + } mtime = data->smb_fname->st.st_ex_mtime; } - if (ret == -1) { - return false; - } - *ret_mtime = mtime; return true; diff --git a/source3/smbd/fileio.c b/source3/smbd/fileio.c index a00b368f92b..067ce5a9ad4 100644 --- a/source3/smbd/fileio.c +++ b/source3/smbd/fileio.c @@ -1068,20 +1068,3 @@ NTSTATUS sync_file(connection_struct *conn, files_struct *fsp, bool write_throug } return NT_STATUS_OK; } - -/************************************************************ - Perform a stat whether a valid fd or not. -************************************************************/ - -int fsp_stat(files_struct *fsp) -{ - if (fsp->fh->fd == -1) { - if (fsp->posix_flags & FSP_POSIX_FLAGS_OPEN) { - return SMB_VFS_LSTAT(fsp->conn, fsp->fsp_name); - } else { - return SMB_VFS_STAT(fsp->conn, fsp->fsp_name); - } - } else { - return SMB_VFS_FSTAT(fsp, &fsp->fsp_name->st); - } -} diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index 99458e50df9..7efbb80d3e3 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -334,7 +334,6 @@ void delete_write_cache(files_struct *fsp); void set_filelen_write_cache(files_struct *fsp, off_t file_size); ssize_t flush_write_cache(files_struct *fsp, enum flush_reason_enum reason); NTSTATUS sync_file(connection_struct *conn, files_struct *fsp, bool write_through); -int fsp_stat(files_struct *fsp); /* The following definitions come from smbd/filename.c */ diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index 4446d927aeb..dcd46dd574c 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -3764,6 +3764,7 @@ void reply_readbraw(struct smb_request *req) files_struct *fsp; struct lock_struct lock; off_t size = 0; + NTSTATUS status; START_PROFILE(SMBreadbraw); @@ -3861,7 +3862,8 @@ void reply_readbraw(struct smb_request *req) return; } - if (fsp_stat(fsp) == 0) { + status = vfs_stat_fsp(fsp); + if (NT_STATUS_IS_OK(status)) { size = fsp->fsp_name->st.st_ex_size; } @@ -4192,6 +4194,7 @@ static void send_file_readX(connection_struct *conn, struct smb_request *req, ssize_t nread = -1; struct lock_struct lock; int saved_errno = 0; + NTSTATUS status; init_strict_lock_struct(fsp, (uint64_t)req->smbpid, (uint64_t)startpos, (uint64_t)smb_maxcnt, READ_LOCK, @@ -4216,8 +4219,9 @@ static void send_file_readX(connection_struct *conn, struct smb_request *req, uint8_t headerbuf[smb_size + 12 * 2 + 1 /* padding byte */]; DATA_BLOB header; - if(fsp_stat(fsp) == -1) { - reply_nterror(req, map_nt_error_from_unix(errno)); + status = vfs_stat_fsp(fsp); + if (!NT_STATUS_IS_OK(status)) { + reply_nterror(req, status); goto out; } @@ -5425,6 +5429,7 @@ void reply_lseek(struct smb_request *req) off_t res= -1; int mode,umode; files_struct *fsp; + NTSTATUS status; START_PROFILE(SMBlseek); @@ -5469,9 +5474,9 @@ void reply_lseek(struct smb_request *req) if(errno == EINVAL) { off_t current_pos = startpos; - if(fsp_stat(fsp) == -1) { - reply_nterror(req, - map_nt_error_from_unix(errno)); + status = vfs_stat_fsp(fsp); + if (!NT_STATUS_IS_OK(status)) { + reply_nterror(req, status); END_PROFILE(SMBlseek); return; } @@ -8856,6 +8861,7 @@ void reply_getattrE(struct smb_request *req) int mode; files_struct *fsp; struct timespec create_ts; + NTSTATUS status; START_PROFILE(SMBgetattrE); @@ -8874,8 +8880,9 @@ void reply_getattrE(struct smb_request *req) } /* Do an fstat on this file */ - if(fsp_stat(fsp)) { - reply_nterror(req, map_nt_error_from_unix(errno)); + status = vfs_stat_fsp(fsp); + if (!NT_STATUS_IS_OK(status)) { + reply_nterror(req, status); END_PROFILE(SMBgetattrE); return; }