]> arthur.barton.de Git - netatalk.git/blob - libatalk/locking/locking.c
Merge remote branch 'netafp/master' into branch-allea
[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 /***************************************************************************
23  * structures and defines
24  ***************************************************************************/
25
26 #define LOCKTABLE_PATH         "/tmp/netatalk-afp-locks.tdb" 
27
28 /* 
29  * Struct for building the the main database of file locks.
30  * vid + cnid build the primary key for database access.
31  */
32 typedef struct afp_lock {
33     /* Keys */
34     uint32_t l_vid;
35     cnid_t   l_cnid;
36     uint64_t l_dev;
37     uint64_t l_ino;
38
39     /* pid holding the lock, also secondary key */
40     pid_t    l_pid;
41
42     /* Refcounting access and deny modes */
43     uint16_t l_amode_r;
44     uint16_t l_amode_w;
45     uint16_t l_dmode_r;
46     uint16_t l_dmode_w;
47 } afp_lock_t;
48
49 #define PACKED_AFP_LOCK_SIZE                 \
50     sizeof(((afp_lock_t *)0)->l_vid) +       \
51     sizeof(((afp_lock_t *)0)->l_cnid) +      \
52     sizeof(((afp_lock_t *)0)->l_dev) +       \
53     sizeof(((afp_lock_t *)0)->l_ino) +       \
54     sizeof(((afp_lock_t *)0)->l_pid) +       \
55     sizeof(((afp_lock_t *)0)->l_amode_r) +   \
56     sizeof(((afp_lock_t *)0)->l_amode_w) +   \
57     sizeof(((afp_lock_t *)0)->l_dmode_r) +   \
58     sizeof(((afp_lock_t *)0)->l_dmode_r)
59
60 /***************************************************************************
61  * Data
62  ***************************************************************************/
63
64 static struct smbdb_ctx *tdb;
65
66 /***************************************************************************
67  * Private functions
68  ***************************************************************************/
69
70 /***************************************************************************
71  * Public functions
72  ***************************************************************************/
73
74 /*!
75  * Open locktable from path
76  */
77 int locktable_init(const char *path)
78 {
79     EC_INIT;
80
81 //    EC_NULL_LOG(tdb = smb_share_mode_db_open(path));
82
83 EC_CLEANUP:
84     EC_EXIT;
85 }
86