/*
- * $Id: directory.c,v 1.59 2003-01-26 10:42:40 didg Exp $
+ * $Id: directory.c,v 1.60 2003-01-31 17:38:00 didg Exp $
*
* Copyright (c) 1990,1993 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
* Check to see if a create was necessary. If it was, we'll want
* to set our name, etc.
*/
- if ( ad_getoflags( &ad, ADFLAGS_HF ) & O_CREAT ) {
+ if ( ad_get_HF_flags( &ad ) & O_CREAT ) {
ad_setentrylen( &ad, ADEID_NAME, strlen( curdir->d_m_name ));
memcpy( ad_entry( &ad, ADEID_NAME ), curdir->d_m_name,
ad_getentrylen( &ad, ADEID_NAME ));
/*
- * $Id: file.c,v 1.80 2003-01-30 17:32:46 didg Exp $
+ * $Id: file.c,v 1.81 2003-01-31 17:38:01 didg Exp $
*
* Copyright (c) 1990,1993 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
return vol_noadouble(vol) ? AFP_OK : AFPERR_ACCESS;
}
isad = 0;
- } else if ((ad_getoflags( adp, ADFLAGS_HF ) & O_CREAT) ) {
+ } else if ((ad_get_HF_flags( adp ) & O_CREAT) ) {
ad_setentrylen( adp, ADEID_NAME, strlen( path->m_name ));
memcpy(ad_entry( adp, ADEID_NAME ), path->m_name,
ad_getentrylen( adp, ADEID_NAME ));
LOG(log_info, logtype_afpd, "begin deletefile:");
#endif /* DEBUG */
+ /* try to open both at once */
+ adflags = ADFLAGS_DF|ADFLAGS_HF;
while(1) {
- /*
- * If can't open read/write then try again read-only. If it's open
- * read-only, we must do a read lock instead of a write lock.
- */
- /* try to open both at once */
- adflags = ADFLAGS_DF|ADFLAGS_HF;
memset(&ad, 0, sizeof(ad));
if ( ad_open( file, adflags, openmode, 0, &ad ) < 0 ) {
switch (errno) {
case ENOENT:
- adflags = ADFLAGS_DF;
+ if (adflags == ADFLAGS_DF)
+ return AFPERR_NOOBJ;
+
/* that failed. now try to open just the data fork */
- memset(&ad, 0, sizeof(ad));
- if ( ad_open( file, adflags, openmode, 0, &ad ) < 0 ) {
- switch (errno) {
- case ENOENT:
- return AFPERR_NOOBJ;
- case EACCES:
- if(openmode == O_RDWR) {
- openmode = O_RDONLY;
- continue;
- } else {
- return AFPERR_ACCESS;
- }
- case EROFS:
- return AFPERR_VLOCK;
- default:
- return AFPERR_PARAM;
- }
- }
- break;
+ adflags = ADFLAGS_DF;
+ continue;
case EACCES:
+ /* If can't open read/write then try again read-only. */
if(openmode == O_RDWR) {
openmode = O_RDONLY;
continue;
- } else {
- return AFPERR_ACCESS;
- }
+ }
+ return AFPERR_ACCESS;
case EROFS:
return AFPERR_VLOCK;
default:
err = netatalk_unlink( file );
}
- if (adflags & ADFLAGS_HF)
- ad_tmplock(&ad, ADEID_RFORK, ADLOCK_CLR |ADLOCK_FILELOCK, 0, 0, 0);
- ad_tmplock(&ad, ADEID_DFORK, ADLOCK_CLR, 0, 0, 0);
- ad_close( &ad, adflags );
+ ad_close( &ad, adflags ); /* ad_close removes locks if any */
#ifdef DEBUG
LOG(log_info, logtype_afpd, "end deletefile:");
/*
- * $Id: fork.c,v 1.47 2003-01-31 11:26:35 didg Exp $
+ * $Id: fork.c,v 1.48 2003-01-31 17:38:01 didg Exp $
*
* Copyright (c) 1990,1993 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
int writeset;
int denyreadset;
int denywriteset;
- int mode;
if (! (access & (OPENACC_WR | OPENACC_RD | OPENACC_DWR | OPENACC_DRD))) {
return setforkmode(adp, eid, ofrefnum, AD_FILELOCK_OPEN_NONE);
struct dir *dir;
struct ofork *ofork, *opened;
struct adouble *adsame = NULL;
- int buflen, ret, adflags, eid, lockop;
+ int buflen, ret, adflags, eid;
u_int32_t did;
u_int16_t vid, bitmap, access, ofrefnum, attrbits = 0;
char fork, *path, *upath;
}
}
- if ((adflags & ADFLAGS_HF) &&
- (ad_getoflags( ofork->of_ad, ADFLAGS_HF ) & O_CREAT)) {
+ if ((adflags & ADFLAGS_HF) && (ad_get_HF_flags( ofork->of_ad) & O_CREAT)) {
ad_setentrylen( ofork->of_ad, ADEID_NAME, strlen( path ));
memcpy(ad_entry( ofork->of_ad, ADEID_NAME ), path,
ad_getentrylen( ofork->of_ad, ADEID_NAME ));
/*
- * $Id: volume.c,v 1.46 2003-01-12 14:40:04 didg Exp $
+ * $Id: volume.c,v 1.47 2003-01-31 17:38:02 didg Exp $
*
* Copyright (c) 1990,1993 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
0666, &ad) < 0 ) {
isad = 0;
- } else if (ad_getoflags( &ad, ADFLAGS_HF ) & O_CREAT) {
+ } else if (ad_get_HF_flags( &ad ) & O_CREAT) {
slash = strrchr( vol->v_path, '/' );
if(slash)
slash++;
/*
- * $Id: adouble.h,v 1.18 2003-01-31 11:26:36 didg Exp $
+ * $Id: adouble.h,v 1.19 2003-01-31 17:38:02 didg Exp $
* Copyright (c) 1990,1991 Regents of The University of Michigan.
* All Rights Reserved.
*
#define ad_getoflags(ad,adf) (((adf)&ADFLAGS_HF) ? \
(ad)->ad_hf.adf_flags : (ad)->ad_df.adf_flags)
+#define ad_get_HF_flags(ad) ((ad)->ad_hf.adf_flags)
+
/* ad_flush.c */
extern void ad_rebuild_header __P((struct adouble *));
extern int ad_flush __P((struct adouble *, int));