summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2000-01-14 01:41:04 +0000
committerJeremy Allison <jra@samba.org>2000-01-14 01:41:04 +0000
commit3a6c2069d77176bfa2b379ef711034396c477791 (patch)
tree87597146847db54925106d9e40b90b31ad86c852 /source3/lib
parent2afd5d5eb5c176f09a9f4f00ea3b517e89ef0ddf (diff)
downloadsamba-3a6c2069d77176bfa2b379ef711034396c477791.tar.gz
samba-3a6c2069d77176bfa2b379ef711034396c477791.tar.bz2
samba-3a6c2069d77176bfa2b379ef711034396c477791.zip
Added "inherit permissions" patch.
Fixed locking bug found by Andrew. Jeremy. (This used to be commit 38dffd360dc2e44bfc9e751f017e24f81ff0f2fa)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/interfaces.c3
-rw-r--r--source3/lib/util.c28
2 files changed, 31 insertions, 0 deletions
diff --git a/source3/lib/interfaces.c b/source3/lib/interfaces.c
index 29181c394a..e7b9efa1f0 100644
--- a/source3/lib/interfaces.c
+++ b/source3/lib/interfaces.c
@@ -39,6 +39,9 @@
#include <arpa/inet.h>
#include <netdb.h>
#include <sys/ioctl.h>
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
#include <net/if.h>
#ifndef SIOCGIFCONF
diff --git a/source3/lib/util.c b/source3/lib/util.c
index a39dc1a516..001baa0e3e 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -3280,3 +3280,31 @@ char *lock_path(char *name)
return fname;
}
+
+/*******************************************************************
+ Given a filename - get its directory name
+ NB: Returned in static storage. Caveats:
+ o Not safe in thread environment.
+ o Caller must not free.
+ o If caller wishes to preserve, they should copy.
+********************************************************************/
+
+char *parent_dirname(const char *path)
+{
+ static pstring dirpath;
+ char *p;
+
+ if (!path)
+ return(NULL);
+
+ pstrcpy(dirpath, path);
+ p = strrchr(dirpath, '/'); /* Find final '/', if any */
+ if (!p) {
+ pstrcpy(dirpath, "."); /* No final "/", so dir is "." */
+ } else {
+ if (p == dirpath)
+ ++p; /* For root "/", leave "/" in place */
+ *p = '\0';
+ }
+ return dirpath;
+}