1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-04 17:47:26 +03:00

added mkdir() and rmdir() support

(This used to be commit ce748e5ea94380147a01de8235b343c7e2852bee)
This commit is contained in:
Andrew Tridgell 1998-10-03 13:27:56 +00:00
parent 03a06267f4
commit aa7aacacab
5 changed files with 152 additions and 0 deletions

View 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)

View File

@ -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);
}

View 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)))

View File

@ -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);
}

View 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;
}