Commit graph

24 commits

Author SHA1 Message Date
John Baldwin eba230afba Purge more stray embedded $FreeBSD$ strings
These do not use __FBSDID but instead use bare char arrays.

Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D41957
2023-09-25 07:54:56 -07:00
Warner Losh 4d846d260e spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD
The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD 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:03 -06:00
Ka Ho Ng 5ee2c35751 truncate(1): Add hole-punching support
This commit adds hole-punching support to the truncate(1) utility. If
the option -d is specified, truncate(1) performs zeroing, and if
possible hole-punching in case the operation is supported by the
underlying file system of the specified files.

Sponsored by:	The FreeBSD Foundation
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D31556
2021-08-19 18:30:41 +08:00
Ka Ho Ng 89c0d2b190 truncate(1): main() return statement style fix
Sponsored by:	The FreeBSD Foundation
2021-08-18 23:45:59 +08:00
Eitan Adler ec9eb99714 truncate: delintify 2018-07-29 07:51:42 +00:00
Eitan Adler c517ae76c1 truncate: use better type for 'round' 2018-07-29 07:51:40 +00:00
Emmanuel Vadot 1017327049 truncate: Add support for -s % and /
% round up to the multiple size and / round down
This is compatible with gnu truncate.
Add tests and document in the man page.
2018-07-09 19:03:30 +00:00
Emmanuel Vadot dde27dbc9b truncate: style(9) some parts 2018-07-09 19:02:05 +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
Jilles Tjoelker fc96358cdd truncate: Detect integer overflow, fix relative sizes, add tests.
The change to expand_number (r204654) broke detection of too large sizes and
relative sizes ('+'/'-').

Also add some tests.

PR:		190735
Submitted by:	Kirk Russell
MFC after:	1 week
2014-06-09 10:39:55 +00:00
Maxim Sobolev 32bdc2b685 Use expand_number(3) from libutil instead of home-grown function to parse
human-friendly power-of-two numbers (i.e. 2k, 5M etc).

Suggested by:	many
MFC after:	1 week
2010-03-03 19:25:28 +00:00
Xin LI 614595dcc7 Initialize 'sz' as 0. 2009-02-21 03:42:31 +00:00
Colin Percival d59e8ae886 Don't close file descriptor number <whatever random garbage was on the
stack>.

Found by:	LLVM/Clang Static Checker
MFC after:	1 week
2008-08-04 06:48:54 +00:00
Maxim Konovalov a39846b5e4 o Don't leak fd on error.
o parselength() returns 0 or -1 so int is enough for its return type.

Submitted by:	Ighighi Ighighi, sheldonh
MFC after:	3 weeks
2006-09-18 16:39:23 +00:00
Ceri Davies 0033dba88b Chase revision 1.10 in usage string and a comment. 2006-09-07 17:10:26 +00:00
Pawel Jakub Dawidek e6f3621dd3 Allow to specify size in terabytes by using T or t suffix.
This speeds up my testing a bit. Because truncate(1) doesn't allocate
blocks on file system before they are used, it is very useful to
emulate huge file systems:

	# truncate -s 16T fs.img
	# mdconfig -a -f fs.img
	# newfs /dev/mdX

(-t swap can be used as well)
2006-04-09 19:16:24 +00:00
Ruslan Ermilov f682f10c76 Sync program's usage() with manpage's SYNOPSIS. 2005-05-21 09:55:10 +00:00
Lukas Ertl 6b61c155e6 Make size suffix case insensitive.
PR:            bin/27604
Submitted by:  David Xu <davidx@viasoft.com.cn>
2004-07-22 13:38:10 +00:00
Warner Losh 3f330d7d1a remove __P 2002-03-22 01:42:45 +00:00
Sheldon Hearn b86e825a0c Simplify some conditionals. 2000-07-24 21:50:38 +00:00
Sheldon Hearn dee82c612a Shut an optimizing compiler up about possibly (but never) unused
variables.

Submitted by:	charnier
2000-07-24 21:46:12 +00:00
Sheldon Hearn 6b88e76b89 truncate.c:
Do not include unused header files.
	Add rcsid.
	Change copyright.

truncate.1:
	Add AUTHORS section.

Submitted by:	charnier
2000-07-24 08:56:42 +00:00
Sheldon Hearn 4d532a362e Close file descriptors after use so as not to abuse the descriptor
table when a long argument list is given. :-)

Reported by:	Sven Agnew <afterhours80@hotmail.com>
2000-07-23 13:24:01 +00:00
Sheldon Hearn edeb84a1b2 Import the new truncate(1) utility.
Approved by:	jdp
2000-07-18 17:03:58 +00:00