summaryrefslogtreecommitdiff
path: root/blockdev/windows
diff options
context:
space:
mode:
Diffstat (limited to 'blockdev/windows')
-rw-r--r--blockdev/windows/file_windows.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/blockdev/windows/file_windows.c b/blockdev/windows/file_windows.c
index 45588e3..75a372f 100644
--- a/blockdev/windows/file_windows.c
+++ b/blockdev/windows/file_windows.c
@@ -80,6 +80,7 @@ static int file_open(struct ext4_blockdev *bdev)
FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH, NULL);
if (dev_file == INVALID_HANDLE_VALUE) {
+ ext4_blockdev_errno = GetLastError();
return EIO;
}
@@ -88,6 +89,7 @@ static int file_open(struct ext4_blockdev *bdev)
&pdg, sizeof(pdg), &junk, (LPOVERLAPPED)NULL);
if (bResult == FALSE) {
+ ext4_blockdev_errno = GetLastError();
CloseHandle(dev_file);
return EIO;
}
@@ -116,19 +118,18 @@ static int file_bread(struct ext4_blockdev *bdev, void *buf, uint64_t blk_id,
{
long hipart = blk_id >> (32 - 9);
long lopart = blk_id << 9;
- long err;
SetLastError(0);
lopart = SetFilePointer(dev_file, lopart, &hipart, FILE_BEGIN);
- if (lopart == -1 && NO_ERROR != (err = GetLastError())) {
+ if (lopart == -1 && NO_ERROR != (ext4_blockdev_errno = GetLastError())) {
return EIO;
}
DWORD n;
if (!ReadFile(dev_file, buf, blk_cnt * 512, &n, NULL)) {
- err = GetLastError();
+ ext4_blockdev_errno = GetLastError();
return EIO;
}
return EOK;
@@ -140,19 +141,18 @@ static int file_bwrite(struct ext4_blockdev *bdev, const void *buf,
{
long hipart = blk_id >> (32 - 9);
long lopart = blk_id << 9;
- long err;
SetLastError(0);
lopart = SetFilePointer(dev_file, lopart, &hipart, FILE_BEGIN);
- if (lopart == -1 && NO_ERROR != (err = GetLastError())) {
+ if (lopart == -1 && NO_ERROR != (ext4_blockdev_errno = GetLastError())) {
return EIO;
}
DWORD n;
if (!WriteFile(dev_file, buf, blk_cnt * 512, &n, NULL)) {
- err = GetLastError();
+ ext4_blockdev_errno = GetLastError();
return EIO;
}
return EOK;