]> arthur.barton.de Git - netatalk.git/commitdiff
Add static getcwd and use it for debugging in ad_open
authorfranklahm <franklahm>
Tue, 5 Jan 2010 13:48:47 +0000 (13:48 +0000)
committerfranklahm <franklahm>
Tue, 5 Jan 2010 13:48:47 +0000 (13:48 +0000)
include/atalk/util.h
libatalk/adouble/ad_open.c
libatalk/util/Makefile.am
libatalk/util/unix.c [new file with mode: 0644]

index 02a0cc6247be5ea49c4faa6338a906537772fa47..52c56280e81b1b362717e77eb05968e3888f6ce2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: util.h,v 1.16 2009-11-23 18:17:30 didg Exp $
+ * $Id: util.h,v 1.17 2010-01-05 13:48:47 franklahm Exp $
  */
 
 #ifndef _ATALK_UTIL_H
@@ -236,3 +236,14 @@ extern void apply_ip_mask(struct sockaddr *ai, int maskbits);
  * IPv6 mapped IPv4 addresses are treated as IPv4 addresses.
  */
 extern int compare_ip(const struct sockaddr *sa1, const struct sockaddr *sa2);
+
+/******************************************************************
+ * unix.c
+ *****************************************************************/
+
+/*!
+ * @brief get cwd in static buffer
+ *
+ * @returns pointer to path or pointer to error messages on error
+ */
+extern const char *getcwdpath(void);
index d8ebc8cc0d45db3f7a239e86235fb4214de8a3c8..6b6e09ca3035ed914903ea6b5c7b88cc836b5864 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: ad_open.c,v 1.62 2010-01-05 12:06:34 franklahm Exp $
+ * $Id: ad_open.c,v 1.63 2010-01-05 13:48:47 franklahm Exp $
  *
  * Copyright (c) 1999 Adrian Sun (asun@u.washington.edu)
  * Copyright (c) 1990,1991 Regents of The University of Michigan.
@@ -1365,6 +1365,7 @@ int ad_open( const char *path, int adflags, int oflags, int mode, struct adouble
              * here.
              * if ((oflags & O_CREAT) ==> (oflags & O_RDWR)
              */
+            LOG(logtype_default, log_debug, "ad_open: creating new adouble file: %s/%s", getcwdpath(), ad_p);
             admode = mode;
             errno = 0;
             st_invalid = ad_mode_st(ad_p, &admode, &st_dir);
index d6351464f19c74c3ad3e61912e930ae62b6aafef..f8eeb6b42c9c6e8506d8f6fcd95e713887c96368 100644 (file)
@@ -21,4 +21,5 @@ libutil_la_SOURCES = \
        strcasestr.c    \
        strdicasecmp.c  \
        strlcpy.c       \
-       volinfo.c
+       volinfo.c \
+       unix.c
diff --git a/libatalk/util/unix.c b/libatalk/util/unix.c
new file mode 100644 (file)
index 0000000..beb9ab5
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+  $Id: unix.c,v 1.1 2010-01-05 13:48:47 franklahm Exp $
+  Copyright (c) 2010 Frank Lahm <franklahm@gmail.com>
+
+  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.
+*/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#include <unistd.h>
+#include <stdint.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <dirent.h>
+
+#include <atalk/adouble.h>
+#include <atalk/ea.h>
+#include <atalk/afp.h>
+#include <atalk/logger.h>
+#include <atalk/volume.h>
+#include <atalk/vfs.h>
+#include <atalk/util.h>
+#include <atalk/unix.h>
+
+extern const char *getcwdpath(void)
+{
+    static char cwd[MAXPATHLEN + 1];
+    char *p;
+
+    if ((p = getcwd(&cwd, MAXPATHLEN)) != NULL)
+        return p;
+    else
+        return strerror(errno);
+}