summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpooka <pooka@NetBSD.org>2009-04-03 13:22:05 +0000
committerpooka <pooka@NetBSD.org>2009-04-03 13:22:05 +0000
commit54f76d2fa4697c2986371f510e7fdacca442de2b (patch)
tree58e54205df40d3235e4b2baabcc5d917b7f39aa2
parentac465a42e77ff9149a5cd1add05f3bd19f88a8c2 (diff)
Issue a better error message if attempting to create a file system
on a block device. Inspired by PR kern/41127.
-rw-r--r--sbin/newfs/newfs.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/sbin/newfs/newfs.c b/sbin/newfs/newfs.c
index e729c9c68d0..0d93e55eaa7 100644
--- a/sbin/newfs/newfs.c
+++ b/sbin/newfs/newfs.c
@@ -1,4 +1,4 @@
-/* $NetBSD: newfs.c,v 1.102 2008/08/01 15:32:30 simonb Exp $ */
+/* $NetBSD: newfs.c,v 1.103 2009/04/03 13:22:05 pooka Exp $ */
/*
* Copyright (c) 1983, 1989, 1993, 1994
@@ -78,7 +78,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 1989, 1993, 1994\
#if 0
static char sccsid[] = "@(#)newfs.c 8.13 (Berkeley) 5/1/95";
#else
-__RCSID("$NetBSD: newfs.c,v 1.102 2008/08/01 15:32:30 simonb Exp $");
+__RCSID("$NetBSD: newfs.c,v 1.103 2009/04/03 13:22:05 pooka Exp $");
#endif
#endif /* not lint */
@@ -468,6 +468,10 @@ main(int argc, char *argv[])
special = device;
if (fsi < 0 || fstat(fsi, &sb) == -1)
err(1, "%s: open for read", special);
+ if (S_ISBLK(sb.st_mode)) {
+ errx(1, "%s is a block device. use raw device",
+ special);
+ }
if (!Nflag) {
fso = open(special, O_WRONLY, 0);