summaryrefslogtreecommitdiff
path: root/source3/smbwrapper
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>1998-10-03 13:27:56 +0000
committerAndrew Tridgell <tridge@samba.org>1998-10-03 13:27:56 +0000
commitaa7aacacab413ec608fcc8ba2ba5d9cbeaa340d8 (patch)
tree710b33606986da75c40d2d3bf9369b7bc6920665 /source3/smbwrapper
parent03a06267f4674201c107b85abf993688312c5093 (diff)
downloadsamba-aa7aacacab413ec608fcc8ba2ba5d9cbeaa340d8.tar.gz
samba-aa7aacacab413ec608fcc8ba2ba5d9cbeaa340d8.tar.bz2
samba-aa7aacacab413ec608fcc8ba2ba5d9cbeaa340d8.zip
added mkdir() and rmdir() support
(This used to be commit ce748e5ea94380147a01de8235b343c7e2852bee)
Diffstat (limited to 'source3/smbwrapper')
-rw-r--r--source3/smbwrapper/mkdir.c31
-rw-r--r--source3/smbwrapper/realcalls.h2
-rw-r--r--source3/smbwrapper/rmdir.c31
-rw-r--r--source3/smbwrapper/smbw.c87
4 files changed, 151 insertions, 0 deletions
diff --git a/source3/smbwrapper/mkdir.c b/source3/smbwrapper/mkdir.c
new file mode 100644
index 0000000000..e28a6a59b5
--- /dev/null
+++ b/source3/smbwrapper/mkdir.c
@@ -0,0 +1,31 @@
+/*
+ Unix SMB/Netbios implementation.
+ Version 2.0
+ SMB wrapper functions
+ Copyright (C) Andrew Tridgell 1998
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "wrapper.h"
+
+ int mkdir(const char *name, mode_t mode)
+{
+ if (smbw_path(name)) {
+ return smbw_mkdir(name, mode);
+ }
+
+ return real_mkdir(name, mode);
+}
diff --git a/source3/smbwrapper/realcalls.h b/source3/smbwrapper/realcalls.h
index 898a94eeb4..f9718a1ef1 100644
--- a/source3/smbwrapper/realcalls.h
+++ b/source3/smbwrapper/realcalls.h
@@ -38,6 +38,8 @@ struct dirent *__libc_readdir(DIR * dir);
#define real_fcntl(fd,cmd,arg) (syscall(SYS_fcntl, (fd), (cmd), (arg)))
#define real_symlink(fn1, fn2) (syscall(SYS_symlink, (fn1), (fn2)))
#define real_unlink(fn) (syscall(SYS_unlink, (fn)))
+#define real_rmdir(fn) (syscall(SYS_rmdir, (fn)))
+#define real_mkdir(fn, mode) (syscall(SYS_mkdir, (fn), (mode)))
#define real_utime(fn, buf) (syscall(SYS_utime, (fn), (buf)))
#define real_utimes(fn, buf) (syscall(SYS_utimes, (fn), (buf)))
#define real_readlink(fn, buf, bufs) (syscall(SYS_readlink, (fn), (buf), (bufs)))
diff --git a/source3/smbwrapper/rmdir.c b/source3/smbwrapper/rmdir.c
new file mode 100644
index 0000000000..120b6eaf22
--- /dev/null
+++ b/source3/smbwrapper/rmdir.c
@@ -0,0 +1,31 @@
+/*
+ Unix SMB/Netbios implementation.
+ Version 2.0
+ SMB wrapper functions
+ Copyright (C) Andrew Tridgell 1998
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "wrapper.h"
+
+ int rmdir(const char *name)
+{
+ if (smbw_path(name)) {
+ return smbw_rmdir(name);
+ }
+
+ return real_rmdir(name);
+}
diff --git a/source3/smbwrapper/smbw.c b/source3/smbwrapper/smbw.c
index 3a98143260..e7030a4e37 100644
--- a/source3/smbwrapper/smbw.c
+++ b/source3/smbwrapper/smbw.c
@@ -1511,3 +1511,90 @@ off_t smbw_lseek(int fd, off_t offset, int whence)
smbw_busy--;
return file->offset;
}
+
+
+/*****************************************************
+a wrapper for mkdir()
+*******************************************************/
+int smbw_mkdir(const char *fname, mode_t mode)
+{
+ struct smbw_server *srv;
+ fstring server, share;
+ pstring path;
+
+ DEBUG(4,("%s (%s)\n", __FUNCTION__, fname));
+
+ if (!fname) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ smbw_init();
+
+ smbw_busy++;
+
+ /* work out what server they are after */
+ smbw_parse_path(fname, server, share, path);
+
+ /* get a connection to the server */
+ srv = smbw_server(server, share);
+ if (!srv) {
+ /* smbw_server sets errno */
+ goto failed;
+ }
+
+ if (!cli_mkdir(&srv->cli, path)) {
+ errno = smbw_errno(&srv->cli);
+ goto failed;
+ }
+
+ smbw_busy--;
+ return 0;
+
+ failed:
+ smbw_busy--;
+ return -1;
+}
+
+/*****************************************************
+a wrapper for rmdir()
+*******************************************************/
+int smbw_rmdir(const char *fname)
+{
+ struct smbw_server *srv;
+ fstring server, share;
+ pstring path;
+
+ DEBUG(4,("%s (%s)\n", __FUNCTION__, fname));
+
+ if (!fname) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ smbw_init();
+
+ smbw_busy++;
+
+ /* work out what server they are after */
+ smbw_parse_path(fname, server, share, path);
+
+ /* get a connection to the server */
+ srv = smbw_server(server, share);
+ if (!srv) {
+ /* smbw_server sets errno */
+ goto failed;
+ }
+
+ if (!cli_rmdir(&srv->cli, path)) {
+ errno = smbw_errno(&srv->cli);
+ goto failed;
+ }
+
+ smbw_busy--;
+ return 0;
+
+ failed:
+ smbw_busy--;
+ return -1;
+}