Add "-F" parameter that, when specified, instructs sockstat(1) to
only display sockets for username/UID specified.
Details
- Reviewers
des asomers - Commits
- rG2deeed061b14: sockstat(1): Add "-F" parameter
Diff Detail
- Repository
- rG FreeBSD src repository
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
Just some sorting nits, I don't know about anything else.
| usr.bin/sockstat/main.c | ||
|---|---|---|
| 93 | 92m90 to match Unix style alphabetical organization like in 93,94 | |
| 1888 | Big F comes before little f, like it does in Cc;Ii: and Ll. | |
| 1924 | This should go before little F like the Ccs and Iis. | |
| usr.bin/sockstat/sockstat.1 | ||
| 86 | 79,82m76 to match Unix sorting like in 72,76 | |
Thanks for preliminary review.
There are still more open issues I need to work on, so this diff is just a placeholder for now (to track my progress).
Thanks for doing this. I think it will be a good addition. But I'm curious: why did you choose -F? Obviously -u and -U were already taken.
| usr.bin/sockstat/main.c | ||
|---|---|---|
| 125 | This would probably be better as an inline function than as a macro. | |
| 919 | realloc is allowed to move the memory. It probably won't as long as we're only shrinking the array, but it's allowed to. If it does, then the pointers already inserted into ftree will become dangling. So I think you should either remove realloc entirely or add an assertion that the files pointer doesn't move. | |
| 920 | ||
| 1618 | These could all be constant strings instead of macros. | |
| 1738 | Here's a minor bug. Not introduced by you, but if -j or -F is in use, sockstat will still gather up all of the sockets in nosocks, even though it's not going to display them. We could skip that gather step to save efficiency. I think we should do that, but it doesn't need to be part of this PR. | |
| 1911 | We filter only on first occurence of -F? For -j, we filter on the last. | |
| usr.bin/sockstat/main.c | ||
|---|---|---|
| 919 |
I've removed the realloc() call completely. | |
| 1618 |
good point, to not duplicate the strings (although I suppose that the compiler would optimize the string in a non-duplicated way). | |
| 1738 |
I've only been able to identify one place where nosocks are being gathered. | |
| 1911 |
For the sake of consistency, I made -F to act on the last occurence. | |