mirror of
				https://github.com/winfsp/winfsp.git
				synced 2025-10-30 19:48:38 -05:00 
			
		
		
		
	sys,dll: reparse point testing
This commit is contained in:
		| @@ -63,6 +63,7 @@ extern const __declspec(selectany) GUID FspFsvrtDeviceClassGuid = | |||||||
|  |  | ||||||
| #define FSP_FSCTL_TRANSACT_REQ_SIZEMAX  (4096 - 64) /* 64: size for internal request header */ | #define FSP_FSCTL_TRANSACT_REQ_SIZEMAX  (4096 - 64) /* 64: size for internal request header */ | ||||||
| #define FSP_FSCTL_TRANSACT_RSP_SIZEMAX  (4096 - 64) /* symmetry! */ | #define FSP_FSCTL_TRANSACT_RSP_SIZEMAX  (4096 - 64) /* symmetry! */ | ||||||
|  | #define FSP_FSCTL_TRANSACT_RSP_BUFFER_SIZEMAX   (FSP_FSCTL_TRANSACT_RSP_SIZEMAX - sizeof(FSP_FSCTL_TRANSACT_RSP)) | ||||||
| #define FSP_FSCTL_TRANSACT_BATCH_BUFFER_SIZEMIN 16384 | #define FSP_FSCTL_TRANSACT_BATCH_BUFFER_SIZEMIN 16384 | ||||||
| #define FSP_FSCTL_TRANSACT_BUFFER_SIZEMIN       FSP_FSCTL_TRANSACT_REQ_SIZEMAX | #define FSP_FSCTL_TRANSACT_BUFFER_SIZEMIN       FSP_FSCTL_TRANSACT_REQ_SIZEMAX | ||||||
|  |  | ||||||
|   | |||||||
| @@ -675,9 +675,9 @@ typedef struct _FSP_FILE_SYSTEM_INTERFACE | |||||||
|      *     The name of the file or directory to have its reparse points resolved. |      *     The name of the file or directory to have its reparse points resolved. | ||||||
|      * @param ReparsePointIndex |      * @param ReparsePointIndex | ||||||
|      *     The index of the first reparse point within FileName. |      *     The index of the first reparse point within FileName. | ||||||
|      * @param OpenReparsePoint |      * @param ResolveLastPathComponent | ||||||
|      *     If TRUE, the last path component of FileName should not be resolved, even |      *     If FALSE, the last path component of FileName should not be resolved, even | ||||||
|      *     if it is a reparse point that can be resolved. If FALSE, all path components |      *     if it is a reparse point that can be resolved. If TRUE, all path components | ||||||
|      *     should be resolved if possible. |      *     should be resolved if possible. | ||||||
|      * @param PIoStatus |      * @param PIoStatus | ||||||
|      *     Pointer to storage that will receive the status to return to the FSD. When |      *     Pointer to storage that will receive the status to return to the FSD. When | ||||||
| @@ -694,7 +694,7 @@ typedef struct _FSP_FILE_SYSTEM_INTERFACE | |||||||
|      *     STATUS_REPARSE or error code. |      *     STATUS_REPARSE or error code. | ||||||
|      */ |      */ | ||||||
|     NTSTATUS (*ResolveReparsePoints)(FSP_FILE_SYSTEM *FileSystem, |     NTSTATUS (*ResolveReparsePoints)(FSP_FILE_SYSTEM *FileSystem, | ||||||
|         PWSTR FileName, UINT32 ReparsePointIndex, BOOLEAN OpenReparsePoint, |         PWSTR FileName, UINT32 ReparsePointIndex, BOOLEAN ResolveLastPathComponent, | ||||||
|         PIO_STATUS_BLOCK PIoStatus, PVOID Buffer, PSIZE_T PSize); |         PIO_STATUS_BLOCK PIoStatus, PVOID Buffer, PSIZE_T PSize); | ||||||
|     /** |     /** | ||||||
|      * Get reparse point. |      * Get reparse point. | ||||||
| @@ -1101,9 +1101,9 @@ FSP_API BOOLEAN FspFileSystemFindReparsePoint(FSP_FILE_SYSTEM *FileSystem, | |||||||
|  *     The name of the file or directory to have its reparse points resolved. |  *     The name of the file or directory to have its reparse points resolved. | ||||||
|  * @param ReparsePointIndex |  * @param ReparsePointIndex | ||||||
|  *     The index of the first reparse point within FileName. |  *     The index of the first reparse point within FileName. | ||||||
|  * @param OpenReparsePoint |  * @param ResolveLastPathComponent | ||||||
|  *     If TRUE, the last path component of FileName should not be resolved, even |  *     If FALSE, the last path component of FileName should not be resolved, even | ||||||
|  *     if it is a reparse point that can be resolved. If FALSE, all path components |  *     if it is a reparse point that can be resolved. If TRUE, all path components | ||||||
|  *     should be resolved if possible. |  *     should be resolved if possible. | ||||||
|  * @param PIoStatus |  * @param PIoStatus | ||||||
|  *     Pointer to storage that will receive the status to return to the FSD. When |  *     Pointer to storage that will receive the status to return to the FSD. When | ||||||
| @@ -1126,7 +1126,7 @@ FSP_API NTSTATUS FspFileSystemResolveReparsePoints(FSP_FILE_SYSTEM *FileSystem, | |||||||
|         FSP_FILE_SYSTEM *FileSystem, PVOID Context, |         FSP_FILE_SYSTEM *FileSystem, PVOID Context, | ||||||
|         PWSTR FileName, BOOLEAN IsDirectory, PVOID Buffer, PSIZE_T PSize), |         PWSTR FileName, BOOLEAN IsDirectory, PVOID Buffer, PSIZE_T PSize), | ||||||
|     PVOID Context, |     PVOID Context, | ||||||
|     PWSTR FileName, UINT32 ReparsePointIndex, BOOLEAN OpenReparsePoint, |     PWSTR FileName, UINT32 ReparsePointIndex, BOOLEAN ResolveLastPathComponent, | ||||||
|     PIO_STATUS_BLOCK PIoStatus, PVOID Buffer, PSIZE_T PSize); |     PIO_STATUS_BLOCK PIoStatus, PVOID Buffer, PSIZE_T PSize); | ||||||
| /** | /** | ||||||
|  * Test whether reparse data can be replaced. |  * Test whether reparse data can be replaced. | ||||||
|   | |||||||
| @@ -103,11 +103,11 @@ NTSTATUS FspFileSystemCallResolveReparsePoints(FSP_FILE_SYSTEM *FileSystem, | |||||||
|     if (0 != FileSystem->Interface->ResolveReparsePoints) |     if (0 != FileSystem->Interface->ResolveReparsePoints) | ||||||
|     { |     { | ||||||
|         memset(&IoStatus, 0, sizeof IoStatus); |         memset(&IoStatus, 0, sizeof IoStatus); | ||||||
|         Size = FSP_FSCTL_TRANSACT_RSP_SIZEMAX - FIELD_OFFSET(FSP_FSCTL_TRANSACT_RSP, Buffer); |         Size = FSP_FSCTL_TRANSACT_RSP_BUFFER_SIZEMAX; | ||||||
|         Result = FileSystem->Interface->ResolveReparsePoints(FileSystem, |         Result = FileSystem->Interface->ResolveReparsePoints(FileSystem, | ||||||
|             (PWSTR)Request->Buffer, |             (PWSTR)Request->Buffer, | ||||||
|             ReparsePointIndex, |             ReparsePointIndex, | ||||||
|             !!(Request->Req.Create.CreateOptions & FILE_OPEN_REPARSE_POINT), |             !(Request->Req.Create.CreateOptions & FILE_OPEN_REPARSE_POINT), | ||||||
|             &IoStatus, |             &IoStatus, | ||||||
|             Response->Buffer, |             Response->Buffer, | ||||||
|             &Size); |             &Size); | ||||||
| @@ -116,6 +116,7 @@ NTSTATUS FspFileSystemCallResolveReparsePoints(FSP_FILE_SYSTEM *FileSystem, | |||||||
|             Result = STATUS_REPARSE; |             Result = STATUS_REPARSE; | ||||||
|             Response->IoStatus.Information = (UINT32)IoStatus.Information; |             Response->IoStatus.Information = (UINT32)IoStatus.Information; | ||||||
|  |  | ||||||
|  |             Response->Size = (UINT16)(sizeof *Response + Size); | ||||||
|             if (0/*IO_REPARSE*/ == IoStatus.Information) |             if (0/*IO_REPARSE*/ == IoStatus.Information) | ||||||
|             { |             { | ||||||
|                 Response->Rsp.Create.Reparse.FileName.Offset = 0; |                 Response->Rsp.Create.Reparse.FileName.Offset = 0; | ||||||
| @@ -901,7 +902,7 @@ FSP_API NTSTATUS FspFileSystemOpFileSystemControl(FSP_FILE_SYSTEM *FileSystem, | |||||||
|             ReparseData = (PREPARSE_DATA_BUFFER)Response->Buffer; |             ReparseData = (PREPARSE_DATA_BUFFER)Response->Buffer; | ||||||
|             memset(ReparseData, 0, sizeof *ReparseData); |             memset(ReparseData, 0, sizeof *ReparseData); | ||||||
|  |  | ||||||
|             Size = FSP_FSCTL_TRANSACT_RSP_SIZEMAX - FIELD_OFFSET(FSP_FSCTL_TRANSACT_RSP, Buffer); |             Size = FSP_FSCTL_TRANSACT_RSP_BUFFER_SIZEMAX; | ||||||
|             Result = FileSystem->Interface->GetReparsePoint(FileSystem, Request, |             Result = FileSystem->Interface->GetReparsePoint(FileSystem, Request, | ||||||
|                 (PVOID)Request->Req.FileSystemControl.UserContext, |                 (PVOID)Request->Req.FileSystemControl.UserContext, | ||||||
|                 (PWSTR)Request->Buffer, ReparseData, &Size); |                 (PWSTR)Request->Buffer, ReparseData, &Size); | ||||||
| @@ -1055,7 +1056,7 @@ FSP_API NTSTATUS FspFileSystemResolveReparsePoints(FSP_FILE_SYSTEM *FileSystem, | |||||||
|         FSP_FILE_SYSTEM *FileSystem, PVOID Context, |         FSP_FILE_SYSTEM *FileSystem, PVOID Context, | ||||||
|         PWSTR FileName, BOOLEAN IsDirectory, PVOID Buffer, PSIZE_T PSize), |         PWSTR FileName, BOOLEAN IsDirectory, PVOID Buffer, PSIZE_T PSize), | ||||||
|     PVOID Context, |     PVOID Context, | ||||||
|     PWSTR FileName, UINT32 ReparsePointIndex, BOOLEAN OpenReparsePoint, |     PWSTR FileName, UINT32 ReparsePointIndex, BOOLEAN ResolveLastPathComponent, | ||||||
|     PIO_STATUS_BLOCK PIoStatus, PVOID Buffer, PSIZE_T PSize) |     PIO_STATUS_BLOCK PIoStatus, PVOID Buffer, PSIZE_T PSize) | ||||||
| { | { | ||||||
|     WCHAR c, *p, *lastp; |     WCHAR c, *p, *lastp; | ||||||
| @@ -1090,9 +1091,9 @@ FSP_API NTSTATUS FspFileSystemResolveReparsePoints(FSP_FILE_SYSTEM *FileSystem, | |||||||
|         { |         { | ||||||
|             if (L'\0' == *p) |             if (L'\0' == *p) | ||||||
|             { |             { | ||||||
|                 if (!OpenReparsePoint) |                 if (!ResolveLastPathComponent) | ||||||
|                     goto exit; |                     goto exit; | ||||||
|                 OpenReparsePoint = FALSE; |                 ResolveLastPathComponent = FALSE; | ||||||
|                 break; |                 break; | ||||||
|             } |             } | ||||||
|             p++; |             p++; | ||||||
| @@ -1157,7 +1158,7 @@ FSP_API NTSTATUS FspFileSystemResolveReparsePoints(FSP_FILE_SYSTEM *FileSystem, | |||||||
|         { |         { | ||||||
|             /* not a symlink; return the full reparse point! */ |             /* not a symlink; return the full reparse point! */ | ||||||
|             if (Size > *PSize) |             if (Size > *PSize) | ||||||
|                 return STATUS_OBJECT_NAME_INVALID; |                 return STATUS_IO_REPARSE_DATA_INVALID; | ||||||
|             memcpy(Buffer, ReparseData, Size); |             memcpy(Buffer, ReparseData, Size); | ||||||
|  |  | ||||||
|             goto no_symlink_exit; |             goto no_symlink_exit; | ||||||
|   | |||||||
| @@ -1877,11 +1877,11 @@ exit: | |||||||
| } | } | ||||||
|  |  | ||||||
| static NTSTATUS fsp_fuse_intf_ResolveReparsePoints(FSP_FILE_SYSTEM *FileSystem, | static NTSTATUS fsp_fuse_intf_ResolveReparsePoints(FSP_FILE_SYSTEM *FileSystem, | ||||||
|     PWSTR FileName, UINT32 ReparsePointIndex, BOOLEAN OpenReparsePoint, |     PWSTR FileName, UINT32 ReparsePointIndex, BOOLEAN ResolveLastPathComponent, | ||||||
|     PIO_STATUS_BLOCK PIoStatus, PVOID Buffer, PSIZE_T PSize) |     PIO_STATUS_BLOCK PIoStatus, PVOID Buffer, PSIZE_T PSize) | ||||||
| { | { | ||||||
|     return FspFileSystemResolveReparsePoints(FileSystem, fsp_fuse_intf_GetReparsePointByName, 0, |     return FspFileSystemResolveReparsePoints(FileSystem, fsp_fuse_intf_GetReparsePointByName, 0, | ||||||
|         FileName, ReparsePointIndex, OpenReparsePoint, |         FileName, ReparsePointIndex, ResolveLastPathComponent, | ||||||
|         PIoStatus, Buffer, PSize); |         PIoStatus, Buffer, PSize); | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -227,7 +227,7 @@ VOID FspIopCompleteIrpEx(PIRP Irp, NTSTATUS Result, BOOLEAN DeviceDereference) | |||||||
|     /* get the device object out of the IRP before completion */ |     /* get the device object out of the IRP before completion */ | ||||||
|     PDEVICE_OBJECT DeviceObject = IoGetCurrentIrpStackLocation(Irp)->DeviceObject; |     PDEVICE_OBJECT DeviceObject = IoGetCurrentIrpStackLocation(Irp)->DeviceObject; | ||||||
|  |  | ||||||
|     if (STATUS_SUCCESS != Result && STATUS_BUFFER_OVERFLOW != Result) |     if (STATUS_SUCCESS != Result && STATUS_REPARSE != Result && STATUS_BUFFER_OVERFLOW != Result) | ||||||
|         Irp->IoStatus.Information = 0; |         Irp->IoStatus.Information = 0; | ||||||
|     Irp->IoStatus.Status = Result; |     Irp->IoStatus.Status = Result; | ||||||
|     IoCompleteRequest(Irp, FSP_IO_INCREMENT); |     IoCompleteRequest(Irp, FSP_IO_INCREMENT); | ||||||
|   | |||||||
| @@ -945,11 +945,11 @@ static NTSTATUS ReadDirectory(FSP_FILE_SYSTEM *FileSystem, | |||||||
| } | } | ||||||
|  |  | ||||||
| static NTSTATUS ResolveReparsePoints(FSP_FILE_SYSTEM *FileSystem, | static NTSTATUS ResolveReparsePoints(FSP_FILE_SYSTEM *FileSystem, | ||||||
|     PWSTR FileName, UINT32 ReparsePointIndex, BOOLEAN OpenReparsePoint, |     PWSTR FileName, UINT32 ReparsePointIndex, BOOLEAN ResolveLastPathComponent, | ||||||
|     PIO_STATUS_BLOCK PIoStatus, PVOID Buffer, PSIZE_T PSize) |     PIO_STATUS_BLOCK PIoStatus, PVOID Buffer, PSIZE_T PSize) | ||||||
| { | { | ||||||
|     return FspFileSystemResolveReparsePoints(FileSystem, GetReparsePointByName, 0, |     return FspFileSystemResolveReparsePoints(FileSystem, GetReparsePointByName, 0, | ||||||
|         FileName, ReparsePointIndex, OpenReparsePoint, |         FileName, ReparsePointIndex, ResolveLastPathComponent, | ||||||
|         PIoStatus, Buffer, PSize); |         PIoStatus, Buffer, PSize); | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user