xref: /illumos-gate/usr/src/uts/common/fs/smbsrv/smb_trans2_create_directory.c (revision 5bb86dd8f405a48942aaaab3ca1f410ed7e6db4d)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #pragma ident	"%Z%%M%	%I%	%E% SMI"
27 
28 /*
29  * SMB: trans2_create_directory
30  *
31  * This requests the server to create a directory relative to Tid in the
32  * SMB header, optionally assigning extended attributes to it.
33  *
34  *  Client Request             Value
35  *  ========================== =========================================
36  *
37  *  WordCount                  15
38  *  MaxSetupCount              0
39  *  SetupCount                 1
40  *  Setup[0]                   TRANS2_CREATE_DIRECTORY
41  *
42  *  Parameter Block Encoding   Description
43  *  ========================== =========================================
44  *
45  *  ULONG Reserved;            Reserved--must be zero
46  *  STRING Name[];             Directory name to create
47  *  UCHAR Data[];              Optional FEAList for the new directory
48  *
49  *  Response Parameter Block   Description
50  *  ========================== =========================================
51  *
52  *  USHORT EaErrorOffset       Offset into FEAList of first error which
53  *                             occurred while setting EAs
54  */
55 
56 #include <smbsrv/nterror.h>
57 #include <smbsrv/ntstatus.h>
58 #include <smbsrv/smb_incl.h>
59 
60 
61 extern int smb_common_create_directory(struct smb_request *sr);
62 
63 
64 /*
65  * smb_com_trans2_create_directory
66  */
67 int
68 smb_com_trans2_create_directory(struct smb_request *sr, struct smb_xa *xa)
69 {
70 	int	rc;
71 	DWORD	status;
72 
73 	if (smb_decode_mbc(&xa->req_param_mb, "%4.s",
74 	    sr, &sr->arg.dirop.fqi.path) != 0) {
75 		smbsr_decode_error(sr);
76 		/* NOTREACHED */
77 	}
78 
79 	if ((status = smb_validate_dirname(sr->arg.dirop.fqi.path)) != 0) {
80 		smbsr_error(sr, status, ERRDOS, ERROR_INVALID_NAME);
81 		/* NOTREACHED */
82 	}
83 
84 	if ((rc = smb_common_create_directory(sr)) != 0) {
85 		smbsr_errno(sr, rc);
86 		/* NOTREACHED */
87 	}
88 
89 	if (smb_encode_mbc(&xa->rep_param_mb, "w", 0) < 0)
90 		smbsr_encode_error(sr);
91 
92 	return (SDRC_NORMAL_REPLY);
93 }
94