summaryrefslogtreecommitdiff
path: root/blockdev/windows
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2022-12-29 23:37:32 +0100
committerCarl Hetherington <cth@carlh.net>2023-01-30 20:52:20 +0100
commitb98f55b806f9dfe9e9374faceed99b689c29f28e (patch)
tree5c626761e0814ae7b9434a5fc66b1e2100743893 /blockdev/windows
parent3dc752da8948564456ce2d721c266b4e1a50e7a1 (diff)
Return platform-specific errors via ext4_blockdev_errno2400-ext-errors
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;