smb_create_directory.c revision faa1795a28a5c712eed6d0a3f84d98c368a316c6
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* SMB: create_directory
*
* The create directory message is sent to create a new directory. The
* appropriate Tid and additional pathname are passed. The directory must
* not exist for it to be created.
*
* Client Request Description
* ================================== =================================
*
* UCHAR WordCount; Count of parameter words = 0
* USHORT ByteCount; Count of data bytes; min = 2
* UCHAR BufferFormat; 0x04
* STRING DirectoryName[]; Directory name
*
* Servers require clients to have at least create permission for the
* subtree containing the directory in order to create a new directory.
* The creator's access rights to the new directory are be determined by
* local policy on the server.
*
* Server Response Description
* ================================== =================================
*
* UCHAR WordCount; Count of parameter words = 0
*
* USHORT ByteCount; Count of data bytes = 0
*/
#include <smbsrv/ntstatus.h>
#include <smbsrv/smb_incl.h>
#include <smbsrv/smb_fsops.h>
typedef struct {
char *sp_path; /* Original path */
char *sp_curp; /* Current pointer into the original path */
} SmbPath;
{
int rc;
}
void
{
}
/*
* smb_com_create_directory
*
* It is possible to get a full pathname here and the client expects any
* or all of the components to be created if they don't already exist.
*/
{
int rc = 0;
return (SDRC_ERROR);
}
return (SDRC_ERROR);
}
/*
* Try each component of the path. It is all right to get an EEXIST
* on each component except the last.
*/
while (smbpath_next(spp)) {
return (SDRC_ERROR);
}
}
/* We should have created one directory successfully! */
if (rc != 0) {
return (SDRC_ERROR);
}
}
/*
* smb_validate_dirname
*
* Very basic directory name validation: checks for colons in a path.
* Need to skip the drive prefix since it contains a colon.
*
* Returns 0 if the name is valid, otherwise NT_STATUS_NOT_A_DIRECTORY.
*/
smb_validate_dirname(char *path)
{
char *name;
return (NT_STATUS_NOT_A_DIRECTORY);
}
return (0);
}
/*
* smb_common_create_directory
*
* Currently called from:
* smb_com_create_directory
* smb_com_trans2_create_directory
*
* Returns errno values.
*/
int
{
int rc;
if (rc)
return (rc);
/*
* Because of FQM_PATH_MUST_NOT_EXIST and the successful return
* value, only fqi.dir_snode has a valid parameter (fqi.last_snode
* is NULL).
*/
return (rc);
}
return (0);
}
{
int pathLen;
char *xpath;
/* Malloc from the request storage area. This is freed automatically */
/* so we don't need to worry about freeing it later */
return (spp);
}
/*
* Perhaps somewhat dangerous since everything happens as a side effect. The
* returns 1 if there is a valid component updated to the fqi, 0 otherwise.
*/
int
{
char *xp;
int xlen;
if (spp == 0)
return (0);
/* Move the index to the "next" "\" and copy the path to the fqi */
/* path for the next component. */
/* First look for the next component */
/* Now get to the end of the component */
}
/* If we made no progress, we are done */
return (0);
/*
* Now copy the original path up to but not including our current
* pointer
*/
/*LINTED E_PTRDIFF_OVERFLOW*/
/* Now NULL terminate it */
return (1);
}