fuser {file} is supposed to return all pids that have {file} open. It doesn't: # fuser /usr/local/sbin/httpd /usr/local/sbin/httpd: cause seems to be a wrong type of fsid in fuser.c. With the following change: --- a/usr.bin/fstat/fuser.c +++ b/usr.bin/fstat/fuser.c @@ -92,7 +92,7 @@ struct consumer { STAILQ_ENTRY(consumer) next; }; struct reqfile { - uint32_t fsid; + uint64_t fsid; uint64_t fileid; const char *name; STAILQ_HEAD(, consumer) consumers; fuser does again what it's supposed to do: # fuser /usr/local/sbin/httpd /usr/local/sbin/httpd: 871x 870x 869x 868x 867x 832x The bug seems to be present in releases since 12 up to at least 13-releng (didn't check 14).
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=e18fbe6f19ed106f035c7d2aaeade6eb55cc0b5a commit e18fbe6f19ed106f035c7d2aaeade6eb55cc0b5a Author: Andriy Gapon <avg@FreeBSD.org> AuthorDate: 2021-11-01 06:40:17 +0000 Commit: Andriy Gapon <avg@FreeBSD.org> CommitDate: 2021-11-01 06:45:26 +0000 fuser: restore functionality by fixing fsid type Use types from sys/stat.h for the filesystem and inode numbers for extra safety. PR: 259504 Reported by: Markus Wild <freebsd-bugs@virtualtec.ch> MFC after: 1 week usr.bin/fstat/fuser.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
(In reply to Markus Wild from comment #0) Thank you very much for the analysis and the fix. Submitted in a slightly different form.
Thanks for taking care of this! Shouldn't then <libprocstat.h> also be changed to non-generic types? struct vnstat uses uint64_t etc.
(In reply to Markus Wild from comment #3) That's an interesting question. I think that libprocstat.h should not be changed as it operates with fixed size types because of libkvm, etc. At the same time, fuser uses both libprocstat and sys/stat.h interfaces. So, it kind of bridges between struct stat and struct vnstat.
A commit in branch stable/13 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=df838c540632ce3840f78a9067dd9de32458c71a commit df838c540632ce3840f78a9067dd9de32458c71a Author: Andriy Gapon <avg@FreeBSD.org> AuthorDate: 2021-11-01 06:40:17 +0000 Commit: Andriy Gapon <avg@FreeBSD.org> CommitDate: 2021-11-08 05:55:30 +0000 fuser: restore functionality by fixing fsid type Use types from sys/stat.h for the filesystem and inode numbers for extra safety. PR: 259504 Reported by: Markus Wild <freebsd-bugs@virtualtec.ch> MFC after: 1 week (cherry picked from commit e18fbe6f19ed106f035c7d2aaeade6eb55cc0b5a) usr.bin/fstat/fuser.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
A commit in branch stable/12 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=d3aca6fe9bf97ea22bb9bee365b616bcb77a1220 commit d3aca6fe9bf97ea22bb9bee365b616bcb77a1220 Author: Andriy Gapon <avg@FreeBSD.org> AuthorDate: 2021-11-01 06:40:17 +0000 Commit: Andriy Gapon <avg@FreeBSD.org> CommitDate: 2021-11-08 05:59:01 +0000 fuser: restore functionality by fixing fsid type Use types from sys/stat.h for the filesystem and inode numbers for extra safety. PR: 259504 Reported by: Markus Wild <freebsd-bugs@virtualtec.ch> MFC after: 1 week (cherry picked from commit e18fbe6f19ed106f035c7d2aaeade6eb55cc0b5a) usr.bin/fstat/fuser.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)