mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-22 08:23:05 -05:00
dll: fuse: CheckSymlinkDirectory: optimization
This commit is contained in:
parent
14b212f9af
commit
378beb55eb
@ -347,7 +347,7 @@ static BOOLEAN fsp_fuse_intf_CheckSymlinkDirectory(FSP_FILE_SYSTEM *FileSystem,
|
|||||||
PWSTR WindowsPath = 0, P;
|
PWSTR WindowsPath = 0, P;
|
||||||
char *PosixResolvedPath = 0;
|
char *PosixResolvedPath = 0;
|
||||||
UINT32 ReparsePointIndex;
|
UINT32 ReparsePointIndex;
|
||||||
UINT32 ResolvedFileAttributes = -1;
|
UINT32 ResolveFileAttributes[2] = { FILE_ATTRIBUTE_REPARSE_POINT, -1 };
|
||||||
IO_STATUS_BLOCK IoStatus;
|
IO_STATUS_BLOCK IoStatus;
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
@ -371,7 +371,7 @@ static BOOLEAN fsp_fuse_intf_CheckSymlinkDirectory(FSP_FILE_SYSTEM *FileSystem,
|
|||||||
|
|
||||||
ReparseDataSize = sizeof ReparseDataBuf - sizeof(WCHAR)/* leave space for term-0 */;
|
ReparseDataSize = sizeof ReparseDataBuf - sizeof(WCHAR)/* leave space for term-0 */;
|
||||||
Result = FspFileSystemResolveReparsePoints(FileSystem,
|
Result = FspFileSystemResolveReparsePoints(FileSystem,
|
||||||
fsp_fuse_intf_GetReparsePointByName, &ResolvedFileAttributes,
|
fsp_fuse_intf_GetReparsePointByName, ResolveFileAttributes,
|
||||||
WindowsPath, ReparsePointIndex, TRUE,
|
WindowsPath, ReparsePointIndex, TRUE,
|
||||||
&IoStatus, &ReparseDataBuf,
|
&IoStatus, &ReparseDataBuf,
|
||||||
&ReparseDataSize);
|
&ReparseDataSize);
|
||||||
@ -384,9 +384,9 @@ static BOOLEAN fsp_fuse_intf_CheckSymlinkDirectory(FSP_FILE_SYSTEM *FileSystem,
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (-1 != ResolvedFileAttributes)
|
if (-1 != ResolveFileAttributes[1])
|
||||||
{
|
{
|
||||||
Result = (FILE_ATTRIBUTE_DIRECTORY & ResolvedFileAttributes) ?
|
Result = (FILE_ATTRIBUTE_DIRECTORY & ResolveFileAttributes[1]) ?
|
||||||
STATUS_SUCCESS : STATUS_UNSUCCESSFUL;
|
STATUS_SUCCESS : STATUS_UNSUCCESSFUL;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
@ -658,7 +658,7 @@ exit:
|
|||||||
|
|
||||||
static NTSTATUS fsp_fuse_intf_GetReparsePointEx(FSP_FILE_SYSTEM *FileSystem,
|
static NTSTATUS fsp_fuse_intf_GetReparsePointEx(FSP_FILE_SYSTEM *FileSystem,
|
||||||
const char *PosixPath, struct fuse_file_info *fi,
|
const char *PosixPath, struct fuse_file_info *fi,
|
||||||
PVOID Buffer, PSIZE_T PSize, PUINT32 PResolvedFileAttributes)
|
PVOID Buffer, PSIZE_T PSize, PUINT32 PResolveFileAttributes)
|
||||||
{
|
{
|
||||||
struct fuse *f = FileSystem->UserContext;
|
struct fuse *f = FileSystem->UserContext;
|
||||||
UINT32 Uid, Gid, Mode, Dev;
|
UINT32 Uid, Gid, Mode, Dev;
|
||||||
@ -668,6 +668,16 @@ static NTSTATUS fsp_fuse_intf_GetReparsePointEx(FSP_FILE_SYSTEM *FileSystem,
|
|||||||
SIZE_T Size;
|
SIZE_T Size;
|
||||||
NTSTATUS Result;
|
NTSTATUS Result;
|
||||||
|
|
||||||
|
if (0 != PResolveFileAttributes && FILE_ATTRIBUTE_REPARSE_POINT == PResolveFileAttributes[0])
|
||||||
|
{
|
||||||
|
Mode = 0120000;
|
||||||
|
memset(&FileInfo, 0, sizeof FileInfo);
|
||||||
|
FileInfo.FileAttributes = PResolveFileAttributes[0];
|
||||||
|
FileInfo.ReparseTag = IO_REPARSE_TAG_SYMLINK;
|
||||||
|
PResolveFileAttributes[0] = 0;
|
||||||
|
goto skip_getattr;
|
||||||
|
}
|
||||||
|
|
||||||
Result = fsp_fuse_intf_GetFileInfoFunnel(FileSystem, PosixPath, fi, 0,
|
Result = fsp_fuse_intf_GetFileInfoFunnel(FileSystem, PosixPath, fi, 0,
|
||||||
&Uid, &Gid, &Mode, &Dev, FALSE, &FileInfo);
|
&Uid, &Gid, &Mode, &Dev, FALSE, &FileInfo);
|
||||||
if (!NT_SUCCESS(Result))
|
if (!NT_SUCCESS(Result))
|
||||||
@ -675,11 +685,12 @@ static NTSTATUS fsp_fuse_intf_GetReparsePointEx(FSP_FILE_SYSTEM *FileSystem,
|
|||||||
|
|
||||||
if (0 == (FILE_ATTRIBUTE_REPARSE_POINT & FileInfo.FileAttributes))
|
if (0 == (FILE_ATTRIBUTE_REPARSE_POINT & FileInfo.FileAttributes))
|
||||||
{
|
{
|
||||||
if (0 != PResolvedFileAttributes)
|
if (0 != PResolveFileAttributes)
|
||||||
*PResolvedFileAttributes = FileInfo.FileAttributes;
|
PResolveFileAttributes[1] = FileInfo.FileAttributes;
|
||||||
return STATUS_NOT_A_REPARSE_POINT;
|
return STATUS_NOT_A_REPARSE_POINT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
skip_getattr:
|
||||||
if (0 == Buffer)
|
if (0 == Buffer)
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user