Page MenuHomeFreeBSD

Add libxo flags to fstat and fuser
Needs ReviewPublic

Authored by ayushjayaswal.connect_gmail.com on Feb 19 2026, 5:28 AM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Jun 11, 9:28 AM
Unknown Object (File)
Thu, Jun 4, 1:36 PM
Unknown Object (File)
Thu, Jun 4, 11:50 AM
Unknown Object (File)
Thu, Jun 4, 1:34 AM
Unknown Object (File)
Wed, May 20, 2:35 AM
Unknown Object (File)
Wed, May 20, 2:35 AM
Unknown Object (File)
Wed, May 20, 2:35 AM
Unknown Object (File)
Apr 27 2026, 6:59 PM
Subscribers

Details

Reviewers
asomers
Summary

Adds libxo flags to fstat and fuser.

Removes extra space added to mode string; all outputs now give a clean mode string.

JSON/XML structure for fstat stays:
processes_list > process_info > files_list > file_info
JSON/XML structure for fuser is:
files_list > file_info > consumers_list > consumer

fuser in text mode preserves original behaviour of sending separate information to stderr and stdout, while all machine-readable output goes to stdout.

man page update

Diff Detail

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

Event Timeline

asomers requested changes to this revision.Wed, May 27, 3:27 PM

I haven't tested this yet, but it looks like a good start. My main questions are why you use manual space padding in some places instead of a field width specifier, and why fuser still includes so many " if (xo_get_style(NULL) == XO_STYLE_TEXT)" expressions.

usr.bin/fstat/fstat.1
28

Don't forget to change the .Dd date.

usr.bin/fstat/fstat.c
300

I would rather you handle alignment with a field width specifier instead than manually pad with spaces.

512

Why the space after the slash?

668

Why are you manually nul-terminating all of these strings? Why wasn't that necessary with printf?

usr.bin/fstat/fuser.1
25

The .Dd date here, too.

usr.bin/fstat/fuser.c
144

Why do you use fprintf directly here? Why can't xo_emit handle it?

272

Also here. Why do you need to use fprintf directly?

283

And here.

This revision now requires changes to proceed.Wed, May 27, 3:27 PM

Add js, who's taken an interest in libxo.

ayushjayaswal.connect_gmail.com added inline comments.
usr.bin/fstat/fstat.c
668

+ removed manual nul-termination, now behaves like printf
+ there shall be a space in structural output for mode; this is the ACL flag (' ' or +)

usr.bin/fstat/fuser.c
144

fuser prints process ids to stdout, but all other information is sent to stderr

I can't think of a way to replicate this behavior with xo, so I use fprintf for text mode output

Some small nitpicks. Looks good to me overall, but I didn't test it extensively.

usr.bin/fstat/fstat.c
205–206
647–650

I think we're missing a "-" here?

666

Adding a trim modifier should fix this:

{
        "user": "root",
        "command": "sh",
        "pid": 721,
        "files": [
          {
            "fd": "text",
            "vnode": {
              "mount": "/",
              "inode": 4112989,
              "mode": "-r-xr-xr-x ", <-------- problem 
              "size": 171080,
              "access_flags": "r"
            }
          },

It's common to run into this problem when using width adjustments to text in libxo. Trim modifier removes whitespace from embedded (XML/JSON) output but not from the text (text/html) output. But you should test and confirm that.