Commit Graph

128 Commits

Author SHA1 Message Date
Dag-Erling Smørgrav
ad4f3bdf73 cat: Missed a couple.
MFC after:	3 days
Sponsored by:	Klara, Inc.
2024-05-10 13:05:45 +02:00
Dag-Erling Smørgrav
c6f9df7064 cat: Check for lack of success rather than a specific failure.
MFC after:	3 days
Sponsored by:	Klara, Inc.
Reviewed by:	oshogbo
Differential Revision:	https://reviews.freebsd.org/D45149
2024-05-10 12:59:30 +02:00
Ed Maste
05f530f4d2 cat: fix cap_rights_init usage
Capability rights passed to cap_rights_* are not simple bitmaks and
cannot be ORed together in general (although it will work for certain
subsets of rights).

PR:		277057
Reported by:	asomers, markj
2024-02-14 19:37:54 -05:00
Zhan-Wei
10b84b88f0 cat: Use present tense
Event: Advanced UNIX Programming Course (Fall23) at NTHU.
Reviewed by: imp, lwhsu
Pull Request: https://github.com/freebsd/freebsd-src/pull/923
2023-12-26 16:53:40 -07:00
Kai-Yang Chen
c1b12377a6 cat(1): Fix typo
Fix type: rebiuld -> rebuild in Makefile

Event: Advanced UNIX Programming Course (Fall’23) at NTHU.
Reviewed by: imp, Mina Galić
Pull Request: https://github.com/freebsd/freebsd-src/pull/933
2023-12-26 10:44:38 -07:00
Warner Losh
e043f37205 bin: Automated cleanup of cdefs and other formatting
Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by:		Netflix
2023-11-26 22:23:59 -07:00
Warner Losh
0b8224d1cc Remove copyright strings ifdef'd out
We've ifdef'd out the copyright strings for some time now. Go ahead and
remove the ifdefs. Plus whatever other detritis was left over from other
recent removals. These copyright strings are present in the comments and
are largely from CSRG's attempt at adding their copyright to every
binary file (which modern interpretations of the license doesn't
require).

Sponsored by:		Netflix
2023-11-26 22:23:58 -07:00
Warner Losh
90aea514c6 bin: Remove ancient SCCS tags.
Remove ancient SCCS tags from the tree, automated scripting, with two
minor fixup to keep things compiling. All the common forms in the tree
were removed with a perl script.

Sponsored by:		Netflix
2023-11-26 22:23:28 -07:00
Martin Matuska
3c773cad57 cat: fallback on EISDIR with copy_file_range(2)
The filesystem may support reading directories directly
when security.bsd.allow_read_dir is set.

MFC after:	1 week
PR:		275099
2023-11-19 02:14:50 +01:00
Mariusz Zaborski
64c6327738 cat: add CAP_SEEK capability
The copy_file_range might require that.

Reviewed by:	emaste, theraven, kib, markj
Differential Revision:	https://reviews.freebsd.org/D41967
2023-09-28 15:38:36 +02:00
Warner Losh
b2c76c41be Remove $FreeBSD$: one-line nroff pattern
Remove /^\.\\"\s*\$FreeBSD\$$\n/
2023-08-16 11:55:15 -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
Martin Matuska
055f920ebe cat: fallback on EBADF with copy_file_range(2)
When stdout is opened with O_APPEND, copy_file_range(2) fails with EBADF.
2023-07-09 01:08:46 +02:00
Martin Matuska
8113cc8276 cat: use copy_file_range(2) with fallback to previous behavior
This allows to use special filesystem features like server-side
copying on NFS 4.2 or block cloning on OpenZFS 2.2.

Reviewed by:	imp, rmacklem
Differential revision:	https://reviews.freebsd.org/D40882
2023-07-08 21:51:15 +02:00
Alfonso Gregory
38f57faa06 cat: ensure serrno is always set
Set serrno to errno before the loop begins for the edge case that res0
is immediately NULL.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/724
2023-07-07 15:56:35 -06:00
Simon J. Gerraty
d9a4274795 Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
Mariusz Zaborski
0614d73967 cat: style nits
Pointed out by:	jhb
2021-01-20 18:46:26 +01:00
Ed Maste
e83b514a95 cat: depend on Makefile to rebuild when WITH_CASPER changes
We try to ensure building WITHOUT_CLEAN (or -DNO_CLEAN) works on an
ongoing basis.  b7ab6832cd changed cat to build w/o -DWITH_CASPER
by default; add a cat.o dependency on the Makefile so that it gets
rebuilt.
2021-01-17 12:19:00 -05:00
Mariusz Zaborski
b7ab6832cd cat: disable building it with Casper
We want to measure what are the actual cost of sandboxing cat(1).

