diff options
author | rsc <devnull@localhost> | 2007-05-20 14:37:29 +0000 |
---|---|---|
committer | rsc <devnull@localhost> | 2007-05-20 14:37:29 +0000 |
commit | b7cb7453e259084a62e0e52ef310000f45afe998 (patch) | |
tree | f9faefb7d3077b5235a5d06ae06e7ad3bab81255 /src/cmd/touch.c | |
parent | e1ad38bf2f1faf34942b72d7540bcc41e3bbf6e3 (diff) | |
download | plan9port-b7cb7453e259084a62e0e52ef310000f45afe998.tar.gz plan9port-b7cb7453e259084a62e0e52ef310000f45afe998.tar.bz2 plan9port-b7cb7453e259084a62e0e52ef310000f45afe998.zip |
print error if changing time fails
Diffstat (limited to 'src/cmd/touch.c')
-rw-r--r-- | src/cmd/touch.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/cmd/touch.c b/src/cmd/touch.c index 539f89d2..6688293e 100644 --- a/src/cmd/touch.c +++ b/src/cmd/touch.c @@ -3,6 +3,7 @@ int touch(int, char *); ulong now; +int tflag; void usage(void) @@ -20,6 +21,7 @@ main(int argc, char **argv) now = time(0); ARGBEGIN{ case 't': + tflag = 1; now = strtoul(EARGF(usage()), 0, 0); break; case 'c': @@ -52,11 +54,15 @@ touch(int nocreate, char *name) fprint(2, "touch: %s: cannot wstat: %r\n", name); return 1; } - if ((fd = create(name, OREAD, 0666)) < 0) { + if((fd = create(name, OREAD, 0666)) < 0) { fprint(2, "touch: %s: cannot create: %r\n", name); return 1; } - dirfwstat(fd, &stbuff); + if(tflag && dirfwstat(fd, &stbuff) < 0){ + fprint(2, "touch: %s: cannot wstat: %r\n", name); + close(fd); + return 1; + } close(fd); return 0; } |