From 7795978051db470465bc8cc7f2cea207a8a7bd02 Mon Sep 17 00:00:00 2001 From: didg Date: Mon, 17 Jun 2002 18:23:02 +0000 Subject: [PATCH 1/1] more bits set in files/folders attributes. Fix error -51 in inspiration --- etc/afpd/directory.c | 3 ++- etc/afpd/file.c | 24 ++++++++++++++++++++++-- etc/afpd/file.h | 3 ++- etc/afpd/fork.c | 27 ++++++++++++++++++++++----- 4 files changed, 48 insertions(+), 9 deletions(-) diff --git a/etc/afpd/directory.c b/etc/afpd/directory.c index f4f594f1..40f78e4a 100644 --- a/etc/afpd/directory.c +++ b/etc/afpd/directory.c @@ -1,5 +1,5 @@ /* - * $Id: directory.c,v 1.33 2002-05-27 04:47:00 didg Exp $ + * $Id: directory.c,v 1.34 2002-06-17 18:23:02 didg Exp $ * * Copyright (c) 1990,1993 Regents of The University of Michigan. * All Rights Reserved. See COPYRIGHT. @@ -993,6 +993,7 @@ int getdirparams(const struct vol *vol, ashort = htons(ATTRBIT_INVISIBLE); } else ashort = 0; + ashort |= htons(ATTRBIT_SHARED); memcpy( data, &ashort, sizeof( ashort )); data += sizeof( ashort ); break; diff --git a/etc/afpd/file.c b/etc/afpd/file.c index 58adb130..30cd045c 100644 --- a/etc/afpd/file.c +++ b/etc/afpd/file.c @@ -1,5 +1,5 @@ /* - * $Id: file.c,v 1.45 2002-05-20 15:03:19 jmarcus Exp $ + * $Id: file.c,v 1.46 2002-06-17 18:23:03 didg Exp $ * * Copyright (c) 1990,1993 Regents of The University of Michigan. * All Rights Reserved. See COPYRIGHT. @@ -366,6 +366,7 @@ int getfilparams(struct vol *vol, struct adouble ad, *adp; struct ofork *of; char *upath; + u_int16_t attrbits = 0; int rc; #ifdef DEBUG LOG(log_info, logtype_default, "begin getfilparams:"); @@ -374,6 +375,9 @@ int getfilparams(struct vol *vol, upath = mtoupath(vol, path); if ((of = of_findname(vol, dir, path))) { 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); + } else { memset(&ad, 0, sizeof(ad)); adp = &ad; @@ -382,7 +386,23 @@ int getfilparams(struct vol *vol, if ( ad_open( upath, ADFLAGS_HF, O_RDONLY, 0, adp) < 0 ) { adp = NULL; } - rc = getmetadata(vol, bitmap, path, dir, st, buf, buflen, adp, 0); + else { +#if 0 + /* FIXME + we need to check if the file is open by another process. + it's slow so we only do it if we have to: + - bitmap is requested. + - we don't already have the answer! + */ + if ((bitmap & (1 << FILPBIT_ATTR))) { + if (!(attrbits & ATTRBIT_ROPEN)) { + } + if (!(attrbits & ATTRBIT_DOPEN)) { + } + } +#endif + } + rc = getmetadata(vol, bitmap, path, dir, st, buf, buflen, adp, attrbits); if ( adp ) { ad_close( adp, ADFLAGS_HF ); } diff --git a/etc/afpd/file.h b/etc/afpd/file.h index 0c970fe1..3deb96d9 100644 --- a/etc/afpd/file.h +++ b/etc/afpd/file.h @@ -1,5 +1,5 @@ /* - * $Id: file.h,v 1.7 2002-05-13 04:59:36 jmarcus Exp $ + * $Id: file.h,v 1.8 2002-06-17 18:23:03 didg Exp $ * * Copyright (c) 1990,1991 Regents of The University of Michigan. * All Rights Reserved. @@ -57,6 +57,7 @@ extern const u_char ufinderi[]; #define ATTRBIT_SYSTEM (1<<2) /* system (d) */ #define ATTRBIT_DOPEN (1<<3) /* data fork already open */ #define ATTRBIT_ROPEN (1<<4) /* resource fork already open */ +#define ATTRBIT_SHARED (1<<4) /* shared area (d) */ #define ATTRBIT_NOWRITE (1<<5) /* write inhibit(v2)/read-only(v1) bit */ #define ATTRBIT_BACKUP (1<<6) /* backup needed (d) */ #define ATTRBIT_NORENAME (1<<7) /* rename inhibit (d) */ diff --git a/etc/afpd/fork.c b/etc/afpd/fork.c index fb6ef4b8..058b2dc9 100644 --- a/etc/afpd/fork.c +++ b/etc/afpd/fork.c @@ -1,5 +1,5 @@ /* - * $Id: fork.c,v 1.29 2002-06-01 05:10:24 didg Exp $ + * $Id: fork.c,v 1.30 2002-06-17 18:23:03 didg Exp $ * * Copyright (c) 1990,1993 Regents of The University of Michigan. * All Rights Reserved. See COPYRIGHT. @@ -232,6 +232,7 @@ int ibuflen, *rbuflen; u_int32_t did; u_int16_t vid, bitmap, access, ofrefnum, attrbits = 0; char fork, *path, *upath; + u_int16_t bshort; ibuf++; fork = *ibuf++; @@ -277,10 +278,13 @@ int ibuflen, *rbuflen; open bits should really be set if the fork is opened by any program, not just this one. however, that's problematic to do if we can't write lock files somewhere. opened is also passed to - ad_open so that we can keep file locks together. */ + ad_open so that we can keep file locks together. + FIXME: add the fork we are opening? + */ if ((opened = of_findname(vol, curdir, path))) { - attrbits = ((opened->of_flags & AFPFORK_RSRC) ? ATTRBIT_ROPEN : 0) | - ((opened->of_flags & AFPFORK_DATA) ? ATTRBIT_DOPEN : 0); + 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); + adsame = opened->of_ad; } @@ -404,6 +408,16 @@ int ibuflen, *rbuflen; memcpy(rbuf, &bitmap, sizeof( u_int16_t )); rbuf += sizeof( u_int16_t ); + /* check WriteInhibit bit, the test is done here, after some Mac trafic capture */ + ad_getattr(ofork->of_ad, &bshort); + if ((bshort & htons(ATTRBIT_NOWRITE)) && (access & OPENACC_WR)) { + ad_close( ofork->of_ad, adflags ); + of_dealloc( ofork ); + ofrefnum = 0; + memcpy(rbuf, &ofrefnum, sizeof(ofrefnum)); + return(AFPERR_OLOCK); + } + /* * synchronization locks: */ @@ -1275,6 +1289,7 @@ int ibuflen, *rbuflen; struct ofork *ofork; int buflen, ret; u_int16_t ofrefnum, bitmap; + u_int16_t attrbits = 0; ibuf += 2; memcpy(&ofrefnum, ibuf, sizeof( ofrefnum )); @@ -1288,9 +1303,11 @@ int ibuflen, *rbuflen; LOG(log_error, logtype_afpd, "afp_getforkparams: of_find"); return( AFPERR_PARAM ); } + attrbits = ((ofork->of_ad->ad_df.adf_refcount > 0) ? ATTRBIT_DOPEN : 0); + attrbits |= ((ofork->of_ad->ad_hf.adf_refcount > ofork->of_ad->ad_df.adf_refcount) ? ATTRBIT_ROPEN : 0); if (( ret = getforkparams( ofork, bitmap, - rbuf + sizeof( u_short ), &buflen, 0 )) != AFP_OK ) { + rbuf + sizeof( u_short ), &buflen, attrbits )) != AFP_OK ) { return( ret ); } -- 2.39.2