try utimes(f, NULL) before trying to read/write the file
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Sun, 7 Mar 1993 05:41:07 +0000 (21:41 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Sun, 7 Mar 1993 05:41:07 +0000 (21:41 -0800)
SCCS-vsn: usr.bin/touch/touch.c 5.3

usr/src/usr.bin/touch/touch.c

index f905264..79c74eb 100644 (file)
@@ -12,7 +12,7 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #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 <sys/types.h>
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -135,6 +135,15 @@ main(argc, argv)
                        warn("%s", *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;
                /* Try reading/writing. */
                if (rw(*argv, &sb, fflag))
                        rval = 1;