]> arthur.barton.de Git - netatalk.git/commitdiff
Start locking using Berkeley db
authorFrank Lahm <franklahm@googlemail.com>
Mon, 7 Feb 2011 11:36:52 +0000 (12:36 +0100)
committerFrank Lahm <franklahm@googlemail.com>
Mon, 7 Feb 2011 11:36:52 +0000 (12:36 +0100)
19 files changed:
configure.in
etc/afpd/afp_dsi.c
etc/afpd/file.c
etc/afpd/fork.c
etc/afpd/fork.h
etc/afpd/main.c
include/atalk/adouble.h
include/atalk/locking.h
include/atalk/rpc.h [new file with mode: 0644]
libatalk/Makefile.am
libatalk/adouble/ad_lock.c
libatalk/adouble/ad_open.c
libatalk/locking/.gitignore [new file with mode: 0644]
libatalk/locking/Makefile.am [new file with mode: 0644]
libatalk/locking/locking.c [new file with mode: 0644]
libatalk/rpc/locking.c
libatalk/util/Makefile.am
libatalk/util/server_ipc.c
libatalk/util/volinfo.c

index bd9febb160639c157c10b3dae89ab1ee49c489b5..81b02430e6f877ccf9fa4e421f9cac4554be0cb7 100644 (file)
@@ -1333,6 +1333,7 @@ AC_OUTPUT([Makefile
        libatalk/cnid/tdb/Makefile
        libatalk/compat/Makefile
        libatalk/dsi/Makefile
+       libatalk/locking/Makefile
        libatalk/nbp/Makefile
        libatalk/netddp/Makefile
        libatalk/rpc/Makefile
index 963a291244bcf8b55d0d5a5fb6064c815ae2d6c2..37a817a8fc30bd1543cf4ad39c7aaecfe9b16e4f 100644 (file)
@@ -30,6 +30,7 @@
 #include <atalk/dsi.h>
 #include <atalk/compat.h>
 #include <atalk/util.h>
+#include <atalk/locking.h>
 
 #include "globals.h"
 #include "switch.h"
index 706577067b5a98ab839202ec712c587b177f7f5f..266b5c7567f384c77864328ccd3139c7bdf4322f 100644 (file)
@@ -1253,8 +1253,8 @@ int afp_copyfile(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf _U_, si
     if (ad_open(adp, s_path->u_name, ADFLAGS_DF | ADFLAGS_HF | ADFLAGS_NOHF, O_RDONLY, O_RDONLY) < 0) {
         return AFPERR_DENYCONF;
     }
-    denyreadset = (getforkmode(adp, ADEID_DFORK, AD_FILELOCK_DENY_RD) != 0 || 
-                  getforkmode(adp, ADEID_RFORK, AD_FILELOCK_DENY_RD) != 0 );
+    denyreadset = (ad_testlock(adp, ADEID_DFORK, AD_FILELOCK_DENY_RD) != 0 || 
+                  ad_testlock(adp, ADEID_RFORK, AD_FILELOCK_DENY_RD) != 0 );
 
     if (denyreadset) {
         retvalue = AFPERR_DENYCONF;
index 889b7ac278287d1cf88ff517ef35869613d15f3f..eb18fd3373109d5c3b72fc1a8ea06e0f5b510cb8 100644 (file)
@@ -96,7 +96,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 +117,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 +137,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 +151,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 +160,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 +181,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 +207,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;
         }
index 151ffcf554062014ba1df388f82f7471a5dd0f58..837cb98f75806b2c634ac79e789c802859a1fac0 100644 (file)
@@ -79,7 +79,6 @@ extern int of_fstatat(int dirfd, struct path *path);
 
 /* in fork.c */
 extern int          flushfork    (struct ofork *);
-extern int          getforkmode  (struct adouble *, int , int );
 
 /* FP functions */
 int afp_openfork (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf,  size_t *rbuflen);
index 8c30392b6ea284118969f5f49462f7285b826b4d..ff1f2a54dbc0965e6875d065e57e6fb04b7b4e54 100644 (file)
@@ -273,8 +273,12 @@ int main(int ac, char **av)
 
     /* Initialize */
     cnid_init();
+    if (locktable_init() != 0)
+        afp_exit(EXITERR_SYS);
+#if 0
     if (rpc_init("127.0.0.1", 4701) != 0)
         afp_exit(EXITERR_SYS);
+#endif
     
     /* watch atp, dsi sockets and ipc parent/child file descriptor. */
     if ((ipc = server_ipc_create())) {
index eac8be144cc7ecfec168d5b809b3a67edddb9f9a..b936b5dd96b27c80220fa9b106a9223181cb3f8c 100644 (file)
@@ -355,28 +355,13 @@ extern int ad_flush (struct adouble *);
 extern int ad_close (struct adouble *, int);
 
 /* ad_lock.c */
-extern int ad_fcntl_lock    (struct adouble *, const u_int32_t /*eid*/,
-                                 const int /*type*/, const off_t /*offset*/,
-                                 const off_t /*len*/, const int /*user*/);
-extern void ad_fcntl_unlock (struct adouble *, const int /*user*/);
-extern int ad_fcntl_tmplock (struct adouble *, const u_int32_t /*eid*/,
-                                 const int /*type*/, const off_t /*offset*/,
-                                 const off_t /*len*/, const int /*user*/);
-extern int ad_testlock      (struct adouble * /*adp*/, int /*eid*/, off_t /*off*/);
-
-extern u_int16_t ad_openforks (struct adouble * /*adp*/, u_int16_t);
-extern int ad_excl_lock     (struct adouble * /*adp*/, const u_int32_t /*eid*/);
-
-#if 0
-#define ad_lock ad_fcntl_lock
-#define ad_tmplock ad_fcntl_tmplock
-#define ad_unlock ad_fcntl_unlock
-#endif
-
-#define ad_lock rpc_lock
-#define ad_tmplock rpc_tmplock
-#define ad_unlock rpc_unlock
+extern int ad_testlock      (struct adouble *adp, int eid, off_t off);
+extern uint16_t ad_openforks(struct adouble *adp, uint16_t);
+extern int ad_excl_lock     (struct adouble *adp, uint32_t eid);
 
+extern int ad_lock(struct adouble *, uint32_t eid, int type, off_t off, off_t len, int user);
+extern void ad_unlock(struct adouble *, int user);
+extern int ad_tmplock(struct adouble *, uint32_t eid, int type, off_t off, off_t len, int user);
 
 /* ad_open.c */
 extern const char *oflags2logstr(int oflags);
index e1c1303aaeb6d0459118c3719357b46460307cc8..5c427c40c21df40e35b70b869339c0c62759566d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010 Frank Lahm
+ * Copyright (c) 2011 Frank Lahm
  * All Rights Reserved.  See COPYRIGHT.
  */
 
 #include <sys/types.h>
 #include <inttypes.h>
 
-#include <atalk/lockrpc.gen.h>
-
-#include "event2/event.h"
-#include "event2/http.h"
-#include "event2/rpc.h"
-
-struct adouble;
-
-extern int rpc_init(const char *addr, unsigned short port);
-extern int rpc_lock(struct adouble *, uint32_t eid, int type, off_t off, off_t len, int user);
-extern void rpc_unlock(struct adouble *, int user);
-extern int rpc_tmplock(struct adouble *, uint32_t eid, int type, off_t off, off_t len, int user);
-
+extern int locktable_init(void);
 
 #endif  /* ATALK_LOCKING_H */
diff --git a/include/atalk/rpc.h b/include/atalk/rpc.h
new file mode 100644 (file)
index 0000000..00a385d
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2011 Frank Lahm
+ * All Rights Reserved.  See COPYRIGHT.
+ */
+
+#ifndef ATALK_RPC_H
+#define ATALK_RPC_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <sys/types.h>
+#include <inttypes.h>
+
+#include <atalk/lockrpc.gen.h>
+
+#include "event2/event.h"
+#include "event2/http.h"
+#include "event2/rpc.h"
+
+struct adouble;
+extern int rpc_init(const char *addr, unsigned short port);
+extern int rpc_lock(struct adouble *, uint32_t eid, int type, off_t off, off_t len, int user);
+extern void rpc_unlock(struct adouble *, int user);
+extern int rpc_tmplock(struct adouble *, uint32_t eid, int type, off_t off, off_t len, int user);
+
+#endif  /* ATALK_RPC_H */
index 5e95bfcb3ca8577d9acf62cf5bfab0bbcc33c3a8..10dd59a0bbe8a1e0372e360c7f7d14e14d4657ef 100644 (file)
@@ -2,7 +2,7 @@
 # Makefile.am for libatalk/
 
 # rpc should be first because it generates RPC headers included elsewhere
-SUBDIRS = rpc acl adouble bstring compat cnid dsi tdb util unicode vfs
+SUBDIRS = rpc acl adouble bstring compat cnid dsi locking tdb util unicode vfs
 
 lib_LTLIBRARIES = libatalk.la
 
@@ -14,6 +14,7 @@ libatalk_la_LIBADD  = \
        bstring/libbstring.la \
        compat/libcompat.la     \
        dsi/libdsi.la           \
+       locking/liblocking.la           \
        rpc/librpc.la           \
        tdb/libtdb.la       \
        unicode/libunicode.la \
@@ -27,6 +28,7 @@ libatalk_la_DEPENDENCIES = \
        bstring/libbstring.la \
        compat/libcompat.la     \
        dsi/libdsi.la           \
+       locking/liblocking.la           \
        rpc/librpc.la           \
        tdb/libtdb.la       \
        unicode/libunicode.la \
index 28b53b12edddc66842dfcf10e0fd79d2464b50e9..40ffd1407a2eb8a100bdb74269f194113aa604fd 100644 (file)
@@ -269,8 +269,8 @@ int start = off;
 }
 
 /* ------------------ */
-int ad_fcntl_lock(struct adouble *ad, const u_int32_t eid, const int locktype,
-                  const off_t off, const off_t len, const int fork)
+static int ad_fcntl_lock(struct adouble *ad, const u_int32_t eid, const int locktype,
+                         const off_t off, const off_t len, const int fork)
 {
 #if 0
   struct flock lock;
@@ -457,6 +457,94 @@ static int testlock(struct ad_fd *adf, off_t off, off_t len)
   return 0;
 }
 
+
+/* -------------------------
+*/
+static int ad_fcntl_tmplock(struct adouble *ad, const u_int32_t eid, const int locktype,
+                            const off_t off, const off_t len, const int fork)
+{
+  struct flock lock;
+  struct ad_fd *adf;
+  int err;
+  int type;  
+
+  lock.l_start = off;
+  type = locktype;
+  if (eid == ADEID_DFORK) {
+    adf = &ad->ad_data_fork;
+  } else {
+    /* FIXME META */
+    adf = &ad->ad_resource_fork;
+    if (adf->adf_fd == -1) {
+        /* there's no resource fork. return success */
+        return 0;
+    }
+    /* if ADLOCK_FILELOCK we want a lock from offset 0
+     * it's used when deleting a file:
+     * in open we put read locks on meta datas
+     * in delete a write locks on the whole file
+     * so if the file is open by somebody else it fails
+    */
+    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;
+
+  /* see if it's locked by another fork. */
+  if (fork && adf_findxlock(adf, fork, ADLOCK_WR | 
+                   ((type & ADLOCK_WR) ? ADLOCK_RD : 0), 
+                   lock.l_start, lock.l_len) > -1) {
+    errno = EACCES;
+    return -1;
+  }
+
+  /* okay, we might have ranges byte-locked. we need to make sure that
+   * we restore the appropriate ranges once we're done. so, we check
+   * for overlap on an unlock and relock. 
+   * XXX: in the future, all the byte locks will be sorted and contiguous.
+   *      we just want to upgrade all the locks and then downgrade them
+   *      here. */
+  if (!adf->adf_excl) {
+       err = set_lock(adf->adf_fd, F_SETLK, &lock);
+  }
+  else {
+      err = 0;
+  }
+  if (!err && (lock.l_type == F_UNLCK))
+    adf_relockrange(adf, adf->adf_fd, lock.l_start, len);
+
+  return err;
+}
+
+/* --------------------- */
+static void ad_fcntl_unlock(struct adouble *ad, const int fork)
+{
+  if (ad_data_fileno(ad) != -1) {
+    adf_unlock(&ad->ad_data_fork, fork);
+  }
+  if (ad_reso_fileno(ad) != -1) {
+    adf_unlock(&ad->ad_resource_fork, fork);
+  }
+
+  if (ad->ad_flags != AD_VERSION_EA) {
+    return;
+  }
+  if (ad_meta_fileno(ad) != -1) {
+    adf_unlock(&ad->ad_metadata_fork, fork);
+  }
+}
+
+/******************************************************************************
+ * Public functions
+ ******************************************************************************/
+
 /* --------------- */
 int ad_testlock(struct adouble *ad, int eid, const off_t off)
 {
@@ -491,7 +579,7 @@ int ad_testlock(struct adouble *ad, int eid, const off_t off)
    - there's no locks held by another process (clients)
    - or we already know the answer and don't need to test.
 */
-u_int16_t ad_openforks(struct adouble *ad, u_int16_t attrbits)
+uint16_t ad_openforks(struct adouble *ad, u_int16_t attrbits)
 {
     return 0;
 #if 0
@@ -549,74 +637,6 @@ u_int16_t ad_openforks(struct adouble *ad, u_int16_t attrbits)
 #endif
 }
 
-/* -------------------------
-*/
-int ad_fcntl_tmplock(struct adouble *ad, const u_int32_t eid, const int locktype,
-                    const off_t off, const off_t len, const int fork)
-{
-    return 0;
-#if 0
-  struct flock lock;
-  struct ad_fd *adf;
-  int err;
-  int type;  
-
-  lock.l_start = off;
-  type = locktype;
-  if (eid == ADEID_DFORK) {
-    adf = &ad->ad_data_fork;
-  } else {
-    /* FIXME META */
-    adf = &ad->ad_resource_fork;
-    if (adf->adf_fd == -1) {
-        /* there's no resource fork. return success */
-        return 0;
-    }
-    /* if ADLOCK_FILELOCK we want a lock from offset 0
-     * it's used when deleting a file:
-     * in open we put read locks on meta datas
-     * in delete a write locks on the whole file
-     * so if the file is open by somebody else it fails
-    */
-    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;
-
-  /* see if it's locked by another fork. */
-  if (fork && adf_findxlock(adf, fork, ADLOCK_WR | 
-                   ((type & ADLOCK_WR) ? ADLOCK_RD : 0), 
-                   lock.l_start, lock.l_len) > -1) {
-    errno = EACCES;
-    return -1;
-  }
-
-  /* okay, we might have ranges byte-locked. we need to make sure that
-   * we restore the appropriate ranges once we're done. so, we check
-   * for overlap on an unlock and relock. 
-   * XXX: in the future, all the byte locks will be sorted and contiguous.
-   *      we just want to upgrade all the locks and then downgrade them
-   *      here. */
-  if (!adf->adf_excl) {
-       err = set_lock(adf->adf_fd, F_SETLK, &lock);
-  }
-  else {
-      err = 0;
-  }
-  if (!err && (lock.l_type == F_UNLCK))
-    adf_relockrange(adf, adf->adf_fd, lock.l_start, len);
-
-  return err;
-#endif
-}
-
 /* -------------------------
    the fork is opened in Read Write, Deny Read, Deny Write mode
    lock the whole file once   
@@ -648,23 +668,17 @@ int ad_excl_lock(struct adouble *ad, const u_int32_t eid)
 #endif
 }
 
-/* --------------------- */
-void ad_fcntl_unlock(struct adouble *ad, const int fork)
+int ad_lock(struct adouble *ad, uint32_t eid, int type, off_t off, off_t len, int user)
 {
-    return;
-#if 0
-  if (ad_data_fileno(ad) != -1) {
-    adf_unlock(&ad->ad_data_fork, fork);
-  }
-  if (ad_reso_fileno(ad) != -1) {
-    adf_unlock(&ad->ad_resource_fork, fork);
-  }
+    return 0;
+}
 
-  if (ad->ad_flags != AD_VERSION_EA) {
+void ad_unlock(struct adouble *ad, int user)
+{
     return;
-  }
-  if (ad_meta_fileno(ad) != -1) {
-    adf_unlock(&ad->ad_metadata_fork, fork);
-  }
-#endif
+}
+
+int ad_tmplock(struct adouble *ad, uint32_t eid, int type, off_t off, off_t len, int user)
+{
+    return 0;
 }
index 00b0ad241543d0a6105fb4bd29819409a1a6dd72..8c47232002da4f5c6d9447063178bb5f761e7ad8 100644 (file)
@@ -49,6 +49,7 @@
 #include <atalk/ea.h>
 #include <atalk/bstrlib.h>
 #include <atalk/bstradd.h>
+#include <atalk/compat.h>
 
 #include "ad_lock.h"
 
diff --git a/libatalk/locking/.gitignore b/libatalk/locking/.gitignore
new file mode 100644 (file)
index 0000000..604ff3c
--- /dev/null
@@ -0,0 +1,7 @@
+Makefile
+Makefile.in
+*.lo
+*.la
+.deps
+.libs
+
diff --git a/libatalk/locking/Makefile.am b/libatalk/locking/Makefile.am
new file mode 100644 (file)
index 0000000..8d2fda6
--- /dev/null
@@ -0,0 +1,5 @@
+# Makefile.am for libatalk/locking/
+
+noinst_LTLIBRARIES = liblocking.la
+
+liblocking_la_SOURCES = locking.c
diff --git a/libatalk/locking/locking.c b/libatalk/locking/locking.c
new file mode 100644 (file)
index 0000000..c19f27c
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2011 Frank Lahm
+ * All Rights Reserved.  See COPYRIGHT.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <pthread.h>
+
+#include <atalk/logger.h>
+#include <atalk/errchk.h>
+#include <atalk/locking.h>
+#include <atalk/cnid.h>
+#define AFP_LOCKTABLE_SIZE (8*1024*1024)
+
+/* 
+ * Struct for building the the main database of file locks.
+ * vid + cnid build the primary key for database access.
+ */
+struct afp_lock {
+    /* Keys */
+    uint32_t vid;
+    cnid_t cnid;
+
+    /* Refcounting access and deny modes */
+    uint16_t amode_r;
+    uint16_t amode_w;
+    uint16_t dmode_r;
+    uint16_t dmode_w;
+};
+
+/* 
+ * Structure for building a table which provides the way to find locks by pid
+ */
+struct pid_lock {
+    /* Key */
+    pid_t pid;
+
+    /* Key for afp_lock */
+    uint32_t vid;
+    cnid_t cnid;
+};
+
+/***************************************************************************
+ * Public functios
+ ***************************************************************************/
+
+int locktable_init(void)
+{
+    EC_INIT;
+
+
+EC_CLEANUP:
+    EC_EXIT;
+}
+
index ce43520aff40f9b6f15ee20f2968b4f0bbf4d47b..62a1b227c5b7ca3d2343a7a58917f279eeb7c42a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010 Frank Lahm
+ * Copyright (c) 2011 Frank Lahm
  * All Rights Reserved.  See COPYRIGHT.
  */
 
 #include <stdio.h>
 #include <string.h>
 #include <errno.h>
+#include <pthread.h>
+
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>
 
 #include "event2/event-config.h"
 
@@ -28,6 +33,7 @@
 #include <atalk/adouble.h>
 #include <atalk/bstrlib.h>
 #include <atalk/bstradd.h>
+#include <atalk/lockrpc.gen.h>
 
 EVRPC_HEADER(lock_msg, lock_req, lock_rep)
 EVRPC_GENERATE(lock_msg, lock_req, lock_rep)
@@ -52,7 +58,7 @@ done:
     event_base_loopexit(ev_base, NULL);
 }
 
-static void rpc_dummy(const char *name)
+static int rpc_dummy(const char *name)
 {
     struct lock *lock = NULL;
        struct lock_req *lock_req = NULL;
@@ -94,6 +100,7 @@ int rpc_tmplock(struct adouble *ad, uint32_t eid, int type, off_t off, off_t len
 int rpc_init(const char *addr, unsigned short port)
 {
     EC_INIT;
+
     struct evhttp_connection *evcon;
 
     EC_NULL_LOG(ev_base = event_init());
index 0afd6fc8e961971ddfe8b785d05c3133df64c535..9b5938f8c0a22a61b4af3f470b707aa679a960d9 100644 (file)
@@ -1,5 +1,7 @@
 # Makefile.am for libatalk/util/
 
+pkgconfdir = @PKGCONFDIR@
+
 noinst_LTLIBRARIES = libutil.la
 
 libutil_la_SOURCES = \
@@ -17,5 +19,7 @@ libutil_la_SOURCES = \
        server_lock.c   \
        socket.c        \
        strdicasecmp.c  \
-       volinfo.c \
+       volinfo.c       \
        unix.c
+
+libutil_la_CFLAGS = -D_PATH_AFPDCONF=\"$(pkgconfdir)/afpd.conf\"
\ No newline at end of file
index 289197fb7ac89a76c2da7e0cd91a3abfa2527e96..45230a29694b34f4ce2c8c70500afad023960d38 100644 (file)
@@ -1,10 +1,5 @@
 /*
- * $Id: server_ipc.c,v 1.4 2010-01-21 14:14:49 didg Exp $
- *
  * All rights reserved. See COPYRIGHT.
- *
- *
- * ipc between parent and children.
  */
 
 #ifdef HAVE_CONFIG_H
 #endif 
 
 #include <sys/types.h>
-#ifdef HAVE_UNISTD_H
 #include <unistd.h>
-#endif 
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#include <errno.h>
 
 #include <atalk/server_child.h>
 #include <atalk/server_ipc.h>
@@ -207,4 +203,3 @@ int server_ipc_write( u_int16_t command, int len, void *msg)
    LOG (log_debug, logtype_afpd, "ipc_write: command: %u, pid: %u, msglen: %u", command, pid, len); 
    return write(pipe_fd[1], block, len+IPC_HEADERLEN );
 }
-
index ef7847a301d532be049798cf875f895258962713..9096412d8b250dec6631e43e41ae45e42cf55b62 100644 (file)
@@ -35,6 +35,7 @@
 #include <atalk/logger.h>
 #include <atalk/volinfo.h>
 #include <atalk/volume.h>
+#include <atalk/compat.h>
 #ifdef CNID_DB
 #include <atalk/cnid.h>
 #endif /* CNID_DB*/