]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: replace fsp_stat() with vfs_stat_fsp()
authorRalph Boehme <slow@samba.org>
Mon, 9 Sep 2019 05:57:34 +0000 (07:57 +0200)
committerRalph Boehme <slow@samba.org>
Tue, 10 Sep 2019 19:05:29 +0000 (19:05 +0000)
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 <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
source3/modules/vfs_dirsort.c
source3/smbd/fileio.c
source3/smbd/proto.h
source3/smbd/reply.c

index c23f6f0152d4ce34c5a57550f1e303e09a20b25e..c6b5ea41c93660336068f9d98d9464243663f5c3 100644 (file)
@@ -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;
index a00b368f92bc7d0f31299968c7cebfd6f4f12264..067ce5a9ad408befbc87fe3f7424c0827607505c 100644 (file)
@@ -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);
-       }
-}
index 99458e50df9a9ed9df7cea28b1de041a9a1de641..7efbb80d3e31cb506fedf6b8580077ed46392119 100644 (file)
@@ -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  */
 
index 4446d927aeb94b4241470be0e0bc086299ad2354..dcd46dd574c0bfb109311c708736c51766045093 100644 (file)
@@ -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;
        }