Commit graph

76 commits

Author SHA1 Message Date
LO WEN-CHIEN 49eeca743b
stat(1): Fix grammar error in stat.c
Event:		Advanced UNIX Programming Course (Fall’23) at NTHU
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1014
2024-02-13 15:33:16 +08:00
Warner Losh fa9896e082 Remove $FreeBSD$: two-line nroff pattern
Remove /^\.\\"\n\.\\"\s*\$FreeBSD\$$\n/
2023-08-16 11:55:10 -06:00
Warner Losh d0b2dbfa0e Remove $FreeBSD$: one-line sh pattern
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
2023-08-16 11:55:03 -06:00
Warner Losh 1d386b48a5 Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:54:42 -06:00
Warner Losh b61a573019 spdx: The BSD-2-Clause-NetBSD identifier is obsolete, drop -NetBSD
The SPDX folks have obsoleted the BSD-2-Clause-NetBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with:		pfg
MFC After:		3 days
Sponsored by:		Netflix
2023-05-12 10:44:04 -06:00
Simon J. Gerraty d9a4274795 Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
Jamie Landeg-Jones 37399d5bcf usr.bin/stat: Fix error message formatting.
PR:		bin/261657
MFC after:	3 days
2023-01-29 14:37:25 -08:00
Alexander Naumochkin 050e4bca94 stat(1): Do not pass S_IFBLK to devname unconditionally
PR:	269190
Reviewed by:	kib
MFC after:	1 week
2023-01-28 20:04:43 +02:00
Kyle Evans 0e73b834f3 tests: readlink: fix atf_test_case call [NFC]
This was meant to read `basic`, rather than a duplicate of `f_flag`.  It
is largely irrelevant, though, as atf_test_case mostly just makes
sure that the proper functions are defined.

Sponsored by:	Klara, Inc.
2022-03-03 21:51:40 -06:00
Stefan Eßer 20f8331aca usr.bin/stat: honour locale for "-t %+"
The man page states that "-t %+" prints time information in the same
format as date with no format specifier.

This was not the case, the format used was always that of date for the
POSIX locale.

The fix suggested by the reporter leads to output that matches the
documentation.

Reported by:	Jamie Landeg-Jones <jamie@catflap.org>
MFC after:	3 days
2021-10-30 09:00:34 +02:00
Edward Tomasz Napierala 98ce554a3d Unbreak the tests after r347002.
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2019-05-01 19:35:45 +00:00
Edward Tomasz Napierala f35f34b153 Add 'Birth' to 'stat -x' output. Current Linux stat(1)
also includes that.

Reviewed by:	cem
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D20130
2019-05-01 18:56:22 +00:00
Conrad Meyer a04ed7615e stat(1): cache id->name resolution
When invoked on a large list of files, it is most common for a small number of
uids/gids to own most of the results.

Like ls(1), use pwcache(3) to avoid repeatedly looking up the same IDs.

Example microbenchmark and non-scientific results:

$ time (find /usr/src -type f -print0 | xargs -0 stat >/dev/null)

BEFORE:
3.62s user 5.23s system 102% cpu 8.655 total
3.47s user 5.38s system 102% cpu 8.647 total

AFTER:
1.23s user 1.81s system 108% cpu 2.810 total
1.43s user 1.54s system 107% cpu 2.754 total

Does this microbenchmark have any real-world significance?  Until a use case
is demonstrated otherwise, I doubt it.  Ordinarily I would be resistant to
optimizing pointless microbenchmarks in base utilities (e.g., recent totally
gratuitous changes to yes(1)).  However, the pwcache(3) APIs actually
simplify stat(1) logic ever so slightly compared to the raw APIs they wrap,
so I think this is at worst harmless.

PR:		230491
Reported by:	Thomas Hurst <tom AT hur.st>
Discussed with:	gad@
2018-08-11 02:56:43 +00:00
Pedro F. Giffuni 1de7b4b805 various: general adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

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.

