#On ZFS, how can I read a file as an inode or znode struct?

29 messages · Page 1 of 1 (latest)

scarlet cove
#

I'm trying to write a programme on FreeBSD to interact with the filesystem (ZFS, in this case), so I am trying to read a file as either a znode or inode struct. There are very few online resources for this—is this possible to do (without casting)?

upper rampartBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For more information use !howto ask.

scarlet cove
rocky onyx
#

the stat struct contains the information of the given inode
type, owner, group, ...

scarlet cove
#

@rocky onyx I might be mistaken but I think an inode struct in ZFS/BSD is not the same as the inode field in the stat struct

rocky onyx
#

the inode field in thr stat struct is just the number of where its located in the inode table

#

the rest of the members are the information related to this inode

scarlet cove
#

There's an inode table? 😅

#

Sorry I don't know much about C...

rocky onyx
#

(and unix as it seems)

scarlet cove
#

Yeah, I haven'e done much low-level programming

rocky onyx
#

dont get me wrong i dont know alot either

#

just trying to help

scarlet cove
#

Thanks, I appreciate it. So do you know how I can access this inode table>

#

?*

rocky onyx
#

you might want to get a copy of "the linux programming interface"

#

and read chapter 14

scarlet cove
#

Okay, thanks 🙂

rocky onyx
scarlet cove
#

Okay, well thank you, I'll see if I can figure it out 🙂

rocky onyx
#

i dont really know what you want to do, but i think stat() should suffice

except you plan on hacking on the filesystem itself

scarlet cove
#

Lol, not trying to hack the filesystem. Actually, the ultimate goal is to get the z_pflags (https://github.com/openzfs/zfs/blob/ede037cda73675f42b1452187e8dd3438fafc220/include/sys/zfs_znode.h#L200) field from the znode struct. However, as I have had limited success with anything related to znode, and I found an ITOZ conversion function (https://github.com/openzfs/zfs/blob/ede037cda73675f42b1452187e8dd3438fafc220/include/os/freebsd/zfs/sys/zfs_znode_impl.h#L104), so I thought I could try getting the znode from an inode

#

Actually, it looks like I might need to figure out vnode in this case, not inode...I'm so confused haha

rocky onyx
#

you might want to find a commandline util that does this

#

eg debugfs

scarlet cove
#

There is zfs list, but I'll take a look at debugfs