Module Name: src
Committed By: pooka
Date: Fri Apr 3 13:22:05 UTC 2009
Modified Files:
src/sbin/newfs: newfs.c
Log Message:
Issue a better error message if attempting to create a file system
on a block device. Inspired by PR kern/41127.
To generate a diff of this commit:
cvs rdiff -u -r1.102 -r1.103 src/sbin/newfs/newfs.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sbin/newfs/newfs.c
diff -u src/sbin/newfs/newfs.c:1.102 src/sbin/newfs/newfs.c:1.103
--- src/sbin/newfs/newfs.c:1.102 Fri Aug 1 15:32:30 2008
+++ src/sbin/newfs/newfs.c Fri Apr 3 13:22:05 2009
@@ -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 @@
#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 @@
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);