1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-25 23:21:54 +03:00

support getcwd() in smbwrapper

This commit is contained in:
Andrew Tridgell 0001-01-01 00:00:00 +00:00
parent ce748e5ea9
commit d516ee383c
4 changed files with 66 additions and 2 deletions

View File

@ -199,7 +199,7 @@ SMBWRAPPER_OBJ = smbwrapper/open.o smbwrapper/stat.o \
smbwrapper/fcntl.o smbwrapper/access.o smbwrapper/chdir.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/chmod.o smbwrapper/lseek.o smbwrapper/getcwd.o \
smbwrapper/mkdir.o smbwrapper/rmdir.o \
$(LIBSMB_OBJ) $(PARAM_OBJ) \
$(UBIQX_OBJ) $(LIB_OBJ)

View File

@ -22,7 +22,7 @@ This is code under development. Lots of things don't work yet.
Things that I have tried and do seem to work include:
emacs, tar, ls, cmp, cp, rsync, du, cat, rm, mv, less, more, wc, head,
tail, bash, tcsh
tail, bash, tcsh, mkdir, rmdir
things that I know don't work:

View File

@ -0,0 +1,28 @@
/*
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"
char *getcwd(char *buf, size_t size)
{
return smbw_getcwd(buf, size);
}

View File

@ -1598,3 +1598,39 @@ int smbw_rmdir(const char *fname)
smbw_busy--;
return -1;
}
/*****************************************************
a wrapper for getcwd()
*******************************************************/
char *smbw_getcwd(char *buf, size_t size)
{
smbw_init();
if (smbw_busy) {
return __getcwd(buf, size);
}
smbw_busy++;
if (!buf) {
if (size <= 0) size = strlen(smb_cwd)+1;
buf = (char *)malloc(size);
if (!buf) {
errno = ENOMEM;
smbw_busy--;
return NULL;
}
}
if (strlen(smb_cwd) > size-1) {
errno = ERANGE;
smbw_busy--;
return NULL;
}
safe_strcpy(buf, smb_cwd, size);
smbw_busy--;
return buf;
}