我想在VFS服務器中創建一個新的系統調用,它將被指定一個文件名作爲參數,並將在MINIX3.2.1中打印該特定文件的inode編號。 我檢查了do_stat()函數的代碼(在/usr/src/servers/vfs/stadir.c中),我發現我必須分配給vnode結構變量派生eat_path()才能訪問v_inode_nr這是inode編號。爲了做到這一點,我如何能夠分配我正在尋找的文件,在哪裏把用戶輸入文件名(m_in.m1_p1)?通過MINIX上的文件名檢索文件的inode編號
這裏是內部stadir.c
int do_stat() {
/* Perform the stat(name, buf) system call. */
int r;
struct vnode *vp;
struct vmnt *vmp;
char fullpath[PATH_MAX];
struct lookup resolve;
int old_stat = 0;
vir_bytes vname1, statbuf;
size_t vname1_length;
vname1 = (vir_bytes)job_m_in.name1;
vname1_length = (size_t)job_m_in.name1_length;
statbuf = (vir_bytes)job_m_in.m1_p2;
lookup_init(&resolve, fullpath, PATH_NOFLAGS, &vmp, &vp);
resolve.l_vmnt_lock = VMNT_READ;
resolve.l_vnode_lock = VNODE_READ;
if (job_call_nr == PREV_STAT)
old_stat = 1;
if (fetch_name(vname1, vname1_length, fullpath) != OK)
return (err_code);
if ((vp = eat_path(&resolve, fp)) == NULL)
return (err_code);
r = req_stat(vp->v_fs_e, vp->v_inode_nr, who_e, statbuf, old_stat);
unlock_vnode(vp);
unlock_vmnt(vmp);
put_vnode(vp);
return r;
}