LXC
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
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> /* For O_* constants */
27 #include <sys/stat.h> /* For mode constants */
28 #include <sys/file.h>
29 #include <semaphore.h>
30 #include <string.h>
31 #include <time.h>
32 
33 #define LXC_LOCK_ANON_SEM 1
34 #define LXC_LOCK_FLOCK 2
36 // private
37 
40 struct lxc_lock {
41  short type;
42 
43  union {
44  sem_t *sem;
45 
46  struct {
47  int fd;
48  char *fname;
49  } f;
50  } u;
51 };
52 
80 extern struct lxc_lock *lxc_newlock(const char *lxcpath, const char *name);
81 
97 extern int lxclock(struct lxc_lock *lock, int timeout);
98 
107 extern int lxcunlock(struct lxc_lock *lock);
108 
114 extern void lxc_putlock(struct lxc_lock *lock);
115 
119 extern void process_lock(void);
120 
124 extern void process_unlock(void);
125 
126 struct lxc_container;
127 
135 extern int container_mem_lock(struct lxc_container *c);
136 
142 extern void container_mem_unlock(struct lxc_container *c);
143 
152 extern int container_disk_lock(struct lxc_container *c);
153 
157 extern void container_disk_unlock(struct lxc_container *c);
158 
159 #endif
Definition: lxccontainer.h:59
void container_disk_unlock(struct lxc_container *c)
Unlock the containers disk data.
union lxc_lock::@2 u
Container for lock type elements.
int fd
fd on which a lock is held (if not -1)
Definition: lxclock.h:47
sem_t * sem
Anonymous semaphore (LXC_LOCK_ANON_SEM)
Definition: lxclock.h:44
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
Name of lock.
Definition: lxclock.h:48
short type
Lock type.
Definition: lxclock.h:41
struct lxc_lock::@2::@3 f
void container_mem_unlock(struct lxc_container *c)
Unlock the containers memory.
Definition: lxclock.h:40
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().