[CRT] Update file descriptor handling to match Wine (3/7). CORE-14504

Import Wine commits by Piotr Caban:
* 6c2d4f1092d msvcrt: Use fd critical section in _fstat64.
* 9278190d468 msvcrt: Use fd critical section in _futime64.
This commit is contained in:
Thomas Faber 2018-03-25 16:15:31 +02:00
parent 9eb1eae28c
commit c529e727d7
No known key found for this signature in database
GPG key ID: 076E7C3D44720826
4 changed files with 35 additions and 23 deletions

View file

@ -39,8 +39,10 @@
#include <time.h>
#include <sys/utime.h>
#include "bitsfixup.h"
#include <internal/wine/msvcrt.h>
HANDLE fdtoh(int fd);
inline ioinfo* get_ioinfo(int fd);
inline void release_ioinfo(ioinfo *info);
/******************************************************************************
* \name _futime
@ -52,12 +54,12 @@ HANDLE fdtoh(int fd);
int
_futime(int fd, struct _utimbuf *filetime)
{
HANDLE handle;
ioinfo *info = get_ioinfo(fd);
FILETIME at, wt;
handle = fdtoh(fd);
if (handle == INVALID_HANDLE_VALUE)
if (info->handle == INVALID_HANDLE_VALUE)
{
release_ioinfo(info);
return -1;
}
@ -84,11 +86,12 @@ _futime(int fd, struct _utimbuf *filetime)
}
}
if (!SetFileTime(handle, NULL, &at, &wt))
if (!SetFileTime(info->handle, NULL, &at, &wt))
{
release_ioinfo(info);
_dosmaperr(GetLastError());
return -1 ;
}
release_ioinfo(info);
return 0;
}