LXC
lxclock.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 
3 #ifndef __LXC_LXCLOCK_H
4 #define __LXC_LXCLOCK_H
5 
6 #include <fcntl.h>
7 #include <semaphore.h>
8 #include <string.h>
9 #include <sys/file.h>
10 #include <sys/stat.h>
11 #include <time.h>
12 #include <unistd.h>
13 
14 #include "compiler.h"
15 
16 #ifndef F_OFD_GETLK
17 #define F_OFD_GETLK 36
18 #endif
19 
20 #ifndef F_OFD_SETLK
21 #define F_OFD_SETLK 37
22 #endif
23 
24 #ifndef F_OFD_SETLKW
25 #define F_OFD_SETLKW 38
26 #endif
27 
28 #define LXC_LOCK_ANON_SEM 1
29 #define LXC_LOCK_FLOCK 2
31 /* private */
32 
35 struct lxc_lock {
36  short type;
38  union {
39  sem_t *sem;
41  struct {
42  int fd;
43  char *fname;
44  } f;
45  } u;
46 };
47 
76 __hidden extern struct lxc_lock *lxc_newlock(const char *lxcpath, const char *name);
77 
94 __hidden extern int lxclock(struct lxc_lock *lock, int timeout);
95 
104 __hidden extern int lxcunlock(struct lxc_lock *lock);
105 
111 __hidden extern void lxc_putlock(struct lxc_lock *lock);
112 
116 __hidden extern void process_lock(void);
117 
121 __hidden extern void process_unlock(void);
122 
123 struct lxc_container;
124 
132 __hidden extern int container_mem_lock(struct lxc_container *c);
133 
139 __hidden extern void container_mem_unlock(struct lxc_container *c);
140 
149 __hidden extern int container_disk_lock(struct lxc_container *c);
150 
157 __hidden extern void container_disk_unlock(struct lxc_container *c);
158 
159 #endif
Definition: lxccontainer.h:50
int fd
Definition: lxclock.h:42
sem_t * sem
Definition: lxclock.h:39
char * fname
Definition: lxclock.h:43
short type
Definition: lxclock.h:36
struct lxc_lock::@4::@5 f
union lxc_lock::@4 u
Definition: lxclock.h:35