summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>1998-10-03 13:58:07 +0000
committerAndrew Tridgell <tridge@samba.org>1998-10-03 13:58:07 +0000
commit4d9ab2add20ea8b6435c5b6a96c4d5df86413a8d (patch)
tree7a74ab6664ccbd8efa50ea78a5d6fe5b5c4c88af
parentaa7aacacab413ec608fcc8ba2ba5d9cbeaa340d8 (diff)
downloadsamba-4d9ab2add20ea8b6435c5b6a96c4d5df86413a8d.tar.gz
samba-4d9ab2add20ea8b6435c5b6a96c4d5df86413a8d.tar.bz2
samba-4d9ab2add20ea8b6435c5b6a96c4d5df86413a8d.zip
support getcwd() in smbwrapper
(This used to be commit d516ee383c287550a5953cf5ea1cd69cc957e1aa)
-rw-r--r--source3/Makefile.in2
-rw-r--r--source3/smbwrapper/README2
-rw-r--r--source3/smbwrapper/getcwd.c28
-rw-r--r--source3/smbwrapper/smbw.c36
4 files changed, 66 insertions, 2 deletions
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;
+}