Requested by:	mjg, cy, Mike Karels
Discussed with:	rwatson, markj
2021-01-17 01:21:46 +01:00
Mariusz Zaborski
de57c3d882 cat: style nits 2021-01-16 12:58:23 +01:00
Mariusz Zaborski
6e8062c855 cat: persistent errno
There is no guarantee that after close(2)/free the errno will remain
persistent. The caller of the udom_open function depends on the errno
for reporting errors.

Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D28185
2021-01-16 12:55:42 +01:00
Mariusz Zaborski
c664d8dfc3 cat: Fix potential memory leak
This was introduced in aefe30c543.
2021-01-15 21:49:52 +01:00
Mariusz Zaborski
aefe30c543 cat: capsicumize it
Reviewed by:	markj, arichardson
Differential Revision:	https://reviews.freebsd.org/D28083
2021-01-15 21:23:42 +01:00
Alex Richardson
ed8455806e Fix all warnings emitted in make kernel-toolchain
With this change and D27598 make kernel-toolchain no longer emits any
warnings for me.

Reviewed By:	emaste
Differential Revision: https://reviews.freebsd.org/D27599
2021-01-07 09:26:22 +00:00
Alex Richardson
a33ee411d9 Allow building bin/cat on non-FreeBSD systems
`cat -l` is needed during the installworld phase and other system's cat
don't support that flag. To avoid portability issues when compiling on
Linux/macOS (such as the the direct access to &fp->_mbstate), we
disable the entire multibyte support when building as a boostrap tool.

Reviewed By:	brooks, emaste
Differential Revision: https://reviews.freebsd.org/D13939
2020-01-16 14:15:00 +00:00
Xin LI
6d5343e38e stddef.h is not used by cat.c, remove the include. 2018-01-07 07:08:59 +00:00
Warner Losh
ca23e64eb4 Sanity check sysconf return value to ensure it's positive before we
use it. Use proper cast to convert long to size_t (instead of
blksize_t) to preclude sign extension issues.

CID: 1193754
2018-01-06 12:45:59 +00:00
Benjamin Kaduk
f3aff7c91b Fix mandoc -Tlint warnings in bin/
Many style-level issues are still reported.

Submitted by:	Yuri Pankov <yuripv@gmx.com>
Reviewed by:	jilles (previous revision)
Differential Revision:	https://reviews.freebsd.org/D13334
2017-12-07 01:57:27 +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
Sevan Janiyan
6d2e5f3ddf Ammend bin/cat/cat.c so the output is the same aside
from blank lines being numbered or unnumbered, depending on whether cat
was invoked with -ne or -be.

At present, when cat is invoked with -be, there is an aditional
difference that the '$' on blank lines is placed on the far left of the
output.

Discussed in bug 210607.

While here, revert the workaround from r304035 which skipped the unit test for
this issue previously.

PR:		210607
Submitted by:	myself
Reviewed by:	bdrewery
Obtained from:	NetBSD
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D12432
2017-09-21 14:14:49 +00:00
Enji Cooper
188e46ab03 Add supporting changes for Add limited sandbox capability to "make check"
Non-tests/... changes:
- Add HAS_TESTS= to Makefiles with libraries and programs to enable iteration
  and propagate the appropriate environment down to *.test.mk.

tests/... changes:
- Add appropriate support Makefile.inc's to set HAS_TESTS in a minimal manner,
  since tests/... is a special subdirectory tree compared to the others.

MFC after:	2 months
MFC with:	r322511
Reviewed by:	arch (silence), testing (silence)
Differential Revision:	D12014
2017-08-14 19:21:37 +00:00
Ed Maste
4be62405c0 cat: fix build with -DNO_UDOM_SUPPORT
Sponsored by:	The FreeBSD Foundation
2017-08-09 18:23:46 +00:00
Enji Cooper
d511b20a69 Add HAS_TESTS to all Makefiles that are currently using the
`SUBDIR.${MK_TESTS}+= tests` idiom.

This is a follow up to r321912.
2017-08-02 08:50:42 +00:00
Enji Cooper
4b330699f8 Convert traditional ${MK_TESTS} conditional idiom for including test
directories to SUBDIR.${MK_TESTS} idiom

This is being done to pave the way for future work (and homogenity) in
^/projects/make-check-sandbox .

No functional change intended.

MFC after:	1 weeks
2017-08-02 08:35:51 +00:00
Enji Cooper
7c91b65f54 Add testcases for cat -b
MFC after:	1 month
Sponsored by:	Dell EMC Isilon
2017-06-06 21:50:00 +00:00
Enji Cooper
9086e0e068 Add additional testcases for cat(1)
Verify the following additional cases:
- -s (in isolation, in addition to the -se testcase obtained via the
      NetBSD test).
