X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=netatalk.git;a=blobdiff_plain;f=etc%2Fafpd%2Fofork.c;h=6182fcff540f71d2bbbb1f32b33338a80b51af09;hp=f5f8a38de8d7fff65a380ac83674fe9c755c190a;hb=465246e257d9aff9855e3e35d8fd5983db932b45;hpb=b31a12f311cea4c63dcda4ca4199988bc15f3490 diff --git a/etc/afpd/ofork.c b/etc/afpd/ofork.c index f5f8a38d..6182fcff 100644 --- a/etc/afpd/ofork.c +++ b/etc/afpd/ofork.c @@ -1,6 +1,4 @@ /* - * $Id: ofork.c,v 1.32 2010/03/12 15:16:49 franklahm Exp $ - * * Copyright (c) 1996 Regents of The University of Michigan. * All Rights Reserved. See COPYRIGHT. */ @@ -23,18 +21,16 @@ #include #include #include +#include -#include "globals.h" #include "volume.h" #include "directory.h" #include "fork.h" -/* we need to have a hashed list of oforks (by dev inode). just hash - * by first letter. */ +/* we need to have a hashed list of oforks (by dev inode) */ #define OFORK_HASHSIZE 64 -static struct ofork *ofork_table[OFORK_HASHSIZE]; - -static struct ofork **oforks = NULL; +static struct ofork *ofork_table[OFORK_HASHSIZE]; /* forks hashed by dev/inode */ +static struct ofork **oforks = NULL; /* point to allocated table of open forks pointers */ static int nforks = 0; static u_short lastrefnum = 0; @@ -42,12 +38,6 @@ static u_short lastrefnum = 0; /* OR some of each character for the hash*/ static unsigned long hashfn(const struct file_key *key) { -#if 0 - unsigned long i = 0; - while (*name) { - i = ((i << 4) | (8*sizeof(i) - 4)) ^ *name++; - } -#endif return key->inode & (OFORK_HASHSIZE - 1); } @@ -213,7 +203,7 @@ of_alloc(struct vol *vol, ad_open really does reinitialize the structure. */ ad_init(ad, vol->v_adouble, vol->v_ad_options); - ad->ad_m_namelen = 255 +1; + ad->ad_m_namelen = UTF8FILELEN_EARLY +1; /* here's the deal: we allocate enough for the standard mac file length. * in the future, we'll reallocate in fairly large jumps in case * of long unicode names */ @@ -274,7 +264,7 @@ int of_stat(struct path *path) } -#ifdef HAVE_RENAMEAT +#ifdef HAVE_ATFUNCS int of_fstatat(int dirfd, struct path *path) { int ret; @@ -287,7 +277,7 @@ int of_fstatat(int dirfd, struct path *path) return ret; } -#endif /* HAVE_RENAMEAT */ +#endif /* HAVE_ATFUNCS */ /* -------------------------- stat the current directory. @@ -367,7 +357,7 @@ struct ofork *of_findname(struct path *path) * @param dirfd (r) directory fd * @param path (rw) pointer to struct path */ -#ifdef HAVE_RENAMEAT +#ifdef HAVE_ATFUNCS struct ofork *of_findnameat(int dirfd, struct path *path) { struct ofork *of; @@ -487,3 +477,23 @@ void of_closevol(const struct vol *vol) return; } +/* ---------------------- + close all forks for a volume +*/ +void of_close_all_forks(void) +{ + int refnum; + + if (!oforks) + return; + + for ( refnum = 0; refnum < nforks; refnum++ ) { + if (oforks[ refnum ] != NULL) { + if (of_closefork( oforks[ refnum ]) < 0 ) { + LOG(log_error, logtype_afpd, "of_close_all_forks: %s", strerror(errno) ); + } + } + } + return; +} +