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 | |
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')
-rw-r--r-- | sys/kern/subr_diskslice.c | 34 | ||||
-rw-r--r-- | sys/sys/disklabel.h | 1 | ||||
-rw-r--r-- | sys/sys/diskmbr.h | 1 | ||||
-rw-r--r-- | sys/sys/diskpc98.h | 1 |
4 files changed, 37 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); diff --git a/sys/sys/disklabel.h b/sys/sys/disklabel.h index ea3e41e..1c9a8be 100644 --- a/sys/sys/disklabel.h +++ b/sys/sys/disklabel.h @@ -401,6 +401,7 @@ struct dos_partition { #define DIOCSDINFO _IOW('d', 102, struct disklabel)/* set */ #define DIOCWDINFO _IOW('d', 103, struct disklabel)/* set, update disk */ #define DIOCGPART _IOW('d', 104, struct partinfo) /* get partition */ +#define DIOCGDVIRGIN _IOR('d', 105, struct disklabel) /* get virgin label */ #define DIOCWLABEL _IOW('d', 109, int) /* write en/disable label */ diff --git a/sys/sys/diskmbr.h b/sys/sys/diskmbr.h index ea3e41e..1c9a8be 100644 --- a/sys/sys/diskmbr.h +++ b/sys/sys/diskmbr.h @@ -401,6 +401,7 @@ struct dos_partition { #define DIOCSDINFO _IOW('d', 102, struct disklabel)/* set */ #define DIOCWDINFO _IOW('d', 103, struct disklabel)/* set, update disk */ #define DIOCGPART _IOW('d', 104, struct partinfo) /* get partition */ +#define DIOCGDVIRGIN _IOR('d', 105, struct disklabel) /* get virgin label */ #define DIOCWLABEL _IOW('d', 109, int) /* write en/disable label */ diff --git a/sys/sys/diskpc98.h b/sys/sys/diskpc98.h index ea3e41e..1c9a8be 100644 --- a/sys/sys/diskpc98.h +++ b/sys/sys/diskpc98.h @@ -401,6 +401,7 @@ struct dos_partition { #define DIOCSDINFO _IOW('d', 102, struct disklabel)/* set */ #define DIOCWDINFO _IOW('d', 103, struct disklabel)/* set, update disk */ #define DIOCGPART _IOW('d', 104, struct partinfo) /* get partition */ +#define DIOCGDVIRGIN _IOR('d', 105, struct disklabel) /* get virgin label */ #define DIOCWLABEL _IOW('d', 109, int) /* write en/disable label */ |