summaryrefslogtreecommitdiff
path: root/source3/smbd/open.c
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2006-12-24 11:45:55 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:16:42 -0500
commitd0c6f9b728936297efd002008b69a59da6bbfabc (patch)
treef2b51e6df6840b4caaae197cb794fc181a25f416 /source3/smbd/open.c
parent469b42c61f73c0bd5166c33a909b3c68c1fb9dde (diff)
downloadsamba-d0c6f9b728936297efd002008b69a59da6bbfabc.tar.gz
samba-d0c6f9b728936297efd002008b69a59da6bbfabc.tar.bz2
samba-d0c6f9b728936297efd002008b69a59da6bbfabc.zip
r20339: Make mkdir_internal static to open.c
(This used to be commit 6dd0886b49969d0edfe16861f19d35275217b2af)
Diffstat (limited to 'source3/smbd/open.c')
-rw-r--r--source3/smbd/open.c50
1 files changed, 47 insertions, 3 deletions
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index dcd1a7a36f..e8536e3335 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -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).
****************************************************************************/