summaryrefslogtreecommitdiff
path: root/sbin/disklabel/disklabel.c
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2007-06-18 22:07:44 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2007-06-18 22:07:44 +0000
commit3aa2b56dd45dc58e4825d293e0f499393fd69e30 (patch)
treefd660b712eed31bc6e11a2aa8c80d3ca1f73d96d /sbin/disklabel/disklabel.c
parentc2756711b461052da2ea095be4bb4f8c056fc252 (diff)
If disklabel(8) is run against unreadable media (e.g. a blank cd)
don't say "can't read master boot record". Just display an empty disklabel. Really yucky code that needs a lot of tough love, but marginally less confusing until then. ok deraadt@
Diffstat (limited to 'sbin/disklabel/disklabel.c')
-rw-r--r--sbin/disklabel/disklabel.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/sbin/disklabel/disklabel.c b/sbin/disklabel/disklabel.c
index deb61d1d7d9..24ba7235a11 100644
--- a/sbin/disklabel/disklabel.c
+++ b/sbin/disklabel/disklabel.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disklabel.c,v 1.115 2007/06/18 21:06:51 krw Exp $ */
+/* $OpenBSD: disklabel.c,v 1.116 2007/06/18 22:07:43 krw Exp $ */
/*
* Copyright (c) 1987, 1993
@@ -39,7 +39,7 @@ static const char copyright[] =
#endif /* not lint */
#ifndef lint
-static const char rcsid[] = "$OpenBSD: disklabel.c,v 1.115 2007/06/18 21:06:51 krw Exp $";
+static const char rcsid[] = "$OpenBSD: disklabel.c,v 1.116 2007/06/18 22:07:43 krw Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -250,7 +250,7 @@ main(int argc, char *argv[])
* Check for presence of DOS partition table in
* master boot record. Return pointer to OpenBSD
* partition, if present. If no valid partition table,
- * return 0. If valid partition table present, but no
+ * return NULL. If valid partition table present, but no
* partition to use, return a pointer to a non-386bsd
* partition.
*/
@@ -625,7 +625,7 @@ readmbr(int f)
dp = (struct dos_partition *)mbr;
if (lseek(f, (off_t)DOSBBSECTOR * DEV_BSIZE, SEEK_SET) < 0 ||
read(f, mbr, sizeof(mbr)) < sizeof(mbr))
- err(4, "can't read master boot record");
+ return (NULL);
signature = *((u_char *)mbr + DOSMBR_SIGNATURE_OFF) |
(*((u_char *)mbr + DOSMBR_SIGNATURE_OFF + 1) << 8);
bcopy((char *)mbr+DOSPARTOFF, (char *)mbr, sizeof(*dp) * NDOSPART);