tst: passthrough-fuse: getpath: GetFinalPathNameByHandle

This commit is contained in:
Bill Zissimopoulos 2022-04-12 18:21:19 +01:00
parent e5879a9cb0
commit facbc2c1b5

View File

@ -215,18 +215,16 @@ int open(const char *path, int oflag, ...)
int fgetpath(int fd, char *buf, size_t size) int fgetpath(int fd, char *buf, size_t size)
{ {
HANDLE h = (HANDLE)(intptr_t)fd; HANDLE h = (HANDLE)(intptr_t)fd;
union WCHAR FileName[FSP_FSCTL_TRANSACT_PATH_SIZEMAX / sizeof(WCHAR)];
{ DWORD FileNameLength;
FILE_NAME_INFO V;
UINT8 B[FIELD_OFFSET(FILE_NAME_INFO, FileName) + FSP_FSCTL_TRANSACT_PATH_SIZEMAX];
} NameInfo;
if (!GetFileInformationByHandleEx(h, FileNormalizedNameInfo, &NameInfo, sizeof NameInfo)) FileNameLength = GetFinalPathNameByHandleW(h, FileName, sizeof FileName / sizeof(WCHAR),
VOLUME_NAME_NONE | FILE_NAME_NORMALIZED);
if (0 == FileNameLength)
return error(); return error();
FspPosixEncodeWindowsPath(NameInfo.V.FileName, NameInfo.V.FileNameLength / sizeof(WCHAR)); FspPosixEncodeWindowsPath(FileName, FileNameLength);
size = WideCharToMultiByte(CP_UTF8, 0, size = WideCharToMultiByte(CP_UTF8, 0, FileName, FileNameLength, buf, (int)(size - 1), 0, 0);
NameInfo.V.FileName, NameInfo.V.FileNameLength / sizeof(WCHAR), buf, (int)(size - 1), 0, 0);
if (0 == size) if (0 == size)
return error(); return error();
buf[size] = '\0'; buf[size] = '\0';