Page MenuHomeFreeBSD

Add kf_file_nlink field to kf_file and populate it
ClosedPublic

Authored by c_jia.je on Jan 23 2023, 1:05 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, May 20, 7:31 PM
Unknown Object (File)
Tue, May 14, 8:19 PM
Unknown Object (File)
Thu, May 9, 11:28 PM
Unknown Object (File)
Thu, May 9, 11:28 PM
Unknown Object (File)
Sun, May 5, 12:37 PM
Unknown Object (File)
Wed, May 1, 7:35 AM
Unknown Object (File)
Apr 27 2024, 7:57 AM
Unknown Object (File)
Apr 24 2024, 2:52 AM
Subscribers

Details

Summary

This will allow user-space programs (e.g. lsof) to locate deleted files
whose nlink equals to zero. Prior to this commit, programs has to use
stat(kf_path) to get nlink, but that will fail if the file is deleted.

Test Plan

Tested the patch with changes in lsof to list deleted files.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 49195
Build 46084: arc lint + arc unit

Event Timeline

Huh, I did not even realize this information was missing.

I'll probably commit in a day or two. Can you show me the matching lsof diff if you have it ready?

In D38169#867072, @mjg wrote:

Huh, I did not even realize this information was missing.

I'll probably commit in a day or two. Can you show me the matching lsof diff if you have it ready?

Sure, you can find it at https://github.com/lsof-org/lsof/commit/4e0aaacf290133859d0f5ac205311079bc9fb170

can you send me the commit generated with git format-patch so that I have something nice to apply? mjg@

I would change "Number of references to file." to "Link count." but I'm not going to insist.

This revision was not accepted when it landed; it landed in state Needs Review.Jan 23 2023, 6:14 PM
This revision was automatically updated to reflect the committed changes.