ubc_headers.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. #include <sys/sysctl.h>
  2. /* vnode types (vnode->v_type) */
  3. enum vtype {
  4. /* 0 */
  5. VNON,
  6. /* 1 - 5 */
  7. VREG, VDIR, VBLK, VCHR, VLNK,
  8. /* 6 - 10 */
  9. VSOCK, VFIFO, VBAD, VSTR, VCPLX
  10. };
  11. struct qm_trace {
  12. char * lastfile;
  13. int lastline;
  14. char * prevfile;
  15. int prevline;
  16. };
  17. typedef struct {
  18. unsigned long opaque[2];
  19. } lck_mtx_t;
  20. struct vnode;
  21. typedef struct vnode * vnode_t;
  22. struct ucred;
  23. typedef struct ucred *kauth_cred_t;
  24. struct vnode {
  25. lck_mtx_t v_lock; /* vnode mutex */
  26. struct {
  27. struct uint64_t *tqh_first;
  28. struct uint64_t **tqh_last;
  29. struct qm_trace trace;
  30. } v_ncchildren;
  31. struct {
  32. struct uint64_t *lh_first;
  33. } v_nclinks;
  34. vnode_t v_defer_reclaimlist; /* in case we have to defer the reclaim to avoid recursion */ // 8(?)
  35. uint32_t v_listflag; /* flags protected by the vnode_list_lock (see below) */ // 4
  36. uint32_t v_flag; /* vnode flags (see below) */ // 4
  37. uint16_t v_lflag; /* vnode local and named ref flags */ // 2
  38. uint8_t v_iterblkflags; /* buf iterator flags */ // 1
  39. uint8_t v_references; /* number of times io_count has been granted */ // 1
  40. int32_t v_kusecount; /* count of in-kernel refs */ // 4
  41. int32_t v_usecount; /* reference count of users */ // 4
  42. int32_t v_iocount; /* iocounters */ // 4
  43. void * v_owner; /* act that owns the vnode */ // 8
  44. uint16_t v_type; /* vnode type */ // 2
  45. uint16_t v_tag; /* type of underlying data */
  46. uint32_t v_id; /* identity of vnode contents */
  47. union {
  48. struct mount *vu_mountedhere; /* ptr to mounted vfs (VDIR) */
  49. struct socket *vu_socket; /* unix ipc (VSOCK) */
  50. struct specinfo *vu_specinfo; /* device (VCHR, VBLK) */
  51. struct fifoinfo *vu_fifoinfo; /* fifo (VFIFO) */
  52. struct ubc_info *vu_ubcinfo; /* valid for (VREG) */
  53. } v_un;
  54. void * v_cleanblkhd;
  55. void * v_dirtyblkhd;
  56. struct klist v_knotes;
  57. kauth_cred_t v_cred;
  58. int v_authorized_actions;
  59. int v_cred_timestamp;
  60. int v_nc_generation;
  61. int32_t v_numoutput;
  62. int32_t v_writecount;
  63. const char *v_name;
  64. vnode_t v_parent;
  65. struct lockf *v_lockf;
  66. int (**v_op)(void *);
  67. void *v_mount;
  68. void *v_data;
  69. struct label *v_label;
  70. /* rest removed */
  71. };
  72. struct ubc_info {
  73. uint64_t ui_pager; /* pager */
  74. uint64_t ui_control; /* VM control for the pager */
  75. vnode_t ui_vnode; /* vnode for this ubc_info */
  76. kauth_cred_t ui_ucred; /* holds credentials for NFS paging */
  77. long long ui_size; /* file size for the vnode */
  78. uint32_t ui_flags; /* flags */
  79. uint32_t cs_add_gen; /* generation count when csblob was validated */
  80. struct cl_readahead *cl_rahead; /* cluster read ahead context */
  81. struct cl_writebehind *cl_wbehind; /* cluster write behind context */
  82. struct timespec cs_mtime; /* modify time of file when first cs_blob was loaded */
  83. struct cs_blob *cs_blobs; /* for CODE SIGNING */
  84. /* rest removed */
  85. };
  86. struct cs_blob {
  87. struct cs_blob *csb_next;
  88. int csb_cpu_type;
  89. unsigned int csb_flags;
  90. long long csb_base_offset; /* Offset of Mach-O binary in fat binary */
  91. long long csb_start_offset; /* Blob coverage area start, from csb_base_offset */
  92. long long csb_end_offset; /* Blob coverage area end, from csb_base_offset */
  93. unsigned long csb_mem_size;
  94. unsigned long csb_mem_offset;
  95. unsigned long csb_mem_kaddr;
  96. unsigned char csb_cdhash[CS_CDHASH_LEN];
  97. const struct cs_hash *csb_hashtype;
  98. unsigned long csb_hash_pagesize; /* each hash entry represent this many bytes */
  99. unsigned long csb_hash_pagemask;
  100. unsigned long csb_hash_pageshift;
  101. unsigned long csb_hash_firstlevel_pagesize;
  102. const CS_CodeDirectory *csb_cd;
  103. const char * csb_teamid;
  104. const CS_GenericBlob *csb_entitlements_blob; /* raw blob, subrange of csb_mem_kaddr */
  105. void * csb_entitlements; /* The entitlements as an OSDictionary */
  106. unsigned int csb_platform_binary;
  107. unsigned int csb_platform_path;
  108. };
  109. struct cs_hash {
  110. uint8_t cs_type; /* type code as per code signing */
  111. size_t cs_size; /* size of effective hash (may be truncated) */
  112. size_t cs_digest_size; /* size of native hash */
  113. uint64_t cs_init;
  114. uint64_t cs_update;
  115. uint64_t cs_final;
  116. };
  117. struct vnode_attr {
  118. /* bitfields */
  119. uint64_t va_supported;
  120. uint64_t va_active;
  121. /*
  122. * Control flags. The low 16 bits are reserved for the
  123. * ioflags being passed for truncation operations.
  124. */
  125. int va_vaflags;
  126. /* traditional stat(2) parameter fields */
  127. dev_t va_rdev; /* device id (device nodes only) */
  128. uint64_t va_nlink; /* number of references to this file */
  129. uint64_t va_total_size; /* size in bytes of all forks */
  130. uint64_t va_total_alloc; /* disk space used by all forks */
  131. uint64_t va_data_size; /* size in bytes of the fork managed by current vnode */
  132. uint64_t va_data_alloc; /* disk space used by the fork managed by current vnode */
  133. uint32_t va_iosize; /* optimal I/O blocksize */
  134. /* file security information */
  135. uid_t va_uid; /* owner UID */
  136. gid_t va_gid; /* owner GID */
  137. mode_t va_mode; /* posix permissions */
  138. uint32_t va_flags; /* file flags */
  139. struct kauth_acl *va_acl; /* access control list */
  140. /* timestamps */
  141. struct timespec va_create_time; /* time of creation */
  142. struct timespec va_access_time; /* time of last access */
  143. struct timespec va_modify_time; /* time of last data modification */
  144. struct timespec va_change_time; /* time of last metadata change */
  145. struct timespec va_backup_time; /* time of last backup */
  146. };