Home | History | Annotate | Download | only in smbsrv
      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/smb_kproto.h>
     55 
     56 
     57 /*
     58  * smb_com_trans2_create_directory
     59  */
     60 smb_sdrc_t
     61 smb_com_trans2_create_directory(struct smb_request *sr, struct smb_xa *xa)
     62 {
     63 	int	rc;
     64 	DWORD	status;
     65 
     66 	if (!STYPE_ISDSK(sr->tid_tree->t_res_type)) {
     67 		smbsr_error(sr, NT_STATUS_ACCESS_DENIED,
     68 		    ERRDOS, ERROR_ACCESS_DENIED);
     69 		return (SDRC_ERROR);
     70 	}
     71 
     72 	if (smb_mbc_decodef(&xa->req_param_mb, "%4.u",
     73 	    sr, &sr->arg.dirop.fqi.fq_path.pn_path) != 0) {
     74 		return (SDRC_ERROR);
     75 	}
     76 
     77 	status = smb_validate_dirname(sr->arg.dirop.fqi.fq_path.pn_path);
     78 	if (status != 0) {
     79 		smbsr_error(sr, status, ERRDOS, ERROR_INVALID_NAME);
     80 		return (SDRC_ERROR);
     81 	}
     82 
     83 	if ((rc = smb_common_create_directory(sr)) != 0) {
     84 		smbsr_errno(sr, rc);
     85 		return (SDRC_ERROR);
     86 	}
     87 
     88 	if (smb_mbc_encodef(&xa->rep_param_mb, "w", 0) < 0)
     89 		return (SDRC_ERROR);
     90 
     91 	return (SDRC_SUCCESS);
     92 }
     93