diff options
Diffstat (limited to 'source3/smbwrapper')
-rw-r--r-- | source3/smbwrapper/README | 2 | ||||
-rw-r--r-- | source3/smbwrapper/getcwd.c | 28 | ||||
-rw-r--r-- | source3/smbwrapper/smbw.c | 36 |
3 files changed, 65 insertions, 1 deletions
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; +} |