2 Unix SMB/CIFS implementation.
4 POSIX NTVFS backend - setfileinfo
6 Copyright (C) Andrew Tridgell 2004
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include "include/includes.h"
24 #include "vfs_posix.h"
27 set info on a open file
29 NTSTATUS pvfs_setfileinfo(struct ntvfs_module_context *ntvfs,
30 struct smbsrv_request *req,
31 union smb_setfileinfo *info)
33 struct pvfs_state *pvfs = ntvfs->private_data;
34 struct utimbuf unix_times;
36 uint32_t create_options;
38 f = pvfs_find_fd(pvfs, req, info->generic.file.fnum);
40 return NT_STATUS_INVALID_HANDLE;
43 switch (info->generic.level) {
44 case RAW_SFILEINFO_END_OF_FILE_INFO:
45 case RAW_SFILEINFO_END_OF_FILE_INFORMATION:
47 info->end_of_file_info.in.size) == -1) {
48 return pvfs_map_errno(pvfs, errno);
51 case RAW_SFILEINFO_SETATTRE:
52 unix_times.actime = info->setattre.in.access_time;
53 unix_times.modtime = info->setattre.in.write_time;
55 if (unix_times.actime == 0 && unix_times.modtime == 0) {
59 /* set modify time = to access time if modify time was 0 */
60 if (unix_times.actime != 0 && unix_times.modtime == 0) {
61 unix_times.modtime = unix_times.actime;
64 /* Set the date on this file */
65 if (utime(f->name->full_name, &unix_times) == -1) {
66 return NT_STATUS_ACCESS_DENIED;
69 case RAW_SFILEINFO_DISPOSITION_INFO:
70 if (!(f->access_mask & STD_RIGHT_DELETE_ACCESS)) {
71 return NT_STATUS_ACCESS_DENIED;
73 create_options = f->create_options;
74 if (info->disposition_info.in.delete_on_close) {
75 create_options |= NTCREATEX_OPTIONS_DELETE_ON_CLOSE;
77 create_options &= ~NTCREATEX_OPTIONS_DELETE_ON_CLOSE;
79 return pvfs_change_create_options(pvfs, req, f, create_options);