summaryrefslogtreecommitdiffstats
path: root/usr.bin/touch
diff options
context:
space:
mode:
authorjh <jh@FreeBSD.org>2009-10-16 20:52:45 +0000
committerjh <jh@FreeBSD.org>2009-10-16 20:52:45 +0000
commitf1d2f78466bdc5c7e30380e7b3042632f0f70d1c (patch)
tree194a09d6c765b4e138d08cb7357ea1356ef37905 /usr.bin/touch
parent205158c2d7e4e1cde4558ae29461315932de3454 (diff)
downloadFreeBSD-src-f1d2f78466bdc5c7e30380e7b3042632f0f70d1c.zip
FreeBSD-src-f1d2f78466bdc5c7e30380e7b3042632f0f70d1c.tar.gz
- 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)
Diffstat (limited to 'usr.bin/touch')
-rw-r--r--usr.bin/touch/touch.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/usr.bin/touch/touch.c b/usr.bin/touch/touch.c
index 624ce05..5ceb175 100644
--- a/usr.bin/touch/touch.c
+++ b/usr.bin/touch/touch.c
@@ -164,6 +164,11 @@ main(int argc, char *argv[])
for (rval = 0; *argv; ++argv) {
/* See if the file exists. */
if (stat_f(*argv, &sb) != 0) {
+ if (errno != ENOENT) {
+ rval = 1;
+ warn("%s", *argv);
+ continue;
+ }
if (!cflag) {
/* Create the file. */
fd = open(*argv,
@@ -206,7 +211,7 @@ main(int argc, char *argv[])
continue;
/* If the user specified a time, nothing else we can do. */
- if (timeset) {
+ if (timeset || Aflag) {
rval = 1;
warn("%s", *argv);
continue;
@@ -222,11 +227,13 @@ main(int argc, char *argv[])
continue;
/* Try reading/writing. */
- if (!S_ISLNK(sb.st_mode) && !S_ISDIR(sb.st_mode) &&
- rw(*argv, &sb, fflag))
+ if (!S_ISLNK(sb.st_mode) && !S_ISDIR(sb.st_mode)) {
+ if (rw(*argv, &sb, fflag))
+ rval = 1;
+ } else {
rval = 1;
- else
warn("%s", *argv);
+ }
}
exit(rval);
}
OpenPOWER on IntegriCloud