]> arthur.barton.de Git - netatalk.git/commitdiff
Substitute ADFLAGS_NOADOUBLE with ADVOL_NOADOUBLE, which gets automatically stuffed...
authorfranklahm <franklahm>
Tue, 5 Jan 2010 12:06:33 +0000 (12:06 +0000)
committerfranklahm <franklahm>
Tue, 5 Jan 2010 12:06:33 +0000 (12:06 +0000)
struct adouble via ad_init. This eleminates the need to call vol_no_adouble(vol) every time
in ad_open in order to pass ADFLAGS_NOADOUBLE with adflags, instead inside ad_open the func checks
ad->ad_options.
Remove forced adouble file creation from ad_metadata, this broke the clean ad_* API semantics of
only creating files with O_CREATE. Instead do it explicitly in enumerate where the original force
adouble patch grew from.

etc/afpd/catsearch.c
etc/afpd/desktop.c
etc/afpd/directory.c
etc/afpd/extattrs.c
etc/afpd/file.c
etc/afpd/filedir.c
etc/afpd/volume.c
include/atalk/adouble.h
include/atalk/volume.h
libatalk/adouble/ad_open.c

index 28fe3411faa625143c74d3a66a038323faffd3b4..59b0227b98e3a3440a0acff25c0aa74c4aefe26f 100644 (file)
@@ -215,7 +215,7 @@ static struct adouble *adl_lkup(struct vol *vol, struct path *path, struct adoub
                adp = &ad;
        } 
 
-    if ( ad_metadata( path->u_name, vol_noadouble(vol) | ((isdir)?ADFLAGS_DIR:0), adp) < 0 ) {
+    if ( ad_metadata( path->u_name, ((isdir) ? ADFLAGS_DIR : 0), adp) < 0 ) {
         adp = NULL; /* FIXME without resource fork adl_lkup will be call again */
     }
     
index a679cf7d8180983cce9c86daa55ea900c83f6e54..fc2e306be3a83e5d235b684ad064923525ff41e1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: desktop.c,v 1.47 2009-11-27 12:37:24 didg Exp $
+ * $Id: desktop.c,v 1.48 2010-01-05 12:06:33 franklahm Exp $
  *
  * See COPYRIGHT.
  *
@@ -693,7 +693,7 @@ static int ad_addcomment(struct vol *vol, struct path *path, char *ibuf)
     } else
         adp = of->of_ad;
 
