diff options
| author | Carl Hetherington <cth@carlh.net> | 2020-04-12 23:18:16 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2020-04-12 23:22:25 +0200 |
| commit | 0f05d54958ccd734981fcd3d67fced9db481a499 (patch) | |
| tree | bb3ebc9009a25d8fe251d14c0ff30b79b9cbea8d /blockdev/windows | |
| parent | 10f7a6720fe6e3f6717620c144f412b46de3024d (diff) | |
Try using DISK_GEOMETRY_EX instead of plain DISK_GEOMETRY so that the disk size is returned explicitly.
Diffstat (limited to 'blockdev/windows')
| -rw-r--r-- | blockdev/windows/file_windows.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/blockdev/windows/file_windows.c b/blockdev/windows/file_windows.c index 291fc11..45588e3 100644 --- a/blockdev/windows/file_windows.c +++ b/blockdev/windows/file_windows.c @@ -67,7 +67,7 @@ EXT4_BLOCKDEV_STATIC_INSTANCE(_filedev, EXT4_IORAW_BSIZE, 0, file_open, static int file_open(struct ext4_blockdev *bdev) { char path[64]; - DISK_GEOMETRY pdg; + DISK_GEOMETRY_EX pdg; uint64_t disk_size; BOOL bResult = FALSE; DWORD junk; @@ -84,7 +84,7 @@ static int file_open(struct ext4_blockdev *bdev) } bResult = - DeviceIoControl(dev_file, IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, + DeviceIoControl(dev_file, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, NULL, 0, &pdg, sizeof(pdg), &junk, (LPOVERLAPPED)NULL); if (bResult == FALSE) { @@ -92,19 +92,16 @@ static int file_open(struct ext4_blockdev *bdev) return EIO; } - _filedev.bdif->ph_bsize = pdg.BytesPerSector; + _filedev.bdif->ph_bsize = pdg.Geometry.BytesPerSector; if (part_size == 0) { /* whole disk */ - disk_size = pdg.Cylinders.QuadPart * (ULONG)pdg.TracksPerCylinder * - (ULONG)pdg.SectorsPerTrack * (ULONG)pdg.BytesPerSector; - - _filedev.bdif->ph_bcnt = disk_size / pdg.BytesPerSector; + _filedev.bdif->ph_bcnt = pdg.DiskSize.QuadPart / pdg.Geometry.BytesPerSector; _filedev.part_offset = 0; - _filedev.part_size = disk_size; + _filedev.part_size = pdg.DiskSize.QuadPart; } else { /* specified partition */ - _filedev.bdif->ph_bcnt = part_size / pdg.BytesPerSector; + _filedev.bdif->ph_bcnt = part_size / pdg.Geometry.BytesPerSector; _filedev.part_offset = part_offset; _filedev.part_size = part_size; } |
