r23508: Fix sync_file() to return NTSTATUS and return this
[sfrench/samba-autobuild/.git] / source / smbd / fileio.c
index 65238c0e9ee60bb0e7c47767e2182caaa2363319..1227d12b08e5333314ebc93f20e6d8e82871b12a 100644 (file)
@@ -834,16 +834,23 @@ ssize_t flush_write_cache(files_struct *fsp, enum flush_reason_enum reason)
 sync a file
 ********************************************************************/
 
-void sync_file(connection_struct *conn, files_struct *fsp, BOOL write_through)
+NTSTATUS sync_file(connection_struct *conn, files_struct *fsp, BOOL write_through)
 {
                if (fsp->fh->fd == -1)
-               return;
+               return NT_STATUS_INVALID_HANDLE;
 
        if (lp_strict_sync(SNUM(conn)) &&
            (lp_syncalways(SNUM(conn)) || write_through)) {
-               flush_write_cache(fsp, SYNC_FLUSH);
-               SMB_VFS_FSYNC(fsp,fsp->fh->fd);
+               int ret = flush_write_cache(fsp, SYNC_FLUSH);
+               if (ret == -1) {
+                       return map_nt_error_from_unix(errno);
+               }
+               ret = SMB_VFS_FSYNC(fsp,fsp->fh->fd);
+               if (ret == -1) {
+                       return map_nt_error_from_unix(errno);
+               }
        }
+       return NT_STATUS_OK;
 }
 
 /************************************************************