/*- * Test code for vn_fullpath() * It does a namei() operation. It then dumps the whole namei structure * After that, it does vn_fullpath() call on the returned vnode. If it * succeeds, it will print the output of vn_fullpath(). */ #include #include #include #include #include #include #include #include #include /* * The function called at load/unload. */ static int load (struct module *module, int cmd, void *arg) { int error; char *freepath, *fullpath; struct nameidata nd; switch (cmd) { case MOD_LOAD : NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, "Makefile", curproc); nd.ni_cnd.cn_flags |= SAVENAME|RDONLY|SAVESTART; if (namei(&nd) == -1) return error; printf("namei() on /sys/dev/fritz/f_http.c (struct dump):\n"); printf("ni_dirp = %s, ni_startdir/rootdir/topdir = %p/%p/%p, ni_vp = %p, ni_dvp = %p, ni_pathlen = %d, cn_pnbuf = %s cn_nameptr = %s\n", nd.ni_dirp, nd.ni_startdir, nd.ni_rootdir, nd.ni_topdir, nd.ni_vp, nd.ni_dvp, (int) nd.ni_pathlen, nd.ni_cnd.cn_pnbuf, nd.ni_cnd.cn_nameptr); /* now perform vn_fullpath (textvp_fullpath in 4.x) */ error = textvp_fullpath(curproc, &fullpath, &freepath); if (error != 0) printf("textvp_fullpath: error = %d\n", error); printf("textvp path = %s\n", fullpath); free(freepath, M_TEMP); NDFREE(&nd, NDF_NO_FREE_PNBUF); break; case MOD_UNLOAD : break; default : error = EINVAL; break; } return error; } static moduledata_t mod_data = { "vnblah3", load, 0 }; DECLARE_MODULE(vnblah4, mod_data, SI_SUB_DRIVERS, SI_ORDER_ANY);