From ad618f5fe4b5130849ebdf23c8c5b9611bc42cbf Mon Sep 17 00:00:00 2001 From: Keith Bostic Date: Sat, 6 Mar 1993 21:41:07 -0800 Subject: [PATCH] try utimes(f, NULL) before trying to read/write the file SCCS-vsn: usr.bin/touch/touch.c 5.3 --- usr/src/usr.bin/touch/touch.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/usr/src/usr.bin/touch/touch.c b/usr/src/usr.bin/touch/touch.c index f90526430b..79c74eb2bd 100644 --- a/usr/src/usr.bin/touch/touch.c +++ b/usr/src/usr.bin/touch/touch.c @@ -12,7 +12,7 @@ char copyright[] = #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)touch.c 5.2 (Berkeley) %G%"; +static char sccsid[] = "@(#)touch.c 5.3 (Berkeley) %G%"; #endif /* not lint */ #include @@ -135,6 +135,15 @@ main(argc, argv) warn("%s", *argv); } + /* + * System V and POSIX 1003.1 require that a NULL argument + * set the access/modification times to the current time. + * The permission checks are different, too, in that the + * ability to write the file is sufficient. Take a shot. + */ + if (!utimes(*argv, NULL)) + continue; + /* Try reading/writing. */ if (rw(*argv, &sb, fflag)) rval = 1; -- 2.20.1