00001 00023 #ifndef __LXC_LXCLOCK_H 00024 #define __LXC_LXCLOCK_H 00025 00026 #include <fcntl.h> /* For O_* constants */ 00027 #include <sys/stat.h> /* For mode constants */ 00028 #include <sys/file.h> 00029 #include <semaphore.h> 00030 #include <string.h> 00031 #include <time.h> 00032 00033 #define LXC_LOCK_ANON_SEM 1 00034 #define LXC_LOCK_FLOCK 2 00036 // private 00037 00040 struct lxc_lock { 00041 short type; 00042 00043 union { 00044 sem_t *sem; 00045 00046 struct { 00047 int fd; 00048 char *fname; 00049 } f; 00050 } u; 00051 }; 00052 00081 extern struct lxc_lock *lxc_newlock(const char *lxcpath, const char *name); 00082 00099 extern int lxclock(struct lxc_lock *lock, int timeout); 00100 00109 extern int lxcunlock(struct lxc_lock *lock); 00110 00116 extern void lxc_putlock(struct lxc_lock *lock); 00117 00121 extern void process_lock(void); 00122 00126 extern void process_unlock(void); 00127 00128 struct lxc_container; 00129 00137 extern int container_mem_lock(struct lxc_container *c); 00138 00144 extern void container_mem_unlock(struct lxc_container *c); 00145 00154 extern int container_disk_lock(struct lxc_container *c); 00155 00162 extern void container_disk_unlock(struct lxc_container *c); 00163 00164 #endif