[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 03/19] qemu-nbd: Detect unused partitions by system =
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 03/19] qemu-nbd: Detect unused partitions by system == 0 |
Date: |
Wed, 18 Mar 2015 12:24:50 +0100 |
From: Max Reitz <address@hidden>
Unused partitions do not necessarily have a total sector count of 0
(although they should have), but they always do have the system field
set to 0, so use that for testing whether a partition is in use rather
than the sector count field alone.
Signed-off-by: Max Reitz <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
qemu-nbd.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/qemu-nbd.c b/qemu-nbd.c
index 064b000..d8daf1d 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -167,8 +167,9 @@ static int find_partition(BlockBackend *blk, int partition,
for (i = 0; i < 4; i++) {
read_partition(&data[446 + 16 * i], &mbr[i]);
- if (!mbr[i].nb_sectors_abs)
+ if (!mbr[i].system || !mbr[i].nb_sectors_abs) {
continue;
+ }
if (mbr[i].system == 0xF || mbr[i].system == 0x5) {
struct partition_record ext[4];
@@ -182,8 +183,9 @@ static int find_partition(BlockBackend *blk, int partition,
for (j = 0; j < 4; j++) {
read_partition(&data1[446 + 16 * j], &ext[j]);
- if (!ext[j].nb_sectors_abs)
+ if (!ext[j].system || !ext[j].nb_sectors_abs) {
continue;
+ }
if ((ext_partnum + j + 1) == partition) {
*offset = (uint64_t)ext[j].start_sector_abs << 9;
--
2.3.0
- [Qemu-devel] [PULL 00/19] Misc bugfixes for 2.3.0-rc1, Paolo Bonzini, 2015/03/18
- [Qemu-devel] [PULL 01/19] nbd: Fix overflow return value, Paolo Bonzini, 2015/03/18
- [Qemu-devel] [PULL 04/19] nbd: Fix nbd_establish_connection()'s return value, Paolo Bonzini, 2015/03/18
- [Qemu-devel] [PULL 05/19] nbd: Pass return value from nbd_handle_list(), Paolo Bonzini, 2015/03/18
- [Qemu-devel] [PULL 03/19] qemu-nbd: Detect unused partitions by system == 0,
Paolo Bonzini <=
- [Qemu-devel] [PULL 02/19] util/uri: Add overflow check to rfc3986_parse_port, Paolo Bonzini, 2015/03/18
- [Qemu-devel] [PULL 08/19] nbd: Fix potential signed overflow issues, Paolo Bonzini, 2015/03/18
- [Qemu-devel] [PULL 09/19] nbd: Set block size to BDRV_SECTOR_SIZE, Paolo Bonzini, 2015/03/18
- [Qemu-devel] [PULL 10/19] nbd: Fix nbd_receive_options(), Paolo Bonzini, 2015/03/18
- [Qemu-devel] [PULL 06/19] nbd: Handle blk_getlength() failure, Paolo Bonzini, 2015/03/18
- [Qemu-devel] [PULL 07/19] qemu-nbd: fork() can fail, Paolo Bonzini, 2015/03/18
- [Qemu-devel] [PULL 14/19] build: pass .d file name to scripts/make_device_config.sh, fix makefile target, Paolo Bonzini, 2015/03/18
- [Qemu-devel] [PULL 11/19] nbd: Fix interpretation of the export flags, Paolo Bonzini, 2015/03/18
- [Qemu-devel] [PULL 15/19] virtio-scsi: Fix assert in virtio_scsi_push_event, Paolo Bonzini, 2015/03/18
- [Qemu-devel] [PULL 12/19] nbd: Drop unexpected data for NBD_OPT_LIST, Paolo Bonzini, 2015/03/18