genlock.h 1.4 KB

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