Commit Graph

159 Commits

Author SHA1 Message Date
Simon J. Gerraty
d9a4274795 Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
Dag-Erling Smørgrav
6fc1bbbf62 w: Unlike err(3), xo_err(3) won't accept a null format string.
MFC after:	1 week
X-MFC-with:	d90ff31ae5
Sponsored by:	Klara, Inc.
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D38192
2023-01-25 18:03:00 +01:00
Dag-Erling Smørgrav
d90ff31ae5 w: Complete libxo transition.
MFC after:	1 week
Sponsred by:	Klara, Inc.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D38172
2023-01-25 07:22:46 +01:00
Dag-Erling Smørgrav
deb2f1b616 w: Fix premature rounding.
If the system has been up more longer than a minute, we add 30 seconds to
the uptime so that subsequent calculations will round to the nearest minute
rather than truncate.  However, since the introduction of libxo, we output
the raw value after performing the adjustment.  Rewrite so that we output
the raw value first, then perform the adjustment and recalculate before
outputting the humanized value.

While there, reduce stack usage and avoid needless allocations.

Sponsored by:	Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D37128
2022-10-26 15:56:40 +00:00
Dag-Erling Smørgrav
04f6b9cb18 w: cosmetic fixes.
Sponsored by:	Klara, Inc.
2022-10-21 16:37:44 +00:00
Kristof Provost
307625842b w: don't truncate if we're writing libxo json/xml
If we're writing structured output (i.e. json or xml) we shouldn't worry
about terminal width, and instead always output full width information.

This means that, for example, if we're called from crontab with 'w
--libxo json' we'll provide full the command field rather than
pointlessly truncating it.

Suggested by:	Phil Shafer
Event:		Aberdeen Hackathon 2022
Differential Revision:	https://reviews.freebsd.org/D25013
2022-10-07 18:21:27 +02:00
Fernando Apesteguía
3f8c71d1c9 w(1): Add EXAMPLES to man page
Add small example section showing general use and -d and -h flags

Approved by:	manpages (bcr@)
Differential Revision:	https://reviews.freebsd.org/D26172
2020-08-24 17:57:08 +00:00
Fernando Apesteguía
976e7c964b uptime(1): Add EXAMPLES section
Add a simple example

Approved by:	manpages (bcr@)
Differential Revision:	https://reviews.freebsd.org/D26063
2020-08-18 16:58:37 +00:00
Yuri Pankov
2d3725d62a w: use locale-based string format specifiers
Use locale-based string format specifiers when printing
the process names/arguments.

Reviewed by:	pstef
Differential Revision:	https://reviews.freebsd.org/D25174
2020-06-21 11:42:49 +00:00
Mike Karels
ae3353515b Fix address annotation in xml output from w
The libxo xml feature of adding an annotation with the "original"
address from the utmpx file if it is different than the final "from"
field was broken by r351379. This was pointed out by the gcc error
that save_p might be used uninitialized. Save the original address
as needed in each entry, don't just use the last one from the previous
loop.

Reviewed by:	marcel@
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D21390
2019-08-29 02:44:18 +00:00
Bjoern A. Zeeb
fada51254f w: initialize save_p to silence 'may be used uninitilized'
After r351379 save_p may be used uninitialized.  Set it to NULL before
first assignment so that a later NULL check will work correctly.

Reported by:		CI system for gcc platforms
MFC after:		1 week
X-MFC with:		351379 (karels)
2019-08-22 07:52:06 +00:00
Mike Karels
ec9801de1e Change w(1) to compute FROM (host) field size dynamically
It's nice to be able to display a full IPv6 host address if
needed, but it's also nice to display more than 3 characters of a command
line. Compute the needed size for the FROM column in an earlier pass,
and determine the maximum, then print what fits for the command.

Reviewed by:	marcel@ (markm@ previous revision)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D21211
2019-08-22 03:28:31 +00:00
Pedro F. Giffuni
8a16b7a18f General further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 3-Clause license.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.
2017-11-20 19:49:47 +00:00
Bryan Drewery
ea825d0274 DIRDEPS_BUILD: Update dependencies.
Sponsored by:	Dell EMC Isilon
2017-10-31 00:07:04 +00:00
Alexander Motin
ba86ca7c84 Fix singular/plural "users" output.
It was broken during libxo'fication.

PR:		221039
Submitted by:	timur@
MFC after:	1 week
2017-07-27 14:34:57 +00:00
Warner Losh
a35f04fba2 Adopt SRCTOP in usr.bin
Prefer ${SRCTOP}/foo over ${.CURDIR}/../../foo and ${SRCTOP}/usr.bin/foo
over ${.CURDIR}/../foo for paths in Makefiles.

Differential Revision:	https://reviews.freebsd.org/D9932
Sponsored by:		Netflix
Silence on:		arch@ (twice)
2017-03-12 18:58:44 +00:00
Marcelo Araujo
807bd0d9f0 Use nitems() from sys/param.h.
Reviewed by:	ume
MFC after:	3 weeks.
Differential Revision:	https://reviews.freebsd.org/D9938
2017-03-10 04:30:31 +00:00
Warner Losh
fbbd9655e5 Renumber copyright clause 4
Renumber cluase 4 to 3, per what everybody else did when BSD granted
them permission to remove clause 3. My insistance on keeping the same
numbering for legal reasons is too pedantic, so give up on that point.

Submitted by:	Jan Schaumann <jschauma@stevens.edu>
Pull Request:	https://github.com/freebsd/freebsd/pull/96
2017-02-28 23:42:47 +00:00
Hajimu UMEMOTO
2279a9a428 When -n is specified, don't make bogus DNS queries. Instead,
when -n is specified more than once, hostnames stored in utmp
are attempted to resolve to display them as network addresses.

