]> arthur.barton.de Git - netatalk.git/blobdiff - etc/afpd/fork.c
Big configure.in cleanup
[netatalk.git] / etc / afpd / fork.c
index 889b7ac278287d1cf88ff517ef35869613d15f3f..0c9ccef9c3c6f5e318532cce3f653c0cbd425276 100644 (file)
 #include "desktop.h"
 #include "volume.h"
 
-#ifdef DEBUG1
-#define Debug(a) ((a)->options.flags & OPTION_DEBUG)
-#else
-#define Debug(a) (0)
-#endif
-
 #ifdef AFS
 struct ofork *writtenfork;
 #endif
@@ -96,7 +90,6 @@ static int getforkparams(struct ofork *ofork, u_int16_t bitmap, char *buf, size_
     return getmetadata(vol, bitmap, &path, dir, buf, buflen, adp );
 }
 
-/* ---------------------------- */
 static off_t get_off_t(char **ibuf, int is64)
 {
     u_int32_t             temp;
@@ -118,7 +111,6 @@ static off_t get_off_t(char **ibuf, int is64)
     return ret;
 }
 
-/* ---------------------- */
 static int set_off_t(off_t offset, char *rbuf, int is64)
 {
     u_int32_t  temp;
@@ -139,8 +131,6 @@ static int set_off_t(off_t offset, char *rbuf, int is64)
     return ret;
 }
 
-/* ------------------------
- */
 static int is_neg(int is64, off_t val)
 {
     if (val < 0 || (sizeof(off_t) == 8 && !is64 && (val & 0x80000000U)))
@@ -155,22 +145,6 @@ static int sum_neg(int is64, off_t offset, off_t reqcount)
     return 0;
 }
 
-/* -------------------------
- */
-static int setforkmode(struct adouble *adp, int eid, int ofrefnum, int what)
-{
-    return ad_lock(adp, eid, ADLOCK_RD | ADLOCK_FILELOCK, what, 1, ofrefnum);
-}
-
-/* -------------------------
- */
-int getforkmode(struct adouble *adp, int eid, int what)
-{
-    return ad_testlock(adp, eid,  what);
-}
-
-/* -------------------------
- */
 static int fork_setmode(struct adouble *adp, int eid, int access, int ofrefnum)
 {
     int ret;
@@ -180,13 +154,13 @@ static int fork_setmode(struct adouble *adp, int eid, int access, int ofrefnum)
     int denywriteset;
 
     if (! (access & (OPENACC_WR | OPENACC_RD | OPENACC_DWR | OPENACC_DRD))) {
-        return setforkmode(adp, eid, ofrefnum, AD_FILELOCK_OPEN_NONE);
+        return ad_lock(adp, eid, ADLOCK_RD | ADLOCK_FILELOCK, AD_FILELOCK_OPEN_NONE, 1, ofrefnum);
     }
 
     if ((access & (OPENACC_RD | OPENACC_DRD))) {
-        if ((readset = getforkmode(adp, eid, AD_FILELOCK_OPEN_RD)) <0)
+        if ((readset = ad_testlock(adp, eid, AD_FILELOCK_OPEN_RD)) <0)
             return readset;
-        if ((denyreadset = getforkmode(adp, eid, AD_FILELOCK_DENY_RD)) <0)
+        if ((denyreadset = ad_testlock(adp, eid, AD_FILELOCK_DENY_RD)) <0)
             return denyreadset;
 
         if ((access & OPENACC_RD) && denyreadset) {
@@ -201,21 +175,21 @@ static int fork_setmode(struct adouble *adp, int eid, int access, int ofrefnum)
          * true
          */
         if ((access & OPENACC_RD)) {
-            ret = setforkmode(adp, eid, ofrefnum, AD_FILELOCK_OPEN_RD);
+            ret = ad_lock(adp, eid, ADLOCK_RD | ADLOCK_FILELOCK, AD_FILELOCK_OPEN_RD, 1, ofrefnum);
             if (ret)
                 return ret;
         }
         if ((access & OPENACC_DRD)) {
-            ret = setforkmode(adp, eid, ofrefnum, AD_FILELOCK_DENY_RD);
+            ret = ad_lock(adp, eid, ADLOCK_RD | ADLOCK_FILELOCK, AD_FILELOCK_DENY_RD, 1, ofrefnum);
             if (ret)
                 return ret;
         }
     }
     /* ------------same for writing -------------- */
     if ((access & (OPENACC_WR | OPENACC_DWR))) {
-        if ((writeset = getforkmode(adp, eid, AD_FILELOCK_OPEN_WR)) <0)
+        if ((writeset = ad_testlock(adp, eid, AD_FILELOCK_OPEN_WR)) <0)
             return writeset;
-        if ((denywriteset = getforkmode(adp, eid, AD_FILELOCK_DENY_WR)) <0)
+        if ((denywriteset = ad_testlock(adp, eid, AD_FILELOCK_DENY_WR)) <0)
             return denywriteset;
 
         if ((access & OPENACC_WR) && denywriteset) {
@@ -227,12 +201,12 @@ static int fork_setmode(struct adouble *adp, int eid, int access, int ofrefnum)
             return -1;
         }
         if ((access & OPENACC_WR)) {
-            ret = setforkmode(adp, eid, ofrefnum, AD_FILELOCK_OPEN_WR);
+            ret = ad_lock(adp, eid, ADLOCK_RD | ADLOCK_FILELOCK, AD_FILELOCK_OPEN_WR, 1, ofrefnum);
             if (ret)
                 return ret;
         }
         if ((access & OPENACC_DWR)) {
-            ret = setforkmode(adp, eid, ofrefnum, AD_FILELOCK_DENY_WR);
+            ret = ad_lock(adp, eid, ADLOCK_RD | ADLOCK_FILELOCK, AD_FILELOCK_DENY_WR, 1, ofrefnum);
             if (ret)
                 return ret;
         }
@@ -938,7 +912,7 @@ static int read_fork(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf, si
         /* due to the nature of afp packets, we have to exit if we get
            an error. we can't do this with translation on. */
 #ifdef WITH_SENDFILE
-        if (!(xlate || Debug(obj) )) {
+        if (!(xlate)) {
             int fd;
 
             fd = ad_readfile_init(ofork->of_ad, eid, &offset, 0);
@@ -965,12 +939,6 @@ static int read_fork(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf, si
                 goto afp_read_exit;
 
             offset += *rbuflen;
-#ifdef DEBUG1
-            if (obj->options.flags & OPTION_DEBUG) {
-                printf( "(read) reply: %d, %d\n", *rbuflen, dsi->clientID);
-                bprint(rbuf, *rbuflen);
-            }
-#endif
             /* dsi_read() also returns buffer size of next allocation */
             cc = dsi_read(dsi, rbuf, *rbuflen); /* send it off */
             if (cc < 0)
@@ -1286,12 +1254,6 @@ static int write_fork(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf, s
             return( AFPERR_PARAM );
         }
 
-#ifdef DEBUG1
-        if (obj->options.flags & OPTION_DEBUG) {
-            printf("(write) len: %d\n", *rbuflen);
-            bprint(rbuf, *rbuflen);
-        }
-#endif
         if ((cc = write_file(ofork, eid, offset, rbuf, *rbuflen,
                              xlate)) < 0) {
             *rbuflen = 0;