-    if (ad_open_metadata( upath , vol_noadouble(vol) | ( (isadir) ? ADFLAGS_DIR :0),O_CREAT, adp) < 0 ) {
+    if (ad_open_metadata( upath , ( (isadir) ? ADFLAGS_DIR : 0), O_CREAT, adp) < 0 ) {
         return( AFPERR_ACCESS );
     }
 
@@ -766,7 +766,7 @@ static int ad_getcomment(struct vol *vol, struct path *path, char *rbuf, size_t
     } else
         adp = of->of_ad;
         
-    if ( ad_metadata( upath,vol_noadouble(vol) | ((isadir) ? ADFLAGS_DIR : 0), adp) < 0 ) {
+    if ( ad_metadata( upath, ((isadir) ? ADFLAGS_DIR : 0), adp) < 0 ) {
         return( AFPERR_NOITEM );
     }
 
index d6845297a855ccfc55c340dcb007c7ace517ff91..3bc836c73a2cfdd82114494fd11f1e2d5652acb3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: directory.c,v 1.121 2009-11-27 12:37:24 didg Exp $
+ * $Id: directory.c,v 1.122 2010-01-05 12:06:33 franklahm Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -1645,7 +1645,7 @@ int getdirparams(const struct vol *vol,
                    (1 << DIRPBIT_FINFO)))) {
 
         ad_init(&ad, vol->v_adouble, vol->v_ad_options);
-        if ( !ad_metadata( upath, vol_noadouble(vol) | ADFLAGS_DIR, &ad) ) {
+        if ( !ad_metadata( upath, ADFLAGS_DIR, &ad) ) {
             isad = 1;
         }
     }
@@ -2079,7 +2079,7 @@ int setdirparams(struct vol *vol,
     }
     ad_init(&ad, vol->v_adouble, vol->v_ad_options);
 
-    if (ad_open_metadata( upath, vol_noadouble(vol)|ADFLAGS_DIR, O_CREAT, &ad) < 0) {
+    if (ad_open_metadata( upath, ADFLAGS_DIR, O_CREAT, &ad) < 0) {
         /*
          * Check to see what we're trying to set.  If it's anything
          * but ACCESS, UID, or GID, give an error.  If it's any of those
@@ -2577,7 +2577,7 @@ int deletecurdir(struct vol *vol)
 
     ad_init(&ad, vol->v_adouble, vol->v_ad_options);
     /* we never want to create a resource fork here, we are going to delete it */
-    if ( ad_metadata( ".", ADFLAGS_NOADOUBLE | ADFLAGS_DIR, &ad) == 0 ) {
+    if ( ad_metadata( ".", ADFLAGS_DIR, &ad) == 0 ) {
 
         ad_getattr(&ad, &ashort);
         ad_close( &ad, ADFLAGS_HF );
index 13e27a03bb836b7a7eee6e42e729af2cb81b30ce..649cc6a30f3044b96533412751f850acee8a10be 100644 (file)
@@ -1,5 +1,5 @@
 /*
-  $Id: extattrs.c,v 1.28 2009-11-27 12:37:24 didg Exp $
+  $Id: extattrs.c,v 1.29 2010-01-05 12:06:33 franklahm Exp $
   Copyright (c) 2009 Frank Lahm <franklahm@gmail.com>
 
   This program is free software; you can redistribute it and/or modify
@@ -140,7 +140,8 @@ int afp_listextattr(AFPObj *obj _U_, char *ibuf, size_t ibuflen _U_, char *rbuf,
         }
 
         adp = of_ad(vol, s_path, &ad);
-        uname = s_path->u_name;        /*
+        uname = s_path->u_name;
+        /*
           We have to check the FinderInfo for the file, because if they aren't all 0
           we must return the synthetic attribute "com.apple.FinderInfo".
           Note: the client will never (never seen in traces) request that attribute
@@ -150,7 +151,7 @@ int afp_listextattr(AFPObj *obj _U_, char *ibuf, size_t ibuflen _U_, char *rbuf,
         if (S_ISDIR(st->st_mode))
             adflags = ADFLAGS_DIR;
 
-        if ( ad_metadata( uname, vol_noadouble(vol) | adflags, adp) < 0 ) {
+        if ( ad_metadata( uname, adflags, adp) < 0 ) {
             switch (errno) {
             case ENOENT:
                 adp = NULL;
index a5a2c1cce76da4b0c0aae24086be55e4c5a2c5aa..905c78200ced4fff7b7d3f12c07ed4fab4e64f69 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: file.c,v 1.126 2009-11-30 15:27:48 didg Exp $
+ * $Id: file.c,v 1.127 2010-01-05 12:06:33 franklahm Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -527,7 +527,7 @@ int getfilparams(struct vol *vol,
         adp = of_ad(vol, path, &ad);
         upath = path->u_name;
 
-        if ( ad_metadata( upath, vol_noadouble(vol) | flags, adp) < 0 ) {
+        if ( ad_metadata( upath, flags, adp) < 0 ) {
             switch (errno) {
             case EACCES:
                 LOG(log_error, logtype_afpd, "getfilparams(%s): %s: check resource fork permission?",
@@ -619,7 +619,7 @@ int afp_createfile(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf _U_,
         openf = O_RDWR|O_CREAT|O_EXCL;
     }
 
-    if ( ad_open( upath, vol_noadouble(vol)|ADFLAGS_DF|ADFLAGS_HF|ADFLAGS_NOHF|ADFLAGS_CREATE,
+    if ( ad_open( upath, ADFLAGS_DF|ADFLAGS_HF|ADFLAGS_NOHF|ADFLAGS_CREATE,
                   openf, 0666, adp) < 0 ) {
         switch ( errno ) {
         case EROFS:
@@ -1498,7 +1498,7 @@ int deletefile(const struct vol *vol, char *file, int checkAttrib)
          * moreover sometimes deletefile is called with a no existent file and 
          * ad_open would create a 0 byte resource fork
         */
-        if ( ad_metadata( file , ADFLAGS_NOADOUBLE | ADFLAGS_OPENFORKS, &ad) == 0 ) {
+        if ( ad_metadata( file, ADFLAGS_OPENFORKS, &ad) == 0 ) {
             ad_close( &ad, adflags );
             if ((err = check_attrib(&ad))) {
                return err;
index 5db262dfe461493fbd1009ed1ec237cc2143d449..2f82fca446005a0316de1b73e8c53e802acc4f16 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: filedir.c,v 1.65 2009-11-27 12:37:24 didg Exp $
+ * $Id: filedir.c,v 1.66 2010-01-05 12:06:33 franklahm Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -360,7 +360,7 @@ static int moveandrename(const struct vol *vol, struct dir *sdir, char *oldname,
      * we are in the dest folder so we need to use p for ad_open
     */
     
-    if (!ad_metadata(p, vol_noadouble(vol) | adflags, adp)) {
+    if (!ad_metadata(p, adflags, adp)) {
         u_int16_t bshort;
 
         ad_getattr(adp, &bshort);
index 7f86f04db838bc34bc31cd770e6b88364f4dcf40..75a8678a34c0a5a8c6cd11971239bb9a095fbabc 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: volume.c,v 1.112 2009-12-18 19:18:40 franklahm Exp $
+ * $Id: volume.c,v 1.113 2010-01-05 12:06:33 franklahm Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -696,6 +696,8 @@ static int creatvol(AFPObj *obj, struct passwd *pwd,
             volume->v_ad_options |= ADVOL_UNIXPRIV;
         if ((volume->v_flags & AFPVOL_INV_DOTS))
             volume->v_ad_options |= ADVOL_INVDOTS;
+        if ((volume->v_flags & AFPVOL_NOADOUBLE))
+            volume->v_ad_options |= ADVOL_NOADOUBLE;
 
         if (options[VOLOPT_PASSWORD].c_value)
             volume->v_password = strdup(options[VOLOPT_PASSWORD].c_value);
@@ -1408,7 +1410,7 @@ static int getvolparams( u_int16_t bitmap, struct vol *vol, struct stat *st, cha
      * .Parent file here if it doesn't exist. */
 
     ad_init(&ad, vol->v_adouble, vol->v_ad_options);
-    if ( ad_open_metadata( vol->v_path, vol_noadouble(vol) | ADFLAGS_DIR, O_CREAT, &ad) < 0 ) {
+    if ( ad_open_metadata( vol->v_path, ADFLAGS_DIR, O_CREAT, &ad) < 0 ) {
         isad = 0;
         vol->v_ctime = AD_DATE_FROM_UNIX(st->st_mtime);
 
@@ -2450,8 +2452,7 @@ static int create_special_folder (const struct vol *vol, const struct _special_f
     if ( !ret && folder->hide) {
         /* Hide it */
         ad_init(&ad, vol->v_adouble, vol->v_ad_options);
-        if (ad_open( p, vol_noadouble(vol) | ADFLAGS_HF|ADFLAGS_DIR,
-                     O_RDWR|O_CREAT, 0666, &ad) < 0) {
+        if (ad_open( p, ADFLAGS_HF|ADFLAGS_DIR, O_RDWR|O_CREAT, 0666, &ad) < 0) {
             free (p);
             free(q);
             return (-1);
index 0c420d041432ec748331c3c9b7feadefea71a82c..8ead1c4de02b7663577393d5f2861493327d7d7f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: adouble.h,v 1.51 2010-01-04 13:49:48 franklahm Exp $
+ * $Id: adouble.h,v 1.52 2010-01-05 12:06:34 franklahm Exp $
  * Copyright (c) 1990,1991 Regents of The University of Michigan.
  * All Rights Reserved.
  *
@@ -300,7 +300,9 @@ struct adouble_fops {
 #define ADFLAGS_DF        (1<<0)
 #define ADFLAGS_HF        (1<<1)
 #define ADFLAGS_DIR       (1<<2)
+/*
 #define ADFLAGS_NOADOUBLE (1<<3)
+*/
 #define ADFLAGS_V1COMPAT  (1<<4)
 #define ADFLAGS_NOHF      (1<<5)  /* not an error if no ressource fork */
 #define ADFLAGS_RDONLY    (1<<6)  /* don't try readwrite */
@@ -312,10 +314,9 @@ struct adouble_fops {
 /* adouble v2 cnid cache */
 #define ADVOL_NODEV      (1 << 0)
 #define ADVOL_CACHE      (1 << 1)
-/* adouble unix priv */
-#define ADVOL_UNIXPRIV   (1 << 2)
-/* dot files (.DS_Store) are invisible) */
-#define ADVOL_INVDOTS    (1 << 3)
+#define ADVOL_UNIXPRIV   (1 << 2) /* adouble unix priv */
+#define ADVOL_INVDOTS    (1 << 3) /* dot files (.DS_Store) are invisible) */
+#define ADVOL_NOADOUBLE  (1 << 4)
 
 /* lock flags */
 #define ADLOCK_CLR      (0)
index bbc9fe48cb1dd7676b4447620212816fb5bcdbf3..0a4f1c88c06c3d51d5ced18e1367b403254980fd 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: volume.h,v 1.10 2010-01-05 10:37:29 franklahm Exp $
+ * $Id: volume.h,v 1.11 2010-01-05 12:06:34 franklahm Exp $
  *
  * Copyright (c) 1990,1994 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -195,15 +195,13 @@ int wincheck(const struct vol *vol, const char *path);
 #define VOLPBIT_XBTOTAL 10
 #define VOLPBIT_BSIZE   11        /* block size */
 
-
-#define vol_noadouble(vol) (((vol)->v_flags & AFPVOL_NOADOUBLE) ?   \
-                            ADFLAGS_NOADOUBLE : 0)
 #ifdef AFP3x
 #define utf8_encoding() (afp_version >= 30)
 #else
 #define utf8_encoding() (0)
 #endif
 
+#define vol_noadouble(vol) (((vol)->v_flags & AFPVOL_NOADOUBLE) ? 1 : 0)
 #define vol_nodev(vol) (((vol)->v_flags & AFPVOL_NODEV) ? 1 : 0)
 #define vol_unix_priv(vol) (afp_version >= 30 && ((vol)->v_flags & AFPVOL_UNIX_PRIV))
 #define vol_inv_dots(vol) (((vol)->v_flags & AFPVOL_INV_DOTS) ? 1 : 0)
index 5b3f93c483b4dd3dbfad88969d2b3a5188194c4b..d8ebc8cc0d45db3f7a239e86235fb4214de8a3c8 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.62 2010-01-05 12:06:34 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)
 {
@@ -1371,7 +1372,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 +1506,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));