]> arthur.barton.de Git - netatalk.git/commitdiff
Add a parameter cachecnid for adouble v2, default off. Solution for
authordidg <didg>
Thu, 10 Feb 2005 01:23:05 +0000 (01:23 +0000)
committerdidg <didg>
Thu, 10 Feb 2005 01:23:05 +0000 (01:23 +0000)
disappearing files?

14 files changed:
bin/adv1tov2/adv1tov2.c
bin/afppasswd/afppasswd.c
bin/megatron/nad.c
etc/afpd/catsearch.c
etc/afpd/desktop.c
etc/afpd/directory.c
etc/afpd/file.c
etc/afpd/filedir.c
etc/afpd/ofork.c
etc/afpd/volume.c
etc/afpd/volume.h
include/atalk/adouble.h
libatalk/adouble/ad_attr.c
libatalk/adouble/ad_open.c

index f68e42af3492c7f62d287f1c7c19799a05064a12..ea3b010d4360ae9de74851db5a1db97f526be3c2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: adv1tov2.c,v 1.3.14.3 2004-08-23 22:20:07 bfernhomberg Exp $
+ * $Id: adv1tov2.c,v 1.3.14.3.2.1 2005-02-10 01:23:05 didg Exp $
  * v1tov2: given a root directory, run down and convert all the
  * files/directories into appledouble v2.
  */
@@ -85,7 +85,7 @@ void descend(DIR *dp)
   int flags;
   static int count = 0;
 
