* fhandler_disk_file.cc (fhandler_disk_file::pread): Correctly return

with errno set to EBADF if file open mode is incorrect.
	(fhandler_disk_file::pwrite): Ditto.
This commit is contained in:
Corinna Vinschen 2011-05-05 13:45:06 +00:00
parent 25c50222d9
commit 2b31bc47a7
2 changed files with 18 additions and 0 deletions

View File

@ -1,3 +1,9 @@
2011-05-05 Corinna Vinschen <corinna@vinschen.de>
* fhandler_disk_file.cc (fhandler_disk_file::pread): Correctly return
with errno set to EBADF if file open mode is incorrect.
(fhandler_disk_file::pwrite): Ditto.
2011-05-05 Corinna Vinschen <corinna@vinschen.de>
* fhandler.cc (is_at_eof): Drop static storage class. Drop err

View File

@ -1415,6 +1415,12 @@ out:
ssize_t __stdcall
fhandler_disk_file::pread (void *buf, size_t count, _off64_t offset)
{
if ((get_flags () & O_ACCMODE) == O_WRONLY)
{
set_errno (EBADF);
return -1;
}
/* In binary mode, we can use an atomic NtReadFile call. */
if (rbinary ())
{
@ -1476,6 +1482,12 @@ fhandler_disk_file::pread (void *buf, size_t count, _off64_t offset)
ssize_t __stdcall
fhandler_disk_file::pwrite (void *buf, size_t count, _off64_t offset)
{
if ((get_flags () & O_ACCMODE) == O_RDONLY)
{
set_errno (EBADF);
return -1;
}
/* In binary mode, we can use an atomic NtWriteFile call. */
if (wbinary ())
{