projects
/
qemu
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
correct split between helper.c and op_helper.c - moved some uops to op_helper.c ...
[qemu]
/
block-cow.c
diff --git
a/block-cow.c
b/block-cow.c
index
ab62c2a
..
eeeab70
100644
(file)
--- a/
block-cow.c
+++ b/
block-cow.c
@@
-54,7
+54,8
@@
static int cow_probe(const uint8_t *buf, int buf_size, const char *filename)
{
const struct cow_header_v2 *cow_header = (const void *)buf;
{
const struct cow_header_v2 *cow_header = (const void *)buf;
- if (be32_to_cpu(cow_header->magic) == COW_MAGIC &&
+ if (buf_size >= sizeof(struct cow_header_v2) &&
+ be32_to_cpu(cow_header->magic) == COW_MAGIC &&
be32_to_cpu(cow_header->version) == COW_VERSION)
return 100;
else
be32_to_cpu(cow_header->version) == COW_VERSION)
return 100;
else
@@
-124,7
+125,7
@@
static int cow_open(BlockDriverState *bs, const char *filename)
return -1;
}
return -1;
}
-static inline void set_bit(uint8_t *bitmap, int64_t bitnum)
+static inline void cow_set_bit(uint8_t *bitmap, int64_t bitnum)
{
bitmap[bitnum / 8] |= (1 << (bitnum%8));
}
{
bitmap[bitnum / 8] |= (1 << (bitnum%8));
}
@@
-173,7
+174,7
@@
static int cow_read(BlockDriverState *bs, int64_t sector_num,
while (nb_sectors > 0) {
if (is_changed(s->cow_bitmap, sector_num, nb_sectors, &n)) {
while (nb_sectors > 0) {
if (is_changed(s->cow_bitmap, sector_num, nb_sectors, &n)) {
- lseek64(s->fd, s->cow_sectors_offset + sector_num * 512, SEEK_SET);
+ lseek(s->fd, s->cow_sectors_offset + sector_num * 512, SEEK_SET);
ret = read(s->fd, buf, n * 512);
if (ret != n * 512)
return -1;
ret = read(s->fd, buf, n * 512);
if (ret != n * 512)
return -1;
@@
-193,16
+194,16
@@
static int cow_write(BlockDriverState *bs, int64_t sector_num,
BDRVCowState *s = bs->opaque;
int ret, i;
BDRVCowState *s = bs->opaque;
int ret, i;
- lseek64(s->fd, s->cow_sectors_offset + sector_num * 512, SEEK_SET);
+ lseek(s->fd, s->cow_sectors_offset + sector_num * 512, SEEK_SET);
ret = write(s->fd, buf, nb_sectors * 512);
if (ret != nb_sectors * 512)
return -1;
for (i = 0; i < nb_sectors; i++)
ret = write(s->fd, buf, nb_sectors * 512);
if (ret != nb_sectors * 512)
return -1;
for (i = 0; i < nb_sectors; i++)
- set_bit(s->cow_bitmap, sector_num + i);
+ cow_set_bit(s->cow_bitmap, sector_num + i);
return 0;
}
return 0;
}
-static int cow_close(BlockDriverState *bs)
+static void cow_close(BlockDriverState *bs)
{
BDRVCowState *s = bs->opaque;
munmap(s->cow_bitmap_addr, s->cow_bitmap_size);
{
BDRVCowState *s = bs->opaque;
munmap(s->cow_bitmap_addr, s->cow_bitmap_size);