From nobody Sun Jan 29 14:38:24 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4P4Yp90F09z3cgPg; Sun, 29 Jan 2023 14:38:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4P4Yp86sNNz48Kx; Sun, 29 Jan 2023 14:38:24 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675003105; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=MEl205dhQ1amRe9YqT/It37i9mHDYsRy+h7DDo3ga20=; b=gFpqmTrYy29/ENdKSvuhUbd2c4TNtWCSP2xhmqIMUALn1H+t4lnQJD0ZHMz9mwAdNAkLa6 PLRBQjaJfUAvCfL+fW9Lt/HbwHNos0VB4Hx1ZgUylmctnPdBaGtdyWyqC+p/x+tYm3fv+2 x/5l0zR6ExGTyN1ctH1KUCG3Q0NvPpIl7HRpVvZLcZKNXYURzI+yGFHQsGlduCdH+qeCBC FLVeXHtavCW281ixGORLsQKsczs9wq6d7oh+yQnGeK5hQaX9rffkYxyOyEYPCG4Tc3nwHN eaDztTjHC/3zQ8T+Q+VPuj6V2OaAwg9n/9GsE7B6+OE+OqUPgVEH4gUjtMRRWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675003105; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=MEl205dhQ1amRe9YqT/It37i9mHDYsRy+h7DDo3ga20=; b=CV+JhqR4KKxYQ5xJCOxRST51FxmXBegKPOrt9O60MFOMCGYfFsx1j/ysi1aK2m02CtjKbj 3W6B6VBC5tsbBxnbrDWXydObDGnQknUumd2LBuT0cQuc4hOq8F9+z8bS3wSMcTZYIsF2i9 EZ4hhegSFwAGjKvyoZlBOXcaCG0NoBTKqjaFrIG1mbGrPq9VC6hZARZoS7iezC5e2fDdC2 uktDBRBuv0BXX/gdDobpe+Z2Yxqele4wwUeiPdCnIme11AxM+Lwnt9c0FMRBJ6QNTgbk8k HLtCCteu9lI+BbYBKNhtb4MnMT6niE7Ql9YWFUcjDXwaCPKmWWTRMd/v5otraQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1675003105; a=rsa-sha256; cv=none; b=jt7ULMl4HDiRp99/g6rM/o5loen7HqXf4+3wL8axYh2TRWc9FAnCUGMBSXQHwvNeb0c4dd mB/LNWrSblcwPWCh548yGibXPou0TnqCc41iJrUEhz0g32FI6B97Px4NYxKsFPMg+TK3hh b+v4yTaBX82POHox/QnXyZaVj6N4TvwgRetgiOAElXQF35soW1zj2a8601JcdbiEUrEdhQ IT4bsaz+sDnFAjPFYMrFXAA1CedfMslmXUyjs9YhCpM0gYPhNcWasTHEeaRVJV5P2OIIl8 5CBJWfkE4yp3CEFJZNXc1FJnqpip0oG2I5fNGlLZFpRfznf+pttaIS+0VpChgQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4P4Yp85vjxzXCJ; Sun, 29 Jan 2023 14:38:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 30TEcO1F021481; Sun, 29 Jan 2023 14:38:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30TEcOe3021480; Sun, 29 Jan 2023 14:38:24 GMT (envelope-from git) Date: Sun, 29 Jan 2023 14:38:24 GMT Message-Id: <202301291438.30TEcOe3021480@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Guzik Subject: git: ba1fc13882d1 - stable/13 - Add kf_file_nlink field to kf_file and populate it List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: ba1fc13882d126a986f629b095ed6bab7378a8f4 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=ba1fc13882d126a986f629b095ed6bab7378a8f4 commit ba1fc13882d126a986f629b095ed6bab7378a8f4 Author: Jiajie Chen AuthorDate: 2023-01-23 16:36:59 +0000 Commit: Mateusz Guzik CommitDate: 2023-01-29 14:37:08 +0000 Add kf_file_nlink field to kf_file and populate it This will allow user-space programs (e.g. lsof) to locate deleted files whose nlink equals zero. Prior to this commit, programs has to use stat(kf_path) to get nlink, but that will fail if the file is deleted. [mjg: s/fail/file in the commit message] Reviewed by: mjg Differential Revision: https://reviews.freebsd.org/D38169 (cherry picked from commit dec7db49602df75119f6b57d32f1eb58e0040abc) --- sys/kern/vfs_vnops.c | 1 + sys/sys/user.h | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index a54d2c463dc7..f4274ee38689 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -2774,6 +2774,7 @@ vn_fill_kinfo_vnode(struct vnode *vp, struct kinfo_file *kif) kif->kf_un.kf_file.kf_file_rdev = va.va_rdev; kif->kf_un.kf_file.kf_file_rdev_freebsd11 = kif->kf_un.kf_file.kf_file_rdev; /* truncate */ + kif->kf_un.kf_file.kf_file_nlink = va.va_nlink; return (0); } diff --git a/sys/sys/user.h b/sys/sys/user.h index 433e44c0f19e..6309c708be95 100644 --- a/sys/sys/user.h +++ b/sys/sys/user.h @@ -389,7 +389,9 @@ struct kinfo_file { int kf_file_type; /* Space for future use */ int kf_spareint[3]; - uint64_t kf_spareint64[30]; + uint64_t kf_spareint64[29]; + /* Number of references to file. */ + uint64_t kf_file_nlink; /* Vnode filesystem id. */ uint64_t kf_file_fsid; /* File device. */