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 2009 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 /* 27 * SMB: trans2_create_directory 28 * 29 * This requests the server to create a directory relative to Tid in the 30 * SMB header, optionally assigning extended attributes to it. 31 * 32 * Client Request Value 33 * ========================== ========================================= 34 * 35 * WordCount 15 36 * MaxSetupCount 0 37 * SetupCount 1 38 * Setup[0] TRANS2_CREATE_DIRECTORY 39 * 40 * Parameter Block Encoding Description 41 * ========================== ========================================= 42 * 43 * ULONG Reserved; Reserved--must be zero 44 * STRING Name[]; Directory name to create 45 * UCHAR Data[]; Optional FEAList for the new directory 46 * 47 * Response Parameter Block Description 48 * ========================== ========================================= 49 * 50 * USHORT EaErrorOffset Offset into FEAList of first error which 51 * occurred while setting EAs 52 */ 53 54 #include <smbsrv/nterror.h> 55 #include <smbsrv/ntstatus.h> 56 #include <smbsrv/smb_incl.h> 57 58 59 /* 60 * smb_com_trans2_create_directory 61 */ 62 smb_sdrc_t 63 smb_com_trans2_create_directory(struct smb_request *sr, struct smb_xa *xa) 64 { 65 int rc; 66 DWORD status; 67 68 if (!STYPE_ISDSK(sr->tid_tree->t_res_type)) { 69 smbsr_error(sr, NT_STATUS_ACCESS_DENIED, 70 ERRDOS, ERROR_ACCESS_DENIED); 71 return (SDRC_ERROR); 72 } 73 74 if (smb_mbc_decodef(&xa->req_param_mb, "%4.u", 75 sr, &sr->arg.dirop.fqi.fq_path.pn_path) != 0) { 76 return (SDRC_ERROR); 77 } 78 79 status = smb_validate_dirname(sr->arg.dirop.fqi.fq_path.pn_path); 80 if (status != 0) { 81 smbsr_error(sr, status, ERRDOS, ERROR_INVALID_NAME); 82 return (SDRC_ERROR); 83 } 84 85 if ((rc = smb_common_create_directory(sr)) != 0) { 86 smbsr_errno(sr, rc); 87 return (SDRC_ERROR); 88 } 89 90 if (smb_mbc_encodef(&xa->rep_param_mb, "w", 0) < 0) 91 return (SDRC_ERROR); 92 93 return (SDRC_SUCCESS); 94 } 95