]> arthur.barton.de Git - netatalk.git/commitdiff
more bits set in files/folders attributes. Fix error -51 in inspiration
authordidg <didg>
Mon, 17 Jun 2002 18:23:02 +0000 (18:23 +0000)
committerdidg <didg>
Mon, 17 Jun 2002 18:23:02 +0000 (18:23 +0000)
etc/afpd/directory.c
etc/afpd/file.c
etc/afpd/file.h
etc/afpd/fork.c

index f4f594f16e188238d60f88fefe0db6a0cfd3a826..40f78e4a191064d9035423959828be5c2ffbb980 100644 (file)
@@ -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;
index 58adb13095bf633b2df5c3c5a0fa740d3ce8f089..30cd045ce6abc850982cbef34a82af3f86ff6bcc 100644 (file)
@@ -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 );
     }
index 0c970fe137c1f75c6f28490f36aca27a7911943f..3deb96d9fa98fe100686963d80610d6582836369 100644 (file)
@@ -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) */
index fb6ef4b8d58be86d86986bd7aa026a71ade2dcca..058b2dc924a8c90eea11d7dfcacaea2186cab164 100644 (file)
@@ -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 );
     }