No functional change intended.
2017-11-27 15:37:16 +00:00
Bryan Drewery ea825d0274 DIRDEPS_BUILD: Update dependencies.
Sponsored by:	Dell EMC Isilon
2017-10-31 00:07:04 +00:00
Bryan Drewery 3806950135 DIRDEPS_BUILD: Connect new directories.
Sponsored by:	Dell EMC Isilon
2017-10-31 00:04:07 +00:00
Enji Cooper 8c09935728 Add HAS_TESTS to all Makefiles that use the SUBDIR.${MK_TESTS}+= tests idiom 2017-08-02 08:14:06 +00:00
Enji Cooper faef91fab6 :l_flag:: be more aggressive when normalizing whitespace
Save output from ls -ldT and stat -l, then normalize all repeating whitespace using
sed to single column spaces.

This makes the test flexible with single-digit days, etc, similar to r320723. This
approach is just a bit more of a hammer approach because of how the columns are
ordered/spaced in both ls and stat.

MFC after:	1 week
MFC with:	r319841
2017-07-06 07:37:03 +00:00
Enji Cooper 5e8e7af348 Use %e instead of %d with x_output_date(..)
stat -x doesn't 0-fill days so %d is inappropriate. %e is correct.

MFC after:	1 week
MFC with:	r319841
2017-07-06 06:15:44 +00:00
Enji Cooper 64a82bcd4e Add initial tests for stat(1)
Testcases for -H, -L, and -f haven't been implemented yet, in part due
to additional complexity needed to validate the features:
* -H and -f will require an external "helper" program to display/modify
  the state/permissions for a given path.
* -L is being covered partially via the -n testcase today.

MFC after:	1 month
2017-06-12 00:21:55 +00:00
Enji Cooper 39aed6d61a stat(1): sort flags in the DESCRIPTION section
-x's description should come after -t's description.

MFC after:	1 month
Sponsored by:	Dell EMC Isilon
2017-06-11 21:23:54 +00:00
Enji Cooper 21860bf938 Write up some basic tests for readlink(1)
The tests exercise -f (f_flag), -n (n_flag), and no arguments (basic).

MFC after:	1 month
Sponsored by:	Dell EMC Isilon
2017-06-11 21:13:12 +00:00
Marcelo Araujo 5d49c30c7b Use MIN() instead of MAX() as the previous syntax was wrote in a weird and
confused way: "prec > 9 ? 9 : prec".

Submitted by:	pfg, ngie and luke <luke.tw@gmail.com>
MFC after:	2 weeks.
2016-04-26 00:29:00 +00:00
Marcelo Araujo cadc2836d8 Use macro MAX() from sys/param.h.
MFC after:	2 weeks.
2016-04-22 03:43:06 +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 ee7b0571c2 Merge head from 7/28 2014-08-19 06:50:54 +00:00
Baptiste Daroussin 2b7af31cf5 use .Mt to mark up email addresses consistently (part3)
PR:		191174
Submitted by:	Franco Fichtner  <franco at lastsummer.de>
2014-06-23 08:23:05 +00:00
Simon J. Gerraty fae50821ae Updated dependencies 2014-05-16 14:09:51 +00:00
Thomas Quinot 55298f0397 Minor fixes to previous change introducing switch -H, as per comments
on -arch.

Reviewed by:	gleb
2014-05-11 18:49:18 +00:00
Simon J. Gerraty 76b28ad6ab Updated dependencies 2014-05-10 05:16:28 +00:00
Simon J. Gerraty cc3f4b9965 Merge from head 2014-05-08 23:54:15 +00:00
Thomas Quinot 4d6bab2606 Introduce a new command line switch '-H' for stat(1)
causing arguments to be interpreted as NFS file handles.

