]> arthur.barton.de Git - netatalk.git/commitdiff
code cleaning: if we can't get a write lock on a file open read only is a fcntl issue...
authordidg <didg>
Thu, 30 Jan 2003 17:32:45 +0000 (17:32 +0000)
committerdidg <didg>
Thu, 30 Jan 2003 17:32:45 +0000 (17:32 +0000)
etc/afpd/file.c
libatalk/adouble/ad_lock.c

index ec2252dc70979222969f1f827eb268f7a7d3033f..bbd5bdd04b434aa8b3d56e518ba91424f4295950 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: file.c,v 1.79 2003-01-26 10:42:40 didg Exp $
+ * $Id: file.c,v 1.80 2003-01-30 17:32:46 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -1353,7 +1353,6 @@ int         checkAttrib;
 {
     struct adouble     ad;
     int                        adflags, err = AFP_OK;
-    int                        locktype = ADLOCK_WR;
     int                        openmode = O_RDWR;
 
 #ifdef DEBUG
@@ -1381,7 +1380,6 @@ int         checkAttrib;
                     case EACCES:
                         if(openmode == O_RDWR) {
                             openmode = O_RDONLY;
-                            locktype = ADLOCK_RD;
                             continue;
                         } else {
                             return AFPERR_ACCESS;
@@ -1397,7 +1395,6 @@ int         checkAttrib;
             case EACCES:
                 if(openmode == O_RDWR) {
                     openmode = O_RDONLY;
-                    locktype = ADLOCK_RD;
                     continue;
                 } else {
                     return AFPERR_ACCESS;
@@ -1433,13 +1430,13 @@ int         checkAttrib;
          *
          * FIXME it doesn't for RFORK open read only and fork open without deny mode
          */
-        if (ad_tmplock(&ad, ADEID_RFORK, locktype |ADLOCK_FILELOCK, 0, 0, 0) < 0 ) {
+        if (ad_tmplock(&ad, ADEID_RFORK, ADLOCK_WR |ADLOCK_FILELOCK, 0, 0, 0) < 0 ) {
             ad_close( &ad, adflags );
             return( AFPERR_BUSY );
         }
     }
 
-    if (ad_tmplock( &ad, ADEID_DFORK, locktype, 0, 0, 0 ) < 0) {
+    if (ad_tmplock( &ad, ADEID_DFORK, ADLOCK_WR, 0, 0, 0 ) < 0) {
         err = AFPERR_BUSY;
     }
     else if ( 0 == (err = netatalk_unlink( ad_path( file, ADFLAGS_HF )) )) {
index 26cf186ae2ecfe0b4d6f5247315b3a7ab4e56af1..a93c4bfa46f15a534ec2014364feab9576586679 100644 (file)
@@ -1,5 +1,5 @@
 /* 
- * $Id: ad_lock.c,v 1.8 2003-01-16 21:18:15 didg Exp $
+ * $Id: ad_lock.c,v 1.9 2003-01-30 17:32:45 didg Exp $
  *
  * Copyright (c) 1998,1999 Adrian Sun (asun@zoology.washington.edu)
  * All Rights Reserved. See COPYRIGHT for more information.
@@ -446,6 +446,11 @@ int ad_fcntl_tmplock(struct adouble *ad, const u_int32_t eid, const int type,
     if (!(type & ADLOCK_FILELOCK))
         lock.l_start += ad_getentryoff(ad, eid);
   }
+
+  if (!(adf->adf_flags & O_RDWR) && (type & ADLOCK_WR)) {
+      type = (type & ~ADLOCK_WR) | ADLOCK_RD;
+  }
+  
   lock.l_type = XLATE_FCNTL_LOCK(type & ADLOCK_MASK);
   lock.l_whence = SEEK_SET;
   lock.l_len = len;