History log of /freebsd-current/usr.bin/touch/touch.c
Revision Date Author Comments
# aa69e0f2 27-Mar-2024 Dag-Erling Smørgrav <des@FreeBSD.org>

touch: Allow setting the timestamp to -1.

Note that VFS internally interprets a timestamp of -1 as “do not set”,
so this has no effect, but at least touch won't incorrectly reject the
given date / time (1969-12-31 23:59:59 UTC) as invalid.

While here, fix some style issues.

MFC after: 1 week
Reviewed by: allanjude
Differential Revision: https://reviews.freebsd.org/D44504


# 0b8224d1 24-Nov-2023 Warner Losh <imp@FreeBSD.org>

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


# bdcbfde3 23-Nov-2023 Warner Losh <imp@FreeBSD.org>

usr.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


# e5d258c9 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: two-line .c pattern

Remove /^#include\s+<sys/cdefs.h>.*$\n\s+__FBSDID\("\$FreeBSD\$"\);\n/


# cb54c500 12-Mar-2022 Mariusz Zaborski <oshogbo@FreeBSD.org>

touch: don't leak descriptor if fstat(2) fails

If fstat(2) fails the close(2) won't be called, which will leak the
file descriptor.

The idea was borrowed from OpenBSD, where similar patch
was applied for futimens(2).

MFC after: 1 week


# 8a16b7a1 20-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

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.


# fbbd9655 28-Feb-2017 Warner Losh <imp@FreeBSD.org>

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


# 51492908 15-Feb-2015 Jilles Tjoelker <jilles@FreeBSD.org>

touch: Fix some subtle bugs related to NULL times fallback:

* Do not subvert vfs.timestamp_precision by reading the time and passing
that to utimensat(). Instead, pass UTIME_NOW. A fallback to a NULL times
pointer is no longer used.

* Do not ignore -a/-m if the user has write access but does not own the
file. Leave timestamps unchanged using UTIME_OMIT and do not fall back to
a NULL times pointer (which would set both timestamps) if that fails.

Reviewed by: bde


# 5faf2ae1 24-Jan-2015 Jilles Tjoelker <jilles@FreeBSD.org>

cp,mv,touch: Set timestamps with nanosecond precision.

This uses utimensat().


# b268ae64 23-Apr-2013 Eitan Adler <eadler@FreeBSD.org>

Constify where appropriate.

Reported by: emaste
Approved by: cperciva (mentor)
MFC After: 3 days


# 4145c5f1 23-Apr-2013 Eitan Adler <eadler@FreeBSD.org>

Cleanups to touch.c
- use const where appropriate
- use static where appropriate
- use explicit checks checks for error conditions

Reviewed by: sbruno
Approved by: cperciva (mentor)
Obtained by: DragonFlyBSD


# 58771450 10-Jun-2012 Jilles Tjoelker <jilles@FreeBSD.org>

touch: Add the -d option from POSIX.1-2008.

This is much like -t but with a different format which is ISO8601-like and
allows fractions of a second.

The precision is limited to microseconds because of utimes() and friends,
even though stat() returns nanoseconds.

MFC after: 10 days


# 401c9fda 04-Feb-2012 Jaakko Heinonen <jh@FreeBSD.org>

Remove useless and potentially dangerous rw() function which tries to
update access and modification times by reading and writing the file.
chmod(2) in rw() doesn't help because utimes(2) allow owner and the
super-user to change times. Using just utimes(2) should be sufficient.

The -f option becomes no-op.

Reviewed by: jilles


# da52b4ca 11-Dec-2010 Joel Dahl <joel@FreeBSD.org>

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


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# 99742a23 28-Mar-2010 Ed Schouten <ed@FreeBSD.org>

Change all our own code to use st_*tim instead of st_*timespec.

Also remove some local patches to diff(1) which are now unneeded.


# f004e813 28-Mar-2010 Jaakko Heinonen <jh@FreeBSD.org>

MFC r198175:

- If lstat()/stat() fails with an error other than ENOENT, don't ignore
the error and assume that the file doesn't exist. Touch could return
success with -c option even if the file existed and time was not set.
- If the first utimes_f() call fails with -A option, give up and don't
continue trying to set times to current time. [1]
- Set exit status to 1 when setting of timestamps fails for a directory
or symbolic link even though lstat()/stat() would succeed.
- Don't print bogus error message when rw() succeeds.

PR: bin/112213


# fe0506d7 09-Mar-2010 Marcel Moolenaar <marcel@FreeBSD.org>

Create the altix project branch. The altix project will add support
for the SGI Altix 350 to FreeBSD/ia64. The hardware used for porting
is a two-module system, consisting of a base compute module and a
CPU expansion module. SGI's NUMAFlex architecture can be an excellent
platform to test CPU affinity and NUMA-aware features in FreeBSD.


# c64b097b 16-Oct-2009 Jaakko Heinonen <jh@FreeBSD.org>

