diff options
Diffstat (limited to 'qemu-nbd.c')
-rw-r--r-- | qemu-nbd.c | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/qemu-nbd.c b/qemu-nbd.c index 5c90c5e55f..598caa656b 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -176,7 +176,7 @@ static void read_partition(uint8_t *p, struct partition_record *r) } static int find_partition(BlockBackend *blk, int partition, - off_t *offset, off_t *size) + uint64_t *offset, uint64_t *size) { struct partition_record mbr[4]; uint8_t data[MBR_SIZE]; @@ -500,14 +500,14 @@ int main(int argc, char **argv) { BlockBackend *blk; BlockDriverState *bs; - off_t dev_offset = 0; + uint64_t dev_offset = 0; uint16_t nbdflags = 0; bool disconnect = false; const char *bindto = NULL; const char *port = NULL; char *sockpath = NULL; char *device = NULL; - off_t fd_size; + int64_t fd_size; QemuOpts *sn_opts = NULL; const char *sn_id_or_name = NULL; const char *sopt = "hVb:o:p:rsnP:c:dvk:e:f:tl:x:T:D:B:"; @@ -665,10 +665,6 @@ int main(int argc, char **argv) error_report("Invalid offset `%s'", optarg); exit(EXIT_FAILURE); } - if (dev_offset < 0) { - error_report("Offset must be positive `%s'", optarg); - exit(EXIT_FAILURE); - } break; case 'l': if (strstart(optarg, SNAPSHOT_OPT_BASE, NULL)) { @@ -1005,15 +1001,14 @@ int main(int argc, char **argv) } if (dev_offset >= fd_size) { - error_report("Offset (%lld) has to be smaller than the image size " - "(%lld)", - (long long int)dev_offset, (long long int)fd_size); + error_report("Offset (%" PRIu64 ") has to be smaller than the image " + "size (%" PRId64 ")", dev_offset, fd_size); exit(EXIT_FAILURE); } fd_size -= dev_offset; if (partition != -1) { - off_t limit; + uint64_t limit; if (dev_offset) { error_report("Cannot request partition and offset together"); @@ -1027,15 +1022,13 @@ int main(int argc, char **argv) } /* * MBR partition limits are (32-bit << 9); this assert lets - * the compiler know that we have two positive values that - * can't overflow 64 bits. + * the compiler know that we can't overflow 64 bits. */ - assert(dev_offset >= 0 && dev_offset + limit >= dev_offset); + assert(dev_offset + limit >= dev_offset); if (dev_offset + limit > fd_size) { - error_report("Discovered partition %d at offset %lld size %lld, " - "but size exceeds file length %lld", partition, - (long long int) dev_offset, (long long int) limit, - (long long int) fd_size); + error_report("Discovered partition %d at offset %" PRIu64 + " size %" PRIu64 ", but size exceeds file length %" + PRId64, partition, dev_offset, limit, fd_size); exit(EXIT_FAILURE); } fd_size = limit; |