]> arthur.barton.de Git - netatalk.git/commitdiff
of_findname: remove vol and dir
authordidg <didg>
Thu, 5 Sep 2002 14:52:05 +0000 (14:52 +0000)
committerdidg <didg>
Thu, 5 Sep 2002 14:52:05 +0000 (14:52 +0000)
etc/afpd/catsearch.c
etc/afpd/desktop.c
etc/afpd/file.c
etc/afpd/filedir.c
etc/afpd/fork.c
etc/afpd/fork.h
etc/afpd/ofork.c

index d8cf010fb11096bee6721221cb8548d723d8aec4..c292c04057c514a87a166a4192f9335296e68c26 100644 (file)
@@ -233,24 +233,19 @@ static int resolve_dir(struct vol *vol, int cidx)
 } /* resolve_dir */
 
 /* Looks up for an opened adouble structure, opens resource fork of selected file. */
-static struct adouble *adl_lkup(struct vol *vol, char *upath, int cidx, int isdir)
+static struct adouble *adl_lkup(char *upath, struct stat *sb)
 {
        static struct adouble ad;
        struct adouble *adp;
-       char *mpath = utompath(vol, upath);
        struct ofork *of;
+       int isdir = S_ISDIR(sb->st_mode);
 
-/*
-       //if (dstack[cidx].dir == NULL && !resolve_dir(vol, cidx))
-       //      return NULL;
-
-       //if ((of = of_findname(vol, dstack[cidx].dir, mpath))) {
-       //      adp = of->of_ad;
-       //} else {
-       */
+       if (!isdir && (of = of_findname(upath, sb ))) {
+               adp = of->of_ad;
+       } else {
                memset(&ad, 0, sizeof(ad));
                adp = &ad;
-       /* } */
+       } 
 
        if ( ad_open( upath, ADFLAGS_HF | (isdir)?ADFLAGS_DIR:0, O_RDONLY, 0, adp) < 0 ) {
                return NULL;
@@ -316,7 +311,7 @@ static int crit_check(struct vol *vol, char *uname, char *fname, int cidx) {
 
        /* Check for creation date... */
        if (c1.rbitmap & (1<<DIRPBIT_CDATE)) {
-               if (adp || (adp = adl_lkup(vol, uname, cidx, r))) {
+               if (adp || (adp = adl_lkup(uname, &sbuf))) {
                        if (ad_getdate(adp, AD_DATE_CREATE, (u_int32_t*)&c_date) >= 0)
                                c_date = AD_DATE_TO_UNIX(c_date);
                        else c_date = sbuf.st_mtime;
@@ -327,7 +322,7 @@ static int crit_check(struct vol *vol, char *uname, char *fname, int cidx) {
 
        /* Check for backup date... */
        if (c1.rbitmap & (1<<DIRPBIT_BDATE)) {
-               if (adp || (adp == adl_lkup(vol, uname, cidx, r))) {
+               if (adp || (adp == adl_lkup(uname, &sbuf))) {
                        if (ad_getdate(adp, AD_DATE_BACKUP, (u_int32_t*)&b_date) >= 0)
                                b_date = AD_DATE_TO_UNIX(b_date);
                        else b_date = sbuf.st_mtime;
@@ -338,7 +333,7 @@ static int crit_check(struct vol *vol, char *uname, char *fname, int cidx) {
                                
        /* Check attributes */
        if ((c1.rbitmap & (1<<DIRPBIT_ATTR)) && c2.attr != 0)
-               if (adp || (adp = adl_lkup(vol, uname, cidx, r))) {
+               if (adp || (adp = adl_lkup(uname, &sbuf))) {
                        ad_getattr(adp, &attr);
                        if ((attr & c2.attr) != c1.attr)
                                goto crit_check_ret;
@@ -347,7 +342,7 @@ static int crit_check(struct vol *vol, char *uname, char *fname, int cidx) {
 
         /* Check file type ID */
        if ((c1.rbitmap & (1<<DIRPBIT_FINFO)) && c2.finfo.f_type != 0)
-               if (adp || (adp = adl_lkup(vol, uname, cidx, r))) {
+               if (adp || (adp = adl_lkup(uname, &sbuf))) {
                        finfo = (struct finderinfo*)ad_entry(adp, ADEID_FINDERI);
                        if (finfo->f_type != c1.finfo.f_type)
                                goto crit_check_ret;
@@ -355,7 +350,7 @@ static int crit_check(struct vol *vol, char *uname, char *fname, int cidx) {
 
        /* Check creator ID */
        if ((c1.rbitmap & (1<<DIRPBIT_FINFO)) && c2.finfo.creator != 0)
-               if (adp || (adp = adl_lkup(vol, uname, cidx, r))) {
+               if (adp || (adp = adl_lkup(uname, &sbuf))) {
                        finfo = (struct finderinfo*)ad_entry(adp, ADEID_FINDERI);
                        if (finfo->creator != c1.finfo.creator)
                                goto crit_check_ret;
@@ -363,7 +358,7 @@ static int crit_check(struct vol *vol, char *uname, char *fname, int cidx) {
        
        /* Check finder info attributes */
        if ((c1.rbitmap & (1<<DIRPBIT_FINFO)) && c2.finfo.attrs != 0)
-               if (adp || (adp = adl_lkup(vol, uname, cidx, r))) {
+               if (adp || (adp = adl_lkup(uname, &sbuf))) {
                        finfo = (struct finderinfo*)ad_entry(adp, ADEID_FINDERI);
                        if ((finfo->attrs & c2.finfo.attrs) != c1.finfo.attrs)
                                goto crit_check_ret;
@@ -371,7 +366,7 @@ static int crit_check(struct vol *vol, char *uname, char *fname, int cidx) {
 
        /* Check label */
        if ((c1.rbitmap & (1<<DIRPBIT_FINFO)) && c2.finfo.label != 0)
-               if (adp || (adp = adl_lkup(vol, uname, cidx, r))) {
+               if (adp || (adp = adl_lkup(uname, &sbuf))) {
                        finfo = (struct finderinfo*)ad_entry(adp, ADEID_FINDERI);
                        if ((finfo->label & c2.finfo.label) != c1.finfo.label)
                                goto crit_check_ret;
index e3f138b70b858d171b2eaf83ba846d753dc3caba..43672599126386072a4d87f7e9e2320585e02451 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: desktop.c,v 1.14 2002-09-04 17:28:08 didg Exp $
+ * $Id: desktop.c,v 1.15 2002-09-05 14:52:05 didg Exp $
  *
  * See COPYRIGHT.
  */
@@ -748,7 +748,7 @@ int         ibuflen, *rbuflen;
     clen = (u_char)*ibuf++;
     clen = min( clen, 199 );
     upath = mtoupath( vol, path );
-    if ((*path == '\0') || !(of = of_findname(vol, curdir, upath, NULL))) {
+    if ((*path == '\0') || !(of = of_findname(upath, NULL))) {
         memset(&ad, 0, sizeof(ad));
         adp = &ad;
     } else
@@ -811,7 +811,7 @@ int         ibuflen, *rbuflen;
 
 
     upath = mtoupath( vol, path );
-    if ((*path == '\0') || !(of = of_findname(vol, curdir, upath, NULL))) {
+    if ((*path == '\0') || !(of = of_findname(upath, NULL))) {
         memset(&ad, 0, sizeof(ad));
         adp = &ad;
     } else
@@ -872,7 +872,7 @@ int         ibuflen, *rbuflen;
     }
 
     upath = mtoupath( vol, path );
-    if ((*path == '\0') || !(of = of_findname(vol, curdir, upath, NULL))) {
+    if ((*path == '\0') || !(of = of_findname(upath, NULL))) {
         memset(&ad, 0, sizeof(ad));
         adp = &ad;
     } else
index 85ab9e9a6f5706d6a3bf2a80c6acda2caabde312..dcbc9b10fc03b0e79e9135c91631ea590624dad4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: file.c,v 1.54 2002-09-04 17:28:08 didg Exp $
+ * $Id: file.c,v 1.55 2002-09-05 14:52:05 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -374,7 +374,7 @@ int getfilparams(struct vol *vol,
 #endif /* DEBUG */
 
     upath = mtoupath(vol, path);
-    if ((of = of_findname(vol, dir, upath, st))) {
+    if ((of = of_findname(upath, st))) {
         adp = of->of_ad;
        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);
@@ -464,7 +464,7 @@ int         ibuflen, *rbuflen;
 
     ret = stat(upath, &st);
     /* if upath is deleted we already in trouble anyway */
-    if (!ret && (of = of_findname(vol, curdir, upath, &st))) {
+    if (!ret && (of = of_findname(upath, &st))) {
         adp = of->of_ad;
     } else {
         memset(&ad, 0, sizeof(ad));
@@ -614,7 +614,7 @@ int setfilparams(struct vol *vol,
 #endif /* DEBUG */
 
     upath = mtoupath(vol, path);
-    if ((of = of_findname(vol, curdir, upath, NULL))) {
+    if ((of = of_findname(upath, NULL))) {
         adp = of->of_ad;
     } else {
         memset(&ad, 0, sizeof(ad));
@@ -934,7 +934,7 @@ int         ibuflen, *rbuflen;
      *      we just balk if the file is opened already. */
 
     upath = mtoupath(vol, newname );
-    if (of_findname(vol, curdir, upath, NULL))
+    if (of_findname(upath, NULL))
         return AFPERR_DENYCONF;
 
     newname = obj->newtmp;
@@ -1701,7 +1701,7 @@ int               ibuflen, *rbuflen;
     }
     memset(&ads, 0, sizeof(ads));
     adsp = &ads;
-    if ((s_of = of_findname(vol, curdir, upath, &srcst))) {
+    if ((s_of = of_findname(upath, &srcst))) {
             /* reuse struct adouble so it won't break locks */
             adsp = s_of->of_ad;
     }
@@ -1751,7 +1751,7 @@ int               ibuflen, *rbuflen;
     }
     memset(&add, 0, sizeof(add));
     addp = &add;
-    if ((d_of = of_findname(vol, curdir, upath, &destst))) {
+    if ((d_of = of_findname( upath, &destst))) {
             /* reuse struct adouble so it won't break locks */
             addp = d_of->of_ad;
     }
index f8a61f5d1983650ad80dcfea33e322a698b01fd3..155c7e6d96c210f8e89819676c6e257ee03896a9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: filedir.c,v 1.29 2002-09-04 17:28:08 didg Exp $
+ * $Id: filedir.c,v 1.30 2002-09-05 14:52:06 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -384,7 +384,7 @@ int         isdir;
         id = cnid_get(vol->v_db, sdir->d_did, p, strlen(p));
 #endif /* CNID_DB */
         p = ctoupath( vol, sdir, oldname );
-        if ((opened = of_findname(vol, sdir, p, NULL))) {
+        if ((opened = of_findname(p, NULL))) {
             /* reuse struct adouble so it won't break locks */
             adp = opened->of_ad;
         }
@@ -429,7 +429,7 @@ int         isdir;
         return AFPERR_EXIST;
 
     if ( !isdir ) {
-        if (of_findname(vol, curdir, upath, &st)) {
+        if (of_findname(upath, &st)) {
             rc = AFPERR_EXIST; /* was AFPERR_BUSY; */
         } else {
             rc = renamefile( p, upath, newname,vol_noadouble(vol), adp );
@@ -582,7 +582,7 @@ int         ibuflen, *rbuflen;
     upath = mtoupath(vol, path );
     if ( *path == '\0' ) {
         rc = deletecurdir( vol, obj->oldtmp, AFPOBJ_TMPSIZ);
-    } else if (of_findname(vol, curdir, upath, NULL)) {
+    } else if (of_findname(upath, NULL)) {
         rc = AFPERR_BUSY;
     } else if ((rc = deletefile( upath, 1)) == AFP_OK) {
 #ifdef CNID_DB /* get rid of entry */
index 28970c0ad26cd790a93fa4b2215c6cda837e041f..2d7446672ba942123b68b3dc19c8c30ca2f92359 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: fork.c,v 1.35 2002-09-04 17:28:08 didg Exp $
+ * $Id: fork.c,v 1.36 2002-09-05 14:52:06 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -303,7 +303,7 @@ int         ibuflen, *rbuflen;
        ad_open so that we can keep file locks together.
        FIXME: add the fork we are opening? 
     */
-    if ((opened = of_findname(vol, curdir, upath, &st))) {
+    if ((opened = of_findname(upath, &st))) {
         attrbits = ((opened->of_ad->ad_df.adf_refcount > 0) ? ATTRBIT_DOPEN : 0);
         attrbits |= ((opened->of_ad->ad_hf.adf_refcount > opened->of_ad->ad_df.adf_refcount)? ATTRBIT_ROPEN : 0);
                    
index d58389f497141d1ca129ade6f3eef667cec5562c..d1bb770fced6d15c599cd8e403b50fe72a97aa63 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: fork.h,v 1.4 2002-09-04 17:28:08 didg Exp $
+ * $Id: fork.h,v 1.5 2002-09-05 14:52:07 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -59,9 +59,7 @@ extern struct ofork *of_alloc    __P((struct vol *, struct dir *,
                                                       struct stat *));
 extern void         of_dealloc   __P((struct ofork *));
 extern struct ofork *of_find     __P((const u_int16_t));
-extern struct ofork *of_findname __P((const struct vol *, const struct dir *,
-                                                      const char *,
-                                                      struct stat *));
+extern struct ofork *of_findname __P((const char *, struct stat *));
 extern int          of_rename    __P((const struct vol *,
                                           struct ofork *,
                                           struct dir *, const char *,
index bbc3aa77885d4a72b3abc412eba192e580b9fda2..b8717cd0ee426b9499563d52a2d7b5bad4b93a53 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: ofork.c,v 1.17 2002-09-04 17:28:08 didg Exp $
+ * $Id: ofork.c,v 1.18 2002-09-05 14:52:07 didg Exp $
  *
  * Copyright (c) 1996 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -273,8 +273,7 @@ struct ofork *of_find(const u_int16_t ofrefnum )
 /* --------------------------
 */
 struct ofork *
-            of_findname(const struct vol *vol, const struct dir *dir, const char *name,
-            struct stat *st)
+            of_findname(const char *name, struct stat *st)
 {
     struct ofork *of;
     struct file_key key;
@@ -290,8 +289,7 @@ struct ofork *
     key.inode = st->st_ino;
 
     for (of = ofork_table[hashfn(&key)]; of; of = of->next) {
-        if (vol == of->of_vol && dir == of->of_dir &&
-                key.dev == of->key.dev && key.inode == of->key.inode ) {
+        if (key.dev == of->key.dev && key.inode == of->key.inode ) {
             return of;
         }
     }