From 4d9ab2add20ea8b6435c5b6a96c4d5df86413a8d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 3 Oct 1998 13:58:07 +0000 Subject: support getcwd() in smbwrapper (This used to be commit d516ee383c287550a5953cf5ea1cd69cc957e1aa) --- source3/Makefile.in | 2 +- source3/smbwrapper/README | 2 +- source3/smbwrapper/getcwd.c | 28 ++++++++++++++++++++++++++++ source3/smbwrapper/smbw.c | 36 ++++++++++++++++++++++++++++++++++++ 4 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 source3/smbwrapper/getcwd.c diff --git a/source3/Makefile.in b/source3/Makefile.in index 2558d8eaf3..f086e0b347 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -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) diff --git a/source3/smbwrapper/README b/source3/smbwrapper/README index 6a72a2e23c..dfea54872e 100644 --- a/source3/smbwrapper/README +++ b/source3/smbwrapper/README @@ -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: diff --git a/source3/smbwrapper/getcwd.c b/source3/smbwrapper/getcwd.c new file mode 100644 index 0000000000..2b0a749904 --- /dev/null +++ b/source3/smbwrapper/getcwd.c @@ -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); +} + diff --git a/source3/smbwrapper/smbw.c b/source3/smbwrapper/smbw.c index e7030a4e37..2842123888 100644 --- a/source3/smbwrapper/smbw.c +++ b/source3/smbwrapper/smbw.c @@ -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; +} -- cgit