]> arthur.barton.de Git - netatalk.git/blob - libatalk/locking/locking.c
Big configure.in cleanup
[netatalk.git] / libatalk / locking / locking.c
1 /*
2  * Copyright (c) 2011 Frank Lahm
3  * All Rights Reserved.  See COPYRIGHT.
4  */
5
6 #ifdef HAVE_CONFIG_H
7 #include "config.h"
8 #endif /* HAVE_CONFIG_H */
9
10 #include <stdlib.h>
11 #include <stdio.h>
12 #include <string.h>
13 #include <errno.h>
14 #include <unistd.h>
15
16 #include <atalk/logger.h>
17 #include <atalk/errchk.h>
18 #include <atalk/locking.h>
19 #include <atalk/cnid.h>
20 #include <atalk/paths.h>
21
22 #include "smb_share_modes.h"
23
24 /***************************************************************************
25  * structures and defines
26  ***************************************************************************/
27
28 #define LOCKTABLE_PATH         "/tmp/netatalk-afp-locks.tdb" 
29
30 /* 
31  * Struct for building the the main database of file locks.
32  * vid + cnid build the primary key for database access.
33  */
34 typedef struct afp_lock {
35     /* Keys */
36     uint32_t l_vid;
37     cnid_t   l_cnid;
38     uint64_t l_dev;
39     uint64_t l_ino;
40
41     /* pid holding the lock, also secondary key */
42     pid_t    l_pid;
43
44     /* Refcounting access and deny modes */
45     uint16_t l_amode_r;
46     uint16_t l_amode_w;
47     uint16_t l_dmode_r;
48     uint16_t l_dmode_w;
49 } afp_lock_t;
50
51 #define PACKED_AFP_LOCK_SIZE                 \
52     sizeof(((afp_lock_t *)0)->l_vid) +       \
53     sizeof(((afp_lock_t *)0)->l_cnid) +      \
54     sizeof(((afp_lock_t *)0)->l_dev) +       \
55     sizeof(((afp_lock_t *)0)->l_ino) +       \
56     sizeof(((afp_lock_t *)0)->l_pid) +       \
57     sizeof(((afp_lock_t *)0)->l_amode_r) +   \
58     sizeof(((afp_lock_t *)0)->l_amode_w) +   \
59     sizeof(((afp_lock_t *)0)->l_dmode_r) +   \
60     sizeof(((afp_lock_t *)0)->l_dmode_r)
61
62 /***************************************************************************
63  * Data
64  ***************************************************************************/
65
66 static struct smbdb_ctx *tdb;
67
68 /***************************************************************************
69  * Private functions
70  ***************************************************************************/
71
72 /***************************************************************************
73  * Public functions
74  ***************************************************************************/
75
76 /*!
77  * Open locktable from path
78  */
79 int locktable_init(const char *path)
80 {
81     EC_INIT;
82
83     EC_NULL_LOG(tdb = smb_share_mode_db_open(path));
84
85 EC_CLEANUP:
86     EC_EXIT;
87 }
88