1 /*
2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
5 * 1.0 of the CDDL.
6 *
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
10 */
11
12 /*
13 * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
14 */
15
16 /*
17 * Dispatch function for SMB2_SET_INFO
18 *
19 * [MS-FSCC 2.4] If a file system does not support ...
20 * an Information Classs, NT_STATUS_INVALID_PARAMETER...
21 */
22
23 #include <smbsrv/smb2_kproto.h>
24 #include <smbsrv/smb_fsops.h>
25 #include <smbsrv/ntifs.h>
26
27 static uint32_t smb2_setf_rename(smb_request_t *, smb_setinfo_t *);
28 static uint32_t smb2_setf_link(smb_request_t *, smb_setinfo_t *);
29
30 static uint32_t smb2_setf_seek(smb_request_t *, smb_setinfo_t *);
31 static uint32_t smb2_setf_full_ea(smb_request_t *, smb_setinfo_t *);
32 static uint32_t smb2_setf_mode(smb_request_t *, smb_setinfo_t *);
33
246 status = NT_STATUS_INVALID_PARAMETER;
247 }
248
249 return (status);
250 }
251
252 /*
253 * FileValidDataLengthInformation
254 */
255 /* ARGSUSED */
256 static uint32_t
257 smb2_setf_valid_len(smb_request_t *sr, smb_setinfo_t *si)
258 {
259 smb_ofile_t *of = sr->fid_ofile;
260 uint64_t eod;
261 int rc;
262
263 if (smb_mbc_decodef(&si->si_data, "q", &eod) != 0)
264 return (NT_STATUS_INFO_LENGTH_MISMATCH);
265
266 rc = smb_fsop_set_data_length(sr, of->f_cr, of->f_node, eod);
267 if (rc != 0)
268 return (smb_errno2status(rc));
269
270 return (0);
271 }
272
273 /*
274 * FileShortNameInformation
275 * We can (optionally) support supply short names,
276 * but you can't change them.
277 */
278 static uint32_t
279 smb2_setf_shortname(smb_request_t *sr, smb_setinfo_t *si)
280 {
281 _NOTE(ARGUNUSED(si))
282 smb_ofile_t *of = sr->fid_ofile;
283
284 if (of->f_ftype != SMB_FTYPE_DISK)
285 return (NT_STATUS_INVALID_PARAMETER);
286 if ((of->f_tree->t_flags & SMB_TREE_SHORTNAMES) == 0)
|
1 /*
2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
5 * 1.0 of the CDDL.
6 *
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
10 */
11
12 /*
13 * Copyright 2016 Nexenta Systems, Inc. All rights reserved.
14 */
15
16 /*
17 * Dispatch function for SMB2_SET_INFO
18 *
19 * [MS-FSCC 2.4] If a file system does not support ...
20 * an Information Classs, NT_STATUS_INVALID_PARAMETER...
21 */
22
23 #include <smbsrv/smb2_kproto.h>
24 #include <smbsrv/smb_fsops.h>
25 #include <smbsrv/ntifs.h>
26
27 static uint32_t smb2_setf_rename(smb_request_t *, smb_setinfo_t *);
28 static uint32_t smb2_setf_link(smb_request_t *, smb_setinfo_t *);
29
30 static uint32_t smb2_setf_seek(smb_request_t *, smb_setinfo_t *);
31 static uint32_t smb2_setf_full_ea(smb_request_t *, smb_setinfo_t *);
32 static uint32_t smb2_setf_mode(smb_request_t *, smb_setinfo_t *);
33
246 status = NT_STATUS_INVALID_PARAMETER;
247 }
248
249 return (status);
250 }
251
252 /*
253 * FileValidDataLengthInformation
254 */
255 /* ARGSUSED */
256 static uint32_t
257 smb2_setf_valid_len(smb_request_t *sr, smb_setinfo_t *si)
258 {
259 smb_ofile_t *of = sr->fid_ofile;
260 uint64_t eod;
261 int rc;
262
263 if (smb_mbc_decodef(&si->si_data, "q", &eod) != 0)
264 return (NT_STATUS_INFO_LENGTH_MISMATCH);
265
266 /*
267 * Zero out data from EoD to end of file.
268 * (Passing len=0 covers to end of file)
269 */
270 rc = smb_fsop_freesp(sr, of->f_cr, of, eod, 0);
271 if (rc != 0)
272 return (smb_errno2status(rc));
273
274 return (0);
275 }
276
277 /*
278 * FileShortNameInformation
279 * We can (optionally) support supply short names,
280 * but you can't change them.
281 */
282 static uint32_t
283 smb2_setf_shortname(smb_request_t *sr, smb_setinfo_t *si)
284 {
285 _NOTE(ARGUNUSED(si))
286 smb_ofile_t *of = sr->fid_ofile;
287
288 if (of->f_ftype != SMB_FTYPE_DISK)
289 return (NT_STATUS_INVALID_PARAMETER);
290 if ((of->f_tree->t_flags & SMB_TREE_SHORTNAMES) == 0)
|