2

I'm trying to use a vnode_t which is defined as struct vnode *. I can find plenty of references to struct vnode but I cannot find the header in which is defined. Can anyone help?

Joe
  • 46,419
  • 33
  • 155
  • 245

1 Answers1

1

It's in the bsd/sys/vnode_internal.h file. Line 134 in my source.

From a test I did it looks like vnode is left undefined from system headers and linked in when run as the definition of vnode is not required as pointers are being passed around with no direct modification to the internal structure except for the kernel functions themselves. It's forward declared in a header file (forgot which now).

The real definition can be found in http://elephant.cs.fiu.edu/source/xref/xnu-1699.24.23/bsd/sys/vnode_internal.h#134

Jesus Ramos
  • 22,940
  • 10
  • 58
  • 88
  • Hm. That file doesn't exist on my system. What OS are you on? I'm on 10.6.7. I have `vnode.h` and `vnode_if.h` in Kernel.framework (I'm building a kext) but no `vnode_internal.h`. – Joe Aug 20 '12 at 23:46
  • Did you download the sources for the XNU kernel onto your machine or are you using the system headers? Here's a link to the file on mine http://elephant.cs.fiu.edu/source/xref/xnu-1699.24.23/bsd/sys/vnode_internal.h#134 – Jesus Ramos Aug 20 '12 at 23:47
  • I wanted to use the system headers. I assumed that since there was so much in the headers that `vnode` would also be defined. Various functions in `sys/*.h` return `vnode_t`s so I would expect the definition so I can actually use the result. – Joe Aug 21 '12 at 06:31
  • Also, doesn't the header have to be packaged with the actual binary (I know this isn't strictly the case for kernel as it's statically linked upon loading) so that struct alignment etc is correct? – Joe Aug 21 '12 at 11:05
  • @Joe From a test I did it looks like vnode is left undefined from system headers and linked in when run as the definition of vnode is not required as pointers are being passed around with no direct modification to the internal structure except for the kernel functions themselves. It's forward declared in a header file (forgot which now). – Jesus Ramos Aug 21 '12 at 13:54
  • That's annoying, I wanted to get some information out of it, not use it as an opaque pointer. Ah well. Maybe there's a function I can use to get the information out. – Joe Aug 21 '12 at 13:56