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)
Sat, Nov 9, 2:52 AM
Unknown Object (File)
Oct 4 2024, 3:05 PM
Unknown Object (File)
Oct 1 2024, 5:12 AM
Unknown Object (File)
Sep 30 2024, 3:01 PM
Unknown Object (File)
Sep 30 2024, 11:01 AM
Unknown Object (File)
Sep 30 2024, 1:21 AM
Unknown Object (File)
Sep 28 2024, 11:44 PM
Unknown Object (File)
Sep 28 2024, 11:24 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 Not Applicable
Unit
Tests Not Applicable

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.