Alexandre Julliard : msvcrt: Avoid depending on the mount manager in fstat().
Alexandre Julliard
julliard at winehq.org
Wed Mar 17 16:23:14 CDT 2021
Module: wine
Branch: master
Commit: 23ed647773546ab3e0817580f6ac28ed8c948c9d
URL: https://source.winehq.org/git/wine.git/?a=commit;h=23ed647773546ab3e0817580f6ac28ed8c948c9d
Author: Alexandre Julliard <julliard at winehq.org>
Date: Wed Mar 17 10:29:28 2021 +0100
msvcrt: Avoid depending on the mount manager in fstat().
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/msvcrt/file.c | 25 ++++++++++++++-----------
1 file changed, 14 insertions(+), 11 deletions(-)
diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c
index 89d6e7d721f..bf7496cc233 100644
--- a/dlls/msvcrt/file.c
+++ b/dlls/msvcrt/file.c
@@ -1754,7 +1754,6 @@ int CDECL _fstat64(int fd, struct _stat64* buf)
ioinfo *info = get_ioinfo(fd);
DWORD dw;
DWORD type;
- BY_HANDLE_FILE_INFORMATION hfi;
TRACE(":fd (%d) stat (%p)\n", fd, buf);
if (info->handle == INVALID_HANDLE_VALUE)
@@ -1771,7 +1770,6 @@ int CDECL _fstat64(int fd, struct _stat64* buf)
return -1;
}
- memset(&hfi, 0, sizeof(hfi));
memset(buf, 0, sizeof(struct _stat64));
type = GetFileType(info->handle);
if (type == FILE_TYPE_PIPE)
@@ -1788,25 +1786,30 @@ int CDECL _fstat64(int fd, struct _stat64* buf)
}
else /* FILE_TYPE_DISK etc. */
{
- if (!GetFileInformationByHandle(info->handle, &hfi))
+ FILE_BASIC_INFORMATION basic_info;
+ FILE_STANDARD_INFORMATION std_info;
+ IO_STATUS_BLOCK io;
+ NTSTATUS status;
+
+ if ((status = NtQueryInformationFile( info->handle, &io, &basic_info, sizeof(basic_info), FileBasicInformation )) ||
+ (status = NtQueryInformationFile( info->handle, &io, &std_info, sizeof(std_info), FileStandardInformation )))
{
- WARN(":failed-last error (%d)\n",GetLastError());
+ WARN(":failed-error %x\n",status);
msvcrt_set_errno(ERROR_INVALID_PARAMETER);
release_ioinfo(info);
return -1;
}
buf->st_mode = _S_IFREG | 0444;
- if (!(hfi.dwFileAttributes & FILE_ATTRIBUTE_READONLY))
+ if (!(basic_info.FileAttributes & FILE_ATTRIBUTE_READONLY))
buf->st_mode |= 0222;
- buf->st_size = ((__int64)hfi.nFileSizeHigh << 32) + hfi.nFileSizeLow;
- RtlTimeToSecondsSince1970((LARGE_INTEGER *)&hfi.ftLastAccessTime, &dw);
+ buf->st_size = std_info.EndOfFile.QuadPart;
+ RtlTimeToSecondsSince1970((LARGE_INTEGER *)&basic_info.LastAccessTime, &dw);
buf->st_atime = dw;
- RtlTimeToSecondsSince1970((LARGE_INTEGER *)&hfi.ftLastWriteTime, &dw);
+ RtlTimeToSecondsSince1970((LARGE_INTEGER *)&basic_info.LastWriteTime, &dw);
buf->st_mtime = buf->st_ctime = dw;
- buf->st_nlink = hfi.nNumberOfLinks;
+ buf->st_nlink = std_info.NumberOfLinks;
+ TRACE(":dwFileAttributes = 0x%x, mode set to 0x%x\n",basic_info.FileAttributes, buf->st_mode);
}
- TRACE(":dwFileAttributes = 0x%x, mode set to 0x%x\n",hfi.dwFileAttributes,
- buf->st_mode);
release_ioinfo(info);
return 0;
}
More information about the wine-cvs
mailing list