diff options
Diffstat (limited to 'source4/ntvfs/posix/pvfs_setfileinfo.c')
-rw-r--r-- | source4/ntvfs/posix/pvfs_setfileinfo.c | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/source4/ntvfs/posix/pvfs_setfileinfo.c b/source4/ntvfs/posix/pvfs_setfileinfo.c index 74b0ed85c5..42ee8a971c 100644 --- a/source4/ntvfs/posix/pvfs_setfileinfo.c +++ b/source4/ntvfs/posix/pvfs_setfileinfo.c @@ -80,7 +80,74 @@ NTSTATUS pvfs_setfileinfo(struct ntvfs_module_context *ntvfs, create_options &= ~NTCREATEX_OPTIONS_DELETE_ON_CLOSE; } return pvfs_change_create_options(pvfs, req, f, create_options); + + case RAW_SFILEINFO_POSITION_INFORMATION: + f->position = info->position_information.in.position; + break; } return NT_STATUS_OK; } + + +/* + set info on a pathname +*/ +NTSTATUS pvfs_setpathinfo(struct ntvfs_module_context *ntvfs, + struct smbsrv_request *req, union smb_setfileinfo *info) +{ + struct pvfs_state *pvfs = ntvfs->private_data; + struct pvfs_filename *name; + NTSTATUS status; + struct utimbuf unix_times; + + /* resolve the cifs name to a posix name */ + status = pvfs_resolve_name(pvfs, req, info->generic.file.fname, + PVFS_RESOLVE_NO_WILDCARD, &name); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (!name->exists) { + return NT_STATUS_OBJECT_NAME_NOT_FOUND; + } + + switch (info->generic.level) { + case RAW_SFILEINFO_END_OF_FILE_INFO: + case RAW_SFILEINFO_END_OF_FILE_INFORMATION: + if (truncate(name->full_name, + info->end_of_file_info.in.size) == -1) { + return pvfs_map_errno(pvfs, errno); + } + break; + + case RAW_SFILEINFO_SETATTRE: + unix_times.actime = info->setattre.in.access_time; + unix_times.modtime = info->setattre.in.write_time; + + if (unix_times.actime == 0 && unix_times.modtime == 0) { + break; + } + + /* set modify time = to access time if modify time was 0 */ + if (unix_times.actime != 0 && unix_times.modtime == 0) { + unix_times.modtime = unix_times.actime; + } + + /* Set the date on this file */ + if (utime(name->full_name, &unix_times) == -1) { + return NT_STATUS_ACCESS_DENIED; + } + break; + + case RAW_SFILEINFO_DISPOSITION_INFO: + case RAW_SFILEINFO_DISPOSITION_INFORMATION: + return NT_STATUS_INVALID_PARAMETER; + + case RAW_SFILEINFO_POSITION_INFORMATION: + return NT_STATUS_OK; + } + + return NT_STATUS_INVALID_LEVEL; +} + |