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 00080 extern struct lxc_lock *lxc_newlock(const char *lxcpath, const char *name); 00081 00097 extern int lxclock(struct lxc_lock *lock, int timeout); 00098 00107 extern int lxcunlock(struct lxc_lock *lock); 00108 00114 extern void lxc_putlock(struct lxc_lock *lock); 00115 00119 extern void process_lock(void); 00120 00124 extern void process_unlock(void); 00125 00126 struct lxc_container; 00127 00135 extern int container_mem_lock(struct lxc_container *c); 00136 00142 extern void container_mem_unlock(struct lxc_container *c); 00143 00152 extern int container_disk_lock(struct lxc_container *c); 00153 00157 extern void container_disk_unlock(struct lxc_container *c); 00158 00159 #endif