]> arthur.barton.de Git - netatalk.git/commitdiff
a little cleaning
authordidg <didg>
Fri, 31 Jan 2003 17:38:00 +0000 (17:38 +0000)
committerdidg <didg>
Fri, 31 Jan 2003 17:38:00 +0000 (17:38 +0000)
etc/afpd/directory.c
etc/afpd/file.c
etc/afpd/fork.c
etc/afpd/volume.c
include/atalk/adouble.h

index dbb0e65a06a1d0ef302e41a1a35a7cbdce78548a..af51cf9e8914b6111f0af3ed861f7cd0be11b0a7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $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.
@@ -1470,7 +1470,7 @@ int setdirparams(const struct vol *vol,
          * 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 ));
index bbd5bdd04b434aa8b3d56e518ba91424f4295950..3ec351b3290b1b57e89dcdcd0b80bf17191e197a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $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.
@@ -733,7 +733,7 @@ int setfilparams(struct vol *vol,
             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 ));
@@ -1359,46 +1359,27 @@ int         checkAttrib;
     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:
@@ -1443,10 +1424,7 @@ int         checkAttrib;
         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:");
index 33d4aef433f1222dc9674266ae488bd6fedbb7b4..e384fe43dd367d6fc0a2f4a14c43631cfae1459d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $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.
@@ -191,7 +191,6 @@ static int fork_setmode(struct adouble *adp, int eid, int access, int ofrefnum)
     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);
@@ -269,7 +268,7 @@ int         ibuflen, *rbuflen;
     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;
@@ -449,8 +448,7 @@ int         ibuflen, *rbuflen;
         }
     }
 
-    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 ));
index f5ef2d5acd6547d0bdbc94015995cca2afc02ee5..f553c74e2db2139834d68ee0006b5b7a4ca948fe 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $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.
@@ -943,7 +943,7 @@ int         *buflen;
                   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++;
index 0485d90f114a171790fd76f5e89f39dab3c2b72d..1cf68a840c49b1d763dc1dd1b8519dc662a0bd54 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $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.
  *
@@ -314,6 +314,8 @@ struct adouble {
 #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));