Deleted Added
full compact
touch.c (102084) touch.c (102412)
1/*
2 * Copyright (c) 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#include <sys/cdefs.h>
35
1/*
2 * Copyright (c) 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#include <sys/cdefs.h>
35
36__FBSDID("$FreeBSD: head/usr.bin/touch/touch.c 102084 2002-08-19 03:07:56Z jmallett $");
36__FBSDID("$FreeBSD: head/usr.bin/touch/touch.c 102412 2002-08-25 13:23:09Z charnier $");
37
38#ifndef lint
39static const char copyright[] =
40"@(#) Copyright (c) 1993\n\
41 The Regents of the University of California. All rights reserved.\n";
42#endif
43
44#ifndef lint
45static const char sccsid[] = "@(#)touch.c 8.1 (Berkeley) 6/6/93";
46#endif
47
48#include <sys/types.h>
49#include <sys/stat.h>
50#include <sys/time.h>
51
52#include <err.h>
53#include <errno.h>
54#include <fcntl.h>
55#include <stdio.h>
56#include <stdlib.h>
57#include <string.h>
58#include <time.h>
59#include <unistd.h>
60
61int rw(char *, struct stat *, int);
62void stime_arg1(char *, struct timeval *);
63void stime_arg2(char *, int, struct timeval *);
64void stime_file(char *, struct timeval *);
65void usage(void);
66
67int
68main(argc, argv)
69 int argc;
70 char *argv[];
71{
72 struct stat sb;
73 struct timeval tv[2];
74 int (*stat_f)(const char *, struct stat *);
75 int (*utimes_f)(const char *, const struct timeval *);
76 int aflag, cflag, fflag, mflag, ch, fd, len, rval, timeset;
77 char *p;
78
79 aflag = cflag = fflag = mflag = timeset = 0;
80 stat_f = stat;
81 utimes_f = utimes;
82 if (gettimeofday(&tv[0], NULL))
83 err(1, "gettimeofday");
84
85 while ((ch = getopt(argc, argv, "acfhmr:t:")) != -1)
86 switch(ch) {
87 case 'a':
88 aflag = 1;
89 break;
90 case 'c':
91 cflag = 1;
92 break;
93 case 'f':
94 fflag = 1;
95 break;
96 case 'h':
97 cflag = 1;
98 stat_f = lstat;
99 utimes_f = lutimes;
100 break;
101 case 'm':
102 mflag = 1;
103 break;
104 case 'r':
105 timeset = 1;
106 stime_file(optarg, tv);
107 break;
108 case 't':
109 timeset = 1;
110 stime_arg1(optarg, tv);
111 break;
112 case '?':
113 default:
114 usage();
115 }
116 argc -= optind;
117 argv += optind;
118
119 /* Default is both -a and -m. */
120 if (aflag == 0 && mflag == 0)
121 aflag = mflag = 1;
122
123 /*
124 * If no -r or -t flag, at least two operands, the first of which
125 * is an 8 or 10 digit number, use the obsolete time specification.
126 */
127 if (!timeset && argc > 1) {
128 (void)strtol(argv[0], &p, 10);
129 len = p - argv[0];
130 if (*p == '\0' && (len == 8 || len == 10)) {
131 timeset = 1;
132 stime_arg2(*argv++, len == 10, tv);
133 }
134 }
135
136 /* Otherwise use the current time of day. */
137 if (!timeset)
138 tv[1] = tv[0];
139
140 if (*argv == NULL)
141 usage();
142
143 for (rval = 0; *argv; ++argv) {
144 /* See if the file exists. */
145 if (stat_f(*argv, &sb) != 0) {
146 if (!cflag) {
147 /* Create the file. */
148 fd = open(*argv,
149 O_WRONLY | O_CREAT, DEFFILEMODE);
150 if (fd == -1 || fstat(fd, &sb) || close(fd)) {
151 rval = 1;
152 warn("%s", *argv);
153 continue;
154 }
155
156 /* If using the current time, we're done. */
157 if (!timeset)
158 continue;
159 } else
160 continue;
161 }
162
163 if (!aflag)
164 TIMESPEC_TO_TIMEVAL(&tv[0], &sb.st_atimespec);
165 if (!mflag)
166 TIMESPEC_TO_TIMEVAL(&tv[1], &sb.st_mtimespec);
167
168 /* Try utimes(2). */
169 if (!utimes_f(*argv, tv))
170 continue;
171
172 /* If the user specified a time, nothing else we can do. */
173 if (timeset) {
174 rval = 1;
175 warn("%s", *argv);
176 }
177
178 /*
179 * System V and POSIX 1003.1 require that a NULL argument
180 * set the access/modification times to the current time.
181 * The permission checks are different, too, in that the
182 * ability to write the file is sufficient. Take a shot.
183 */
184 if (!utimes_f(*argv, NULL))
185 continue;
186
187 /* Try reading/writing. */
188 if (!S_ISLNK(sb.st_mode) && !S_ISDIR(sb.st_mode) &&
189 rw(*argv, &sb, fflag))
190 rval = 1;
191 else
192 warn("%s", *argv);
193 }
194 exit(rval);
195}
196
197#define ATOI2(ar) ((ar)[0] - '0') * 10 + ((ar)[1] - '0'); (ar) += 2;
198
199void
200stime_arg1(arg, tvp)
201 char *arg;
202 struct timeval *tvp;
203{
204 time_t now;
205 struct tm *t;
206 int yearset;
207 char *p;
208 /* Start with the current time. */
209 now = tvp[0].tv_sec;
210 if ((t = localtime(&now)) == NULL)
211 err(1, "localtime");
212 /* [[CC]YY]MMDDhhmm[.SS] */
213 if ((p = strchr(arg, '.')) == NULL)
214 t->tm_sec = 0; /* Seconds defaults to 0. */
215 else {
216 if (strlen(p + 1) != 2)
217 goto terr;
218 *p++ = '\0';
219 t->tm_sec = ATOI2(p);
220 }
221
222 yearset = 0;
223 switch(strlen(arg)) {
224 case 12: /* CCYYMMDDhhmm */
225 t->tm_year = ATOI2(arg);
226 t->tm_year *= 100;
227 yearset = 1;
37
38#ifndef lint
39static const char copyright[] =
40"@(#) Copyright (c) 1993\n\
41 The Regents of the University of California. All rights reserved.\n";
42#endif
43
44#ifndef lint
45static const char sccsid[] = "@(#)touch.c 8.1 (Berkeley) 6/6/93";
46#endif
47
48#include <sys/types.h>
49#include <sys/stat.h>
50#include <sys/time.h>
51
52#include <err.h>
53#include <errno.h>
54#include <fcntl.h>
55#include <stdio.h>
56#include <stdlib.h>
57#include <string.h>
58#include <time.h>
59#include <unistd.h>
60
61int rw(char *, struct stat *, int);
62void stime_arg1(char *, struct timeval *);
63void stime_arg2(char *, int, struct timeval *);
64void stime_file(char *, struct timeval *);
65void usage(void);
66
67int
68main(argc, argv)
69 int argc;
70 char *argv[];
71{
72 struct stat sb;
73 struct timeval tv[2];
74 int (*stat_f)(const char *, struct stat *);
75 int (*utimes_f)(const char *, const struct timeval *);
76 int aflag, cflag, fflag, mflag, ch, fd, len, rval, timeset;
77 char *p;
78
79 aflag = cflag = fflag = mflag = timeset = 0;
80 stat_f = stat;
81 utimes_f = utimes;
82 if (gettimeofday(&tv[0], NULL))
83 err(1, "gettimeofday");
84
85 while ((ch = getopt(argc, argv, "acfhmr:t:")) != -1)
86 switch(ch) {
87 case 'a':
88 aflag = 1;
89 break;
90 case 'c':
91 cflag = 1;
92 break;
93 case 'f':
94 fflag = 1;
95 break;
96 case 'h':
97 cflag = 1;
98 stat_f = lstat;
99 utimes_f = lutimes;
100 break;
101 case 'm':
102 mflag = 1;
103 break;
104 case 'r':
105 timeset = 1;
106 stime_file(optarg, tv);
107 break;
108 case 't':
109 timeset = 1;
110 stime_arg1(optarg, tv);
111 break;
112 case '?':
113 default:
114 usage();
115 }
116 argc -= optind;
117 argv += optind;
118
119 /* Default is both -a and -m. */
120 if (aflag == 0 && mflag == 0)
121 aflag = mflag = 1;
122
123 /*
124 * If no -r or -t flag, at least two operands, the first of which
125 * is an 8 or 10 digit number, use the obsolete time specification.
126 */
127 if (!timeset && argc > 1) {
128 (void)strtol(argv[0], &p, 10);
129 len = p - argv[0];
130 if (*p == '\0' && (len == 8 || len == 10)) {
131 timeset = 1;
132 stime_arg2(*argv++, len == 10, tv);
133 }
134 }
135
136 /* Otherwise use the current time of day. */
137 if (!timeset)
138 tv[1] = tv[0];
139
140 if (*argv == NULL)
141 usage();
142
143 for (rval = 0; *argv; ++argv) {
144 /* See if the file exists. */
145 if (stat_f(*argv, &sb) != 0) {
146 if (!cflag) {
147 /* Create the file. */
148 fd = open(*argv,
149 O_WRONLY | O_CREAT, DEFFILEMODE);
150 if (fd == -1 || fstat(fd, &sb) || close(fd)) {
151 rval = 1;
152 warn("%s", *argv);
153 continue;
154 }
155
156 /* If using the current time, we're done. */
157 if (!timeset)
158 continue;
159 } else
160 continue;
161 }
162
163 if (!aflag)
164 TIMESPEC_TO_TIMEVAL(&tv[0], &sb.st_atimespec);
165 if (!mflag)
166 TIMESPEC_TO_TIMEVAL(&tv[1], &sb.st_mtimespec);
167
168 /* Try utimes(2). */
169 if (!utimes_f(*argv, tv))
170 continue;
171
172 /* If the user specified a time, nothing else we can do. */
173 if (timeset) {
174 rval = 1;
175 warn("%s", *argv);
176 }
177
178 /*
179 * System V and POSIX 1003.1 require that a NULL argument
180 * set the access/modification times to the current time.
181 * The permission checks are different, too, in that the
182 * ability to write the file is sufficient. Take a shot.
183 */
184 if (!utimes_f(*argv, NULL))
185 continue;
186
187 /* Try reading/writing. */
188 if (!S_ISLNK(sb.st_mode) && !S_ISDIR(sb.st_mode) &&
189 rw(*argv, &sb, fflag))
190 rval = 1;
191 else
192 warn("%s", *argv);
193 }
194 exit(rval);
195}
196
197#define ATOI2(ar) ((ar)[0] - '0') * 10 + ((ar)[1] - '0'); (ar) += 2;
198
199void
200stime_arg1(arg, tvp)
201 char *arg;
202 struct timeval *tvp;
203{
204 time_t now;
205 struct tm *t;
206 int yearset;
207 char *p;
208 /* Start with the current time. */
209 now = tvp[0].tv_sec;
210 if ((t = localtime(&now)) == NULL)
211 err(1, "localtime");
212 /* [[CC]YY]MMDDhhmm[.SS] */
213 if ((p = strchr(arg, '.')) == NULL)
214 t->tm_sec = 0; /* Seconds defaults to 0. */
215 else {
216 if (strlen(p + 1) != 2)
217 goto terr;
218 *p++ = '\0';
219 t->tm_sec = ATOI2(p);
220 }
221
222 yearset = 0;
223 switch(strlen(arg)) {
224 case 12: /* CCYYMMDDhhmm */
225 t->tm_year = ATOI2(arg);
226 t->tm_year *= 100;
227 yearset = 1;
228 /* FALLTHOUGH */
228 /* FALLTHROUGH */
229 case 10: /* YYMMDDhhmm */
230 if (yearset) {
231 yearset = ATOI2(arg);
232 t->tm_year += yearset;
233 } else {
234 yearset = ATOI2(arg);
235 if (yearset < 69)
236 t->tm_year = yearset + 2000;
237 else
238 t->tm_year = yearset + 1900;
239 }
240 t->tm_year -= 1900; /* Convert to UNIX time. */
241 /* FALLTHROUGH */
242 case 8: /* MMDDhhmm */
243 t->tm_mon = ATOI2(arg);
244 --t->tm_mon; /* Convert from 01-12 to 00-11 */
245 t->tm_mday = ATOI2(arg);
246 t->tm_hour = ATOI2(arg);
247 t->tm_min = ATOI2(arg);
248 break;
249 default:
250 goto terr;
251 }
252
253 t->tm_isdst = -1; /* Figure out DST. */
254 tvp[0].tv_sec = tvp[1].tv_sec = mktime(t);
255 if (tvp[0].tv_sec == -1)
256terr: errx(1,
257 "out of range or illegal time specification: [[CC]YY]MMDDhhmm[.SS]");
258
259 tvp[0].tv_usec = tvp[1].tv_usec = 0;
260}
261
262void
263stime_arg2(arg, year, tvp)
264 char *arg;
265 int year;
266 struct timeval *tvp;
267{
268 time_t now;
269 struct tm *t;
270 /* Start with the current time. */
271 now = tvp[0].tv_sec;
272 if ((t = localtime(&now)) == NULL)
273 err(1, "localtime");
274
275 t->tm_mon = ATOI2(arg); /* MMDDhhmm[yy] */
276 --t->tm_mon; /* Convert from 01-12 to 00-11 */
277 t->tm_mday = ATOI2(arg);
278 t->tm_hour = ATOI2(arg);
279 t->tm_min = ATOI2(arg);
280 if (year) {
281 t->tm_year = ATOI2(arg);
282 if (t->tm_year < 39) /* support 2000-2038 not 1902-1969 */
283 t->tm_year += 100;
284 }
285
286 t->tm_isdst = -1; /* Figure out DST. */
287 tvp[0].tv_sec = tvp[1].tv_sec = mktime(t);
288 if (tvp[0].tv_sec == -1)
289 errx(1,
290 "out of range or illegal time specification: MMDDhhmm[yy]");
291
292 tvp[0].tv_usec = tvp[1].tv_usec = 0;
293}
294
295void
296stime_file(fname, tvp)
297 char *fname;
298 struct timeval *tvp;
299{
300 struct stat sb;
301
302 if (stat(fname, &sb))
303 err(1, "%s", fname);
304 TIMESPEC_TO_TIMEVAL(tvp, &sb.st_atimespec);
305 TIMESPEC_TO_TIMEVAL(tvp + 1, &sb.st_mtimespec);
306}
307
308int
309rw(fname, sbp, force)
310 char *fname;
311 struct stat *sbp;
312 int force;
313{
314 int fd, needed_chmod, rval;
315 u_char byte;
316
317 /* Try regular files. */
318 if (!S_ISREG(sbp->st_mode)) {
319 warnx("%s: %s", fname, strerror(EFTYPE));
320 return (1);
321 }
322
323 needed_chmod = rval = 0;
324 if ((fd = open(fname, O_RDWR, 0)) == -1) {
325 if (!force || chmod(fname, DEFFILEMODE))
326 goto err;
327 if ((fd = open(fname, O_RDWR, 0)) == -1)
328 goto err;
329 needed_chmod = 1;
330 }
331
332 if (sbp->st_size != 0) {
333 if (read(fd, &byte, sizeof(byte)) != sizeof(byte))
334 goto err;
335 if (lseek(fd, (off_t)0, SEEK_SET) == -1)
336 goto err;
337 if (write(fd, &byte, sizeof(byte)) != sizeof(byte))
338 goto err;
339 } else {
340 if (write(fd, &byte, sizeof(byte)) != sizeof(byte)) {
341err: rval = 1;
342 warn("%s", fname);
343 } else if (ftruncate(fd, (off_t)0)) {
344 rval = 1;
345 warn("%s: file modified", fname);
346 }
347 }
348
349 if (close(fd) && rval != 1) {
350 rval = 1;
351 warn("%s", fname);
352 }
353 if (needed_chmod && chmod(fname, sbp->st_mode) && rval != 1) {
354 rval = 1;
355 warn("%s: permissions modified", fname);
356 }
357 return (rval);
358}
359
360void
361usage()
362{
363 (void)fprintf(stderr, "usage: touch [-acfhm] [-r file] [-t [[CC]YY]MMDDhhmm[.SS]] file ...\n");
364 exit(1);
365}
229 case 10: /* YYMMDDhhmm */
230 if (yearset) {
231 yearset = ATOI2(arg);
232 t->tm_year += yearset;
233 } else {
234 yearset = ATOI2(arg);
235 if (yearset < 69)
236 t->tm_year = yearset + 2000;
237 else
238 t->tm_year = yearset + 1900;
239 }
240 t->tm_year -= 1900; /* Convert to UNIX time. */
241 /* FALLTHROUGH */
242 case 8: /* MMDDhhmm */
243 t->tm_mon = ATOI2(arg);
244 --t->tm_mon; /* Convert from 01-12 to 00-11 */
245 t->tm_mday = ATOI2(arg);
246 t->tm_hour = ATOI2(arg);
247 t->tm_min = ATOI2(arg);
248 break;
249 default:
250 goto terr;
251 }
252
253 t->tm_isdst = -1; /* Figure out DST. */
254 tvp[0].tv_sec = tvp[1].tv_sec = mktime(t);
255 if (tvp[0].tv_sec == -1)
256terr: errx(1,
257 "out of range or illegal time specification: [[CC]YY]MMDDhhmm[.SS]");
258
259 tvp[0].tv_usec = tvp[1].tv_usec = 0;
260}
261
262void
263stime_arg2(arg, year, tvp)
264 char *arg;
265 int year;
266 struct timeval *tvp;
267{
268 time_t now;
269 struct tm *t;
270 /* Start with the current time. */
271 now = tvp[0].tv_sec;
272 if ((t = localtime(&now)) == NULL)
273 err(1, "localtime");
274
275 t->tm_mon = ATOI2(arg); /* MMDDhhmm[yy] */
276 --t->tm_mon; /* Convert from 01-12 to 00-11 */
277 t->tm_mday = ATOI2(arg);
278 t->tm_hour = ATOI2(arg);
279 t->tm_min = ATOI2(arg);
280 if (year) {
281 t->tm_year = ATOI2(arg);
282 if (t->tm_year < 39) /* support 2000-2038 not 1902-1969 */
283 t->tm_year += 100;
284 }
285
286 t->tm_isdst = -1; /* Figure out DST. */
287 tvp[0].tv_sec = tvp[1].tv_sec = mktime(t);
288 if (tvp[0].tv_sec == -1)
289 errx(1,
290 "out of range or illegal time specification: MMDDhhmm[yy]");
291
292 tvp[0].tv_usec = tvp[1].tv_usec = 0;
293}
294
295void
296stime_file(fname, tvp)
297 char *fname;
298 struct timeval *tvp;
299{
300 struct stat sb;
301
302 if (stat(fname, &sb))
303 err(1, "%s", fname);
304 TIMESPEC_TO_TIMEVAL(tvp, &sb.st_atimespec);
305 TIMESPEC_TO_TIMEVAL(tvp + 1, &sb.st_mtimespec);
306}
307
308int
309rw(fname, sbp, force)
310 char *fname;
311 struct stat *sbp;
312 int force;
313{
314 int fd, needed_chmod, rval;
315 u_char byte;
316
317 /* Try regular files. */
318 if (!S_ISREG(sbp->st_mode)) {
319 warnx("%s: %s", fname, strerror(EFTYPE));
320 return (1);
321 }
322
323 needed_chmod = rval = 0;
324 if ((fd = open(fname, O_RDWR, 0)) == -1) {
325 if (!force || chmod(fname, DEFFILEMODE))
326 goto err;
327 if ((fd = open(fname, O_RDWR, 0)) == -1)
328 goto err;
329 needed_chmod = 1;
330 }
331
332 if (sbp->st_size != 0) {
333 if (read(fd, &byte, sizeof(byte)) != sizeof(byte))
334 goto err;
335 if (lseek(fd, (off_t)0, SEEK_SET) == -1)
336 goto err;
337 if (write(fd, &byte, sizeof(byte)) != sizeof(byte))
338 goto err;
339 } else {
340 if (write(fd, &byte, sizeof(byte)) != sizeof(byte)) {
341err: rval = 1;
342 warn("%s", fname);
343 } else if (ftruncate(fd, (off_t)0)) {
344 rval = 1;
345 warn("%s: file modified", fname);
346 }
347 }
348
349 if (close(fd) && rval != 1) {
350 rval = 1;
351 warn("%s", fname);
352 }
353 if (needed_chmod && chmod(fname, sbp->st_mode) && rval != 1) {
354 rval = 1;
355 warn("%s: permissions modified", fname);
356 }
357 return (rval);
358}
359
360void
361usage()
362{
363 (void)fprintf(stderr, "usage: touch [-acfhm] [-r file] [-t [[CC]YY]MMDDhhmm[.SS]] file ...\n");
364 exit(1);
365}