Page MenuHomeFreeBSD

fstat(1) -s option
ClosedPublic

Authored by jlh on Oct 2 2019, 8:18 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Apr 16, 10:05 PM
Unknown Object (File)
Sat, Apr 13, 4:49 PM
Unknown Object (File)
Mon, Apr 1, 6:15 AM
Unknown Object (File)
Thu, Mar 28, 11:17 PM
Unknown Object (File)
Thu, Mar 28, 3:29 AM
Unknown Object (File)
Feb 12 2024, 12:17 PM
Unknown Object (File)
Dec 22 2023, 11:45 PM
Unknown Object (File)
Dec 20 2023, 5:49 AM

Details

Summary

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 192.168.1.22:22 <-> *:0
1000     ssh-agent  24448    3* local stream fffff8001d34fa00 /tmp/ssh-VIm9vDnboKfn/agent.24447
root     sendmail   29954    3* internet stream tcp fffff80297f813d0 192.168.1.31:25 <-> *:0
root     sendmail   29954    4* local dgram fffff8001d34a300 <-> fffff8001d344100 /var/run/logpriv
root     ssh        92165    4* internet stream tcp fffff80167375b70 192.168.1.3:41033 <-> 62.210.137.175:22
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

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 26965
Build 25265: arc lint + arc unit

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.

usr.bin/fstat/fstat.1
89

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

203–204

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

216

This sentence is incomplete.

usr.bin/fstat/fstat.c
346

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

460

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.

usr.bin/fstat/fstat.1
203–204

Good catch, thanks!

Updated diff again to remove whitespace diff.

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

usr.bin/fstat/fstat.1
216

socket endpoint information *is* shown

This revision is now accepted and ready to land.Oct 9 2019, 9:29 PM
usr.bin/fstat/fstat.1
216

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

fstat.1:

  • fix minor grammer issue
  • bump Dd

fstat.c:

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.
head/usr.bin/fstat/fstat.1
218 ↗(On Diff #63483)

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?

head/usr.bin/fstat/fstat.1
218 ↗(On Diff #63483)

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

head/usr.bin/fstat/fstat.1
218 ↗(On Diff #63483)

"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.