From: James Peach Date: Mon, 15 Oct 2007 21:46:17 +0000 (-0700) Subject: Let SMB clients set the file creation time. X-Git-Url: http://git.samba.org/jpeach/samba.git/?p=jpeach%2Fsamba.git;a=commitdiff_plain;h=4ac99876da3737c141be6ab0d8c157023f19e17a Let SMB clients set the file creation time. This patch adds support for the protocol calls that sre used to set the file creation time. Note that this does not trigger a file change notification, so some refactoring is required. --- diff --git a/source/smbd/trans2.c b/source/smbd/trans2.c index d266b95e545..6f4866bc9d5 100644 --- a/source/smbd/trans2.c +++ b/source/smbd/trans2.c @@ -4823,6 +4823,7 @@ static NTSTATUS smb_set_info_standard(connection_struct *conn, const SMB_STRUCT_STAT *psbuf) { struct timespec ts[2]; + time_t create_time; if (total_data < 12) { return NT_STATUS_INVALID_PARAMETER; @@ -4833,6 +4834,14 @@ static NTSTATUS smb_set_info_standard(connection_struct *conn, /* write time */ ts[1] = convert_time_t_to_timespec(srv_make_unix_date2(pdata+l1_fdateLastWrite)); + /* create time */ + /* XXX: this code should be in smb_set_file_time() -- jpeach */ + create_time = srv_make_unix_date2(pdata+l1_fdateCreation); + /* They want to set the create time and the share is writable */ + if ((!null_mtime(create_time)) && (CAN_WRITE(conn)) && !fsp) { + SMB_VFS_SET_CREATE_TIME(conn, fname, create_time); + } + DEBUG(10,("smb_set_info_standard: file %s\n", fname ? fname : fsp->fsp_name )); @@ -4854,6 +4863,7 @@ static NTSTATUS smb_set_file_basic_info(connection_struct *conn, const char *fname, SMB_STRUCT_STAT *psbuf) { + time_t create_time; /* Patch to do this correctly from Paul Eggert . */ struct timespec write_time; struct timespec changed_time; @@ -4875,7 +4885,12 @@ static NTSTATUS smb_set_file_basic_info(connection_struct *conn, return status; } - /* Ignore create time at offset pdata. */ + /* create time */ + create_time = convert_timespec_to_time_t(interpret_long_date(pdata+0)); + /* They want to set the create time and the share is writable */ + if ((!null_mtime(create_time)) && (CAN_WRITE(conn)) && !fsp) { + SMB_VFS_SET_CREATE_TIME(conn, fname, create_time); + } /* access time */ ts[0] = interpret_long_date(pdata+8); @@ -5298,6 +5313,7 @@ static NTSTATUS smb_set_file_unix_info2(connection_struct *conn, const char *fname, SMB_STRUCT_STAT *psbuf) { + time_t create_time; NTSTATUS status; uint32 smb_fflags; uint32 smb_fmask; @@ -5315,6 +5331,12 @@ static NTSTATUS smb_set_file_unix_info2(connection_struct *conn, return status; } + create_time = convert_timespec_to_time_t(interpret_long_date(pdata+100)); /* create_time */ + /* They want to set the create time and the share is writable */ + if ((!null_mtime(create_time)) && (CAN_WRITE(conn)) && !fsp) { + SMB_VFS_SET_CREATE_TIME(conn, fname, create_time); + } + smb_fflags = IVAL(pdata, 108); smb_fmask = IVAL(pdata, 112);