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, Jul 15, 12:11 AM
Unknown Object (File)
Sat, Jul 13, 1:09 PM
Unknown Object (File)
Sun, Jun 30, 1:45 PM
Unknown Object (File)
Sun, Jun 30, 1:13 PM
Unknown Object (File)
Fri, Jun 28, 11:54 PM
Unknown Object (File)
Fri, Jun 28, 10:20 PM
Unknown Object (File)
Fri, Jun 28, 6:55 PM
Unknown Object (File)
Thu, Jun 27, 10:45 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.