Reviewed by:	-arch (jhb, eadler)
MFC after:	1 month
2014-05-07 19:22:54 +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
Simon J. Gerraty 23090366f7 Sync from head 2012-11-04 02:52:03 +00:00
Ed Schouten bf70becee6 More -Wmissing-variable-declarations fixes.
In addition to adding `static' where possible:

- bin/date: Move `retval' into extern.h to make it visible to date.c.
- bin/ed: Move globally used variables into ed.h.
- sbin/camcontrol: Move `verbose' into camcontrol.h and fix shadow warnings.
- usr.bin/calendar: Remove unneeded variables.
- usr.bin/chat: Make `line' local instead of global.
- usr.bin/elfdump: Comment out unneeded function.
- usr.bin/rlogin: Use _Noreturn instead of __dead2.
- usr.bin/tset: Pull `Ospeed' into extern.h.
- usr.sbin/mfiutil: Put global variables in mfiutil.h.
- usr.sbin/pkg: Remove unused `os_corres'.
- usr.sbin/quotaon, usr.sbin/repquota: Remove unused `qfname'.
2012-10-19 14:49:42 +00:00
Marcel Moolenaar 7750ad47a9 Sync FreeBSD's bmake branch with Juniper's internal bmake branch.
Requested by: Simon Gerraty <sjg@juniper.net>
2012-08-22 19:25:57 +00:00
Christian Brueffer fbe83f25fb Remove duplicate -l description.
Submitted by:	Rainer Hurling <rhurlin@gwdg.de>
MFC after:	1 week
2012-04-22 18:18:49 +00:00
Doug Barton 4939927762 Synthesize the change from NetBSD's 1.33:
"Do not crash if a date cannot be represented (localtime returning
NULL), use the Epoch value instead."

Obtained from:  njoly@NetBSD.org
2011-02-11 05:33:35 +00:00
Doug Barton 34aba78b16 Bring in the relevant changes from NetBSD's 1.31:
"Use strlcpy, not strncpy, when the desired semantics are strlcpy's
rather than strncpy's."

Note: NetBSD's 1.32 is their adoption of our r216206

Obtained from:	dholland@NetBSD.org
2010-12-18 00:30:52 +00:00
Doug Barton de28c1d699 Bring in the change from OpenBSD's 1.14:
"synchronize synopsis and usage; "-l", "-r", "-s" and "-x" are mutually
exclusive; while here, slightly improve spacing in the source code
so it fits on a 80-column display again.

diff greatly improved by martynas@"

Obtained from:	sobrado@OpenBSD.org
2010-12-09 23:57:23 +00:00
Doug Barton 4221d3eb78 Bring in the change from NetBSD 1.28:
"\\ -> \e"

Obtained from:	joerg@NetBSD.org

Bump .Dd because we're now up to date with the latest NetBSD version
2010-12-05 22:47:08 +00:00
Doug Barton c6281ac026 Bring in the following changes from NetBSD:
1.21
"Document the flags displayed by the default format, and mention their short
names. From espie@openbsd via jmc@openbsd."

1.24
"Fix three variable names.
From Todd T. Fries via Jason McIntyre."

Obtained from:	wiz@NetBSD.org (previous 2)

1.25
"Be consistent: document the birthtime field of struct stat for
the "B" field specifier."

Obtained from:	reed@NetBSD.org

1.26
"Drop trailing space."

Obtained from:	wiz@NetBSD.org

1.27
"Since we have st_birthtime in struct stat, it is in default display."

Obtained from:	enami@NetBSD.org

Purposely skipping the following revisions:
1.22	NetBSD-specific change
1.23	Removal of license clauses 3 and 4, already handled by imp
	in our r203971
2010-12-05 22:41:58 +00:00
Doug Barton dc5e1d528e Bring in the change from NetBSD 1.20:
"Make sentence easier to parse. From jsing@openbsd via jmc@openbsd."

Obtained from:	wiz@NetBSD.org
2010-12-05 22:24:34 +00:00
Doug Barton 7c304a3b0f Bring in the changes from NetBSD 1.16 that we did not already have.
"Some fixes from jmc@openbsd."

Obtained from:	wiz@NetBSD.org
2010-12-05 22:20:08 +00:00
Doug Barton d127a98c99 Bring in the changes from NetBSD 1.13 that we did not already have, with
some differences.

"Sort options. Use more mdoc macros. Some nit fixes. Bump date."

Obtained from:	wiz@NetBSD.org
2010-12-05 22:16:51 +00:00
Doug Barton 1c40e1f66c Bring in the change from NetBSD 1.12:
"document default format."

Obtained from:	yamt@NetBSD.org
2010-12-05 22:01:01 +00:00
Doug Barton da78facc72 Bring in the following changes from NetBSD. See the discussion at:
http://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=44128

1.29
"Don't printf time_t with %d; fixes PR 44128 from yamt. With this change it
successfully prints mtimes after 2038."

1.30
"Improve previous with comments."

Obtained from:	dholland@NetBSD.org (both)
2010-12-05 21:53:12 +00:00
Doug Barton d7233fd615 Fix an "unused variable" error that gets us all the way to WARNS=6 2010-12-05 21:33:05 +00:00