summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sbin/bsdlabel/bsdlabel.c14
-rw-r--r--sbin/disklabel/disklabel.c14
-rw-r--r--sys/kern/subr_diskslice.c22
3 files changed, 29 insertions, 21 deletions
diff --git a/sbin/bsdlabel/bsdlabel.c b/sbin/bsdlabel/bsdlabel.c
index 3de7004..5fcd1cd 100644
--- a/sbin/bsdlabel/bsdlabel.c
+++ b/sbin/bsdlabel/bsdlabel.c
@@ -1329,26 +1329,20 @@ getvirginlabel(void)
if (dkname[0] == '/') {
fprintf(stderr,
"\"auto\" requires the usage of a canonical disk name.\n");
- return 0;
+ return (NULL);
}
(void)snprintf(namebuf, BBSIZE, "%sr%s", _PATH_DEV, dkname);
if ((f = open(namebuf, O_RDONLY, 0)) == -1) {
Perror("open()");
- return 0;
+ return (NULL);
}
if (ioctl(f, DIOCGDINFO, &lab) < 0) {
Perror("ioctl DIOCGDINFO");
close(f);
- return 0;
+ return (NULL);
}
close(f);
- /* insert reasonable defaults where necessary */
- if (lab.d_npartitions < 8) lab.d_npartitions = 8;
- if (lab.d_bbsize == 0) lab.d_bbsize = BBSIZE;
- if (lab.d_sbsize == 0) lab.d_sbsize = SBSIZE;
- if (lab.d_rpm == 0) lab.d_rpm = 3600;
- if (lab.d_interleave == 0) lab.d_interleave = 1;
- return &lab;
+ return (&lab);
}
diff --git a/sbin/disklabel/disklabel.c b/sbin/disklabel/disklabel.c
index 3de7004..5fcd1cd 100644
--- a/sbin/disklabel/disklabel.c
+++ b/sbin/disklabel/disklabel.c
@@ -1329,26 +1329,20 @@ getvirginlabel(void)
if (dkname[0] == '/') {
fprintf(stderr,
"\"auto\" requires the usage of a canonical disk name.\n");
- return 0;
+ return (NULL);
}
(void)snprintf(namebuf, BBSIZE, "%sr%s", _PATH_DEV, dkname);
if ((f = open(namebuf, O_RDONLY, 0)) == -1) {
Perror("open()");
- return 0;
+ return (NULL);
}
if (ioctl(f, DIOCGDINFO, &lab) < 0) {
Perror("ioctl DIOCGDINFO");
close(f);
- return 0;
+ return (NULL);
}
close(f);
- /* insert reasonable defaults where necessary */
- if (lab.d_npartitions < 8) lab.d_npartitions = 8;
- if (lab.d_bbsize == 0) lab.d_bbsize = BBSIZE;
- if (lab.d_sbsize == 0) lab.d_sbsize = SBSIZE;
- if (lab.d_rpm == 0) lab.d_rpm = 3600;
- if (lab.d_interleave == 0) lab.d_interleave = 1;
- return &lab;
+ return (&lab);
}
diff --git a/sys/kern/subr_diskslice.c b/sys/kern/subr_diskslice.c
index 4b95b07..1fece29 100644
--- a/sys/kern/subr_diskslice.c
+++ b/sys/kern/subr_diskslice.c
@@ -43,7 +43,7 @@
* from: wd.c,v 1.55 1994/10/22 01:57:12 phk Exp $
* from: @(#)ufs_disksubr.c 7.16 (Berkeley) 5/4/91
* from: ufs_disksubr.c,v 1.8 1994/06/07 01:21:39 phk Exp $
- * $Id: subr_diskslice.c,v 1.25 1996/04/19 19:22:29 bde Exp $
+ * $Id: subr_diskslice.c,v 1.26 1996/06/12 05:07:31 gpalmer Exp $
*/
#include <sys/param.h>
@@ -62,6 +62,8 @@
#include <sys/systm.h>
#include <sys/vnode.h>
+#include <ufs/ffs/fs.h>
+
#define b_cylinder b_resid
#define TRACE(str) do { if (ds_debug) printf str; } while (0)
@@ -642,6 +644,24 @@ dsopen(dname, dev, mode, sspp, lp, strat, setgeom, bdevsw, cdevsw)
lp1 = malloc(sizeof *lp1, M_DEVBUF, M_WAITOK);
*lp1 = *lp;
+
+ /*
+ * Initialize defaults for the label for the whole disk so
+ * that it can be used as a template for disklabel(8).
+ * d_rpm = 3600 is unlikely to be correct for a modern
+ * disk, but d_rpm is normally irrelevant.
+ */
+ if (lp1->d_rpm == 0)
+ lp1->d_rpm = 3600;
+ if (lp1->d_interleave == 0)
+ lp1->d_interleave = 1;
+ if (lp1->d_npartitions == 0)
+ lp1->d_npartitions = MAXPARTITIONS;
+ if (lp1->d_bbsize == 0)
+ lp1->d_bbsize = BBSIZE;
+ if (lp1->d_sbsize == 0)
+ lp1->d_sbsize = SBSIZE;
+
ssp->dss_slices[WHOLE_DISK_SLICE].ds_label = lp1;
ssp->dss_slices[WHOLE_DISK_SLICE].ds_wlabel = TRUE;
if (setgeom != NULL) {
OpenPOWER on IntegriCloud