- If lstat()/stat() fails with an error other than ENOENT, don't ignore
the error and assume that the file doesn't exist. Touch could return
success with -c option even if the file existed and time was not set.
- If the first utimes_f() call fails with -A option, give up and don't
continue trying to set times to current time. [1]
- Set exit status to 1 when setting of timestamps fails for a directory
or symbolic link even though lstat()/stat() would succeed.
- Don't print bogus error message when rw() succeeds.

PR: bin/112213
Submitted by: jilles [1]
Reviewed by: jilles
Approved by: trasz (mentor)


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# 1b54381b 10-Apr-2007 Greg Lehey <grog@FreeBSD.org>

Usage: print base name of program.

-A flag: respect the -a and -m flags.
imply the -c flag.

Requested in principle by: brian


# 3481910d 08-Apr-2007 Greg Lehey <grog@FreeBSD.org>

Add -A flag to adjust existing time stamps.
Print name by which program was started in usage() message.

MFC after: 2 weeks


# fb1a11d7 30-Jan-2006 Andrey A. Chernov <ache@FreeBSD.org>

Don't set time to current, if set to specific time fails

PR: 92577


# f4ac32de 04-Sep-2002 David Malone <dwmalone@FreeBSD.org>

ANSIify function definitions.
Add some constness to avoid some warnings.
Remove use register keyword.
Deal with missing/unneeded extern/prototypes.
Some minor type changes/casts to avoid warnings.

Reviewed by: md5


# 93b0017f 25-Aug-2002 Philippe Charnier <charnier@FreeBSD.org>

Replace various spelling with FALLTHROUGH which is lint()able


# 3a7fc8ce 18-Aug-2002 Juli Mallett <jmallett@FreeBSD.org>

Remove local prototypes for main().


# 4d01a8fb 22-Jul-2002 Eric Melville <eric@FreeBSD.org>

Handle directories correctly.

PR: 40801
MFC after: 5 days


# 3f330d7d 21-Mar-2002 Warner Losh <imp@FreeBSD.org>

remove __P


# 1a9e1c9d 11-Dec-2001 Mark Murray <markm@FreeBSD.org>

WARNS=2 is going to be the default, so don't specify it. Use __FBSDID().


# d39947fd 22-Sep-2001 David E. O'Brien <obrien@FreeBSD.org>

blah, remove debugging code that crept in with last commit.


# 842d1c6c 22-Sep-2001 David E. O'Brien <obrien@FreeBSD.org>

Add the 'h' flag to operate on symlinks rather than what they point to.


# 16dd925f 26-May-2001 Kris Kennaway <kris@FreeBSD.org>

Fix some trivial warnings and clamp down with WARNS=2

MFC after: 1 week


# 9ef5c48b 04-Jul-1999 Bill Fumerola <billf@FreeBSD.org>

Clean up some ambiguous nested if/elses.


# ecb80458 12-May-1999 Dag-Erling Smørgrav <des@FreeBSD.org>

Brucify.


# 6b284d8a 11-May-1999 Dag-Erling Smørgrav <des@FreeBSD.org>

Sync usage() with man page.

PR: 11539
Submitted by: Ruslan Ermilov <ru@ucb.crimea.ua>


# 25c4d008 05-Jan-1999 Daniel O'Callaghan <danny@FreeBSD.org>

Merge from 2_2 man page change.


# 34c7ff49 05-Jan-1999 Daniel O'Callaghan <danny@FreeBSD.org>

PR: 9323
Submitted by: ishisone@sra.co.jp
Make touch handle years 2000-2038 in the obsoleted format, rather
than 1902-1969 as was previously the case with two digit year spec.


# 39470616 29-Jun-1998 Bruce Evans <bde@FreeBSD.org>

Don't assume that time_t is long.


# c44252b6 06-Jul-1997 Bruce Evans <bde@FreeBSD.org>

Finish importing Lite2's src/usr.bin, except for ex, diff, grep, mail,
pascal and vmstat.sparc. All changed files on the vendor branch should
already have been imported.


# 1c8af878 28-Mar-1997 Warner Losh <imp@FreeBSD.org>

compare return value from getopt against -1 rather than EOF, per the final
posix standard on the topic.


# eaa86f9d 13-Sep-1996 Bruce Evans <bde@FreeBSD.org>

Don't use __dead or __pure in user code. They were obfuscations
for gcc >= 2.5 and no-ops for gcc >= 2.6. Converted to use __dead2
or __pure2 where it wasn't already done, except in math.h where use
of __pure was mostly wrong.


# d38ca307 08-Jul-1995 Joerg Wunsch <joerg@FreeBSD.org>

PR # bin/274
> The command:
>
> touch -t 199504011200 testfile
>
> gives the error message:
>
> touch: out of range or illegal time specification: [[CC]YY]MMDDhhmm[.SS]

Submitted by: mpp@legarto.minn.net (Mike Pritchard)


# 7799f52a 30-May-1995 Rodney W. Grimes <rgrimes@FreeBSD.org>

Remove trailing whitespace.


# 9b50d902 26-May-1994 Rodney W. Grimes <rgrimes@FreeBSD.org>

BSD 4.4 Lite Usr.bin Sources