Changeset 745 for trunk/server/source3/smbd/smb2_close.c
- Timestamp:
- Nov 27, 2012, 4:43:17 PM (13 years ago)
- Location:
- trunk/server
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 581,587,591,594,597,600,615,618,740
- Property svn:mergeinfo changed
-
trunk/server/source3/smbd/smb2_close.c
r414 r745 20 20 21 21 #include "includes.h" 22 #include "smbd/smbd.h" 22 23 #include "smbd/globals.h" 23 24 #include "../libcli/smb/smb_common.h" … … 25 26 static NTSTATUS smbd_smb2_close(struct smbd_smb2_request *req, 26 27 uint16_t in_flags, 27 uint64_t in_file_id_volatile); 28 uint64_t in_file_id_volatile, 29 DATA_BLOB *outbody); 28 30 29 31 NTSTATUS smbd_smb2_request_process_close(struct smbd_smb2_request *req) … … 53 55 } 54 56 57 outbody = data_blob_talloc(req->out.vector, NULL, 0x3C); 58 if (outbody.data == NULL) { 59 return smbd_smb2_request_error(req, NT_STATUS_NO_MEMORY); 60 } 61 55 62 in_flags = SVAL(inbody, 0x02); 56 63 in_file_id_persistent = BVAL(inbody, 0x08); … … 59 66 if (req->compat_chain_fsp) { 60 67 /* skip check */ 61 } else if (in_file_id_persistent != 0) {68 } else if (in_file_id_persistent != in_file_id_volatile) { 62 69 return smbd_smb2_request_error(req, NT_STATUS_FILE_CLOSED); 63 70 } … … 65 72 status = smbd_smb2_close(req, 66 73 in_flags, 67 in_file_id_volatile); 74 in_file_id_volatile, 75 &outbody); 68 76 if (!NT_STATUS_IS_OK(status)) { 69 77 return smbd_smb2_request_error(req, status); … … 71 79 72 80 outhdr = (uint8_t *)req->out.vector[i].iov_base; 73 74 outbody = data_blob_talloc(req->out.vector, NULL, 0x3C);75 if (outbody.data == NULL) {76 return smbd_smb2_request_error(req, NT_STATUS_NO_MEMORY);77 }78 79 SSVAL(outbody.data, 0x00, 0x3C); /* struct size */80 SSVAL(outbody.data, 0x02, 0); /* flags */81 SIVAL(outbody.data, 0x04, 0); /* reserved */82 SBVAL(outbody.data, 0x08, 0); /* creation time */83 SBVAL(outbody.data, 0x10, 0); /* last access time */84 SBVAL(outbody.data, 0x18, 0); /* last write time */85 SBVAL(outbody.data, 0x20, 0); /* change time */86 SBVAL(outbody.data, 0x28, 0); /* allocation size */87 SBVAL(outbody.data, 0x30, 0); /* end of size */88 SIVAL(outbody.data, 0x38, 0); /* file attributes */89 90 81 return smbd_smb2_request_done(req, outbody, NULL); 91 82 } … … 93 84 static NTSTATUS smbd_smb2_close(struct smbd_smb2_request *req, 94 85 uint16_t in_flags, 95 uint64_t in_file_id_volatile) 86 uint64_t in_file_id_volatile, 87 DATA_BLOB *outbody) 96 88 { 97 89 NTSTATUS status; … … 99 91 connection_struct *conn = req->tcon->compat_conn; 100 92 files_struct *fsp; 93 struct smb_filename *smb_fname = NULL; 94 struct timespec mdate_ts, adate_ts, cdate_ts, create_date_ts; 95 uint64_t allocation_size = 0; 96 uint64_t file_size = 0; 97 uint32_t dos_attrs = 0; 98 uint16_t out_flags = 0; 99 bool posix_open = false; 100 101 ZERO_STRUCT(create_date_ts); 102 ZERO_STRUCT(adate_ts); 103 ZERO_STRUCT(mdate_ts); 104 ZERO_STRUCT(cdate_ts); 101 105 102 106 DEBUG(10,("smbd_smb2_close: file_id[0x%016llX]\n", … … 119 123 } 120 124 125 posix_open = fsp->posix_open; 126 status = copy_smb_filename(talloc_tos(), 127 fsp->fsp_name, 128 &smb_fname); 129 if (!NT_STATUS_IS_OK(status)) { 130 return status; 131 } 132 121 133 status = close_file(smbreq, fsp, NORMAL_CLOSE); 122 134 if (!NT_STATUS_IS_OK(status)) { … … 126 138 } 127 139 140 if (in_flags & SMB2_CLOSE_FLAGS_FULL_INFORMATION) { 141 int ret; 142 if (posix_open) { 143 ret = SMB_VFS_LSTAT(conn, smb_fname); 144 } else { 145 ret = SMB_VFS_STAT(conn, smb_fname); 146 } 147 if (ret == 0) { 148 out_flags = SMB2_CLOSE_FLAGS_FULL_INFORMATION; 149 dos_attrs = dos_mode(conn, smb_fname); 150 mdate_ts = smb_fname->st.st_ex_mtime; 151 adate_ts = smb_fname->st.st_ex_atime; 152 create_date_ts = get_create_timespec(conn, NULL, smb_fname); 153 cdate_ts = get_change_timespec(conn, NULL, smb_fname); 154 155 if (lp_dos_filetime_resolution(SNUM(conn))) { 156 dos_filetime_timespec(&create_date_ts); 157 dos_filetime_timespec(&mdate_ts); 158 dos_filetime_timespec(&adate_ts); 159 dos_filetime_timespec(&cdate_ts); 160 } 161 if (!(dos_attrs & FILE_ATTRIBUTE_DIRECTORY)) { 162 file_size = get_file_size_stat(&smb_fname->st); 163 } 164 165 allocation_size = SMB_VFS_GET_ALLOC_SIZE(conn, NULL, &smb_fname->st); 166 } 167 } 168 169 SSVAL(outbody->data, 0x00, 0x3C); /* struct size */ 170 SSVAL(outbody->data, 0x02, out_flags); /* flags */ 171 SIVAL(outbody->data, 0x04, 0); /* reserved */ 172 put_long_date_timespec(conn->ts_res, 173 (char *)&outbody->data[0x8],create_date_ts); /* creation time */ 174 put_long_date_timespec(conn->ts_res, 175 (char *)&outbody->data[0x10],adate_ts); /* last access time */ 176 put_long_date_timespec(conn->ts_res, 177 (char *)&outbody->data[0x18],mdate_ts); /* last write time */ 178 put_long_date_timespec(conn->ts_res, 179 (char *)&outbody->data[0x20],cdate_ts); /* change time */ 180 SBVAL(outbody->data, 0x28, allocation_size);/* allocation size */ 181 SBVAL(outbody->data, 0x30, file_size); /* end of file */ 182 SIVAL(outbody->data, 0x38, dos_attrs); /* file attributes */ 183 128 184 return NT_STATUS_OK; 129 185 }
Note:
See TracChangeset
for help on using the changeset viewer.