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 */
33struct 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
74extern struct lxc_lock *lxc_newlock(const char *lxcpath, const char *name);
75
92extern int lxclock(struct lxc_lock *lock, int timeout);
93
102extern int lxcunlock(struct lxc_lock *lock);
103
109extern void lxc_putlock(struct lxc_lock *lock);
110
114extern void process_lock(void);
115
119extern void process_unlock(void);
120
121struct lxc_container;
122
130extern int container_mem_lock(struct lxc_container *c);
131
137extern void container_mem_unlock(struct lxc_container *c);
138
147extern int container_disk_lock(struct lxc_container *c);
148
155extern void container_disk_unlock(struct lxc_container *c);
156
157#ifdef HAVE_ISULAD
158int container_disk_removelock(struct lxc_container *c);
159#endif
160
161#endif
Definition: lxccontainer.h:94
Definition: lxclock.h:33
union lxc_lock::@4 u
int fd
Definition: lxclock.h:40
sem_t * sem
Definition: lxclock.h:37
struct lxc_lock::@4::@5 f
char * fname
Definition: lxclock.h:41
short type
Definition: lxclock.h:34