*/
#include "qemu-common.h"
-#include "block_int.h"
+#include "block.h"
#include "nbd.h"
#include <stdarg.h>
}
if (data[510] != 0x55 || data[511] != 0xaa) {
- errno = -EINVAL;
- return -1;
+ return -EINVAL;
}
for (i = 0; i < 4; i++) {
}
}
- errno = -ENOENT;
- return -1;
+ return -ENOENT;
}
static void termsig_handler(int signum)
err(EXIT_FAILURE, "Failed to bdrv_open '%s'", argv[optind]);
}
- fd_size = bs->total_sectors * 512;
+ fd_size = bdrv_getlength(bs);
- if (partition != -1 &&
- find_partition(bs, partition, &dev_offset, &fd_size)) {
- err(EXIT_FAILURE, "Could not find partition %d", partition);
+ if (partition != -1) {
+ ret = find_partition(bs, partition, &dev_offset, &fd_size);
+ if (ret < 0) {
+ errno = -ret;
+ err(EXIT_FAILURE, "Could not find partition %d", partition);
+ }
}
exp = nbd_export_new(bs, dev_offset, fd_size, nbdflags);