Page MenuHomeFreeBSD

fstat(1) -s option

Authored by jlh on Oct 2 2019, 8:18 PM.



This adds a -s option to fstat(1) to display socket endpoint(s) information.

Test Plan

Here is the sample output:

# /usr/obj/usr/src-svn/amd64.amd64/usr.bin/fstat/fstat -s | awk '$5 ~ /^(local|internet)$/' | head
root     sshd       92160    3* internet stream tcp fffff8049255fb70 <-> *:0
1000     ssh-agent  24448    3* local stream fffff8001d34fa00 /tmp/ssh-VIm9vDnboKfn/agent.24447
root     sendmail   29954    3* internet stream tcp fffff80297f813d0 <-> *:0
root     sendmail   29954    4* local dgram fffff8001d34a300 <-> fffff8001d344100 /var/run/logpriv
root     ssh        92165    4* internet stream tcp fffff80167375b70 <->
smmsp    sendmail   29957    3* local dgram fffff8001d63c100 <-> fffff8001d348000 /var/run/log
root     cron       92166    5* local dgram fffff8001d343800 <-> fffff8001d63dd00 /var/run/logpriv
root     cron       29961    4* local dgram fffff8001d34cc00 <-> fffff8001d344100 /var/run/logpriv
root     smbd       86666    6* local dgram fffff8001d854600 /var/db/samba4/private/msg.sock/86666
root     smbd       86666   29* local dgram fffff8047d297600 <-> fffff8047cff3100 /var/run/logpriv

Diff Detail

rS FreeBSD src repository - subversion
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Remove an unintended whitespace diff.

Did not review the code but I love the change. One less reason to install lsof!

jilles requested changes to this revision.Oct 6 2019, 6:27 PM
jilles added a subscriber: jilles.

This seems useful.

89 ↗(On Diff #62854)

"(s)" is not needed, as below.

204–206 ↗(On Diff #62854)

This is no longer true since fstat now duplicates parts of netstat, but that need not be bad. Consider simply removing the sentence.

219 ↗(On Diff #62854)

This sentence is incomplete.

346 ↗(On Diff #62854)

Perhaps use inet_ntop() here as well to avoid using mutable static data (even though this program is single-threaded).

457 ↗(On Diff #62854)

non-NULL (NUL is '\0')

This revision now requires changes to proceed.Oct 6 2019, 6:27 PM
jlh marked 5 inline comments as done.

Update diff after jilles@ review.

Diff updated.

204–206 ↗(On Diff #62854)

Good catch, thanks!

Updated diff again to remove whitespace diff.

Looks good with one grammar issue. Don't forget to bump .Dd.

216 ↗(On Diff #63096)

socket endpoint information *is* shown

This revision is now accepted and ready to land.Oct 9 2019, 9:29 PM
216 ↗(On Diff #63096)

Ah, this is uncountable in English (not in French :-)). Thanks!


  • fix minor grammer issue
  • bump Dd


This revision now requires review to proceed.Oct 19 2019, 7:48 PM
This revision was not accepted when it landed; it landed in state Needs Review.Oct 19 2019, 7:52 PM
This revision was automatically updated to reflect the committed changes.
yuripv added inline comments.

With a "non-native speaker" disclaimer, this looks somehow wrong to me, should it be "the local and remote addresses are shown", or even "both local and remote addresses are shown" instead?


Can't really tell. Leaving it to a native speaker.


"The a and b" is plural. So "addresses" is needed.

jlh marked an inline comment as done.Oct 28 2019, 9:40 PM

I won't update the patch here given it's already submitted but I'm submitting a fix to HEAD now.