]> arthur.barton.de Git - netatalk.git/commitdiff
Decouple struct ofork from struct dir, replace ofork.of_dir with ofork.of_did which...
authorFrank Lahm <franklahm@googlemail.com>
Wed, 10 Nov 2010 11:47:12 +0000 (12:47 +0100)
committerFrank Lahm <franklahm@googlemail.com>
Wed, 10 Nov 2010 11:47:12 +0000 (12:47 +0100)
etc/afpd/dircache.c
etc/afpd/directory.c
etc/afpd/fork.c
etc/afpd/fork.h
etc/afpd/ofork.c
include/atalk/directory.h

index 44378c641107cafa3d9b7dcb30e082e0d37cb48a..ef776bfa329223f545df62970210b5b04d4767ee 100644 (file)
@@ -260,7 +260,6 @@ static void dircache_evict(void)
         queue_count--;
 
         if (curdir == dir
-            || dir->d_ofork
             || (dir->d_flags & DIRF_CACHELOCK)) {     /* 2 */
             if ((dir->qidx_node = enqueue(index_queue, dir)) == NULL) {
                 dircache_dump();
@@ -605,57 +604,54 @@ void dircache_dump(void)
     fprintf(dump, "Configured maximum cache size: %u\n\n", dircache_maxsize);
 
     fprintf(dump, "Primary CNID index:\n");
-    fprintf(dump, "       VID     DID    CNID STAT  PATH\n");
+    fprintf(dump, "       VID     DID    CNID STAT PATH\n");
     fprintf(dump, "====================================================================\n");
     hash_scan_begin(&hs, dircache);
     i = 1;
     while ((hn = hash_scan_next(&hs))) {
         dir = hnode_get(hn);
-        fprintf(dump, "%05u: %3u  %6u  %6u  %s%s%s  %s\n",
+        fprintf(dump, "%05u: %3u  %6u  %6u  %s%s  %s\n",
                 i++,
                 ntohs(dir->d_vid),
                 ntohl(dir->d_pdid),
                 ntohl(dir->d_did),
                 dir->d_fullpath ? "d" : "f",
                 (dir->d_flags & DIRF_CACHELOCK) ? "l" : "-",
-                dir->d_ofork ? "o" : "-",
                 cfrombstr(dir->d_u_name));
     }
 
     fprintf(dump, "\nSecondary DID/name index:\n");
-    fprintf(dump, "       VID     DID    CNID STAT  PATH\n");
+    fprintf(dump, "       VID     DID    CNID STAT PATH\n");
     fprintf(dump, "====================================================================\n");
     hash_scan_begin(&hs, index_didname);
     i = 1;
     while ((hn = hash_scan_next(&hs))) {
         dir = hnode_get(hn);
-        fprintf(dump, "%05u: %3u  %6u  %6u  %s%s%s  %s\n",
+        fprintf(dump, "%05u: %3u  %6u  %6u  %s%s  %s\n",
                 i++,
                 ntohs(dir->d_vid),
                 ntohl(dir->d_pdid),
                 ntohl(dir->d_did),
                 dir->d_fullpath ? "d" : "f",
                 (dir->d_flags & DIRF_CACHELOCK) ? "l" : "-",
-                dir->d_ofork ? "o" : "-",
                 cfrombstr(dir->d_u_name));
     }
 
     fprintf(dump, "\nLRU Queue:\n");
-    fprintf(dump, "       VID     DID    CNID STAT  PATH\n");
+    fprintf(dump, "       VID     DID    CNID STAT PATH\n");
     fprintf(dump, "====================================================================\n");
 
     for (i = 1; i <= queue_count; i++) {
         if (n == index_queue)
             break;
         dir = (struct dir *)n->data;
-        fprintf(dump, "%05u: %3u  %6u  %6u  %s%s%s  %s\n",
+        fprintf(dump, "%05u: %3u  %6u  %6u  %s%s  %s\n",
                 i,
                 ntohs(dir->d_vid),
                 ntohl(dir->d_pdid),
                 ntohl(dir->d_did),
                 dir->d_fullpath ? "d" : "f",
                 (dir->d_flags & DIRF_CACHELOCK) ? "l" : "-",
-                dir->d_ofork ? "o" : "-",
                 cfrombstr(dir->d_u_name));
         n = n->next;
     }
index 61a385f1f2f6f62db98ce85f6de63ed45f9b4573..4c891feebc3d3373d1641e5a646d7b9b7b721ebc 100644 (file)
@@ -56,7 +56,7 @@ int         afp_errno;
 /* As long as directory.c hasn't got its own init call, this get initialized in dircache_init */
 struct dir rootParent  = {
     NULL, NULL, NULL, NULL,          /* path, d_m_name, d_u_name, d_m_name_ucs2 */
-    NULL, NULL, 0, 0,                /* qidx_node, d_ofork, ctime, d_flags */
+    NULL, 0, 0,                      /* qidx_node, ctime, d_flags */
     0, 0, 0, 0                       /* pdid, did, offcnt, d_vid */
 };
 struct dir  *curdir = &rootParent;
@@ -872,8 +872,8 @@ int dir_remove(const struct vol *vol, struct dir *dir)
     if (dir->d_did == DIRDID_ROOT_PARENT || dir->d_did == DIRDID_ROOT)
         return 0;
 
-    if (dir->d_flags & DIRF_CACHELOCK || dir->d_ofork) { /* 1 */
-        LOG(log_warning, logtype_afpd, "dir_remove(did:%u,'%s'): dir is locked or has opened forks",
+    if (dir->d_flags & DIRF_CACHELOCK) { /* 1 */
+        LOG(log_warning, logtype_afpd, "dir_remove(did:%u,'%s'): dir is locked",
             ntohl(dir->d_did), cfrombstr(dir->d_u_name));
         return 0;
     }
index e8c019e1093cf8723e839daa62fc8a8b9fa493be..f4d0d04cbee4c9f4ee93952c35469010e8f0b688 100644 (file)
@@ -73,7 +73,7 @@ static int getforkparams(struct ofork *ofork, u_int16_t bitmap, char *buf, size_
     }
 
     vol = ofork->of_vol;
-    dir = ofork->of_dir;
+    dir = dirlookup(vol, ofork->of_did);
 
     if (NULL == (path.u_name = mtoupath(vol, of_name(ofork), dir->d_did, utf8_encoding()))) {
         return( AFPERR_MISC );
index 5a42afc71dc202492c3ca875876b913a5f944a86..ab75f1f7930856b8e03a206299d880ce97b6e62c 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * $Id: fork.h,v 1.18 2010-03-12 15:16:49 franklahm Exp $
- *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
  */
 #include "directory.h"
 
 struct file_key {
-    dev_t              dev;
-    ino_t              inode;
+    dev_t       dev;
+    ino_t       inode;
 };
 
 struct ofork {
     struct file_key     key;
-    struct adouble     *of_ad;
+    struct adouble      *of_ad;
     struct vol          *of_vol;
-    struct dir         *of_dir;
-
-    u_int16_t           of_refnum;
+    cnid_t              of_did;
+    uint16_t            of_refnum;
     int                 of_flags;
-
     struct ofork        **prevp, *next;
-    struct ofork        *of_d_prev, *of_d_next;
+//    struct ofork        *of_d_prev, *of_d_next;
 };
 
-#define OPENFORK_DATA  (0)
-#define OPENFORK_RSCS  (1<<7)
+#define OPENFORK_DATA   (0)
+#define OPENFORK_RSCS   (1<<7)
 
-#define OPENACC_RD     (1<<0)
-#define OPENACC_WR     (1<<1)
-#define OPENACC_DRD    (1<<4)
-#define OPENACC_DWR    (1<<5)
+#define OPENACC_RD  (1<<0)
+#define OPENACC_WR  (1<<1)
+#define OPENACC_DRD (1<<4)
+#define OPENACC_DWR (1<<5)
 
 /* ofork.of_flags bits */
-#define AFPFORK_OPEN   (1<<0)
-#define AFPFORK_RSRC   (1<<1)
-#define AFPFORK_DATA   (1<<2)
+#define AFPFORK_OPEN    (1<<0)
+#define AFPFORK_RSRC    (1<<1)
+#define AFPFORK_DATA    (1<<2)
 #define AFPFORK_DIRTY   (1<<3)
 #define AFPFORK_ACCRD   (1<<4)
 #define AFPFORK_ACCWR   (1<<5)
index b82eabcb2f24405130b0b04782259b8642b61a38..f5f8a38de8d7fff65a380ac83674fe9c755c190a 100644 (file)
@@ -108,7 +108,7 @@ int of_rename(const struct vol *vol,
               struct dir *olddir, const char *oldpath _U_,
               struct dir *newdir, const char *newpath)
 {
-    struct ofork *of, *next, *d_ofork;
+    struct ofork *of, *next;
     int done = 0;
 
     if (!s_of)
@@ -118,30 +118,16 @@ int of_rename(const struct vol *vol,
     while ((of = next)) {
         next = next->next; /* so we can unhash and still be all right. */
 
-        if (vol == of->of_vol && olddir == of->of_dir &&
-            s_of->key.dev == of->key.dev &&
-            s_of->key.inode == of->key.inode ) {
+        if (vol == of->of_vol
+            && olddir->d_did == of->of_did
+            && s_of->key.dev == of->key.dev
+            && s_of->key.inode == of->key.inode ) {
             if (!done) {
                 strlcpy( of_name(of), newpath, of->of_ad->ad_m_namelen);
                 done = 1;
             }
-            if (newdir != olddir) {
-                of->of_d_prev->of_d_next = of->of_d_next;
-                of->of_d_next->of_d_prev = of->of_d_prev;
-                if (of->of_dir->d_ofork == of) {
-                    of->of_dir->d_ofork = (of == of->of_d_next) ? NULL : of->of_d_next;
-                }
-                of->of_dir = newdir;
-                if (!(d_ofork = newdir->d_ofork)) {
-                    newdir->d_ofork = of;
-                    of->of_d_next = of->of_d_prev = of;
-                } else {
-                    of->of_d_next = d_ofork;
-                    of->of_d_prev = d_ofork->of_d_prev;
-                    of->of_d_prev->of_d_next = of;
-                    d_ofork->of_d_prev = of;
-                }
-            }
+            if (newdir != olddir)
+                of->of_did = newdir->d_did;
         }
     }
 
@@ -159,7 +145,7 @@ of_alloc(struct vol *vol,
          struct adouble *ad,
          struct stat    *st)
 {
-    struct ofork        *of, *d_ofork;
+    struct ofork        *of;
     u_int16_t       refnum, of_refnum;
 
     int         i;
@@ -247,17 +233,7 @@ of_alloc(struct vol *vol,
 
     of->of_ad = ad;
     of->of_vol = vol;
-    of->of_dir = dir;
-
-    if (!(d_ofork = dir->d_ofork)) {
-        dir->d_ofork = of;
-        of->of_d_next = of->of_d_prev = of;
-    } else {
-        of->of_d_next = d_ofork;
-        of->of_d_prev = d_ofork->of_d_prev;
-        d_ofork->of_d_prev->of_d_next = of;
-        d_ofork->of_d_prev = of;
-    }
+    of->of_did = dir->d_did;
 
     *ofrefnum = refnum;
     of->of_refnum = refnum;
@@ -423,14 +399,6 @@ void of_dealloc( struct ofork *of)
         return;
 
     of_unhash(of);
-
-    /* detach ofork */
-    of->of_d_prev->of_d_next = of->of_d_next;
-    of->of_d_next->of_d_prev = of->of_d_prev;
-    if (of->of_dir->d_ofork == of) {
-        of->of_dir->d_ofork = (of == of->of_d_next) ? NULL : of->of_d_next;
-    }
-
     oforks[ of->of_refnum % nforks ] = NULL;
 
     /* decrease refcount */
index 079d01c3d054386a7541d1f2a5cb07d9823bec59..d15c048940e772229334e10f5f50aad76eefb9da 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * $Id: directory.h,v 1.3.2.1 2010-02-01 10:56:08 franklahm Exp $
- *
  * Copyright (c) 1990,1991 Regents of The University of Michigan.
  * All Rights Reserved.
  *
@@ -57,7 +55,6 @@ struct dir {
                                      /* will just point to the same storage as d_m_name !! */
     ucs2_t      *d_m_name_ucs2;       /* mac name as UCS2 */
     qnode_t     *qidx_node;           /* pointer to position in queue index */
-    void        *d_ofork;             /* oforks using this directory. */
     time_t      ctime;                /* inode ctime, used and modified by reenumeration */
     time_t      ctime_dircache;       /* inode ctime, used and modified by dircache */
     int         d_flags;              /* directory flags */