From nobody Mon Jan 23 18:13:59 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 4P0ysg4lDXz3b2nr; Mon, 23 Jan 2023 18:13:59 +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 4P0ysg4573z47H5; Mon, 23 Jan 2023 18:13:59 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674497639; 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=rw7M0RdtJCbpC64kL2m4dI3JHGqsSxghNJjIZFz9ys8=; b=GTQFJiTcGEI23JlIsDNZ7N60DwBcu6X+LFJP/961LN7L2TAioTTBT4tmiK7JgRTaFyUbI7 SDaLqp+CBbiXQdMpW45riQ1wIU9G6KJUD/77K5m+HALlxHUdraB+Rya4h/CiST9N71ABSa x7380GyGoun48uayRHzd8oS+JBBaM/BzvoJ2i41O/EzKiIGEFoqCTVrS7TzBWXTPOQydX+ z6UCHaZX4sYXjLNKTDn7HztijrYEVQ5oCM8w9E2XnquZqOSnvWA22MwGJ/eOKj+pYwg97I l1qJUmtfAQwiPTHBeh5tpaq79xmrvRiF3S9Cks2a6V8c9WUoauSSPxhjvrPLZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674497639; 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=rw7M0RdtJCbpC64kL2m4dI3JHGqsSxghNJjIZFz9ys8=; b=i8xlMLrED/oWauiiQ9eTEbYPvrqzHOg6qn3b7JAycIvwKL0NpN5TboeG8e4/1KzVTx17y6 cmvO3KbyF69FJObHTXDx2QZ1oQjhOZ97bXDj9DCDreu99F0aVMy+U64N2vWJ+xGBpvFraB T/xYyTqZPGcAj0XtIKHS3YEymwlACI71i1WGU7HMCgs6WAF5Gm7MVybL78Kzgsuw9jehyG npt3iKIFNLs7HIQ6QHkdI5AxGY2XdDkHaUBU48kKijEh91qPwFB0On89slxxCaOQ59se5D c0fjneoyJYYcSLW25h1a0f++/Ufvgby9LZ3MUBYJRir+YzNsETaGQaXmMhc5zA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674497639; a=rsa-sha256; cv=none; b=ZqkFEfuFaYNcFPPbeG+i1+XbIOGLoSP7b2otTpid11OA9OTau6rwGtoAEICL8Bh8O0v9XX e42YtC85gugnm7i51ozSPIQZ2gkQkTrlhZeHcHLHtyiCPgLOxSWFZUUczec4LCNfTH25Zb GWllo05Kk/npZ/QA4aeSPMUBCKmMxnyk1zh5uPXw/02MQW7lqwpMyPXRk5u4LmHV8lJHBK M1RgMGY52K8zGaJHWzAFxrUpXynn90g9BFGxA/oBAtXz/lDjXE3PzdtJUTT9FD6PPBgZ16 tb+Vvan83OIT2+0JotVfSZ4LuMVKN+rRxueYZxN4rQfaT3VN3xT92NCYfpD9bg== 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 4P0ysg37r3zf7L; Mon, 23 Jan 2023 18:13:59 +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 30NIDxvp072681; Mon, 23 Jan 2023 18:13:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30NIDx4P072680; Mon, 23 Jan 2023 18:13:59 GMT (envelope-from git) Date: Mon, 23 Jan 2023 18:13:59 GMT Message-Id: <202301231813.30NIDx4P072680@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: dec7db49602d - main - 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/main X-Git-Reftype: branch X-Git-Commit: dec7db49602df75119f6b57d32f1eb58e0040abc Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=dec7db49602df75119f6b57d32f1eb58e0040abc commit dec7db49602df75119f6b57d32f1eb58e0040abc Author: Jiajie Chen AuthorDate: 2023-01-23 16:36:59 +0000 Commit: Mateusz Guzik CommitDate: 2023-01-23 17:09:52 +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 --- 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 48d15ce6ab25..a49070b6060d 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -2792,6 +2792,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 edbe6a8655ff..42799a70fbfc 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. */