1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-22 22:04:08 +03:00

r20339: Make mkdir_internal static to open.c

(This used to be commit 6dd0886b49969d0edfe16861f19d35275217b2af)
This commit is contained in:
Volker Lendecke 2006-12-24 11:45:55 +00:00 committed by Gerald (Jerry) Carter
parent 469b42c61f
commit d0c6f9b728
3 changed files with 50 additions and 52 deletions

View File

@ -1800,7 +1800,7 @@ WERROR move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract
DEBUG(5,("Creating first directory\n"));
slprintf(new_dir, sizeof(new_dir)-1, "%s/%d", architecture, driver->cversion);
driver_unix_convert(new_dir, conn, NULL, &bad_path, &st);
mkdir_internal(conn, new_dir, bad_path);
create_directory(conn, new_dir);
/* For each driver file, archi\filexxx.yyy, if there is a duplicate file
* listed for this driver which has already been moved, skip it (note:

View File

@ -1851,6 +1851,30 @@ int close_file_fchmod(files_struct *fsp)
return ret;
}
static NTSTATUS mkdir_internal(connection_struct *conn,
const pstring directory)
{
int ret= -1;
if(!CAN_WRITE(conn)) {
DEBUG(5,("mkdir_internal: failing create on read-only share "
"%s\n", lp_servicename(SNUM(conn))));
return NT_STATUS_ACCESS_DENIED;
}
if (!check_name(directory, conn)) {
return map_nt_error_from_unix(errno);
}
ret = vfs_MkDir(conn,directory,unix_mode(conn,aDIR,directory,True));
if (ret == -1) {
return map_nt_error_from_unix(errno);
}
return NT_STATUS_OK;
}
/****************************************************************************
Open a directory from an NT SMB call.
****************************************************************************/
@ -1899,7 +1923,7 @@ NTSTATUS open_directory(connection_struct *conn,
/* If directory exists error. If directory doesn't
* exist create. */
status = mkdir_internal(conn, fname, False);
status = mkdir_internal(conn, fname);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(2, ("open_directory: unable to create "
"%s. Error was %s\n", fname,
@ -1916,7 +1940,7 @@ NTSTATUS open_directory(connection_struct *conn,
* exist create.
*/
status = mkdir_internal(conn, fname, False);
status = mkdir_internal(conn, fname);
if (NT_STATUS_IS_OK(status)) {
info = FILE_WAS_CREATED;
@ -1948,7 +1972,7 @@ NTSTATUS open_directory(connection_struct *conn,
}
if(!S_ISDIR(psbuf->st_mode)) {
DEBUG(0,("open_directory: %s is not a directory !\n",
DEBUG(5,("open_directory: %s is not a directory !\n",
fname ));
return NT_STATUS_NOT_A_DIRECTORY;
}
@ -2037,6 +2061,26 @@ NTSTATUS open_directory(connection_struct *conn,
return NT_STATUS_OK;
}
NTSTATUS create_directory(connection_struct *conn, const char *directory)
{
NTSTATUS status;
SMB_STRUCT_STAT sbuf;
files_struct *fsp;
SET_STAT_INVALID(sbuf);
status = open_directory(conn, directory, &sbuf,
FILE_READ_ATTRIBUTES, /* Just a stat open */
FILE_SHARE_NONE, /* Ignored for stat opens */
FILE_CREATE, 0, NULL, &fsp);
if (NT_STATUS_IS_OK(status)) {
close_file(fsp, NORMAL_CLOSE);
}
return status;
}
/****************************************************************************
Open a pseudo-file (no locking checks - a 'stat' open).
****************************************************************************/

View File

@ -3744,46 +3744,6 @@ int reply_printwrite(connection_struct *conn, char *inbuf,char *outbuf, int dum_
return(outsize);
}
/****************************************************************************
The guts of the mkdir command, split out so it may be called by the NT SMB
code.
****************************************************************************/
NTSTATUS mkdir_internal(connection_struct *conn, const pstring directory, BOOL bad_path)
{
int ret= -1;
if(!CAN_WRITE(conn)) {
DEBUG(5,("mkdir_internal: failing create on read-only share %s\n", lp_servicename(SNUM(conn))));
return NT_STATUS_ACCESS_DENIED;
}
if (bad_path) {
return NT_STATUS_OBJECT_PATH_NOT_FOUND;
}
if (!check_name(directory, conn)) {
if(errno == ENOENT) {
if (bad_path) {
return NT_STATUS_OBJECT_PATH_NOT_FOUND;
} else {
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
}
}
return map_nt_error_from_unix(errno);
}
ret = vfs_MkDir(conn,directory,unix_mode(conn,aDIR,directory,True));
if (ret == -1) {
if(errno == ENOENT) {
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
}
return map_nt_error_from_unix(errno);
}
return NT_STATUS_OK;
}
/****************************************************************************
Reply to a mkdir.
****************************************************************************/
@ -3795,7 +3755,6 @@ int reply_mkdir(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
NTSTATUS status;
BOOL bad_path = False;
SMB_STRUCT_STAT sbuf;
files_struct *fsp;
START_PROFILE(SMBmkdir);
@ -3809,12 +3768,9 @@ int reply_mkdir(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
unix_convert(directory,conn,0,&bad_path,&sbuf);
status = open_directory(conn, directory, &sbuf,
FILE_READ_ATTRIBUTES, /* Just a stat open */
FILE_SHARE_NONE, /* Ignored for stat opens */
FILE_CREATE, 0, NULL, &fsp);
status = create_directory(conn, directory);
DEBUG(1, ("open_directory returned %s\n", nt_errstr(status)));
DEBUG(1, ("create_directory returned %s\n", nt_errstr(status)));
if (!NT_STATUS_IS_OK(status)) {
@ -3833,8 +3789,6 @@ int reply_mkdir(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
return ERROR_NT(status);
}
close_file(fsp, NORMAL_CLOSE);
outsize = set_message(outbuf,0,0,False);
DEBUG( 3, ( "mkdir %s ret=%d\n", directory, outsize ) );