我正在尝试加密和解密通过nullfs进行读取和写入的文件,但是我需要inode编号才能进行加密/解密。我正在/usr/src/sys/fs/nullfs/null_vnops.c中修改null_open并尝试在结构vop_open_args * ap中查找inode编号
但是我找不到从结构中获取索引节点号的方法。有什么办法吗?谢谢。
最佳答案
我知道了怎么做。我添加了“
MALLOC_DECLARE(M_ATTR);
MALLOC_DEFINE(M_ATTR,"vattr","attribute in null_open");
包含和之后的文件顶部
struct vattr *outStuff = malloc(sizeof(struct vattr), M_ATTR, M_ZERO);
VOP_GETATTR(vp,outStuff,ap->a_cred );
printf("uid = %d fileid = %ld \n", outStuff->va_uid,outStuff->va_fileid);
free(outStuff,M_ATTR);
在null_open中,以从function参数访问索引节点。