-  ad_init(&ad, AD_VERSION2);
+  ad_init(&ad, AD_VERSION2, 0);
   if (count++ > MAXDESCEND) {
     fprintf(stderr, "FAILURE: too many subdirectories! possible infinite recursion.");
     return;
@@ -128,7 +128,7 @@ int main(int argc, char **argv)
   DIR           *dp;
   struct adouble ad;
  
-  ad_init(&ad, AD_VERSION2);
+  ad_init(&ad, AD_VERSION2, 0);
   if (argc != 2) {
     fprintf(stderr, "%s <directory>\n", *argv);
     return -1;
index b68d2db7794230dd42c2c974e8605059b142059b..ffe636efed13ca83d5be9f5706cb96d18707c7df 100644 (file)
@@ -1,5 +1,5 @@
 /* 
- * $Id: afppasswd.c,v 1.11.6.1 2004-10-08 00:54:40 bfernhomberg Exp $
+ * $Id: afppasswd.c,v 1.11.6.1.2.1 2005-02-10 01:23:07 didg Exp $
  *
  * Copyright 1999 (c) Adrian Sun (asun@u.washington.edu)
  * All Rights Reserved. See COPYRIGHT.
@@ -73,7 +73,7 @@ static void convert_passwd(char *buf, char *newpwd, const int keyfd)
 {
   u_int8_t key[HEXPASSWDLEN];
   Key_schedule schedule;
-  int i, j;
+  unsigned int i, j;
 
   if (!newpwd) {
     /* convert to binary */
index afb5505b074e9e4e2e528f0fd25d90e4f80e7d22..be5561fbc223d92555472ca1d1692f91cbcfdaeb 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: nad.c,v 1.11.8.2 2004-06-27 02:38:42 didg Exp $
+ * $Id: nad.c,v 1.11.8.2.2.1 2005-02-10 01:23:08 didg Exp $
  */
 
 #ifdef HAVE_CONFIG_H
@@ -424,12 +424,12 @@ static void initvol(char *path)
 {
     if (!loadvolinfo(path, &vol)) {
         vol_load_charsets(&vol);
-        ad_init(&nad.ad, vol.v_adouble);
+        ad_init(&nad.ad, vol.v_adouble, 0);
         _mtoupath = mtoupathiconv;
         _utompath = utompathiconv;
     }
     else
-        ad_init(&nad.ad, 0);
+        ad_init(&nad.ad, 0, 0);
 }
 
 
index 6c7241f4a16d51ea4b981f9f396c61971fb29cb9..dc14dea61f3d18cbf9fe002374bf563148b564a1 100644 (file)
@@ -250,7 +250,7 @@ static struct adouble *adl_lkup(struct vol *vol, struct path *path)
        if (!isdir && (of = of_findname(path))) {
                adp = of->of_ad;
        } else {
-               ad_init(&ad, vol->v_adouble);
+               ad_init(&ad, vol->v_adouble, vol->v_ad_options);
                adp = &ad;
        } 
 
index 913f5c7765ab2faa130722c6c3baf6676d2cea47..e6ab34ca6959b40dd9bc88b24411a33e5065c50d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: desktop.c,v 1.26.2.4.2.18.2.1 2005-02-06 10:16:01 didg Exp $
+ * $Id: desktop.c,v 1.26.2.4.2.18.2.2 2005-02-10 01:23:10 didg Exp $
  *
  * See COPYRIGHT.
  *
@@ -727,7 +727,7 @@ static int ad_addcomment(struct vol *vol, struct path *path, char *ibuf)
     
     isadir = path_isadir(path);
     if (isadir || !(of = of_findname(path))) {
-        ad_init(&ad, vol->v_adouble);
+        ad_init(&ad, vol->v_adouble, vol->v_ad_options);
         adp = &ad;
     } else
         adp = of->of_ad;
@@ -805,7 +805,7 @@ static int ad_getcomment(struct vol *vol, struct path *path, char *rbuf, int *rb
     upath = path->u_name;
     isadir = path_isadir(path);
     if (isadir || !(of = of_findname(path))) {
-        ad_init(&ad, vol->v_adouble);
+        ad_init(&ad, vol->v_adouble, vol->v_ad_options);
         adp = &ad;
     } else
         adp = of->of_ad;
@@ -884,7 +884,7 @@ static int ad_rmvcomment(struct vol *vol, struct path *path)
 
     isadir = path_isadir(path);
     if (isadir || !(of = of_findname(path))) {
-        ad_init(&ad, vol->v_adouble);
+        ad_init(&ad, vol->v_adouble, vol->v_ad_options);
         adp = &ad;
     } else
         adp = of->of_ad;
index dc2dd3e71dbc41c5245b70642543cec084cbfea8..9f3798503f121226b4bf7486348bff5b2ff64af5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: directory.c,v 1.71.2.4.2.15.2.4 2005-01-31 17:00:43 didg Exp $
+ * $Id: directory.c,v 1.71.2.4.2.15.2.5 2005-02-10 01:23:10 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -1318,7 +1318,7 @@ int getdirparams(const struct vol *vol,
                   (1 << DIRPBIT_BDATE) |
                   (1 << DIRPBIT_FINFO)))) {
 
-        ad_init(&ad, vol->v_adouble);
+        ad_init(&ad, vol->v_adouble, vol->v_ad_options);
        if ( !ad_metadata( upath, ADFLAGS_DIR, &ad) ) {
             isad = 1;
         }
@@ -1756,7 +1756,7 @@ int setdirparams(const struct vol *vol,
         bitmap = bitmap>>1;
         bit++;
     }
-    ad_init(&ad, vol->v_adouble);
+    ad_init(&ad, vol->v_adouble, vol->v_ad_options);
 
     if (ad_open( upath, vol_noadouble(vol)|ADFLAGS_HF|ADFLAGS_DIR,
                  O_RDWR|O_CREAT, 0666, &ad) < 0) {
@@ -1941,8 +1941,7 @@ setdirparam_done:
             struct stat *st = &path->st;
 
             if (dir && dir->d_parent) {
-                ad_setid(&ad,(vol->v_flags & AFPVOL_NODEV)?0:st->st_dev, 
-                         st->st_ino,  dir->d_did, dir->d_parent->d_did, vol->v_stamp);
+                ad_setid(&ad, st->st_dev, st->st_ino,  dir->d_did, dir->d_parent->d_did, vol->v_stamp);
             }
         }
         ad_flush( &ad, ADFLAGS_HF );
@@ -2027,7 +2026,7 @@ int               ibuflen, *rbuflen;
         return( AFPERR_PARAM );
     }
 
-    ad_init(&ad, vol->v_adouble);
+    ad_init(&ad, vol->v_adouble, vol->v_ad_options);
     if (ad_open( ".", vol_noadouble(vol)|ADFLAGS_HF|ADFLAGS_DIR,
                  O_RDWR|O_CREAT, 0666, &ad ) < 0)  {
         if (vol_noadouble(vol))
@@ -2035,8 +2034,7 @@ int               ibuflen, *rbuflen;
         return( AFPERR_ACCESS );
     }
     ad_setname(&ad, s_path->m_name);
-    ad_setid( &ad, (vol->v_flags & AFPVOL_NODEV)?0:s_path->st.st_dev,
-                   s_path->st.st_ino, dir->d_did, did, vol->v_stamp);
+    ad_setid( &ad, s_path->st.st_dev, s_path->st.st_ino, dir->d_did, did, vol->v_stamp);
 
     ad_flush( &ad, ADFLAGS_HF );
     ad_close( &ad, ADFLAGS_HF );
@@ -2102,7 +2100,7 @@ struct dir        *dir, *newparent;
      * .Parent
     */
     
-    ad_init(&ad, vol->v_adouble);
+    ad_init(&ad, vol->v_adouble, vol->v_ad_options);
 
     if (!ad_open( dst, ADFLAGS_HF|ADFLAGS_DIR, O_RDWR, 0, &ad)) {
         ad_setname(&ad, newname);
@@ -2169,7 +2167,7 @@ int pathlen;
 
     fdir = curdir;
 
-    ad_init(&ad, vol->v_adouble);
+    ad_init(&ad, vol->v_adouble, vol->v_ad_options);
     if ( ad_metadata( ".", ADFLAGS_DIR, &ad) == 0 ) {
 
         ad_getattr(&ad, &ashort);
index 6567254f7ea2efb74056e57a6d1a3a1fb080097e..c97a4eff978c1bee4fc6e599fd59622edeee6fd2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: file.c,v 1.92.2.2.2.31.2.9 2005-02-05 14:46:35 didg Exp $
+ * $Id: file.c,v 1.92.2.2.2.31.2.10 2005-02-10 01:23:12 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -176,34 +176,12 @@ u_int32_t get_id(struct vol *vol, struct adouble *adp,  const struct stat *st,
 u_int32_t aint = 0;
 
 #if AD_VERSION > AD_VERSION1
-dev_t  dev;
-ino_t  ino;
-cnid_t a_did;
-char   stamp[ADEDLEN_PRIVSYN];
-    /* look in AD v2 header 
-     * note inode and device are opaques and not in network order
-    */
-    if (adp 
-           && sizeof(dev_t) == ad_getentrylen(adp, ADEID_PRIVDEV)
-           && sizeof(ino_t) == ad_getentrylen(adp,ADEID_PRIVINO)
-           && sizeof(stamp) == ad_getentrylen(adp,ADEID_PRIVSYN)
-           && sizeof(cnid_t) == ad_getentrylen(adp, ADEID_DID)
-           && sizeof(cnid_t) == ad_getentrylen(adp, ADEID_PRIVID)
-           
-    ) {
-        memcpy(&dev, ad_entry(adp, ADEID_PRIVDEV), sizeof(dev_t));
-        memcpy(&ino, ad_entry(adp, ADEID_PRIVINO), sizeof(ino_t));
-        memcpy(stamp, ad_entry(adp, ADEID_PRIVSYN), sizeof(stamp));
-        memcpy(&a_did, ad_entry(adp, ADEID_DID), sizeof(cnid_t));
-
-        if (  ( (vol->v_flags & AFPVOL_NODEV) || dev == st->st_dev)
-              && ino == st->st_ino && a_did == did 
-              && !memcmp(vol->v_stamp, stamp, sizeof(stamp))) { 
-           memcpy(&aint, ad_entry(adp, ADEID_PRIVID), sizeof(aint));
-           return aint;
-        }
+
+    if ((aint = ad_getid(adp, st->st_dev, st->st_ino, did, vol->v_stamp))) {
+       return aint;
     }
 #endif
+
     if (vol->v_cdb != NULL) {
            aint = cnid_add(vol->v_cdb, st, did, upath, len, aint);
            /* Throw errors if cnid_add fails. */
@@ -228,7 +206,7 @@ char   stamp[ADEDLEN_PRIVSYN];
             /* update the ressource fork
              * for a folder adp is always null
              */
-            if (ad_setid(adp,(vol->v_flags & AFPVOL_NODEV)?0:st->st_dev, st->st_ino, aint, did, vol->v_stamp)) {
+            if (ad_setid(adp, st->st_dev, st->st_ino, aint, did, vol->v_stamp)) {
                 ad_flush(adp, ADFLAGS_HF);
             }
         }
@@ -528,7 +506,7 @@ int getfilparams(struct vol *vol,
            attrbits = ((of->of_ad->ad_df.adf_refcount > 0) ? ATTRBIT_DOPEN : 0);
            attrbits |= ((of->of_ad->ad_hf.adf_refcount > of->of_ad->ad_df.adf_refcount)? ATTRBIT_ROPEN : 0);
         } else {
-            ad_init(&ad, vol->v_adouble);
+            ad_init(&ad, vol->v_adouble, vol->v_ad_options);
             adp = &ad;
         }
 
@@ -634,7 +612,7 @@ int         ibuflen, *rbuflen;
     if ((of = of_findname(s_path))) {
         adp = of->of_ad;
     } else {
-        ad_init(&ad, vol->v_adouble);
+        ad_init(&ad, vol->v_adouble, vol->v_ad_options);
         adp = &ad;
     }
     if ( creatf) {
@@ -1076,7 +1054,7 @@ struct adouble    *adp;
              * create .AppleDouble if the file is already opened, so we
              * use a diff one, it's not a pb,ie it's not the same file, yet.
              */
-            ad_init(&ad, vol->v_adouble); 
+            ad_init(&ad, vol->v_adouble, vol->v_ad_options); 
             if (!ad_open(dst, ADFLAGS_HF, O_RDWR | O_CREAT, 0666, &ad)) {
                ad_close(&ad, ADFLAGS_HF);
                if (!unix_rename( adsrc, vol->ad_path( dst, 0 )) ) 
@@ -1418,10 +1396,10 @@ struct adouble *adp;
 #endif /* DEBUG */
 
     if (adp == NULL) {
-        ad_init(&ads, s_vol->v_adouble); 
+        ad_init(&ads, s_vol->v_adouble, s_vol->v_ad_options); 
         adp = &ads;
     }
-    ad_init(&add, d_vol->v_adouble);
+    ad_init(&add, d_vol->v_adouble, d_vol->v_ad_options);
     adflags = ADFLAGS_DF;
     if (newname) {
         adflags |= ADFLAGS_HF;
@@ -1463,7 +1441,7 @@ struct adouble *adp;
         goto done;
     } 
     else {
-       ad_init(&add, d_vol->v_adouble);
+       ad_init(&add, d_vol->v_adouble, d_vol->v_ad_options);
        if (ad_open(dst , adflags | noadouble, O_RDWR, 0666, &add) < 0) {
            ret_err = errno;
        }
@@ -1539,8 +1517,8 @@ int         checkAttrib;
 
     /* try to open both forks at once */
     adflags = ADFLAGS_DF|ADFLAGS_HF;
+    ad_init(&ad, vol->v_adouble, vol->v_ad_options);  /* OK */
     while(1) {
-        ad_init(&ad, vol->v_adouble);  /* OK */
         if ( ad_open( file, adflags, O_RDONLY, 0, &ad ) < 0 ) {
             switch (errno) {
             case ENOENT:
@@ -1578,7 +1556,7 @@ int         checkAttrib;
         }
         else if (!adp) {
             /* was EACCESS error try to get only metadata */
-            ad_init(&ad, vol->v_adouble);  /* OK */
+            ad_init(&ad, vol->v_adouble, vol->v_ad_options);  /* OK */
             if ( ad_metadata( file , 0, &ad) == 0 ) {
                 ad_getattr(&ad, &bshort);
                 ad_close( &ad, ADFLAGS_HF );
@@ -1751,7 +1729,7 @@ reenumerate_id(const struct vol *vol, char *name, cnid_t did)
             if ( ad_open( de->d_name, ADFLAGS_HF, O_RDWR, 0, adp ) < 0 ) {
                 continue;
             }
-            if (ad_setid(adp,(vol->v_flags & AFPVOL_NODEV)?0:path.st.st_dev, path.st.st_ino, aint, did, vol->v_stamp)) {
+            if (ad_setid(adp, path.st.st_dev, path.st.st_ino, aint, did, vol->v_stamp)) {
                ad_flush(adp, ADFLAGS_HF);
             }
             ad_close(adp, ADFLAGS_HF);
@@ -2087,7 +2065,7 @@ int               ibuflen, *rbuflen;
         return AFPERR_PARAM ;
     }
     
-    ad_init(&ads, vol->v_adouble);
+    ad_init(&ads, vol->v_adouble, vol->v_ad_options);
     if (!(adsp = find_adouble( path, &s_of, &ads))) {
         return afp_errno;
     }
@@ -2120,7 +2098,7 @@ int               ibuflen, *rbuflen;
         goto err_exchangefile;
     }
 
-    ad_init(&add, vol->v_adouble);
+    ad_init(&add, vol->v_adouble, vol->v_ad_options);
     if (!(addp = find_adouble( path, &d_of, &add))) {
         err = afp_errno;
         goto err_exchangefile;
@@ -2198,12 +2176,12 @@ int             ibuflen, *rbuflen;
     }
     
     /* here we need to reopen if crossdev */
-    if (sid && ad_setid(addp,(vol->v_flags & AFPVOL_NODEV)?0:destst.st_dev, destst.st_ino,  sid, sdir->d_did, vol->v_stamp)) 
+    if (sid && ad_setid(addp, destst.st_dev, destst.st_ino,  sid, sdir->d_did, vol->v_stamp)) 
     {
        ad_flush( addp, ADFLAGS_HF );
     }
         
-    if (did && ad_setid(adsp,(vol->v_flags & AFPVOL_NODEV)?0:srcst.st_dev, srcst.st_ino,  did, curdir->d_did, vol->v_stamp)) 
+    if (did && ad_setid(adsp, srcst.st_dev, srcst.st_ino,  did, curdir->d_did, vol->v_stamp)) 
     {
        ad_flush( adsp, ADFLAGS_HF );
     }
index 8555cadac82e8c4059e23f2f023d122a02ca275f..2f2ca1c66365ff2253b553192273c4b30d60a6d0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: filedir.c,v 1.45.2.2.2.14.2.1 2004-12-07 02:58:08 didg Exp $
+ * $Id: filedir.c,v 1.45.2.2.2.14.2.2 2005-02-10 01:23:14 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -345,7 +345,7 @@ int         isdir;
     struct path         path;
     cnid_t      id;
 
-    ad_init(&ad, vol->v_adouble);
+    ad_init(&ad, vol->v_adouble, vol->v_ad_options);
     adp = &ad;
     adflags = 0;
     
index 17b5ae59a914a1b5d963b24d4db6877fb59e5294..7c227adaab68a177cc04da54d3709b0e519702ae 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: ofork.c,v 1.20.6.6.2.1 2004-12-07 03:23:51 didg Exp $
+ * $Id: ofork.c,v 1.20.6.6.2.2 2005-02-10 01:23:15 didg Exp $
  *
  * Copyright (c) 1996 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -220,7 +220,7 @@ struct stat     *st;
 
         /* initialize to zero. This is important to ensure that
            ad_open really does reinitialize the structure. */
-        ad_init(ad, vol->v_adouble);
+        ad_init(ad, vol->v_adouble, vol->v_ad_options);
     } else {
         /* Increase the refcount on this struct adouble. This is
            decremented again in oforc_dealloc. */
@@ -384,7 +384,7 @@ struct adouble *of_ad(const struct vol *vol, struct path *path, struct adouble *
     if ((of = of_findname(path))) {
         adp = of->of_ad;
     } else {
-        ad_init(ad, vol->v_adouble);
+        ad_init(ad, vol->v_adouble, vol->v_ad_options);
         adp = ad;
     }
     return adp;
index c68ac3d492a7c2de4d43f12565d31879fe424192..68c2c10ed89530abedb184df780cd10602144236 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: volume.c,v 1.51.2.7.2.33.2.3 2005-02-06 10:16:01 didg Exp $
+ * $Id: volume.c,v 1.51.2.7.2.33.2.4 2005-02-10 01:23:16 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -468,6 +468,8 @@ static void volset(struct vol_option *options, struct vol_option *save,
                 options[VOLOPT_FLAGS].i_value |= AFPVOL_UNIX_PRIV;
             else if (strcasecmp(p, "nodev") == 0)
                 options[VOLOPT_FLAGS].i_value |= AFPVOL_NODEV;
+            else if (strcasecmp(p, "cachecnid") == 0)
+                options[VOLOPT_FLAGS].i_value |= AFPVOL_CACHE;
 
             p = strtok(NULL, ",");
         }
@@ -628,6 +630,12 @@ static int creatvol(AFPObj *obj, struct passwd *pwd,
         /* shift in some flags */
         volume->v_flags = options[VOLOPT_FLAGS].i_value;
 
+        volume->v_ad_options = 0;
+        if ((volume->v_flags & AFPVOL_NODEV))
+            volume->v_ad_options |= AFPVOL_NODEV;
+        if ((volume->v_flags & AFPVOL_CACHE))
+            volume->v_ad_options |= AFPVOL_CACHE;
+        
         if (options[VOLOPT_PASSWORD].c_value)
             volume->v_password = strdup(options[VOLOPT_PASSWORD].c_value);
 
@@ -1227,7 +1235,7 @@ int               *buflen;
      * For MacOS8.x support we need to create the
      * .Parent file here if it doesn't exist. */
 
-    ad_init(&ad, vol->v_adouble);
+    ad_init(&ad, vol->v_adouble, vol->v_ad_options);
     if ( ad_open( vol->v_path, vol_noadouble(vol) |
                   ADFLAGS_HF|ADFLAGS_DIR, O_RDWR | O_CREAT,
                   0666, &ad) < 0 ) {
@@ -1824,7 +1832,7 @@ void close_all_vol(void)
     struct vol *ovol;
     curdir = NULL;
     for ( ovol = Volumes; ovol; ovol = ovol->v_next ) {
-        if ( ovol->v_flags & AFPVOL_OPEN ) {
+        if ( (ovol->v_flags & AFPVOL_OPEN) ) {
             ovol->v_flags &= ~AFPVOL_OPEN;
             closevol(ovol);
         }
@@ -1849,7 +1857,7 @@ int               ibuflen, *rbuflen;
 
     vol->v_flags &= ~AFPVOL_OPEN;
     for ( ovol = Volumes; ovol; ovol = ovol->v_next ) {
-        if ( ovol->v_flags & AFPVOL_OPEN ) {
+        if ( (ovol->v_flags & AFPVOL_OPEN) ) {
             break;
         }
     }
@@ -2033,14 +2041,14 @@ int             ibuflen, *rbuflen;
         return( AFPERR_PARAM );
     }
 
-    if (vol->v_flags & AFPVOL_RO)
+    if ((vol->v_flags & AFPVOL_RO))
         return AFPERR_VLOCK;
 
     /* we can only set the backup date. */
     if (bitmap != (1 << VOLPBIT_BDATE))
         return AFPERR_BITMAP;
 
-    ad_init(&ad, vol->v_adouble);
+    ad_init(&ad, vol->v_adouble, vol->v_ad_options);
     if ( ad_open( vol->v_path, ADFLAGS_HF|ADFLAGS_DIR, O_RDWR,
                   0666, &ad) < 0 ) {
         if (errno == EROFS)
@@ -2136,7 +2144,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);
+               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) {
                        free (p);
@@ -2174,7 +2182,7 @@ static void handle_special_folders (const struct vol * vol)
 {
        const _special_folder *p = &special_folders[0];
 
-       if (vol->v_flags & AFPVOL_RO)
+       if ((vol->v_flags & AFPVOL_RO))
                return;
 
         for (; p->name != NULL; p++) {
@@ -2262,7 +2270,7 @@ static int savevoloptions (const struct vol *vol)
     /* volume flags */
     strcpy(item, "VOLUME_OPTS:");
     for (;op->name; op++) {
-       if ( vol->v_flags & op->option ) {
+       if ( (vol->v_flags & op->option) ) {
             strlcat(item, op->name, sizeof(item));
             strlcat(item, " ", sizeof(item));
         }
@@ -2273,7 +2281,7 @@ static int savevoloptions (const struct vol *vol)
     /* casefold flags */
     strcpy(item, "VOLCASEFOLD:");
     for (;cf->name; cf++) {
-        if ( vol->v_casefold & cf->option ) {
+        if ( (vol->v_casefold & cf->option) ) {
             strlcat(item, cf->name, sizeof(item));
             strlcat(item, " ", sizeof(item));
         }
index 7719782a4f42e642461cc1a9efdaa086141bc68f..4a69634fe394e31b976df3d71fe5fbc49bfc8e0d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: volume.h,v 1.19.2.5.2.7 2004-06-24 00:46:12 bfernhomberg Exp $
+ * $Id: volume.h,v 1.19.2.5.2.7.2.1 2005-02-10 01:23:16 didg Exp $
  *
  * Copyright (c) 1990,1994 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -61,10 +61,11 @@ struct vol {
     charset_t          v_maccharset;
     struct charset_functions   *v_mac;
 
-    int                 v_deleted;  /* volume open but deleted in new config file */
-    int                 v_hide;     /* new volume wait open volume */
-    int                 v_adouble;  /* default adouble format */
-
+    int                 v_deleted;    /* volume open but deleted in new config file */
+    int                 v_hide;       /* new volume wait open volume */
+    int                 v_adouble;    /* default adouble format */
+    int                        v_ad_options; /* adouble option NODEV, NOCACHE, etc.. */
+    
     char                *v_root_preexec;
     char                *v_preexec;
 
@@ -114,6 +115,7 @@ this is going away. */
                                      * help if device number is notconsistent across reboot 
                                      * NOTE symlink to a different device will return an ACCESS error
                                      */
+#define AFPVOL_CACHE      (1 << 19)  /* Use adouble v2 CNID caching, default don't use it */
 
 /* FPGetSrvrParms options */
 #define AFPSRVR_CONFIGINFO     (1 << 0)
index 56a453232c6c941d102135e884d1f30f0f868efb..11ccd52f7ec55ab081ca68166407a8ae2ac32a55 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: adouble.h,v 1.21.6.20.2.1 2004-10-20 20:16:21 didg Exp $
+ * $Id: adouble.h,v 1.21.6.20.2.2 2005-02-10 01:23:16 didg Exp $
  * Copyright (c) 1990,1991 Regents of The University of Michigan.
  * All Rights Reserved.
  *
@@ -247,6 +247,7 @@ struct adouble {
     struct ad_entry    ad_eid[ ADEID_MAX ];
     struct ad_fd       ad_df, ad_hf;
     int                 ad_flags, ad_inited;
+    int                 ad_options;
     int                 ad_refcount; /* used in afpd/ofork.c */
     off_t               ad_rlen;     /* ressource fork len with AFP 3.0
                                         the header parameter size is too small.
@@ -268,6 +269,10 @@ struct adouble {
 #define ADFLAGS_NOHF      (1<<5)  /* not an error if no ressource fork */
 #define ADFLAGS_RDONLY    (1<<6)  /* don't try readwrite */
 
+/* adouble v2 cnid cache */
+#define ADVOL_NODEV      (1 << 0)   
+#define ADVOL_CACHE      (1 << 1)
+
 /* lock flags */
 #define ADLOCK_CLR      (0)
 #define ADLOCK_RD       (1<<0)
@@ -372,7 +377,7 @@ extern char *ad_path_osx  __P((const char *, int));
 
 extern int ad_mode        __P((const char *, int));
 extern int ad_mkdir       __P((const char *, int));
-extern void ad_init       __P((struct adouble *, int ));
+extern void ad_init       __P((struct adouble *, int, int ));
 
 extern int ad_open        __P((const char *, int, int, int, struct adouble *)); 
 extern int ad_refresh     __P((struct adouble *));
@@ -451,6 +456,7 @@ extern int ad_getattr __P((const struct adouble *, u_int16_t *));
 extern int ad_setname __P((struct adouble *, const char *));
 #if AD_VERSION == AD_VERSION2
 extern int ad_setid __P((struct adouble *, const dev_t dev,const ino_t ino, const u_int32_t, const u_int32_t, const void *));
+extern u_int32_t ad_getid __P((struct adouble *, const dev_t, const ino_t, const cnid_t, const void *));
 #else
 #define ad_setid(a, b, c)
 #endif
index b897cd67ff6cc258b90a8aaf71293c2b2fff4297..f4787601a1be862d2c90fd00c389346414b60eda 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: ad_attr.c,v 1.4.8.7 2004-09-06 09:38:22 didg Exp $
+ * $Id: ad_attr.c,v 1.4.8.7.2.1 2005-02-10 01:23:17 didg Exp $
  */
 
 #ifdef HAVE_CONFIG_H
@@ -66,11 +66,17 @@ int ad_setattr(const struct adouble *ad, const u_int16_t attr)
 #if AD_VERSION == AD_VERSION2
 int ad_setid (struct adouble *adp, const dev_t dev, const ino_t ino , const u_int32_t id, const cnid_t did, const void *stamp)
 {
-    if (adp->ad_flags == AD_VERSION2  && ad_getentryoff(adp, ADEID_PRIVDEV) &&
+    if (adp->ad_flags == AD_VERSION2  && ( adp->ad_options & ADVOL_CACHE) &&
+                ad_getentryoff(adp, ADEID_PRIVDEV) &&
                 sizeof(dev_t) == ADEDLEN_PRIVDEV && sizeof(ino_t) == ADEDLEN_PRIVINO) 
     {
         ad_setentrylen( adp, ADEID_PRIVDEV, sizeof(dev_t));
-        memcpy(ad_entry( adp, ADEID_PRIVDEV ), &dev, sizeof(dev_t));
+       if ((adp->ad_options & ADVOL_NODEV)) {
+            memset(ad_entry( adp, ADEID_PRIVDEV ), 0, sizeof(dev_t));
+        }
+       else {
+            memcpy(ad_entry( adp, ADEID_PRIVDEV ), &dev, sizeof(dev_t));
+        }
 
         ad_setentrylen( adp, ADEID_PRIVINO, sizeof(ino_t));
         memcpy(ad_entry( adp, ADEID_PRIVINO ), &ino, sizeof(ino_t));
@@ -88,6 +94,40 @@ int ad_setid (struct adouble *adp, const dev_t dev, const ino_t ino , const u_in
     return 0;
 }
 
+/* ----------------------------- */
+u_int32_t ad_getid (struct adouble *adp, const dev_t st_dev, const ino_t st_ino , const cnid_t did, const void *stamp)
+{
+u_int32_t aint = 0;
+dev_t  dev;
+ino_t  ino;
+cnid_t a_did;
+char   temp[ADEDLEN_PRIVSYN];
+
+    /* look in AD v2 header 
+     * note inode and device are opaques and not in network order
+    */
+    if (adp && ( adp->ad_options & ADVOL_CACHE) 
+            && sizeof(dev_t) == ad_getentrylen(adp, ADEID_PRIVDEV)
+            && sizeof(ino_t) == ad_getentrylen(adp,ADEID_PRIVINO)
+            && sizeof(temp) == ad_getentrylen(adp,ADEID_PRIVSYN)
+            && sizeof(cnid_t) == ad_getentrylen(adp, ADEID_DID)
+            && sizeof(cnid_t) == ad_getentrylen(adp, ADEID_PRIVID)
+    ) {
+        memcpy(&dev, ad_entry(adp, ADEID_PRIVDEV), sizeof(dev_t));
+        memcpy(&ino, ad_entry(adp, ADEID_PRIVINO), sizeof(ino_t));
+        memcpy(temp, ad_entry(adp, ADEID_PRIVSYN), sizeof(stamp));
+        memcpy(&a_did, ad_entry(adp, ADEID_DID), sizeof(cnid_t));
+
+        if (  ((adp->ad_options & ADVOL_NODEV) || dev == st_dev)
+              && ino == st_ino && a_did == did 
+              && !memcmp(stamp, temp, sizeof(temp))) { 
+            memcpy(&aint, ad_entry(adp, ADEID_PRIVID), sizeof(aint));
+            return aint;
+        }
+    }
+    return 0; 
+}
+
 #endif
 
 /* ----------------- 
index 39e51c803b30fbacadf4f938f8fae156e1a49f85..bb445ae06008f589b076409708f7839c38572402 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: ad_open.c,v 1.30.6.18.2.2 2005-02-05 14:54:49 didg Exp $
+ * $Id: ad_open.c,v 1.30.6.18.2.3 2005-02-10 01:23:18 didg Exp $
  *
  * Copyright (c) 1999 Adrian Sun (asun@u.washington.edu)
  * Copyright (c) 1990,1991 Regents of The University of Michigan.
@@ -931,7 +931,7 @@ static int new_rfork(const char *path, struct adouble *ad, int adflags);
 #define AD_SET(a) a = 0
 #endif
 
-void ad_init(struct adouble *ad, int flags)
+void ad_init(struct adouble *ad, int flags, int options)
 {
     memset( ad, 0, sizeof( struct adouble ) );
     ad->ad_flags = flags;
@@ -941,6 +941,7 @@ void ad_init(struct adouble *ad, int flags)
     else {
         ad->ad_path     = ad_path;
     }
+    ad->ad_options = options;
 }
 
 /* -------------------