diff options
author | phk <phk@FreeBSD.org> | 2002-04-02 11:40:45 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2002-04-02 11:40:45 +0000 |
commit | edf19c6634cd152eb481ec7cd757957c3cf9cf06 (patch) | |
tree | 443dd6e4e6601e0bf7930f5707a598a241c9a6f7 /sys/dev/vinum | |
parent | 79a894e10e07aef12898bb4e43dd33a501a1edb9 (diff) | |
download | FreeBSD-src-edf19c6634cd152eb481ec7cd757957c3cf9cf06.zip FreeBSD-src-edf19c6634cd152eb481ec7cd757957c3cf9cf06.tar.gz |
Stop using the bogus DIOCGPART ioctl, use DIOCGSECTORSIZE and
DIOCGMEDIASIZE instead.
The partition type check has been XXX'ed out since we cannot expect
that a BSD disklabel with a type field be available on all platforms.
Diffstat (limited to 'sys/dev/vinum')
-rw-r--r-- | sys/dev/vinum/vinumio.c | 23 | ||||
-rw-r--r-- | sys/dev/vinum/vinumobj.h | 3 |
2 files changed, 19 insertions, 7 deletions
diff --git a/sys/dev/vinum/vinumio.c b/sys/dev/vinum/vinumio.c index a9a7e54..c12ed03 100644 --- a/sys/dev/vinum/vinumio.c +++ b/sys/dev/vinum/vinumio.c @@ -164,13 +164,12 @@ set_drive_parms(struct drive *drive) { drive->blocksize = BLKDEV_IOSIZE; /* do we need this? */ drive->secsperblock = drive->blocksize /* number of sectors per block */ - / drive->partinfo.disklab->d_secsize; + / drive->sectorsize; /* Now update the label part */ bcopy(hostname, drive->label.sysname, VINUMHOSTNAMELEN); /* put in host name */ getmicrotime(&drive->label.date_of_birth); /* and current time */ - drive->label.drive_size = ((u_int64_t) drive->partinfo.part->p_size) /* size of the drive in bytes */ - *((u_int64_t) drive->partinfo.disklab->d_secsize); + drive->label.drive_size = drive->mediasize; #ifdef VINUMDEBUG if (debug & DEBUG_BIGDRIVE) /* pretend we're 100 times as big */ drive->label.drive_size *= 100; @@ -220,10 +219,16 @@ init_drive(struct drive *drive, int verbose) return drive->lasterror; drive->lasterror = (*devsw(drive->dev)->d_ioctl) (drive->dev, - DIOCGPART, - (caddr_t) & drive->partinfo, + DIOCGSECTORSIZE, + (caddr_t) & drive->sectorsize, FREAD, curthread); + if (drive->lasterror == 0) + drive->lasterror = (*devsw(drive->dev)->d_ioctl) (drive->dev, + DIOCGMEDIASIZE, + (caddr_t) & drive->mediasize, + FREAD, + curthread); if (drive->lasterror) { if (verbose) log(LOG_WARNING, @@ -233,6 +238,11 @@ init_drive(struct drive *drive, int verbose) close_drive(drive); return drive->lasterror; } +#if 0 + /* + * XXX: this check is bogus and needs to be rewitten, we cannot guarantee + * XXX: that there will be a label with a typefield on all platforms. + */ if (drive->partinfo.part->p_fstype != FS_VINUM) { /* not Vinum */ drive->lasterror = EFTYPE; if (verbose) @@ -242,6 +252,7 @@ init_drive(struct drive *drive, int verbose) close_drive(drive); return EFTYPE; } +#endif return set_drive_parms(drive); /* set various odds and ends */ } @@ -326,7 +337,7 @@ driveio(struct drive *drive, char *buf, size_t length, off_t offset, int flag) bp->b_flags = 0; bp->b_iocmd = flag; bp->b_dev = drive->dev; /* device */ - bp->b_blkno = offset / drive->partinfo.disklab->d_secsize; /* block number */ + bp->b_blkno = offset / drive->sectorsize; /* block number */ bp->b_saveaddr = bp->b_data; bp->b_data = buf; bp->b_bcount = len; diff --git a/sys/dev/vinum/vinumobj.h b/sys/dev/vinum/vinumobj.h index 8f81264..457189e 100644 --- a/sys/dev/vinum/vinumobj.h +++ b/sys/dev/vinum/vinumobj.h @@ -176,7 +176,8 @@ struct _drive int freelist_entries; /* number of entries used in free list */ struct drive_freelist *freelist; /* sorted list of free space on drive */ #ifdef _KERNEL - struct partinfo partinfo; /* partition information */ + u_int sectorsize; + off_t mediasize; dev_t dev; /* device information */ #ifdef VINUMDEBUG char lockfilename[16]; /* name of file from which we were locked */ |