1 #ifndef _GENLOCK_H_ 2 #define _GENLOCK_H_ 3 4 #ifdef __KERNEL__ 5 6 struct genlock; 7 struct genlock_handle; 8 9 struct genlock_handle *genlock_get_handle(void); 10 struct genlock_handle *genlock_get_handle_fd(int fd); 11 void genlock_put_handle(struct genlock_handle *handle); 12 struct genlock *genlock_create_lock(struct genlock_handle *); 13 struct genlock *genlock_attach_lock(struct genlock_handle *, int fd); 14 int genlock_wait(struct genlock_handle *handle, u32 timeout); 15 /* genlock_release_lock was deprecated */ 16 int genlock_lock(struct genlock_handle *handle, int op, int flags, 17 u32 timeout); 18 #endif 19 20 #define GENLOCK_UNLOCK 0 21 #define GENLOCK_WRLOCK 1 22 #define GENLOCK_RDLOCK 2 23 24 #define GENLOCK_NOBLOCK (1 << 0) 25 #define GENLOCK_WRITE_TO_READ (1 << 1) 26 27 struct genlock_lock { 28 int fd; 29 int op; 30 int flags; 31 int timeout; 32 }; 33 34 #define GENLOCK_IOC_MAGIC 'G' 35 36 #define GENLOCK_IOC_NEW _IO(GENLOCK_IOC_MAGIC, 0) 37 #define GENLOCK_IOC_EXPORT _IOR(GENLOCK_IOC_MAGIC, 1, \ 38 struct genlock_lock) 39 #define GENLOCK_IOC_ATTACH _IOW(GENLOCK_IOC_MAGIC, 2, \ 40 struct genlock_lock) 41 42 /* Deprecated */ 43 #define GENLOCK_IOC_LOCK _IOW(GENLOCK_IOC_MAGIC, 3, \ 44 struct genlock_lock) 45 46 /* Deprecated */ 47 #define GENLOCK_IOC_RELEASE _IO(GENLOCK_IOC_MAGIC, 4) 48 #define GENLOCK_IOC_WAIT _IOW(GENLOCK_IOC_MAGIC, 5, \ 49 struct genlock_lock) 50 #define GENLOCK_IOC_DREADLOCK _IOW(GENLOCK_IOC_MAGIC, 6, \ 51 struct genlock_lock) 52 #endif 53