Page MenuHomeFreeBSD

fstat(1) -s option

Authored by jlh on Wed, Oct 2, 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
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

jlh created this revision.Wed, Oct 2, 8:18 PM
jlh updated this revision to Diff 62854.Wed, Oct 2, 8:20 PM

Remove an unintended whitespace diff.

jlh edited the test plan for this revision. (Show Details)Fri, Oct 4, 7:34 AM
wollman added a subscriber: wollman.Fri, Oct 4, 5:56 PM

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

jilles requested changes to this revision.Sun, Oct 6, 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.Sun, Oct 6, 6:27 PM
jlh updated this revision to Diff 63093.Wed, Oct 9, 7:48 PM
jlh marked 5 inline comments as done.

Update diff after jilles@ review.

jlh added a comment.Wed, Oct 9, 7:49 PM

Diff updated.

204–206 ↗(On Diff #62854)

Good catch, thanks!

jlh updated this revision to Diff 63096.Wed, Oct 9, 7:58 PM

Updated diff again to remove whitespace diff.

jilles accepted this revision.Wed, Oct 9, 9:29 PM

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.Wed, Oct 9, 9:29 PM
jlh added inline comments.Sat, Oct 19, 7:46 PM
216 ↗(On Diff #63096)

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

jlh updated this revision to Diff 63482.Sat, Oct 19, 7:48 PM


  • fix minor grammer issue
  • bump Dd


This revision now requires review to proceed.Sat, Oct 19, 7:48 PM
This revision was not accepted when it landed; it landed in state Needs Review.Sat, Oct 19, 7:52 PM
This revision was automatically updated to reflect the committed changes.
yuripv added a subscriber: yuripv.Sat, Oct 19, 8:07 PM
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?

jlh added inline comments.Sat, Oct 19, 8:14 PM

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

imp added inline comments.Sat, Oct 19, 8:59 PM

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