[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 08/19] cow: use pread/pwrite
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 08/19] cow: use pread/pwrite |
Date: |
Tue, 15 Jun 2010 16:19:30 +0200 |
From: Christoph Hellwig <address@hidden>
Use pread/pwrite instead of lseek + read/write in preparation of using the
qemu block API.
Signed-off-by: Christoph Hellwig <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/cow.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/block/cow.c b/block/cow.c
index fde066e..1a48ac0 100644
--- a/block/cow.c
+++ b/block/cow.c
@@ -78,7 +78,7 @@ static int cow_open(BlockDriverState *bs, const char
*filename, int flags)
}
s->fd = fd;
/* see if it is a cow image */
- if (read(fd, &cow_header, sizeof(cow_header)) != sizeof(cow_header)) {
+ if (pread(fd, &cow_header, sizeof(cow_header), 0) != sizeof(cow_header)) {
goto fail;
}
@@ -159,8 +159,8 @@ 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)) {
- lseek(s->fd, s->cow_sectors_offset + sector_num * 512, SEEK_SET);
- ret = read(s->fd, buf, n * 512);
+ ret = pread(s->fd, buf, n * 512,
+ s->cow_sectors_offset + sector_num * 512);
if (ret != n * 512)
return -1;
} else {
@@ -186,8 +186,8 @@ static int cow_write(BlockDriverState *bs, int64_t
sector_num,
BDRVCowState *s = bs->opaque;
int ret, i;
- lseek(s->fd, s->cow_sectors_offset + sector_num * 512, SEEK_SET);
- ret = write(s->fd, buf, nb_sectors * 512);
+ ret = pwrite(s->fd, buf, nb_sectors * 512,
+ s->cow_sectors_offset + sector_num * 512);
if (ret != nb_sectors * 512)
return -1;
for (i = 0; i < nb_sectors; i++)
--
1.6.6.1
- [Qemu-devel] [PULL 00/19] Block patches, Kevin Wolf, 2010/06/15
- [Qemu-devel] [PATCH 01/19] vpc: Read/write multiple sectors at once, Kevin Wolf, 2010/06/15
- [Qemu-devel] [PATCH 03/19] qcow2: Allow alloc_clusters_noref to return errors, Kevin Wolf, 2010/06/15
- [Qemu-devel] [PATCH 02/19] qcow2: Allow get_refcount to return errors, Kevin Wolf, 2010/06/15
- [Qemu-devel] [PATCH 04/19] qcow2: Return real error code in load_refcount_block, Kevin Wolf, 2010/06/15
- [Qemu-devel] [PATCH 05/19] savevm: Really verify if a drive supports snapshots, Kevin Wolf, 2010/06/15
- [Qemu-devel] [PATCH 07/19] qcow2: Restore L1 entry on l2_allocate failure, Kevin Wolf, 2010/06/15
- [Qemu-devel] [PATCH 08/19] cow: use pread/pwrite,
Kevin Wolf <=
- [Qemu-devel] [PATCH 06/19] Fix regression for "-drive file=", Kevin Wolf, 2010/06/15
- [Qemu-devel] [PATCH 10/19] cow: use qemu block API, Kevin Wolf, 2010/06/15
- [Qemu-devel] [PATCH 14/19] block: New bdrv_next(), Kevin Wolf, 2010/06/15
- [Qemu-devel] [PATCH 12/19] block: Decouple block device "commit all" from DriveInfo, Kevin Wolf, 2010/06/15
- [Qemu-devel] [PATCH 13/19] monitor: Make "commit FOO" complain when FOO doesn't exist, Kevin Wolf, 2010/06/15
- [Qemu-devel] [PATCH 11/19] block: Move error actions from DriveInfo to BlockDriverState, Kevin Wolf, 2010/06/15
- [Qemu-devel] [PATCH 15/19] block: Decouple savevm from DriveInfo, Kevin Wolf, 2010/06/15
- [Qemu-devel] [PATCH 09/19] cow: stop using mmap, Kevin Wolf, 2010/06/15
- [Qemu-devel] [PATCH 17/19] Correct definitions for FD_CMD_SAVE and FD_CMD_RESTORE, Kevin Wolf, 2010/06/15