From 260e4e8b8ab44d235434bf13dbf9fcf08dcc13bd Mon Sep 17 00:00:00 2001 From: Alex Hornung Date: Mon, 17 Aug 2009 07:52:05 +0100 Subject: [PATCH] DEVFS - add link-to-link support to nresolve * Add support for devfs autolinks linking to other devfs autolinks, up to a level of 8, to avoid recursion. --- sys/vfs/devfs/devfs_vnops.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sys/vfs/devfs/devfs_vnops.c b/sys/vfs/devfs/devfs_vnops.c index 73c6ce8878..765784a083 100644 --- a/sys/vfs/devfs/devfs_vnops.c +++ b/sys/vfs/devfs/devfs_vnops.c @@ -438,6 +438,7 @@ devfs_nresolve(struct vop_nresolve_args *ap) int error = 0; int len; int hidden = 0; + int depth; ncp = ap->a_nch->ncp; len = ncp->nc_nlen; @@ -463,8 +464,16 @@ devfs_nresolve(struct vop_nresolve_args *ap) } if (found) { - if ((found->node_type == Plink) && (found->link_target)) + depth = 0; + while ((found->node_type == Plink) && (found->link_target)) { + if (depth >= 8) { + devfs_debug(DEVFS_DEBUG_SHOW, "Recursive link or depth >= 8"); + break; + } + found = found->link_target; + ++depth; + } if (!(found->flags & DEVFS_HIDDEN)) devfs_allocv(/*ap->a_dvp->v_mount, */ &vp, found); -- 2.41.0