From e72e6a7ee1fc7376c9367879323d9d86952dc5f4 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 16 Dec 2010 16:42:33 -0800 Subject: [PATCH 7/8] file_set_sparse needs to be a handle based call. --- source3/include/proto.h | 2 +- source3/smbd/dosmode.c | 18 ++++++++---------- source3/smbd/nttrans.c | 2 +- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/source3/include/proto.h b/source3/include/proto.h index 53c1f5d..9583388 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -4621,7 +4621,7 @@ uint32 dos_mode(connection_struct *conn, struct smb_filename *smb_fname); int file_set_dosmode(connection_struct *conn, struct smb_filename *smb_fname, uint32 dosmode, const char *parent_dir, bool newfile); NTSTATUS file_set_sparse(connection_struct *conn, - struct smb_filename *smb_fname, + struct files_struct *fsp, bool sparse); int file_ntimes(connection_struct *conn, const struct smb_filename *smb_fname, struct smb_file_time *ft); diff --git a/source3/smbd/dosmode.c b/source3/smbd/dosmode.c index 5d6e4b4..86f7807 100644 --- a/source3/smbd/dosmode.c +++ b/source3/smbd/dosmode.c @@ -848,27 +848,26 @@ int file_set_dosmode(connection_struct *conn, struct smb_filename *smb_fname, NTSTATUS file_set_sparse(connection_struct *conn, - struct smb_filename *smb_fname, + files_struct *fsp, bool sparse) { - SMB_STRUCT_STAT st; uint32_t old_dosmode; uint32_t new_dosmode; + NTSTATUS status; DEBUG(10,("file_set_sparse: setting sparse bit %u on file %s\n", - sparse, smb_fname_str_dbg(smb_fname))); + sparse, smb_fname_str_dbg(fsp->fsp_name))); if (!lp_store_dos_attributes(SNUM(conn))) { return NT_STATUS_INVALID_DEVICE_REQUEST; } - SET_STAT_INVALID(st); - - if (SMB_VFS_STAT(conn, smb_fname)) { - return map_nt_error_from_unix(errno); + status = vfs_stat_fsp(fsp); + if (!NT_STATUS_IS_OK(status)) { + return status; } - old_dosmode = dos_mode(conn, smb_fname); + old_dosmode = dos_mode(conn, fsp->fsp_name); if (sparse && !(old_dosmode & FILE_ATTRIBUTE_SPARSE)) { new_dosmode = old_dosmode | FILE_ATTRIBUTE_SPARSE; @@ -879,7 +878,7 @@ NTSTATUS file_set_sparse(connection_struct *conn, } /* Store the DOS attributes in an EA. */ - if (!set_ea_dos_attribute(conn, smb_fname, + if (!set_ea_dos_attribute(conn, fsp->fsp_name, new_dosmode)) { if (errno == 0) { errno = EIO; @@ -894,7 +893,6 @@ NTSTATUS file_set_sparse(connection_struct *conn, return NT_STATUS_OK; } - /******************************************************************* Wrapper around the VFS ntimes that possibly allows DOS semantics rather than POSIX. diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c index 8d92d60..55804b9 100644 --- a/source3/smbd/nttrans.c +++ b/source3/smbd/nttrans.c @@ -2140,7 +2140,7 @@ static void call_nt_transact_ioctl(connection_struct *conn, return; } - status = file_set_sparse(conn, fsp->fsp_name, set_sparse); + status = file_set_sparse(conn, fsp, set_sparse); if (!NT_STATUS_IS_OK(status)) { DEBUG(9,("FSCTL_SET_SPARSE: fname[%s] set[%u] - %s\n", smb_fname_str_dbg(fsp->fsp_name), set_sparse, nt_errstr(status))); -- 1.7.3.1