- -vt

Submitted by:	shivansh
Reviewed by:	asomers (earlier diff), ngie
MFC after:	1 month
Sponsored by:	Google, Inc (GSoC 2017)
Differential Revision:	D11020
2017-06-06 21:03:43 +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
Andrey A. Chernov
2aa6b16f74 Implement multibyte encoding support for -v with fallback
MFC after:      7 days
2016-09-15 17:24:39 +00:00
Enji Cooper
fbc71595f0 Hack around output differences between FreeBSD and other BSDs
with cat(1)

cat -be on FreeBSD doesn't align the $ with the start of the line
like NetBSD, et al's cat -be does

PR:		210607
Sponsored by:	EMC / Isilon Storage Division
2016-08-13 02:53:02 +00:00
Enji Cooper
640235e2c2 Checkpoint initial integration work
- Some of the lib/libc and lib/thr tests fail
- lib/msun/exp_test:exp2_values now passes with clang 3.8.0

The Makefiles in contrib/netbsd-tests were pruned as they have no value

Sponsored by: EMC / Isilon Storage Division
2016-08-12 08:50:05 +00:00
Enji Cooper
014db25b98 Update ^/vendor/NetBSD/tests/dist to a more recent snapshot
Pulled on "Thu Aug 11 18:01:19 PDT 2016"
2016-08-12 01:05:07 +00:00
Enji Cooper
430f7286a5 Merge ^/user/ngie/release-pkg-fix-tests to unbreak how test files are installed
after r298107

Summary of changes:

- Replace all instances of FILES/TESTS with ${PACKAGE}FILES. This ensures that
  namespacing is kept with FILES appropriately, and that this shouldn't need
  to be repeated if the namespace changes -- only the definition of PACKAGE
  needs to be changed
- Allow PACKAGE to be overridden by callers instead of forcing it to always be
  `tests`. In the event we get to the point where things can be split up
  enough in the base system, it would make more sense to group the tests
  with the blocks they're a part of, e.g. byacc with byacc-tests, etc
- Remove PACKAGE definitions where possible, i.e. where FILES wasn't used
  previously.
- Remove unnecessary TESTSPACKAGE definitions; this has been elided into
  bsd.tests.mk
- Remove unnecessary BINDIRs used previously with ${PACKAGE}FILES;
  ${PACKAGE}FILESDIR is now automatically defined in bsd.test.mk.
- Fix installation of files under data/ subdirectories in lib/libc/tests/hash
  and lib/libc/tests/net/getaddrinfo
- Remove unnecessary .include <bsd.own.mk>s (some opportunistic cleanup)

Document the proposed changes in share/examples/tests/tests/... via examples
so it's clear that ${PACKAGES}FILES is the suggested way forward in terms of
replacing FILES. share/mk/bsd.README didn't seem like the appropriate method
of communicating that info.

MFC after: never probably
X-MFC with: r298107
PR: 209114
Relnotes: yes
Tested with: buildworld, installworld, checkworld; buildworld, packageworld
Sponsored by: EMC / Isilon Storage Division
2016-05-04 23:20:53 +00:00
Glen Barber
7d536dc855 MFH
Sponsored by:	The FreeBSD Foundation
2016-03-10 21:16:01 +00:00
Bryan Drewery
15c433351f DIRDEPS_BUILD: Connect MK_TESTS.
Sponsored by:	EMC / Isilon Storage Division
2016-03-09 22:46:01 +00:00
Glen Barber
ac2875fa16 Explicitly add unmarked bin/ binaries to the runtime package.
Note: tcsh(1) has a MK_TCSH=no test, so this should be a separate
package, which requires pre-install/post-install scripts, to be
added later.

Sponsored by:	The FreeBSD Foundation
2016-02-09 16:58:50 +00:00
Glen Barber
43faedc133 First pass to fix the 'tests' packages.
Sponsored by:	The FreeBSD Foundation
2016-02-02 22:26:49 +00:00
Enji Cooper
b2d48be1bc Refactor the test/ Makefiles after recent changes to bsd.test.mk (r289158) and
netbsd-tests.test.mk (r289151)

- Eliminate explicit OBJTOP/SRCTOP setting
- Convert all ad hoc NetBSD test integration over to netbsd-tests.test.mk
- Remove unnecessary TESTSDIR setting
- Use SRCTOP where possible for clarity

MFC after: 2 weeks
Sponsored by: EMC / Isilon Storage Divison
2015-10-12 08:16:03 +00:00
Sean Bruno
64c7af10a7 Initialize fd to -1 so that gcc doesn't emit an unitialized warning. 2015-10-04 01:56:11 +00:00