/*
- * $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.
ashort = htons(ATTRBIT_INVISIBLE);
} else
ashort = 0;
+ ashort |= htons(ATTRBIT_SHARED);
memcpy( data, &ashort, sizeof( ashort ));
data += sizeof( ashort );
break;
/*
- * $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.
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:");
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;
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 );
}
/*
- * $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.
#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) */
/*
- * $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.
u_int32_t did;
u_int16_t vid, bitmap, access, ofrefnum, attrbits = 0;
char fork, *path, *upath;
+ u_int16_t bshort;
ibuf++;
fork = *ibuf++;
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;
}
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:
*/
struct ofork *ofork;
int buflen, ret;
u_int16_t ofrefnum, bitmap;
+ u_int16_t attrbits = 0;
ibuf += 2;
memcpy(&ofrefnum, ibuf, sizeof( ofrefnum ));
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 );
}