Home | History | Annotate | Download | only in block

Lines Matching refs:bs

60 static int cow_open(BlockDriverState *bs, int flags)
62 BDRVCowState *s = bs->opaque;
68 if (bdrv_pread(bs->file, 0, &cow_header, sizeof(cow_header)) !=
80 bs->total_sectors = size / 512;
82 pstrcpy(bs->backing_file, sizeof(bs->backing_file),
85 bitmap_size = ((bs->total_sectors + 7) >> 3) + sizeof(cow_header);
96 static inline int cow_set_bit(BlockDriverState *bs, int64_t bitnum)
102 ret = bdrv_pread(bs->file, offset, &bitmap, sizeof(bitmap));
109 ret = bdrv_pwrite_sync(bs->file, offset, &bitmap, sizeof(bitmap));
116 static inline int is_bit_set(BlockDriverState *bs, int64_t bitnum)
122 ret = bdrv_pread(bs->file, offset, &bitmap, sizeof(bitmap));
133 static int cow_is_allocated(BlockDriverState *bs, int64_t sector_num,
143 changed = is_bit_set(bs, sector_num);
149 if (is_bit_set(bs, sector_num + *num_same) != changed)
156 static int cow_update_bitmap(BlockDriverState *bs, int64_t sector_num,
163 error = cow_set_bit(bs, sector_num + i);
172 static int cow_read(BlockDriverState *bs, int64_t sector_num,
175 BDRVCowState *s = bs->opaque;
179 if (cow_is_allocated(bs, sector_num, nb_sectors, &n)) {
180 ret = bdrv_pread(bs->file,
186 if (bs->backing_hd) {
188 ret = bdrv_read(bs->backing_hd, sector_num, buf, n);
202 static int cow_write(BlockDriverState *bs, int64_t sector_num,
205 BDRVCowState *s = bs->opaque;
208 ret = bdrv_pwrite(bs->file, s->cow_sectors_offset + sector_num * 512,
213 return cow_update_bitmap(bs, sector_num, nb_sectors);
216 static void cow_close(BlockDriverState *bs)
285 static void cow_flush(BlockDriverState *bs)
287 bdrv_flush(bs->file);