added mkdir() and rmdir() support
authorAndrew Tridgell <tridge@samba.org>
Sat, 3 Oct 1998 13:27:56 +0000 (13:27 +0000)
committerAndrew Tridgell <tridge@samba.org>
Sat, 3 Oct 1998 13:27:56 +0000 (13:27 +0000)
source/Makefile.in
source/smbwrapper/mkdir.c [new file with mode: 0644]
source/smbwrapper/realcalls.h
source/smbwrapper/rmdir.c [new file with mode: 0644]
source/smbwrapper/smbw.c

index b7f5d3d78d7de2114dd45c497dd99cd1885c3cc9..2558d8eaf3b5361ddce2dc26e643cd175ea7edb4 100644 (file)
@@ -200,6 +200,7 @@ SMBWRAPPER_OBJ = smbwrapper/open.o smbwrapper/stat.o \
                smbwrapper/write.o smbwrapper/readlink.o smbwrapper/unlink.o \
                smbwrapper/rename.o smbwrapper/utime.o smbwrapper/chown.o \
                smbwrapper/chmod.o smbwrapper/lseek.o \
+               smbwrapper/mkdir.o smbwrapper/rmdir.o \
                $(LIBSMB_OBJ) $(PARAM_OBJ) \
                 $(UBIQX_OBJ) $(LIB_OBJ)
 
diff --git a/source/smbwrapper/mkdir.c b/source/smbwrapper/mkdir.c
new file mode 100644 (file)
index 0000000..e28a6a5
--- /dev/null
@@ -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);
+}
index 898a94eeb437733c54a442c9f2ad3d536f58150f..f9718a1ef18a91cf5d54b89e246e826d5a5b9a50 100644 (file)
@@ -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/source/smbwrapper/rmdir.c b/source/smbwrapper/rmdir.c
new file mode 100644 (file)
index 0000000..120b6ea
--- /dev/null
@@ -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);
+}
index 3a98143260e3e9ff3281e9e09d6b93a42cb89247..e7030a4e370a4e2518baed55520e5ba9e1b9eb5a 100644 (file)
@@ -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;
+}