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 #ifndef F_OFD_GETLK
15 #define F_OFD_GETLK 36
16 #endif
17 
18 #ifndef F_OFD_SETLK
19 #define F_OFD_SETLK 37
20 #endif
21 
22 #ifndef F_OFD_SETLKW
23 #define F_OFD_SETLKW 38
24 #endif
25 
26 #define LXC_LOCK_ANON_SEM 1
27 #define LXC_LOCK_FLOCK 2
29 /* private */
30 
33 struct lxc_lock {
34  short type;
36  union {
37  sem_t *sem;
39  struct {
40  int fd;
41  char *fname;
42  } f;
43  } u;
44 };
45 
74 extern struct lxc_lock *lxc_newlock(const char *lxcpath, const char *name);
75 
92 extern int lxclock(struct lxc_lock *lock, int timeout);
93 
102 extern int lxcunlock(struct lxc_lock *lock);
103 
109 extern void lxc_putlock(struct lxc_lock *lock);
110 
114 extern void process_lock(void);
115 
119 extern void process_unlock(void);
120 
121 struct lxc_container;
122 
130 extern int container_mem_lock(struct lxc_container *c);
131 
137 extern void container_mem_unlock(struct lxc_container *c);
138 
147 extern int container_disk_lock(struct lxc_container *c);
148 
155 extern void container_disk_unlock(struct lxc_container *c);
156 
157 #ifdef HAVE_ISULAD
158 int container_disk_removelock(struct lxc_container *c);
159 #endif
160 
161 #endif
lxc_lock::type
short type
Definition: lxclock.h:34
lxc_container
Definition: lxccontainer.h:85
lxc_lock::fname
char * fname
Definition: lxclock.h:41
lxc_lock::u
union lxc_lock::@4 u
lxc_lock::f
struct lxc_lock::@4::@5 f
lxc_lock
Definition: lxclock.h:33
lxc_lock::fd
int fd
Definition: lxclock.h:40
lxc_lock::sem
sem_t * sem
Definition: lxclock.h:37