summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-07-12 18:11:41 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:28:35 -0500
commit967b22827ff51d2f546931206cdb4a876f345820 (patch)
tree4444a46408025d15ba95797f6aa37be337b01d06
parentc52c8b4821e26bb0192858612fd27ab1cc5c9849 (diff)
downloadsamba-967b22827ff51d2f546931206cdb4a876f345820.tar.gz
samba-967b22827ff51d2f546931206cdb4a876f345820.tar.bz2
samba-967b22827ff51d2f546931206cdb4a876f345820.zip
r23855: Setting the allocation size updates the modified time
as a write does. Fix bug #4779. Jeremy. (This used to be commit ed0e2174a895b25ce2b4e8ffd912ad57b31dd2e9)
-rw-r--r--source3/smbd/trans2.c41
1 files changed, 29 insertions, 12 deletions
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index 8711f988a8..1659c8fcbd 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -5009,17 +5009,24 @@ static NTSTATUS smb_set_file_allocation_info(connection_struct *conn,
allocation_size = smb_roundup(conn, allocation_size);
}
- if(allocation_size == get_file_size(*psbuf)) {
- return NT_STATUS_OK;
- }
-
DEBUG(10,("smb_set_file_allocation_info: file %s : setting new allocation size to %.0f\n",
fname, (double)allocation_size ));
-
+
if (fsp && fsp->fh->fd != -1) {
/* Open file handle. */
- if (vfs_allocate_file_space(fsp, allocation_size) == -1) {
- return map_nt_error_from_unix(errno);
+ /* Only change if needed. */
+ if (allocation_size != get_file_size(*psbuf)) {
+ if (vfs_allocate_file_space(fsp, allocation_size) == -1) {
+ return map_nt_error_from_unix(errno);
+ }
+ }
+ /* But always update the time. */
+ if (null_timespec(fsp->pending_modtime)) {
+ /*
+ * This is equivalent to a write. Ensure it's seen immediately
+ * if there are no pending writes.
+ */
+ set_filetime(fsp->conn, fsp->fsp_name, timespec_current());
}
return NT_STATUS_OK;
}
@@ -5034,17 +5041,27 @@ static NTSTATUS smb_set_file_allocation_info(connection_struct *conn,
FILE_ATTRIBUTE_NORMAL,
FORCE_OPLOCK_BREAK_TO_NONE,
NULL, &new_fsp);
-
+
if (!NT_STATUS_IS_OK(status)) {
/* NB. We check for open_was_deferred in the caller. */
return status;
}
- if (vfs_allocate_file_space(new_fsp, allocation_size) == -1) {
- status = map_nt_error_from_unix(errno);
- close_file(new_fsp,NORMAL_CLOSE);
- return status;
+
+ /* Only change if needed. */
+ if (allocation_size != get_file_size(*psbuf)) {
+ if (vfs_allocate_file_space(new_fsp, allocation_size) == -1) {
+ status = map_nt_error_from_unix(errno);
+ close_file(new_fsp,NORMAL_CLOSE);
+ return status;
+ }
}
+ /* Changing the allocation size should set the last mod time. */
+ /* Don't need to call set_filetime as this will be flushed on
+ * close. */
+
+ fsp_set_pending_modtime(new_fsp, timespec_current());
+
close_file(new_fsp,NORMAL_CLOSE);
return NT_STATUS_OK;
}