]> arthur.barton.de Git - netatalk.git/blobdiff - libatalk/adouble/ad_read.c
Spelling fix in log message: continous -> continuous
[netatalk.git] / libatalk / adouble / ad_read.c
index 9991e3f0aa86c5ad366bceacf4be862b0f17557d..17c2361faa99a775fef26c000bfb1ff82a8b2675 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: ad_read.c,v 1.8 2009-09-11 13:26:05 franklahm Exp $
+ * $Id: ad_read.c,v 1.10 2010-02-10 14:05:37 franklahm Exp $
  *
  * Copyright (c) 1990,1991 Regents of The University of Michigan.
  * All Rights Reserved.
@@ -59,19 +59,23 @@ ssize_t adf_pread(struct ad_fd *ad_fd, void *buf, size_t count, off_t offset)
 /* XXX: locks have to be checked before each stream of consecutive
  *      ad_reads to prevent a denial in the middle from causing
  *      problems. */
-ssize_t ad_read( ad, eid, off, buf, buflen)
-    struct adouble  *ad;
-    const u_int32_t     eid;
-    off_t               off;
-    char        *buf;
-    const size_t    buflen;
+ssize_t ad_read( struct adouble *ad, const u_int32_t eid, off_t off, char *buf, const size_t buflen)
 {
     ssize_t     cc;
 
     /* We're either reading the data fork (and thus the data file)
      * or we're reading anything else (and thus the header file). */
     if ( eid == ADEID_DFORK ) {
-        cc = adf_pread(&ad->ad_data_fork, buf, buflen, off);
+        if (ad->ad_data_fork.adf_syml !=0 ) {
+            /* It's a symlink, we already have the target in adf_syml */
+            cc = strlen(ad->ad_data_fork.adf_syml);
+            if (buflen < cc)
+                /* Request buffersize is too small, force AFPERR_PARAM */
+                return -1;
+            memcpy(buf, ad->ad_data_fork.adf_syml, cc);
+        } else {
+            cc = adf_pread(&ad->ad_data_fork, buf, buflen, off);
+        }
     } else {
         off_t r_off;