PageRenderTime 36ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/core/10.4/fusefs/fuse_node.h

http://macfuse.googlecode.com/
C++ Header | 205 lines | 147 code | 36 blank | 22 comment | 1 complexity | 88103e64e99ef8fb79cb538beb55c235 MD5 | raw file
Possible License(s): Apache-2.0, BSD-3-Clause, GPL-2.0
  1. /*
  2. * Copyright (C) 2006-2008 Google. All Rights Reserved.
  3. * Amit Singh <singh@>
  4. */
  5. #ifndef _FUSE_NODE_H_
  6. #define _FUSE_NODE_H_
  7. #include "fuse_file.h"
  8. #include "fuse_knote.h"
  9. #include "fuse_nodehash.h"
  10. #include <fuse_param.h>
  11. extern errno_t (**fuse_vnode_operations)(void *);
  12. #if M_MACFUSE_ENABLE_FIFOFS
  13. extern errno_t (**fuse_fifo_operations)(void *);
  14. #endif /* M_MACFUSE_ENABLE_FIFOFS */
  15. #if M_MACFUSE_ENABLE_SPECFS
  16. extern errno_t (**fuse_spec_operations)(void *);
  17. #endif /* M_MACFUSE_ENABLE_SPECFS */
  18. enum {
  19. kFSNodeMagic = 'FUSE',
  20. kFSNodeBadMagic = 'FU**',
  21. kHNodeMagic = 'HNOD',
  22. };
  23. #define FN_ACCESS_NOOP 0x00000001
  24. #define FN_CREATING 0x00000002
  25. #define FN_DIRECT_IO 0x00000004
  26. #define FN_HAS_ACL 0x00000008
  27. #define FN_IS_ROOT 0x00000010
  28. #define FN_REVOKED 0x00000020
  29. #define C_NEED_RVNODE_PUT 0x000000001
  30. #define C_NEED_DVNODE_PUT 0x000000002
  31. #define C_ZFWANTSYNC 0x000000004
  32. #define C_FROMSYNC 0x000000008
  33. #define C_MODIFIED 0x000000010
  34. #define C_NOEXISTS 0x000000020
  35. #define C_DELETED 0x000000040
  36. #define C_HARDLINK 0x000000080
  37. #define C_FORCEUPDATE 0x000000100
  38. #define C_HASXATTRS 0x000000200
  39. #define C_NEED_DATA_SETSIZE 0x000001000
  40. #define C_NEED_RSRC_SETSIZE 0x000002000
  41. #define C_CREATING 0x000004000
  42. #define C_ACCESS_NOOP 0x000008000
  43. #define C_TOUCH_ACCTIME 0x000010000
  44. #define C_TOUCH_CHGTIME 0x000020000
  45. #define C_TOUCH_MODTIME 0x000040000
  46. #define C_XTIMES_VALID 0x000080000
  47. struct fuse_vnode_data {
  48. /** check **/
  49. uint32_t fMagic;
  50. boolean_t fInitialised;
  51. /** self **/
  52. vnode_t vp;
  53. uint64_t nodeid;
  54. uint64_t generation;
  55. /** parent **/
  56. vnode_t parentvp;
  57. uint64_t parent_nodeid;
  58. /** I/O **/
  59. struct fuse_filehandle fufh[FUFH_MAXTYPE];
  60. /** flags **/
  61. uint32_t flag;
  62. uint32_t c_flag;
  63. /** meta **/
  64. struct timespec modify_time;
  65. struct timespec entry_valid;
  66. struct timespec attr_valid;
  67. struct vnode_attr cached_attr;
  68. off_t filesize;
  69. uint64_t nlookup;
  70. enum vtype vtype;
  71. /** locking **/
  72. lck_mtx_t *createlock;
  73. void *creator;
  74. #if M_MACFUSE_ENABLE_TSLOCKING
  75. /*
  76. * The nodelock must be held when data in the FUSE node is accessed or
  77. * modified. Typically, we would take this lock at the beginning of a
  78. * vnop and drop it at the end of the vnop.
  79. */
  80. lck_rw_t *nodelock;
  81. void *nodelockowner;
  82. /*
  83. * The truncatelock guards against the EOF changing on us (that is, a
  84. * file resize) unexpectedly.
  85. */
  86. lck_rw_t *truncatelock;
  87. #endif
  88. /** miscellaneous **/
  89. #if M_MACFUSE_ENABLE_KQUEUE
  90. struct klist c_knotes;
  91. #endif /* M_MACFUSE_ENABLE_KQUEUE */
  92. };
  93. typedef struct fuse_vnode_data * fusenode_t;
  94. #define VTOFUD(vp) \
  95. ((struct fuse_vnode_data *)FSNodeGenericFromHNode(vnode_fsnode(vp)))
  96. #define VTOI(vp) (VTOFUD(vp)->nodeid)
  97. #define VTOVA(vp) (&(VTOFUD(vp)->cached_attr))
  98. #define VTOILLU(vp) ((uint64_t)(VTOFUD(vp) ? VTOI(vp) : 0))
  99. #define FUSE_NULL_ID 0
  100. static __inline__
  101. void
  102. fuse_invalidate_attr(vnode_t vp)
  103. {
  104. if (VTOFUD(vp)) {
  105. bzero(&VTOFUD(vp)->attr_valid, sizeof(struct timespec));
  106. VTOFUD(vp)->c_flag &= ~C_XTIMES_VALID;
  107. }
  108. }
  109. void fuse_vnode_init(vnode_t vp, struct fuse_vnode_data *fvdat,
  110. uint64_t nodeid, enum vtype vtyp, uint64_t parentid);
  111. void fuse_vnode_ditch(vnode_t vp, vfs_context_t context);
  112. void fuse_vnode_teardown(vnode_t vp, vfs_context_t context, enum vtype vtyp);
  113. struct get_filehandle_param {
  114. enum fuse_opcode opcode;
  115. uint8_t do_gc:1;
  116. uint8_t do_new:1;
  117. int explicitidentity;
  118. pid_t pid;
  119. uid_t uid;
  120. gid_t gid;
  121. };
  122. errno_t
  123. FSNodeGetOrCreateFileVNodeByID(vnode_t *vpp,
  124. uint32_t flags,
  125. struct fuse_entry_out *feo,
  126. mount_t mp,
  127. vnode_t dvp,
  128. vfs_context_t context,
  129. uint32_t *oflags);
  130. void FSNodeScrub(struct fuse_vnode_data *fvdat);
  131. int
  132. fuse_vget_i(vnode_t *vpp,
  133. uint32_t flags,
  134. struct fuse_entry_out *feo,
  135. struct componentname *cnp,
  136. vnode_t dvp,
  137. mount_t mp,
  138. vfs_context_t context);
  139. /* Name cache wrappers */
  140. static __inline__
  141. void
  142. fuse_vncache_enter(vnode_t dvp, vnode_t vp, struct componentname *cnp)
  143. {
  144. #if FUSE_TRACE_VNCACHE
  145. IOLog("MacFUSE: cache enter dvp=%p, vp=%p, %s\n", dvp, vp, cnp->cn_nameptr);
  146. #endif
  147. return cache_enter(dvp, vp, cnp);
  148. }
  149. static __inline__
  150. void
  151. fuse_vncache_purge(vnode_t vp)
  152. {
  153. #if FUSE_TRACE_VNCACHE
  154. IOLog("MacFUSE: cache purge vp=%p\n", vp);
  155. #endif
  156. return cache_purge(vp);
  157. }
  158. static __inline__
  159. int
  160. fuse_vncache_lookup(vnode_t dvp, vnode_t *vpp, struct componentname *cnp)
  161. {
  162. int ret = cache_lookup(dvp, vpp, cnp);
  163. #if FUSE_TRACE_VNCACHE
  164. IOLog("MacFUSE: cache lookup ret=%d, dvp=%p, *vpp=%p, %s\n",
  165. ret, dvp, *vpp, cnp->cn_nameptr);
  166. #endif
  167. return ret;
  168. }
  169. #endif /* _FUSE_NODE_H_ */