LXC
lxclock.h
Go to the documentation of this file.
1 
23 #ifndef __LXC_LXCLOCK_H
24 #define __LXC_LXCLOCK_H
25 
26 #include <fcntl.h>
27 #include <semaphore.h>
28 #include <string.h>
29 #include <sys/file.h>
30 #include <sys/stat.h>
31 #include <time.h>
32 #include <unistd.h>
33 
34 #ifndef F_OFD_GETLK
35 #define F_OFD_GETLK 36
36 #endif
37 
38 #ifndef F_OFD_SETLK
39 #define F_OFD_SETLK 37
40 #endif
41 
42 #ifndef F_OFD_SETLKW
43 #define F_OFD_SETLKW 38
44 #endif
45 
46 #define LXC_LOCK_ANON_SEM 1
47 #define LXC_LOCK_FLOCK 2
49 /* private */
50 
53 struct lxc_lock {
54  short type;
56  union {
57  sem_t *sem;
59  struct {
60  int fd;
61  char *fname;
62  } f;
63  } u;
64 };
65 
94 extern struct lxc_lock *lxc_newlock(const char *lxcpath, const char *name);
95 
112 extern int lxclock(struct lxc_lock *lock, int timeout);
113 
122 extern int lxcunlock(struct lxc_lock *lock);
123 
129 extern void lxc_putlock(struct lxc_lock *lock);
130 
134 extern void process_lock(void);
135 
139 extern void process_unlock(void);
140 
141 struct lxc_container;
142 
150 extern int container_mem_lock(struct lxc_container *c);
151 
157 extern void container_mem_unlock(struct lxc_container *c);
158 
167 extern int container_disk_lock(struct lxc_container *c);
168 
175 extern void container_disk_unlock(struct lxc_container *c);
176 
177 #endif
Definition: lxccontainer.h:69
void container_disk_unlock(struct lxc_container *c)
Unlock the containers disk data.
int fd
Definition: lxclock.h:60
sem_t * sem
Definition: lxclock.h:57
int container_disk_lock(struct lxc_container *c)
Lock the containers disk data.
struct lxc_lock * lxc_newlock(const char *lxcpath, const char *name)
Create a new (unlocked) lock.
char * fname
Definition: lxclock.h:61
short type
Definition: lxclock.h:54
struct lxc_lock::@4::@5 f
union lxc_lock::@4 u
void container_mem_unlock(struct lxc_container *c)
Unlock the containers memory.
Definition: lxclock.h:53
void process_unlock(void)
Unlock the current process.
int container_mem_lock(struct lxc_container *c)
Lock the containers memory.
void process_lock(void)
Lock the current process.
int lxclock(struct lxc_lock *lock, int timeout)
Take an existing lock.
int lxcunlock(struct lxc_lock *lock)
Unlock specified lock previously locked using lxclock().
void lxc_putlock(struct lxc_lock *lock)
Free a lock created by lxc_newlock().