From owner-svn-src-head@FreeBSD.ORG Fri Dec 12 01:00:39 2008 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1A69C1065688; Fri, 12 Dec 2008 01:00:39 +0000 (UTC) (envelope-from marcus@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0A1A68FC28; Fri, 12 Dec 2008 01:00:39 +0000 (UTC) (envelope-from marcus@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id mBC10cbb081843; Fri, 12 Dec 2008 01:00:38 GMT (envelope-from marcus@svn.freebsd.org) Received: (from marcus@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mBC10cwZ081842; Fri, 12 Dec 2008 01:00:38 GMT (envelope-from marcus@svn.freebsd.org) Message-Id: <200812120100.mBC10cwZ081842@svn.freebsd.org> From: Joe Marcus Clarke Date: Fri, 12 Dec 2008 01:00:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r185959 - head/sys/fs/devfs X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Dec 2008 01:00:39 -0000 Author: marcus (doc,ports committer) Date: Fri Dec 12 01:00:38 2008 New Revision: 185959 URL: http://svn.freebsd.org/changeset/base/185959 Log: Implement VOP_VPTOCNP for devfs. Directory and character device vnodes are properly translated to their component names. Reviewed by: arch Approved by: kib Modified: head/sys/fs/devfs/devfs_vnops.c Modified: head/sys/fs/devfs/devfs_vnops.c ============================================================================== --- head/sys/fs/devfs/devfs_vnops.c Fri Dec 12 00:59:36 2008 (r185958) +++ head/sys/fs/devfs/devfs_vnops.c Fri Dec 12 01:00:38 2008 (r185959) @@ -185,6 +185,69 @@ devfs_clear_cdevpriv(void) devfs_fpdrop(fp); } +static int +devfs_vptocnp(struct vop_vptocnp_args *ap) +{ + struct vnode *vp = ap->a_vp; + struct vnode **dvp = ap->a_vpp; + struct devfs_mount *dmp; + char *buf = ap->a_buf; + int *buflen = ap->a_buflen; + struct devfs_dirent *dd, *de; + int i, error; + + dmp = VFSTODEVFS(vp->v_mount); + i = *buflen; + dd = vp->v_data; + error = 0; + + sx_xlock(&dmp->dm_lock); + + if (vp->v_type == VCHR) { + i -= strlen(dd->de_cdp->cdp_c.si_name); + if (i < 0) { + error = ENOMEM; + goto finished; + } + bcopy(dd->de_cdp->cdp_c.si_name, buf + i, + strlen(dd->de_cdp->cdp_c.si_name)); + de = dd->de_dir; + } else if (vp->v_type == VDIR) { + if (dd == dmp->dm_rootdir) { + *dvp = vp; + vhold(*dvp); + goto finished; + } + i -= dd->de_dirent->d_namlen; + if (i < 0) { + error = ENOMEM; + goto finished; + } + bcopy(dd->de_dirent->d_name, buf + i, + dd->de_dirent->d_namlen); + de = dd; + } else { + error = ENOENT; + goto finished; + } + *buflen = i; + de = TAILQ_FIRST(&de->de_dlist); /* "." */ + de = TAILQ_NEXT(de, de_list); /* ".." */ + de = de->de_dir; + mtx_lock(&devfs_de_interlock); + *dvp = de->de_vnode; + if (*dvp != NULL) { + VI_LOCK(*dvp); + mtx_unlock(&devfs_de_interlock); + vholdl(*dvp); + VI_UNLOCK(*dvp); + } else + error = ENOENT; +finished: + sx_xunlock(&dmp->dm_lock); + return (error); +} + /* * Construct the fully qualified path name relative to the mountpoint */ @@ -1465,6 +1528,7 @@ static struct vop_vector devfs_vnodeops .vop_setlabel = devfs_setlabel, #endif .vop_symlink = devfs_symlink, + .vop_vptocnp = devfs_vptocnp, }; static struct vop_vector devfs_specops = { @@ -1499,6 +1563,7 @@ static struct vop_vector devfs_specops = #endif .vop_strategy = VOP_PANIC, .vop_symlink = VOP_PANIC, + .vop_vptocnp = devfs_vptocnp, .vop_write = VOP_PANIC, };