]> arthur.barton.de Git - netatalk.git/blobdiff - libatalk/adouble/ad_open.c
Add static getcwd and use it for debugging in ad_open
[netatalk.git] / libatalk / adouble / ad_open.c
index 5b3f93c483b4dd3dbfad88969d2b3a5188194c4b..6b6e09ca3035ed914903ea6b5c7b88cc836b5864 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: ad_open.c,v 1.61 2010-01-04 13:49:48 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.
@@ -1246,7 +1246,8 @@ void ad_init(struct adouble *ad, int flags, int options)
  * @returns 0 on success
  *
  * @note It's not possible to open the header file O_RDONLY -- the read
- *       will fail and return an error. this refcounts things now.
+ *       will fail and return an error. this refcounts things now.\n
+ *       metadata(ressource)-fork only gets created with O_CREAT.
  */
 int ad_open( const char *path, int adflags, int oflags, int mode, struct adouble  *ad)
 {
@@ -1364,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);
@@ -1371,7 +1373,7 @@ int ad_open( const char *path, int adflags, int oflags, int mode, struct adouble
                 admode = mode;
             }
             admode = ad_hf_mode(admode);
-            if ( errno == ENOENT && !(adflags & ADFLAGS_NOADOUBLE) && ad->ad_flags != AD_VERSION2_OSX) {
+            if ( errno == ENOENT && !(ad->ad_options & ADVOL_NOADOUBLE) && ad->ad_flags != AD_VERSION2_OSX) {
                 if (ad->ad_ops->ad_mkrf( ad_p) < 0) {
                     return ad_error(ad, adflags);
                 }
@@ -1505,22 +1507,15 @@ sfm:
 }
 
 /* -----------------------------------
- * return only metadata but try very hard
+ * return only metadata but try very hard ie at first try as user, then try as root
  */
 int ad_metadata(const char *name, int flags, struct adouble *adp)
 {
     uid_t uid;
     int   ret, err;
     int   dir = flags & ADFLAGS_DIR;
-    int   adouble = 0;
     
-    if (!(flags & ADFLAGS_NOADOUBLE)) {
-      adouble = O_CREAT;
-    }
-    
-    /* Open with O_CREAT, thus enumarating a dir will create missing adouble files, see: */
-    /* http://marc.info/?l=netatalk-devel&m=124039156832408&w=2 */
-    if ((ret = ad_open(name, ADFLAGS_HF | dir, O_RDWR | adouble, 0666, adp)) < 0 && errno == EACCES) {
+    if ((ret = ad_open(name, ADFLAGS_HF | dir, O_RDWR, 0666, adp)) < 0 && errno == EACCES) {
         uid = geteuid();
         if (seteuid(0)) {
             LOG(log_error, logtype_default, "ad_metadata(%s): seteuid failed %s", name, strerror(errno));