mirror of
https://github.com/samba-team/samba.git
synced 2025-08-30 17:49:30 +03:00
r20339: Make mkdir_internal static to open.c
(This used to be commit 6dd0886b49
)
This commit is contained in:
committed by
Gerald (Jerry) Carter
parent
469b42c61f
commit
d0c6f9b728
@ -1800,7 +1800,7 @@ WERROR move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract
|
|||||||
DEBUG(5,("Creating first directory\n"));
|
DEBUG(5,("Creating first directory\n"));
|
||||||
slprintf(new_dir, sizeof(new_dir)-1, "%s/%d", architecture, driver->cversion);
|
slprintf(new_dir, sizeof(new_dir)-1, "%s/%d", architecture, driver->cversion);
|
||||||
driver_unix_convert(new_dir, conn, NULL, &bad_path, &st);
|
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
|
/* 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:
|
* listed for this driver which has already been moved, skip it (note:
|
||||||
|
@ -1851,6 +1851,30 @@ int close_file_fchmod(files_struct *fsp)
|
|||||||
return ret;
|
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.
|
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
|
/* If directory exists error. If directory doesn't
|
||||||
* exist create. */
|
* exist create. */
|
||||||
|
|
||||||
status = mkdir_internal(conn, fname, False);
|
status = mkdir_internal(conn, fname);
|
||||||
if (!NT_STATUS_IS_OK(status)) {
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
DEBUG(2, ("open_directory: unable to create "
|
DEBUG(2, ("open_directory: unable to create "
|
||||||
"%s. Error was %s\n", fname,
|
"%s. Error was %s\n", fname,
|
||||||
@ -1916,7 +1940,7 @@ NTSTATUS open_directory(connection_struct *conn,
|
|||||||
* exist create.
|
* exist create.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
status = mkdir_internal(conn, fname, False);
|
status = mkdir_internal(conn, fname);
|
||||||
|
|
||||||
if (NT_STATUS_IS_OK(status)) {
|
if (NT_STATUS_IS_OK(status)) {
|
||||||
info = FILE_WAS_CREATED;
|
info = FILE_WAS_CREATED;
|
||||||
@ -1948,7 +1972,7 @@ NTSTATUS open_directory(connection_struct *conn,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!S_ISDIR(psbuf->st_mode)) {
|
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 ));
|
fname ));
|
||||||
return NT_STATUS_NOT_A_DIRECTORY;
|
return NT_STATUS_NOT_A_DIRECTORY;
|
||||||
}
|
}
|
||||||
@ -2037,6 +2061,26 @@ NTSTATUS open_directory(connection_struct *conn,
|
|||||||
return NT_STATUS_OK;
|
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).
|
Open a pseudo-file (no locking checks - a 'stat' open).
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
@ -3744,46 +3744,6 @@ int reply_printwrite(connection_struct *conn, char *inbuf,char *outbuf, int dum_
|
|||||||
return(outsize);
|
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.
|
Reply to a mkdir.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -3795,7 +3755,6 @@ int reply_mkdir(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
|
|||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
BOOL bad_path = False;
|
BOOL bad_path = False;
|
||||||
SMB_STRUCT_STAT sbuf;
|
SMB_STRUCT_STAT sbuf;
|
||||||
files_struct *fsp;
|
|
||||||
|
|
||||||
START_PROFILE(SMBmkdir);
|
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);
|
unix_convert(directory,conn,0,&bad_path,&sbuf);
|
||||||
|
|
||||||
status = open_directory(conn, directory, &sbuf,
|
status = create_directory(conn, directory);
|
||||||
FILE_READ_ATTRIBUTES, /* Just a stat open */
|
|
||||||
FILE_SHARE_NONE, /* Ignored for stat opens */
|
|
||||||
FILE_CREATE, 0, NULL, &fsp);
|
|
||||||
|
|
||||||
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)) {
|
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);
|
return ERROR_NT(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
close_file(fsp, NORMAL_CLOSE);
|
|
||||||
|
|
||||||
outsize = set_message(outbuf,0,0,False);
|
outsize = set_message(outbuf,0,0,False);
|
||||||
|
|
||||||
DEBUG( 3, ( "mkdir %s ret=%d\n", directory, outsize ) );
|
DEBUG( 3, ( "mkdir %s ret=%d\n", directory, outsize ) );
|
||||||
|
Reference in New Issue
Block a user