Page MenuHomeFreeBSD

patch libxo support for fstat
Needs ReviewPublic

Authored by ayushjayaswal.connect_gmail.com on Jun 5 2025, 10:35 AM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Oct 3, 6:34 PM
Unknown Object (File)
Fri, Oct 3, 8:16 AM
Unknown Object (File)
Wed, Oct 1, 10:23 PM
Unknown Object (File)
Wed, Oct 1, 2:29 PM
Unknown Object (File)
Tue, Sep 30, 6:40 PM
Unknown Object (File)
Tue, Sep 30, 5:34 PM
Unknown Object (File)
Tue, Sep 30, 8:27 AM
Unknown Object (File)
Sat, Sep 27, 11:35 PM
Subscribers

Details

Reviewers
asomers
Summary

This Patch does the following:

+ provides --libxo flag for output and replaces all printf and fprintf calls with libxo equivalents.
+ fixes compilation warning at fstat.c:186:45
+ updates man page for fstat

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 65222
Build 62105: arc lint + arc unit

Event Timeline

Please adjust the indentation style as per style(9).

+ fixed indents
+ made the the xo flags compatible with https://reviews.freebsd.org/D48706 that handles kqueue, mqueue, and procdesc file descriptors

Looks good now, but perhaps someone with more experience with libxo should have a look over D50699 and this one.

You need to add "LIBADD= xo" to usr.bin/fstat/Makefile. Also, a lot of fields are missing in the html output, for example file_type. Is that intentional?

usr.bin/fstat/fstat.c
193–196

This part prints out a garbled title line like this:

{T:/%-13s}{T:/%-6s}{T:/%-3s}USER         CMD   PIDFD         MOUNT
327

Here, and also for mqueue, eventfd, and procdesc, I don't think it makes sense to include the brackets in the json output. The purpose of those brackets was to tell the user that "this thing doesn't really have a mountpoint". But with any kind of machine-readable output, there's no need. Especially since it's in a field clearly labeled "file_type".

647

The json output contains an extra space in the mode. I don't think it should be there:

"inode": 4582283,
"mode": "drwxr-xr-x ",
"size": 11,
651

For device files, this prints a nonsensical size:

"vnode": {
  "mount": "/dev",
  "inode": 54,
  "mode": "crw--w---- ",
  "size": "pts/0",
  "access": {
    "access_flags": "rw"
  }