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, Apr 22, 10:44 PM
Unknown Object (File)
Mar 14 2024, 2:43 AM
Unknown Object (File)
Feb 28 2024, 8:19 AM
Unknown Object (File)
Feb 18 2024, 8:29 AM
Unknown Object (File)
Jan 29 2024, 9:04 PM
Unknown Object (File)
Jan 18 2024, 7:56 AM
Unknown Object (File)
Jan 12 2024, 8:23 AM
Unknown Object (File)
Jan 4 2024, 8:01 PM
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.