diff options
author | jkh <jkh@FreeBSD.org> | 2000-10-31 07:05:40 +0000 |
---|---|---|
committer | jkh <jkh@FreeBSD.org> | 2000-10-31 07:05:40 +0000 |
commit | 7f3f30a6781f4feda57bd393fff125a6f56d2880 (patch) | |
tree | e7dda30c6aa991b4fefbe34f5ec52159008b6d45 /sys/kern | |
parent | e53e2907c0d4f674eb0e72547a99c7f72d50b02b (diff) | |
download | FreeBSD-src-7f3f30a6781f4feda57bd393fff125a6f56d2880.zip FreeBSD-src-7f3f30a6781f4feda57bd393fff125a6f56d2880.tar.gz |
Add a new ioctl for doing virgin disklabels.
Submitted by: dillon
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/subr_diskslice.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/sys/kern/subr_diskslice.c b/sys/kern/subr_diskslice.c index c4ecdc5..8696941 100644 --- a/sys/kern/subr_diskslice.c +++ b/sys/kern/subr_diskslice.c @@ -342,6 +342,7 @@ dsioctl(dev, cmd, data, flags, sspp) int slice; struct diskslice *sp; struct diskslices *ssp; + struct partition *pp; slice = dkslice(dev); ssp = *sspp; @@ -349,6 +350,39 @@ dsioctl(dev, cmd, data, flags, sspp) lp = sp->ds_label; switch (cmd) { + case DIOCGDVIRGIN: + lp = (struct disklabel *)data; + if (ssp->dss_slices[WHOLE_DISK_SLICE].ds_label) { + *lp = *ssp->dss_slices[WHOLE_DISK_SLICE].ds_label; + } else { + bzero(lp, sizeof(struct disklabel)); + } + + lp->d_magic = DISKMAGIC; + lp->d_magic2 = DISKMAGIC; + pp = &lp->d_partitions[RAW_PART]; + pp->p_offset = 0; + pp->p_size = sp->ds_size; + + lp->d_npartitions = MAXPARTITIONS; + if (lp->d_interleave == 0) + lp->d_interleave = 1; + if (lp->d_rpm == 0) + lp->d_rpm = 3600; + if (lp->d_nsectors == 0) + lp->d_nsectors = 32; + if (lp->d_ntracks == 0) + lp->d_ntracks = 64; + + lp->d_bbsize = BBSIZE; + lp->d_sbsize = SBSIZE; + lp->d_secpercyl = lp->d_nsectors * lp->d_ntracks; + lp->d_ncylinders = sp->ds_size / lp->d_secpercyl; + lp->d_secperunit = sp->ds_size; + lp->d_checksum = 0; + lp->d_checksum = dkcksum(lp); + return (0); + case DIOCGDINFO: if (lp == NULL) return (EINVAL); |