Commit Graph

85 Commits

Author SHA1 Message Date
Fernando Apesteguía
1831993577 cmp(1): Add EXAMPLES section
Add a small number of examples depicting the use of -l, -z and byte offsets

Approved by:	0mp@
2020-06-20 11:20:16 +00:00
Fernando Apesteguía
022ebaf543 cmp(1): Add EXAMPLES section
Add simple examples showing the use of -l, -z, stdin and offsets

Approved by:	bcr@
Differential Revision: https://reviews.freebsd.org/D25280
2020-06-16 15:54:59 +00:00
Alan Somers
809a8352dd Drop "All rights reserved" from the files I own
Also, add SPDX tags where needed.

MFC after:	2 weeks
2019-03-11 22:23:56 +00:00
Mark Johnston
2528b7e2cb Fix handling of rights on stdio streams, take two.
Split the rights-limiting code into two cases: if one of the input
files isn't a regular file, use caph_limit_stream(3) instead of
open-coding the same logic; if both input files are regular files,
and the initial attempts to map them succeed, we limit the rights on
those files to CAP_MMAP_R.

Add a regression test for PR 234885.

PR:		234885
Reviewed by:	delphij
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D19216
2019-02-25 19:47:27 +00:00
Mark Johnston
109b5c109c Fix cmp(1) tests for "special" mode.
Test failures don't seem to propagate up if atf_check is run in
a pipeline.  Thus, the tests continued to pass despite the bug reverted
in r343245.

MFC after:	1 week
2019-01-21 03:57:49 +00:00
Mark Johnston
33a28349a7 Revert r343117.
It breaks the special mode specified by passing "-" as one of the
input files.  Revert for now while we discuss a fix.

PR:		234885
Reported by:	delphij
MFC after:	now
2019-01-21 03:47:20 +00:00
Mark Johnston
e6de40fa79 Fix handling of rights on stdio streams.
- Limit rights on stdio before opening input files.  Otherwise, open()
  may return one of the standard descriptors and we end up limiting
  rights such that we cannot read from one of the input files.
- Use caph_limit_stdio(), which suppresses EBADF, to ensure that
  we don't emit an error if one of the stdio streams is closed.
- Don't bother further limiting rights on stdin when stdin isn't going
  to be used.  Doing so correctly requires checking for a number of
  edge cases, and it doesn't provide any significant benefit.

PR:		234885
Reviewed by:	oshogbo
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D18860
2019-01-17 17:36:18 +00:00
Mariusz Zaborski
377421df96 capsicum: use a new capsicum helpers in tools
Use caph_{rights,ioctls,fcntls}_limit to simplify the code.
2018-11-04 19:24:49 +00:00
Mariusz Zaborski
7672a0148f Convert cap_enter() < 0 && errno != ENOSYS to caph_enter() < 0.
No functional change intended.
2018-06-19 23:43:14 +00:00
Kyle Evans
8facfdcf21 cmp(1): Provide some long options
These match GNU cmp(1) for compatibility where applicable.

Future work might implement the -i option from GNU cmp(1) to express skip
either in terms of both files or of the form "SKIP1:SKIP2" rather than
specifying them as additional arguments to cmp(1).

MFC after:	1 month
2018-05-02 01:32:34 +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
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
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
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
Alan Somers
4e354796e9 Fix file descriptor leaks in cmp(1)
Also, add a few test cases

Reported by:	Coverity
CID:		271624 275338
Reviewed by:	ngie
MFC after:	4 weeks
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D9074
2017-01-07 00:59:06 +00:00
Bryan Drewery
490a8aa9a1 DIRDEPS_BUILD: Update dependencies.
MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2016-11-13 00:11:30 +00:00
Mariusz Zaborski
abdfa0b19c Restrict stdin if it's not in use.
Reviewed by:	emaste, cem
Differential Revision:	https://reviews.freebsd.org/D8184
2016-10-07 19:02:13 +00:00
Mariusz Zaborski
a4e3fc54a0 Remove the duplicated code using Capsicum helpers.
Reviewed by:	cem, ed, bapt, emaste
Differential Revision	https://reviews.freebsd.org/D8140
2016-10-07 17:56:57 +00:00
Conrad Meyer
d36899d10f Move sys/capsicum.h includes after types.h or param.h
This is not actually documented or even implied in style(9).  Make the change
to match convention.  Someone should document this convention in style(9).

Reported by:	jhb
Sponsored by:	EMC Dell Isilon
2016-09-19 20:43:03 +00:00
Conrad Meyer
e75a7302d3 cmp(1): Capsicumify
Reviewed by:	allanjude, bapt, oshogbo
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D7912
2016-09-19 16:13:00 +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
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
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
9268022b74 Merge from head@274682 2014-11-19 01:07:58 +00:00
Enji Cooper
0306a0a804 Integrate usr.bin/cmp/tests from NetBSD into atf/kyua
In collaboration with: sjg
Sponsored by: EMC / Isilon Storage Division
2014-10-09 00:50:33 +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
Simon J. Gerraty
3b8f084595 Merge head 2014-04-28 07:50:45 +00:00
Eitan Adler
7dfb7dad8b Bump .Dd for recent change 2013-11-18 23:11:42 +00:00
Eitan Adler
c4dfa475ca Indicate which options are extensions to POSIX.
Inspired by:	DragonFlyBSD
2013-11-18 22:53:24 +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
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
Ed Schouten
8ef8574d1a Add missing static keywords to cmp(1) 2011-11-06 08:14:16 +00:00
Xin LI
71024a974d Eliminate unneeded headers. 2011-06-21 20:44:06 +00:00
Joel Dahl
da52b4caaf Remove the advertising clause from UCB copyrighted files in usr.bin. This
is in accordance with the information provided at
ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change

Also add $FreeBSD$ to a few files to keep svn happy.

Discussed with:	imp, rwatson
2010-12-11 08:32:16 +00:00
Xin LI
821df508e8 Revert most part of 200420 as requested, as more review and polish is
needed.
2009-12-13 03:14:06 +00:00
Xin LI
6f2d322192 Remove unneeded header includes from usr.bin/ except contributed code.
Tested with:	make universe
2009-12-11 23:35:38 +00:00
Philippe Charnier
dd99983988 add __unused to succeed at WARNS=6 2008-07-10 13:26:46 +00:00
Ruslan Ermilov
fe0e364354 Refine markup and add the EXIT STATUS section where appropriate. 2006-12-19 10:34:14 +00:00
Ruslan Ermilov
4e9e907d63 -mdoc sweep. 2005-11-18 10:36:29 +00:00
Brian Somers
e1bfde1b04 Add a -h option to tell cmp not to follow symbolic links.
MFC after:	3 weeks
Sponsored by:	Sophos/ActiveState
2005-08-23 13:13:13 +00:00
Murray Stokely
1b8d837cd0 phk added the -x option in May 2000, but only for regular files; for
special files it was treated like -l.  This commit adds the -x option
in for special files as well.

PR:		bin/46249
Submitted by:	Colin Percival <cperciva@sfu.ca>
2003-06-19 07:24:26 +00:00
David Schultz
d48905120d The cmp utility has the questionable feature of using mmap when
comparing regular files.  Add a SIGSEGV handler to make its
behavior less surprising when a read error occurs.  The handler
does not attempt to distinguish errors from file truncation, but
anyone actively modifying a file while trying to compare it
shouldn't even expect something sane to happen.

PR:		45391
Reviewed by:	mike (mentor)
2003-02-26 06:44:46 +00:00