svn commit: samba r20339 - in branches/SAMBA_3_0/source: printing
smbd
vlendec at samba.org
vlendec at samba.org
Sun Dec 24 11:45:56 GMT 2006
Author: vlendec
Date: 2006-12-24 11:45:55 +0000 (Sun, 24 Dec 2006)
New Revision: 20339
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=20339
Log:
Make mkdir_internal static to open.c
Modified:
branches/SAMBA_3_0/source/printing/nt_printing.c
branches/SAMBA_3_0/source/smbd/open.c
branches/SAMBA_3_0/source/smbd/reply.c
Changeset:
Modified: branches/SAMBA_3_0/source/printing/nt_printing.c
===================================================================
--- branches/SAMBA_3_0/source/printing/nt_printing.c 2006-12-24 11:13:32 UTC (rev 20338)
+++ branches/SAMBA_3_0/source/printing/nt_printing.c 2006-12-24 11:45:55 UTC (rev 20339)
@@ -1800,7 +1800,7 @@
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:
Modified: branches/SAMBA_3_0/source/smbd/open.c
===================================================================
--- branches/SAMBA_3_0/source/smbd/open.c 2006-12-24 11:13:32 UTC (rev 20338)
+++ branches/SAMBA_3_0/source/smbd/open.c 2006-12-24 11:45:55 UTC (rev 20339)
@@ -1851,6 +1851,30 @@
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 @@
/* 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 @@
* 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 @@
}
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 @@
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).
****************************************************************************/
Modified: branches/SAMBA_3_0/source/smbd/reply.c
===================================================================
--- branches/SAMBA_3_0/source/smbd/reply.c 2006-12-24 11:13:32 UTC (rev 20338)
+++ branches/SAMBA_3_0/source/smbd/reply.c 2006-12-24 11:45:55 UTC (rev 20339)
@@ -3745,46 +3745,6 @@
}
/****************************************************************************
- 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 @@
NTSTATUS status;
BOOL bad_path = False;
SMB_STRUCT_STAT sbuf;
- files_struct *fsp;
START_PROFILE(SMBmkdir);
@@ -3809,12 +3768,9 @@
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 @@
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 ) );
More information about the samba-cvs
mailing list