Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
e04da6bb
Commit
e04da6bb
authored
Nov 28, 2004
by
Dmitry Timoshkov
Committed by
Alexandre Julliard
Nov 28, 2004
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a test for ReadFile/WriteFile fault handling, make it pass under
Wine.
parent
c33c2da8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
72 additions
and
6 deletions
+72
-6
file.c
dlls/kernel/file.c
+4
-2
file.c
dlls/kernel/tests/file.c
+56
-0
file.c
dlls/ntdll/file.c
+12
-4
No files found.
dlls/kernel/file.c
View file @
e04da6bb
...
@@ -449,13 +449,15 @@ BOOL WINAPI WriteFile( HANDLE hFile, LPCVOID buffer, DWORD bytesToWrite,
...
@@ -449,13 +449,15 @@ BOOL WINAPI WriteFile( HANDLE hFile, LPCVOID buffer, DWORD bytesToWrite,
status
=
NtWriteFile
(
hFile
,
hEvent
,
NULL
,
NULL
,
piosb
,
status
=
NtWriteFile
(
hFile
,
hEvent
,
NULL
,
NULL
,
piosb
,
buffer
,
bytesToWrite
,
poffset
,
NULL
);
buffer
,
bytesToWrite
,
poffset
,
NULL
);
if
(
status
!=
STATUS_PENDING
&&
bytesWritten
)
*
bytesWritten
=
piosb
->
Information
;
if
(
status
)
if
(
status
)
{
{
SetLastError
(
RtlNtStatusToDosError
(
status
)
);
SetLastError
(
RtlNtStatusToDosError
(
status
)
);
return
FALSE
;
return
FALSE
;
}
}
if
(
bytesWritten
)
*
bytesWritten
=
piosb
->
Information
;
return
TRUE
;
return
TRUE
;
}
}
...
...
dlls/kernel/tests/file.c
View file @
e04da6bb
...
@@ -1265,6 +1265,61 @@ static void test_async_file_errors(void)
...
@@ -1265,6 +1265,61 @@ static void test_async_file_errors(void)
/*printf("Error = %ld\n", GetLastError());*/
/*printf("Error = %ld\n", GetLastError());*/
}
}
static
void
test_read_write
(
void
)
{
DWORD
bytes
,
ret
;
HANDLE
hFile
;
char
temp_path
[
MAX_PATH
];
char
filename
[
MAX_PATH
];
static
const
char
prefix
[]
=
"pfx"
;
ret
=
GetTempPathA
(
MAX_PATH
,
temp_path
);
ok
(
ret
!=
0
,
"GetTempPathA error %ld
\n
"
,
GetLastError
());
ok
(
ret
<
MAX_PATH
,
"temp path should fit into MAX_PATH
\n
"
);
ret
=
GetTempFileNameA
(
temp_path
,
prefix
,
0
,
filename
);
ok
(
ret
!=
0
,
"GetTempFileNameA error %ld
\n
"
,
GetLastError
());
hFile
=
CreateFileA
(
filename
,
GENERIC_READ
|
GENERIC_WRITE
,
0
,
NULL
,
CREATE_ALWAYS
,
FILE_FLAG_RANDOM_ACCESS
,
0
);
ok
(
hFile
!=
INVALID_HANDLE_VALUE
,
"CreateFileA: error %ld
\n
"
,
GetLastError
());
SetLastError
(
12345678
);
bytes
=
12345678
;
ret
=
WriteFile
(
hFile
,
NULL
,
0
,
&
bytes
,
NULL
);
ok
(
ret
&&
GetLastError
()
==
12345678
,
"ret = %ld, error %ld
\n
"
,
ret
,
GetLastError
());
ok
(
!
bytes
,
"bytes = %ld
\n
"
,
bytes
);
SetLastError
(
12345678
);
bytes
=
12345678
;
ret
=
WriteFile
(
hFile
,
NULL
,
10
,
&
bytes
,
NULL
);
ok
((
!
ret
&&
GetLastError
()
==
ERROR_INVALID_USER_BUFFER
)
||
/* Win2k */
(
ret
&&
GetLastError
()
==
12345678
),
/* Win9x */
"ret = %ld, error %ld
\n
"
,
ret
,
GetLastError
());
ok
(
!
bytes
||
/* Win2k */
bytes
==
10
,
/* Win9x */
"bytes = %ld
\n
"
,
bytes
);
SetLastError
(
12345678
);
bytes
=
12345678
;
ret
=
ReadFile
(
hFile
,
NULL
,
0
,
&
bytes
,
NULL
);
ok
(
ret
&&
GetLastError
()
==
12345678
,
"ret = %ld, error %ld
\n
"
,
ret
,
GetLastError
());
ok
(
!
bytes
,
"bytes = %ld
\n
"
,
bytes
);
SetLastError
(
12345678
);
bytes
=
12345678
;
ret
=
ReadFile
(
hFile
,
NULL
,
10
,
&
bytes
,
NULL
);
ok
(
!
ret
&&
(
GetLastError
()
==
ERROR_NOACCESS
||
/* Win2k */
GetLastError
()
==
ERROR_INVALID_PARAMETER
),
/* Win9x */
"ret = %ld, error %ld
\n
"
,
ret
,
GetLastError
());
ok
(
!
bytes
,
"bytes = %ld
\n
"
,
bytes
);
ok
(
CloseHandle
(
hFile
),
"CloseHandle: error %ld
\n
"
,
GetLastError
());
ok
(
DeleteFileA
(
filename
),
"DeleteFileA: error %ld
\n
"
,
GetLastError
());
}
START_TEST
(
file
)
START_TEST
(
file
)
{
{
test__hread
(
);
test__hread
(
);
...
@@ -1292,4 +1347,5 @@ START_TEST(file)
...
@@ -1292,4 +1347,5 @@ START_TEST(file)
test_MapFile
();
test_MapFile
();
test_GetFileType
();
test_GetFileType
();
test_async_file_errors
();
test_async_file_errors
();
test_read_write
();
}
}
dlls/ntdll/file.c
View file @
e04da6bb
...
@@ -531,8 +531,12 @@ NTSTATUS WINAPI NtReadFile(HANDLE hFile, HANDLE hEvent,
...
@@ -531,8 +531,12 @@ NTSTATUS WINAPI NtReadFile(HANDLE hFile, HANDLE hEvent,
while
((
io_status
->
Information
=
read
(
unix_handle
,
buffer
,
length
))
==
-
1
)
while
((
io_status
->
Information
=
read
(
unix_handle
,
buffer
,
length
))
==
-
1
)
{
{
if
((
errno
==
EAGAIN
)
||
(
errno
==
EINTR
))
continue
;
if
((
errno
==
EAGAIN
)
||
(
errno
==
EINTR
))
continue
;
if
(
errno
==
EFAULT
)
FIXME
(
"EFAULT handling broken for now
\n
"
);
if
(
errno
==
EFAULT
)
io_status
->
u
.
Status
=
FILE_GetNtStatus
();
{
io_status
->
Information
=
0
;
io_status
->
u
.
Status
=
STATUS_ACCESS_VIOLATION
;
}
else
io_status
->
u
.
Status
=
FILE_GetNtStatus
();
break
;
break
;
}
}
wine_server_release_fd
(
hFile
,
unix_handle
);
wine_server_release_fd
(
hFile
,
unix_handle
);
...
@@ -724,8 +728,12 @@ NTSTATUS WINAPI NtWriteFile(HANDLE hFile, HANDLE hEvent,
...
@@ -724,8 +728,12 @@ NTSTATUS WINAPI NtWriteFile(HANDLE hFile, HANDLE hEvent,
while
((
io_status
->
Information
=
write
(
unix_handle
,
buffer
,
length
))
==
-
1
)
while
((
io_status
->
Information
=
write
(
unix_handle
,
buffer
,
length
))
==
-
1
)
{
{
if
((
errno
==
EAGAIN
)
||
(
errno
==
EINTR
))
continue
;
if
((
errno
==
EAGAIN
)
||
(
errno
==
EINTR
))
continue
;
if
(
errno
==
EFAULT
)
FIXME
(
"EFAULT handling broken for now
\n
"
);
if
(
errno
==
EFAULT
)
if
(
errno
==
ENOSPC
)
io_status
->
u
.
Status
=
STATUS_DISK_FULL
;
{
io_status
->
Information
=
0
;
io_status
->
u
.
Status
=
STATUS_INVALID_USER_BUFFER
;
}
else
if
(
errno
==
ENOSPC
)
io_status
->
u
.
Status
=
STATUS_DISK_FULL
;
else
io_status
->
u
.
Status
=
FILE_GetNtStatus
();
else
io_status
->
u
.
Status
=
FILE_GetNtStatus
();
break
;
break
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment