From owner-svn-src-head@freebsd.org Wed Jun 20 08:34:30 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8306B100AFDC; Wed, 20 Jun 2018 08:34:30 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3135970791; Wed, 20 Jun 2018 08:34:30 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0E9011FE2D; Wed, 20 Jun 2018 08:34:30 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5K8YTS3082991; Wed, 20 Jun 2018 08:34:29 GMT (envelope-from bz@FreeBSD.org) Received: (from bz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5K8YThd082989; Wed, 20 Jun 2018 08:34:29 GMT (envelope-from bz@FreeBSD.org) Message-Id: <201806200834.w5K8YThd082989@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bz set sender to bz@FreeBSD.org using -f From: "Bjoern A. Zeeb" Date: Wed, 20 Jun 2018 08:34:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r335437 - in head: share/man/man4 sys/kern X-SVN-Group: head X-SVN-Commit-Author: bz X-SVN-Commit-Paths: in head: share/man/man4 sys/kern X-SVN-Commit-Revision: 335437 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 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: Wed, 20 Jun 2018 08:34:30 -0000 Author: bz Date: Wed Jun 20 08:34:29 2018 New Revision: 335437 URL: https://svnweb.freebsd.org/changeset/base/335437 Log: Sometimes it is helpful to get the path for a vnode. Implement a ddb function walking the namecache to do this. Reviewed by: jhb, mjg Inspired by: gdb macro from jhb (old version) Sponsored by: iXsystems, Inc. Differential Revision: https://reviews.freebsd.org/D14898 Modified: head/share/man/man4/ddb.4 head/sys/kern/vfs_cache.c Modified: head/share/man/man4/ddb.4 ============================================================================== --- head/share/man/man4/ddb.4 Wed Jun 20 07:02:19 2018 (r335436) +++ head/share/man/man4/ddb.4 Wed Jun 20 08:34:29 2018 (r335437) @@ -60,7 +60,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 24, 2017 +.Dd June 20, 2018 .Dt DDB 4 .Os .Sh NAME @@ -1121,6 +1121,11 @@ header file. .Pp .It Ic show Cm vnodebufs Ar addr Shows clean/dirty buffer lists of the vnode located at +.Ar addr . +.\" +.Pp +.It Ic show Cm vpath Ar addr +Walk the namecache to lookup the pathname of the vnode located at .Ar addr . .\" .Pp Modified: head/sys/kern/vfs_cache.c ============================================================================== --- head/sys/kern/vfs_cache.c Wed Jun 20 07:02:19 2018 (r335436) +++ head/sys/kern/vfs_cache.c Wed Jun 20 08:34:29 2018 (r335437) @@ -37,6 +37,7 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_ddb.h" #include "opt_ktrace.h" #include @@ -62,6 +63,10 @@ __FBSDID("$FreeBSD$"); #include #endif +#ifdef DDB +#include +#endif + #include SDT_PROVIDER_DECLARE(vfs); @@ -2529,3 +2534,54 @@ out: free(fbuf, M_TEMP); return (error); } + +#ifdef DDB +static void +db_print_vpath(struct vnode *vp) +{ + + while (vp != NULL) { + db_printf("%p: ", vp); + if (vp == rootvnode) { + db_printf("/"); + vp = NULL; + } else { + if (vp->v_vflag & VV_ROOT) { + db_printf(""); + vp = vp->v_mount->mnt_vnodecovered; + } else { + struct namecache *ncp; + char *ncn; + int i; + + ncp = TAILQ_FIRST(&vp->v_cache_dst); + if (ncp != NULL) { + ncn = ncp->nc_name; + for (i = 0; i < ncp->nc_nlen; i++) + db_printf("%c", *ncn++); + vp = ncp->nc_dvp; + } else { + vp = NULL; + } + } + } + db_printf("\n"); + } + + return; +} + +DB_SHOW_COMMAND(vpath, db_show_vpath) +{ + struct vnode *vp; + + if (!have_addr) { + db_printf("usage: show vpath \n"); + return; + } + + vp = (struct vnode *)addr; + db_print_vpath(vp); +} + +#endif