PR:		212272
2016-09-02 18:28:14 +00:00
Craig Rodrigues
06691045ba Add more text to explain --libxo flag. 2015-12-01 19:18:53 +00:00
Bryan Drewery
cf990407e1 Update dependencies after r291406 added libelf to libkvm.
Unfortunately filemon/meta mode tracks all indirect dependencies here
since ld(1) is reading libelf when linking in libkvm.  Churn would be
reduced if this was able to be limited to direct dependencies.

Sponsored by:	EMC / Isilon Storage Division
2015-12-01 05:18:48 +00:00
Xin LI
ab9cee11d6 w(1) is not setgid binary since r53279, so remove the setgid() call.
Reviewed By:	wollman
MFC after:	2 weeks
Differential Revision: https://reviews.freebsd.org/D3541
2015-09-09 05:17:04 +00:00
Marcel Moolenaar
d1a0d267b7 Upgrade libxo to 0.4.5.
Local changes incorporated by 0.4.5: r284340
Local changes retained: r276260, r282117

Obtained from:	https://github.com/Juniper/libxo
2015-08-24 16:26:20 +00:00
Mark Murray
339ce033d2 Widen the host field so that a full IPv6 address will be seen. 2015-07-14 18:53:24 +00:00
Simon J. Gerraty
ccfb965433 Add META_MODE support.
Off by default, build behaves normally.
WITH_META_MODE we get auto objdir creation, the ability to
start build from anywhere in the tree.

Still need to add real targets under targets/ to build packages.

Differential Revision:       D2796
Reviewed by: brooks imp
2015-06-13 19:20:56 +00:00
Simon J. Gerraty
44d314f704 dirdeps.mk now sets DEP_RELDIR 2015-06-08 23:35:17 +00:00
Simon J. Gerraty
98e0ffaefb Merge sync of head 2015-05-27 01:19:58 +00:00
Allan Jude
630a02daae Fix libxo output from uptime command
the libxo output for uptime returned multiple 'uptime' keys, one each for number of days, hours, and minutes of uptime.
This is invalid JSON.
This patch makes the output the raw number of seconds, as well as adding keys for the individual unit values
A string of the original output from the plain-text uptime command is also added

Differential Revision:	https://reviews.freebsd.org/D2063
Reviewed by:	jmg
Approved by:	marcel
Sponsored by:	ScaleEngine Inc.
2015-04-16 22:09:37 +00:00
Mark Johnston
10b92369a1 Call xo_finish(3) before exiting in usage(). 2015-03-09 03:31:26 +00:00
Michael Gmelin
441ee032a3 Add xo_finish() to w.c in case it's invoked as uptime
Reviewed by:	marcel
Approved by:	marcel
Differential Revision: https://reviews.freebsd.org/D1821
2015-02-10 22:23:52 +00:00
Baptiste Daroussin
3e11bd9e2a Convert to usr.bin/ to LIBADD
Reduce overlinking
2014-11-25 14:29:10 +00:00
Simon J. Gerraty
488c975a1f Updated/new dependencies 2014-11-19 07:10:38 +00:00
Simon J. Gerraty
9268022b74 Merge from head@274682 2014-11-19 01:07:58 +00:00
Marcel Moolenaar
bab0558297 Fix text output for the uptime command.
Reported by: "Max N. Boyarov" <zotrix@bsd.by>, ae@
2014-11-11 21:52:10 +00:00
Marcel Moolenaar
a01ced3391 Sort the references in "SEE ALSO" by section first; then alphabetically.
Pointed out by: brueffer@
2014-11-06 16:17:41 +00:00
Marcel Moolenaar
d6112c71c6 Document that w(1) supports libxo(3). 2014-11-05 23:59:52 +00:00
Marcel Moolenaar
76c0abf129 Convert to use libxo.
Obtained from:  Phil Shafer <phil@juniper.net>
Sponsored by:   Juniper Networks, Inc.
2014-11-05 23:54:33 +00:00
Eitan Adler
920aa23dad don't reinvent the wheel: rely on basename(3)
Reviewed by:	nwhitehorn
2014-10-08 05:04:31 +00:00
Simon J. Gerraty
fae50821ae Updated dependencies 2014-05-16 14:09:51 +00:00
Simon J. Gerraty
76b28ad6ab Updated dependencies 2014-05-10 05:16:28 +00:00
Andriy Gapon
a29cc9a34b Revert r253748,253749
This WIP should not have been committed yet.

Pointyhat to:	avg
2013-07-28 18:44:17 +00:00
Andriy Gapon
c722ec3a51 remove needless inclusion of machine/cpu.h in userland
MFC after:	21 days
2013-07-28 18:35:43 +00:00
Simon J. Gerraty
7cf3a1c6b2 Updated dependencies 2013-03-11 17:21:52 +00:00
Simon J. Gerraty
f5f7c05209 Updated dependencies 2013-02-16 01:23:54 +00:00
David E. O'Brien
d9a447559b Sync with HEAD. 2013-02-08 16:10:16 +00:00
John Baldwin
9f0b6e5e27 - Move 'showthreads' check out of fmt.c.
- Update shadow copy of fmt_argv() prototype in w.c and fix calls for
  additional parameter.
2013-01-19 00:21:55 +00:00
Xin LI
c3a1bb32f4 Set showthread = 0 for w(1).
X-MFC:	together with r245610
2013-01-18 23:54:27 +00:00
Ed Schouten
dbd1414ddc Fix whitespace.
MFC after:	1 week
2012-11-17 16:47:05 +00:00
Simon J. Gerraty
23090366f7 Sync from head 2012-11-04 02:52:03 +00:00
Ed Maste
b6eec535d3 Use CLOCK_UPTIME to get the uptime. 2012-10-12 15:03:28 +00:00