support getcwd() in smbwrapper
authorAndrew Tridgell <tridge@samba.org>
Sat, 3 Oct 1998 13:58:07 +0000 (13:58 +0000)
committerAndrew Tridgell <tridge@samba.org>
Sat, 3 Oct 1998 13:58:07 +0000 (13:58 +0000)
(This used to be commit d516ee383c287550a5953cf5ea1cd69cc957e1aa)

source3/Makefile.in
source3/smbwrapper/README
source3/smbwrapper/getcwd.c [new file with mode: 0644]
source3/smbwrapper/smbw.c

index 2558d8eaf3b5361ddce2dc26e643cd175ea7edb4..f086e0b34768c8ce77ea234bf91fadbab1f5736b 100644 (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)
index 6a72a2e23cdb458f3b30a03860838239c46b9be4..dfea54872e478d1f1f3af40ae371130d6c2122c9 100644 (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:
  
diff --git a/source3/smbwrapper/getcwd.c b/source3/smbwrapper/getcwd.c
new file mode 100644 (file)
index 0000000..2b0a749
--- /dev/null
@@ -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);
+}
+
index e7030a4e370a4e2518baed55520e5ba9e1b9eb5a..28421238885b8bbfee63486f12c4e50c0a2b97e3 100644 (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;
+}