From: Frank Lahm Date: Wed, 10 Nov 2010 11:47:12 +0000 (+0100) Subject: Decouple struct ofork from struct dir, replace ofork.of_dir with ofork.of_did which... X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=netatalk.git;a=commitdiff_plain;h=b31a12f311cea4c63dcda4ca4199988bc15f3490 Decouple struct ofork from struct dir, replace ofork.of_dir with ofork.of_did which can be used with dirlookup to get the struct dir --- diff --git a/etc/afpd/dircache.c b/etc/afpd/dircache.c index 44378c64..ef776bfa 100644 --- a/etc/afpd/dircache.c +++ b/etc/afpd/dircache.c @@ -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; } diff --git a/etc/afpd/directory.c b/etc/afpd/directory.c index 61a385f1..4c891fee 100644 --- a/etc/afpd/directory.c +++ b/etc/afpd/directory.c @@ -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; } diff --git a/etc/afpd/fork.c b/etc/afpd/fork.c index e8c019e1..f4d0d04c 100644 --- a/etc/afpd/fork.c +++ b/etc/afpd/fork.c @@ -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 ); diff --git a/etc/afpd/fork.h b/etc/afpd/fork.h index 5a42afc7..ab75f1f7 100644 --- a/etc/afpd/fork.h +++ b/etc/afpd/fork.h @@ -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. */ @@ -17,35 +15,33 @@ #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) diff --git a/etc/afpd/ofork.c b/etc/afpd/ofork.c index b82eabcb..f5f8a38d 100644 --- a/etc/afpd/ofork.c +++ b/etc/afpd/ofork.c @@ -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 */ diff --git a/include/atalk/directory.h b/include/atalk/directory.h index 079d01c3..d15c0489 100644 --- a/include/atalk/directory.h +++ b/include/atalk/directory.h @@ -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 */