-
Notifications
You must be signed in to change notification settings - Fork 125
Description
Describe the bug
When running on Darwin/MacOS, lsof_file.name seems to always be NULL for regular files. When running command line lsof, the name field is populated correctly. lsof_file.name seems to be correctly populated on (at least) Linux.
To Reproduce
Steps to reproduce the behavior:
1 Run lsof_gather() against any process with an open regular file.
2. Examine lsof_file.name
Expected behavior
lsof_file.name to be populated
Environment (please complete the following information):
- Kernel: Darwin
- OS: MacOS 26.3
- lsof Version: Current Git Master (63c2646)
- Origin: Built from Git.
Additional context
It seems that void enter_vnode_info() never calls enter_nm() for regular files, as Namech is never populated.
When running in cmdline mode (ie not using liblsof directly), the name is outputted via a cache. I.e. via this mechanism -
#if defined(HASPRIVNMCACHE)
if (HASPRIVNMCACHE(ctx, Lf)) {
ps++;
goto print_nma;
}
#endif /* defined(HASPRIVNMCACHE) */
The following seems to fix the problem, but I have no idea if it's correct.
--- a/lib/dialects/darwin/dfile.c
+++ b/lib/dialects/darwin/dfile.c
@@ -205,14 +205,12 @@ void enter_vnode_info(
/*
* Enter name characters.
*/
+ if(!Namech[0]) {
+ snpf(Namech, Namechl, "%s", Lf->V_path);
+ }
+