summaryrefslogtreecommitdiffstats
path: root/usr.bin/touch
diff options
context:
space:
mode:
authoreric <eric@FreeBSD.org>2002-07-23 04:54:57 +0000
committereric <eric@FreeBSD.org>2002-07-23 04:54:57 +0000
commit7ff3e005dc93b849f0be34012396b3aabe1410e5 (patch)
tree64d25d2b8d4b21e4b2e102319e8c0a20a4331172 /usr.bin/touch
parentb5578712f7a8afca882ec729970e6fedd1aa4751 (diff)
downloadFreeBSD-src-7ff3e005dc93b849f0be34012396b3aabe1410e5.zip
FreeBSD-src-7ff3e005dc93b849f0be34012396b3aabe1410e5.tar.gz
Handle directories correctly.
PR: 40801 MFC after: 5 days
Diffstat (limited to 'usr.bin/touch')
-rw-r--r--usr.bin/touch/touch.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/usr.bin/touch/touch.c b/usr.bin/touch/touch.c
index d92af2d..ce2e712 100644
--- a/usr.bin/touch/touch.c
+++ b/usr.bin/touch/touch.c
@@ -186,8 +186,11 @@ main(argc, argv)
continue;
/* Try reading/writing. */
- if (rw(*argv, &sb, fflag))
+ if (!S_ISLNK(sb.st_mode) && !S_ISDIR(sb.st_mode) &&
+ rw(*argv, &sb, fflag))
rval = 1;
+ else
+ warn("%s", *argv);
}
exit(rval);
}
@@ -312,8 +315,8 @@ rw(fname, sbp, force)
int fd, needed_chmod, rval;
u_char byte;
- /* Try regular files and directories. */
- if (!S_ISREG(sbp->st_mode) && !S_ISDIR(sbp->st_mode)) {
+ /* Try regular files. */
+ if (!S_ISREG(sbp->st_mode)) {
warnx("%s: %s", fname, strerror(EFTYPE));
return (1);
}
OpenPOWER on IntegriCloud