commit - e1ad38bf2f1faf34942b72d7540bcc41e3bbf6e3
commit + b7cb7453e259084a62e0e52ef310000f45afe998
blob - 539f89d2cf2f5bc83e8cf77e84a5a16cef0acd2a
blob + 6688293e33b72599114f6fb15f30d9b4141aec1c
--- src/cmd/touch.c
+++ src/cmd/touch.c
int touch(int, char *);
ulong now;
+int tflag;
void
usage(void)
now = time(0);
ARGBEGIN{
case 't':
+ tflag = 1;
now = strtoul(EARGF(usage()), 0, 0);
break;
case 'c':
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;
}