Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

94 lines
2.4 KiB

  1. #ifndef _DLM_H
  2. #define _DLM_H
  3. #define DLM_VERSION 1
  4. #define DLM_VBLK_SZ 32
  5. typedef HANDLE dlm_lockid_t;
  6. typedef UCHAR dlm_nodeid_t;
  7. typedef CHAR dlm_mode_t;
  8. typedef HANDLE dlm_lockval_t;
  9. typedef HANDLE dlm_cevent_t;
  10. typedef HANDLE dlm_bevent_t;
  11. typedef char dlm_vblk[DLM_VBLK_SZ];
  12. typedef dlm_vblk *dlm_vblk_t;
  13. typedef enum {
  14. DLM_MODE_INVAL = -1,
  15. DLM_MODE_NL = 0,
  16. DLM_MODE_CR = 1,
  17. DLM_MODE_CW = 2,
  18. DLM_MODE_PR = 3,
  19. DLM_MODE_PW = 4,
  20. DLM_MODE_EX = 5
  21. }dlm_mode_type_t;
  22. #define DLM_ERROR_SUCCESS 0
  23. #define DLM_ERROR_GRANTED 0
  24. #define DLM_ERROR_QUEUED 1
  25. #define DLM_ERROR_CANCELED 2
  26. #define DLM_ERROR_BADID 11
  27. #define DLM_ERROR_NOMEM 12
  28. #define DLM_ERROR_BADMODE 13
  29. #define DLM_ERROR_NOOP 15
  30. #define DLM_ERROR_WOULDBLOCK 16
  31. #define DLM_ERROR_INVAL 17
  32. #define DLM_ERROR_INVALOP 18
  33. #define DLM_ERROR_LOCKWAIT 19
  34. #define DLM_ERROR_BUSY 20
  35. #define DLM_ERROR_NOTOWNER 21
  36. // List of DLM supported Flags
  37. #define DLM_FLAGS_FASTLOCK 0x0001 // issue convert without fairness
  38. #define DLM_FLAGS_TRYLOCK 0x0002 // if can't get it, don't bother
  39. #define DLM_FLAGS_ASYNC 0x0004 // don't block
  40. #define DLM_FLAGS_EVBLOCK 0x0008 // register callback/event on this lock
  41. #define DLM_FLAGS_VBIO 0x0010 // rw value block
  42. #define DLM_FLAGS_VBIV 0x0020 // invalidate value block
  43. // *** from WDM.H (apps can't be expected to have this defined) ***
  44. typedef ULONG NTSTATUS;
  45. typedef struct _IO_STATUS_BLOCK {
  46. union {
  47. NTSTATUS Status;
  48. PVOID Pointer;
  49. };
  50. ULONG_PTR Information;
  51. } IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
  52. typedef
  53. VOID
  54. (NTAPI *PIO_APC_ROUTINE) (
  55. IN PVOID ApcContext,
  56. IN PIO_STATUS_BLOCK IoStatusBlock,
  57. IN ULONG Reserved);
  58. // *****************************************************************
  59. int InitializeDistributedLockManager(dlm_nodeid_t *nodeid);
  60. int InitializeDistributedLock(dlm_lockid_t *lock, dlm_lockid_t parent, char *name, int sz);
  61. int ConvertDistributedLock(dlm_lockid_t lock, dlm_mode_t mode);
  62. int ConvertDistributedLockEx(dlm_lockid_t lock, dlm_mode_t mode, int flags, dlm_vblk_t vblk,
  63. PIO_APC_ROUTINE callback, PVOID arg,
  64. HANDLE event, PIO_STATUS_BLOCK iostatus);
  65. int QueueDistributedLockEvent(dlm_lockid_t lock, PIO_APC_ROUTINE callback, PVOID arg,
  66. HANDLE event, PIO_STATUS_BLOCK iostatus);
  67. int DestroyDistributedLock(dlm_lockid_t lock);
  68. #endif