diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2008-08-04 18:46:33 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2008-08-04 18:46:33 +0000 |
commit | c178a8db046c94d9857a1a51b96a797cd9b10686 (patch) | |
tree | 0845a436426aed50fb6ece1aa3028510834a58cd /sbin/newfs/newfs.c | |
parent | 406b4c3a38a92a6d3c6943554a27ea301ae4044f (diff) |
refuse to run on block devices; prompted by marco; ok marco@ millert@
deraadt@
Diffstat (limited to 'sbin/newfs/newfs.c')
-rw-r--r-- | sbin/newfs/newfs.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/sbin/newfs/newfs.c b/sbin/newfs/newfs.c index 911b8f1c257..23c4d5aa406 100644 --- a/sbin/newfs/newfs.c +++ b/sbin/newfs/newfs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: newfs.c,v 1.79 2008/07/06 15:03:36 krw Exp $ */ +/* $OpenBSD: newfs.c,v 1.80 2008/08/04 18:46:32 otto Exp $ */ /* $NetBSD: newfs.c,v 1.20 1996/05/16 07:13:03 thorpej Exp $ */ /* @@ -398,9 +398,13 @@ main(int argc, char *argv[]) fatal("%s: %s", special, strerror(errno)); if (fstat(fsi, &st) < 0) fatal("%s: %s", special, strerror(errno)); - if (!S_ISCHR(st.st_mode) && !mfs) - warnx("%s: not a character-special device\n", - special); + if (!mfs) { + if (S_ISBLK(st.st_mode)) + fatal("%s: block device", special); + if (!S_ISCHR(st.st_mode)) + warnx("%s: not a character-special device", + special); + } cp = strchr(argv[0], '\0') - 1; if (cp == NULL || ((*cp < 'a' || *cp > ('a' + maxpartitions - 1)) && !isdigit(*cp))) |