问题描述
我目前正在尝试从Freebsd VFS vnode提取文件数据.
I am currently trying to extract file data from Freebsd VFS vnode.
struct vnode {
/*
* Fields which define the identity of the vnode. These fields are
* owned by the filesystem (XXX: and vgone() ?)
*/
const char *v_tag; /* u type of underlying data */
struct vop_vector *v_op; /* u vnode operations vector */
void *v_data; /* u private data for fs */
/*
* Filesystem instance stuff
*/
struct mount *v_mount; /* u ptr to vfs we are in */
TAILQ_ENTRY(vnode) v_nmntvnodes; /* m vnodes for mount point */
/*
* Type specific fields, only one applies to any given vnode.
* See #defines below for renaming to v_* namespace.
*/
union {
struct mount *vu_mount; /* v ptr to mountpoint (VDIR) */
struct socket *vu_socket; /* v unix domain net (VSOCK) */
struct cdev *vu_cdev; /* v device (VCHR, VBLK) */
struct fifoinfo *vu_fifoinfo; /* v fifo (VFIFO) */
} v_un;
/*
* vfs_hash: (mount + inode) -> vnode hash. The hash value
* itself is grouped with other int fields, to avoid padding.
*/
LIST_ENTRY(vnode) v_hashlist;
/*
* VFS_namecache stuff
*/
LIST_HEAD(, namecache) v_cache_src; /* c Cache entries from us */
TAILQ_HEAD(, namecache) v_cache_dst; /* c Cache entries to us */
struct namecache *v_cache_dd; /* c Cache entry for .. vnode */
/*
* Locking
*/
struct lock v_lock; /* u (if fs don't have one) */
struct mtx v_interlock; /* lock for "i" things */
struct lock *v_vnlock; /* u pointer to vnode lock */
/*
* The machinery of being a vnode
*/
TAILQ_ENTRY(vnode) v_actfreelist; /* f vnode active/free lists */
struct bufobj v_bufobj; /* * Buffer cache object */
/*
* Hooks for various subsystems and features.
*/
struct vpollinfo *v_pollinfo; /* i Poll events, p for *v_pi */
struct label *v_label; /* MAC label for vnode */
struct lockf *v_lockf; /* Byte-level advisory lock list */
struct rangelock v_rl; /* Byte-range lock */
/*
* clustering stuff
*/
daddr_t v_cstart; /* v start block of cluster */
daddr_t v_lasta; /* v last allocation */
daddr_t v_lastw; /* v last write */
int v_clen; /* v length of cur. cluster */
int v_holdcnt; /* i prevents recycling. */
int v_usecount; /* i ref count of users */
u_int v_iflag; /* i vnode flags (see below) */
u_int v_vflag; /* v vnode flags */
int v_writecount; /* v ref count of writers */
u_int v_hash;
enum vtype v_type; /* u vnode type */
};
我假设数据存在于bufobj中,但是我不知道如何提取它. Bufobj还包含其他bufobj的列表.它还包含包含干净缓冲区和脏缓冲区的bufvs对象.如果有人指出我正确的方向,那将对我有很大帮助.
I assumed the data lives in bufobj, but I have no clue how to extract it. Bufobj also contains list of other bufobj. It also contain bufvs objects that contain clean and dirty buffers. It would help me greatly if someone points me to the correct direction.
推荐答案
要从内核读取文件,可以使用 VOP_READ(9)
.查看 vnode(9)
联机帮助页获取更多信息,以及处理vnode的其他宏列表.
To read a file from the kernel, you can use VOP_READ(9)
. Look at the vnode(9)
manpage for more informations and a list of other macros to handle vnodes.
如果您想举个例子,请 md(4)
源代码是一个好的开始.
If you want an example, md(4)
source code is a good start.
这篇关于如何从Freebsd VFS vnode读取实际文件数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!