LXC
lxclock.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 
3 #ifndef __LXC_LXCLOCK_H
4 #define __LXC_LXCLOCK_H
5 
6 #include "config.h"
7 
8 #include <fcntl.h>
9 #include <semaphore.h>
10 #include <string.h>
11 #include <sys/file.h>
12 #include <sys/stat.h>
13 #include <time.h>
14 #include <unistd.h>
15 
16 #include "compiler.h"
17 
18 #ifndef F_OFD_GETLK
19 #define F_OFD_GETLK 36
20 #endif
21 
22 #ifndef F_OFD_SETLK
23 #define F_OFD_SETLK 37
24 #endif
25 
26 #ifndef F_OFD_SETLKW
27 #define F_OFD_SETLKW 38
28 #endif
29 
30 #define LXC_LOCK_ANON_SEM 1
31 #define LXC_LOCK_FLOCK 2
33 /* private */
34 
37 struct lxc_lock {
38  short type;
40  union {
41  sem_t *sem;
43  struct {
44  int fd;
45  char *fname;
46  } f;
47  } u;
48 };
49 
78 __hidden extern struct lxc_lock *lxc_newlock(const char *lxcpath, const char *name);
79 
96 __hidden extern int lxclock(struct lxc_lock *lock, int timeout);
97 
106 __hidden extern int lxcunlock(struct lxc_lock *lock);
107 
113 __hidden extern void lxc_putlock(struct lxc_lock *lock);
114 
118 __hidden extern void process_lock(void);
119 
123 __hidden extern void process_unlock(void);
124 
125 struct lxc_container;
126 
134 __hidden extern int container_mem_lock(struct lxc_container *c);
135 
141 __hidden extern void container_mem_unlock(struct lxc_container *c);
142 
151 __hidden extern int container_disk_lock(struct lxc_container *c);
152 
159 __hidden extern void container_disk_unlock(struct lxc_container *c);
160 
161 #endif
Definition: lxccontainer.h:50
int fd
Definition: lxclock.h:44
sem_t * sem
Definition: lxclock.h:41
char * fname
Definition: lxclock.h:45
short type
Definition: lxclock.h:38
struct lxc_lock::@4::@5 f
union lxc_lock::@4 u
Definition: lxclock.h:37