Moved initialization of defaults for the label for the whole disk from

disklabel(8) to the kernel (dsopen()).  Drivers should initialize the
hardware values (rpm, interleave, skews).  Drivers currently don't do
this, but it usually doesn't matter since rotational position stuff is
normally disabled.
This commit is contained in:
Bruce Evans 1996-06-17 14:43:54 +00:00
parent 7d64a7fe80
commit 43be698cb6
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=16431
3 changed files with 29 additions and 21 deletions

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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) {