View | Details | Raw Unified | Return to bug 260871
Collapse All | Expand All

(-)usr.bin/touch/touch.c (-2 / +19 lines)
Lines 62-67 Link Here
62
static void	stime_arg2(const char *, int, struct timespec *);
62
static void	stime_arg2(const char *, int, struct timespec *);
63
static void	stime_darg(const char *, struct timespec *);
63
static void	stime_darg(const char *, struct timespec *);
64
static void	stime_file(const char *, struct timespec *);
64
static void	stime_file(const char *, struct timespec *);
65
static void	lstime_file(const char *, struct timespec *);
65
static int	timeoffset(const char *);
66
static int	timeoffset(const char *);
66
static void	usage(const char *);
67
static void	usage(const char *);
67
68
Lines 81-87 Link Here
81
	ts[0].tv_sec = ts[1].tv_sec = 0;
82
	ts[0].tv_sec = ts[1].tv_sec = 0;
82
	ts[0].tv_nsec = ts[1].tv_nsec = UTIME_NOW;
83
	ts[0].tv_nsec = ts[1].tv_nsec = UTIME_NOW;
83
84
84
	while ((ch = getopt(argc, argv, "A:acd:fhmr:t:")) != -1)
85
	while ((ch = getopt(argc, argv, "A:acd:fhmr:R:t:")) != -1)
85
		switch(ch) {
86
		switch(ch) {
86
		case 'A':
87
		case 'A':
87
			Aflag = timeoffset(optarg);
88
			Aflag = timeoffset(optarg);
Lines 110-115 Link Here
110
			timeset = 1;
111
			timeset = 1;
111
			stime_file(optarg, ts);
112
			stime_file(optarg, ts);
112
			break;
113
			break;
114
		case 'R':
115
			timeset = 1;
116
			lstime_file(optarg, ts);
117
			break;
113
		case 't':
118
		case 't':
114
			timeset = 1;
119
			timeset = 1;
115
			stime_arg1(optarg, ts);
120
			stime_arg1(optarg, ts);
Lines 396-405 Link Here
396
}
401
}
397
402
398
static void
403
static void
404
lstime_file(const char *fname, struct timespec *tsp)
405
{
406
	struct stat sb;
407
408
	if (lstat(fname, &sb))
409
		err(1, "%s", fname);
410
	tsp[0] = sb.st_atim;
411
	tsp[1] = sb.st_mtim;
412
}
413
414
static void
399
usage(const char *myname)
415
usage(const char *myname)
400
{
416
{
401
	fprintf(stderr, "usage: %s [-A [-][[hh]mm]SS] [-achm] [-r file] "
417
	fprintf(stderr, "usage: %s [-A [-][[hh]mm]SS] [-achm] [-r file] "
402
		"[-t [[CC]YY]MMDDhhmm[.SS]]\n"
418
		"[-R file]\n"
419
		"       [-t [[CC]YY]MMDDhhmm[.SS]]\n"
403
		"       [-d YYYY-MM-DDThh:mm:SS[.frac][tz]] "
420
		"       [-d YYYY-MM-DDThh:mm:SS[.frac][tz]] "
404
		"file ...\n", myname);
421
		"file ...\n", myname);
405
	exit(1);
422
	exit(1);
(-)usr.bin/touch/touch.1 (+7 lines)
Lines 42-47 Link Here
42
.Op Fl A Ar [-][[hh]mm]SS
42
.Op Fl A Ar [-][[hh]mm]SS
43
.Op Fl achm
43
.Op Fl achm
44
.Op Fl r Ar file
44
.Op Fl r Ar file
45
.Op Fl R Ar file
45
.Op Fl t Ar [[CC]YY]MMDDhhmm[.SS]
46
.Op Fl t Ar [[CC]YY]MMDDhhmm[.SS]
46
.Op Fl d Ar YYYY-MM-DDThh:mm:SS[.frac][tz]
47
.Op Fl d Ar YYYY-MM-DDThh:mm:SS[.frac][tz]
47
.Ar
48
.Ar
Lines 161-166 Link Here
161
.It Fl r
162
.It Fl r
162
Use the access and modifications times from the specified file
163
Use the access and modifications times from the specified file
163
instead of the current time of day.
164
instead of the current time of day.
165
.It Fl R
166
As
167
.Fl r
168
, but if the file is a symbolic link, return the times of the link
169
itself rather than the file that the link points to.
170
(NB: This is a FreeBSD 13+ only extension)
164
.It Fl t
171
.It Fl t
165
Change the access and modification times to the specified time instead
172
Change the access and modification times to the specified time instead
166
of the current time of day.
173
of the current time of day.

Return to bug 260871