All checks were successful
Fuse test / go-test (push) Successful in 32s
Signed-off-by: Matheus Sampaio Queiroga <srherobrine20@gmail.com>
317 lines
8.4 KiB
Go
317 lines
8.4 KiB
Go
//go:build windows
|
|
|
|
package fuse
|
|
|
|
import (
|
|
"unsafe"
|
|
|
|
"golang.org/x/sys/windows"
|
|
)
|
|
|
|
// const SIZEOF_WCHAR = 2
|
|
const SIZEOF_WCHAR = unsafe.Sizeof(uint16(0))
|
|
|
|
const (
|
|
FspFsctlTransactReservedKind = iota
|
|
FspFsctlTransactCreateKind
|
|
FspFsctlTransactOverwriteKind
|
|
FspFsctlTransactCleanupKind
|
|
FspFsctlTransactCloseKind
|
|
FspFsctlTransactReadKind
|
|
FspFsctlTransactWriteKind
|
|
FspFsctlTransactQueryInformationKind
|
|
FspFsctlTransactSetInformationKind
|
|
FspFsctlTransactQueryEaKind
|
|
FspFsctlTransactSetEaKind
|
|
FspFsctlTransactFlushBuffersKind
|
|
FspFsctlTransactQueryVolumeInformationKind
|
|
FspFsctlTransactSetVolumeInformationKind
|
|
FspFsctlTransactQueryDirectoryKind
|
|
FspFsctlTransactFileSystemControlKind
|
|
FspFsctlTransactDeviceControlKind
|
|
FspFsctlTransactShutdownKind
|
|
FspFsctlTransactLockControlKind
|
|
FspFsctlTransactQuerySecurityKind
|
|
FspFsctlTransactSetSecurityKind
|
|
FspFsctlTransactQueryStreamInformationKind
|
|
FspFsctlTransactKindCount
|
|
)
|
|
|
|
const (
|
|
FSP_FSCTL_VOLUME_NAME_SIZE = 64 * SIZEOF_WCHAR
|
|
FSP_FSCTL_VOLUME_PREFIX_SIZE = 192 * SIZEOF_WCHAR
|
|
FSP_FSCTL_VOLUME_FSNAME_SIZE = 16 * SIZEOF_WCHAR
|
|
FSP_FSCTL_VOLUME_NAME_SIZEMAX = FSP_FSCTL_VOLUME_NAME_SIZE + FSP_FSCTL_VOLUME_PREFIX_SIZE
|
|
)
|
|
|
|
const FILE_NEED_EA = 0x00000080
|
|
|
|
const (
|
|
FSP_FILE_SYSTEM_OPERATION_GUARD_STRATEGY_FINE = 0
|
|
FSP_FILE_SYSTEM_OPERATION_GUARD_STRATEGY_COARSE = 1
|
|
)
|
|
|
|
const (
|
|
FspCleanupDelete = 0x01
|
|
FspCleanupSetAllocationSize = 0x02
|
|
FspCleanupSetArchiveBit = 0x10
|
|
FspCleanupSetLastAccessTime = 0x20
|
|
FspCleanupSetLastWriteTime = 0x40
|
|
FspCleanupSetChangeTime = 0x80
|
|
)
|
|
|
|
const (
|
|
// basic filesystem attributes
|
|
FspFSAttributeCaseSensitive = 1 << iota
|
|
FspFSAttributeCasePreservedNames
|
|
FspFSAttributeUnicodeOnDisk
|
|
FspFSAttributePersistentAcls
|
|
FspFSAttributeReparsePoints
|
|
FspFSAttributeReparsePointsAccessCheck
|
|
FspFSAttributeNamedStreams
|
|
FspFSAttributeHardLinks
|
|
FspFSAttributeExtendedAttributes
|
|
FspFSAttributeReadOnlyVolume
|
|
|
|
// kernel mode flags
|
|
FspFSAttributePostCleanupWhenModifiedOnly
|
|
FspFSAttributePassQueryDirectoryPattern
|
|
FspFSAttributeAlwaysUseDoubleBuffering
|
|
FspFSAttributePassQueryDirectoryFileName
|
|
FspFSAttributeFlushAndPurgeOnCleanup
|
|
FspFSAttributeDeviceControl
|
|
|
|
// user mode flags
|
|
FspFSAttributeUmFileContextIsUserContext2
|
|
FspFSAttributeUmFileContextIsFullContext
|
|
FspFSAttributeUmNoReparsePointsDirCheck
|
|
FspFSAttributeUmReservedFlags0
|
|
FspFSAttributeUmReservedFlags1
|
|
FspFSAttributeUmReservedFlags2
|
|
FspFSAttributeUmReservedFlags3
|
|
FspFSAttributeUmReservedFlags4
|
|
|
|
// additional kernel mode flags
|
|
FspFSAttributeAllowOpenInKernelMode
|
|
FspFSAttributeCasePreservedExtendedAttributes
|
|
FspFSAttributeWslFeatures
|
|
FspFSAttributeDirectoryMarkerAsNextOffset
|
|
FspFSAttributeRejectIrpPriorToTransact0
|
|
FspFSAttributeSupportsPosixUnlinkRename
|
|
FspFSAttributePostDispositionWhenNecessaryOnly
|
|
FspFSAttributeKmReservedFlags0
|
|
)
|
|
|
|
const (
|
|
FspFSAttribute2VolumeInfoTimeoutValid = 1 << iota
|
|
FspFSAttribute2DirInfoTimeoutValid
|
|
FspFSAttribute2SecurityTimeoutValid
|
|
FspFSAttribute2StreamInfoTimeoutValid
|
|
FspFSAttribute2EaTimeoutValid
|
|
)
|
|
|
|
type FSP_FILE_SYSTEM_INTERFACE struct {
|
|
GetVolumeInfo uintptr
|
|
SetVolumeLabel uintptr
|
|
GetSecurityByName uintptr
|
|
Create uintptr
|
|
Open uintptr
|
|
Overwrite uintptr
|
|
Cleanup uintptr
|
|
Close uintptr
|
|
Read uintptr
|
|
Write uintptr
|
|
Flush uintptr
|
|
GetFileInfo uintptr
|
|
SetBasicInfo uintptr
|
|
SetFileSize uintptr
|
|
CanDelete uintptr
|
|
Rename uintptr
|
|
GetSecurity uintptr
|
|
SetSecurity uintptr
|
|
ReadDirectory uintptr
|
|
ResolveReparsePoints uintptr
|
|
GetReparsePoint uintptr
|
|
SetReparsePoint uintptr
|
|
DeleteReparsePoint uintptr
|
|
GetStreamInfo uintptr
|
|
GetDirInfoByName uintptr
|
|
Control uintptr
|
|
SetDelete uintptr
|
|
CreateEx uintptr
|
|
OverwriteEx uintptr
|
|
GetEa uintptr
|
|
SetEa uintptr
|
|
Obsolete0 uintptr
|
|
DispatcherStopped uintptr
|
|
Reserved [31]uintptr
|
|
}
|
|
|
|
type REPARSE_DATA_BUFFER_GENERIC struct {
|
|
ReparseTag uint32
|
|
ReparseDataLength uint16
|
|
Reserved uint16
|
|
DataBuffer [1]byte
|
|
}
|
|
|
|
const SYMLINK_FLAG_RELATIVE = 1
|
|
|
|
type REPARSE_DATA_BUFFER_SYMBOLIC_LINK struct {
|
|
ReparseTag uint32
|
|
ReparseDataLength uint16
|
|
Reserved uint16
|
|
SubstituteNameOffset uint16
|
|
SubstituteNameLength uint16
|
|
PrintNameOffset uint16
|
|
PrintNameLength uint16
|
|
Flags uint32
|
|
PathBuffer [1]uint16
|
|
}
|
|
|
|
type REPARSE_DATA_BUFFER_MOUNT_POINT struct {
|
|
ReparseTag uint32
|
|
ReparseDataLength uint16
|
|
Reserved uint16
|
|
SubstituteNameOffset uint16
|
|
SubstituteNameLength uint16
|
|
PrintNameOffset uint16
|
|
PrintNameLength uint16
|
|
PathBuffer [1]uint16
|
|
}
|
|
|
|
type FILE_FULL_EA_INFORMATION struct {
|
|
NextEntryOffset uint32
|
|
Flags uint8
|
|
EaNameLength uint8
|
|
EaValueLength int16
|
|
EaName [1]byte
|
|
}
|
|
|
|
type FSP_FILE_SYSTEM struct {
|
|
Version uint16
|
|
UserContext uintptr
|
|
VolumeName [FSP_FSCTL_VOLUME_NAME_SIZEMAX / SIZEOF_WCHAR]uint16
|
|
VolumeHandle windows.Handle
|
|
EnterOperation, LeaveOperation uintptr
|
|
Operations [FspFsctlTransactKindCount]uintptr
|
|
Interface *FSP_FILE_SYSTEM_INTERFACE
|
|
DispatcherThread windows.Handle
|
|
DispatcherThreadCount uint32
|
|
DispatcherResult windows.NTStatus
|
|
MountPoint *uint16
|
|
MountHandle windows.Handle
|
|
DebugLog uint32
|
|
OpGuardStrategy uintptr
|
|
OpGuardLock uintptr
|
|
UmFileContextIsUserContext2 uint8
|
|
UmFileContextIsFullContext uint8
|
|
UmDispatcherFlags uint16
|
|
}
|
|
|
|
type FSP_FSCTL_VOLUME_INFO struct {
|
|
TotalSize uint64
|
|
FreeSize uint64
|
|
VolumeLabelLength uint16
|
|
VolumeLabel [32]uint16
|
|
}
|
|
|
|
type FSP_FSCTL_VOLUME_PARAMS_V0 struct {
|
|
Zero uint16
|
|
SectorSize uint16
|
|
SectorsPerAllocationUnit uint16
|
|
MaxComponentLength uint16
|
|
VolumeCreationTime uint64
|
|
VolumeSerialNumber uint32
|
|
TransactTimeout uint32
|
|
IrpTimeout uint32
|
|
IrpCapacity uint32
|
|
FileInfoTimeout uint32
|
|
FileSystemAttribute uint32
|
|
Prefix [FSP_FSCTL_VOLUME_PREFIX_SIZE / SIZEOF_WCHAR]uint16
|
|
FileSystemName [FSP_FSCTL_VOLUME_FSNAME_SIZE / SIZEOF_WCHAR]uint16
|
|
// 416 bytes
|
|
}
|
|
|
|
type FSP_FSCTL_VOLUME_PARAMS_V1 struct {
|
|
SizeOfVolumeParamsV1 uint16
|
|
SectorSize uint16
|
|
SectorsPerAllocationUnit uint16
|
|
MaxComponentLength uint16
|
|
VolumeCreationTime uint64
|
|
VolumeSerialNumber uint32
|
|
TransactTimeout uint32
|
|
IrpTimeout uint32
|
|
IrpCapacity uint32
|
|
FileInfoTimeout uint32
|
|
FileSystemAttribute uint32
|
|
Prefix [FSP_FSCTL_VOLUME_PREFIX_SIZE / SIZEOF_WCHAR]uint16
|
|
FileSystemName [FSP_FSCTL_VOLUME_FSNAME_SIZE / SIZEOF_WCHAR]uint16
|
|
FileSystemAttribute2 uint32
|
|
VolumeInfoTimeout uint32
|
|
DirInfoTimeout uint32
|
|
SecurityTimeout uint32
|
|
StreamInfoTimeout uint32
|
|
EaTimeout uint32
|
|
FsextControlCode uint32
|
|
Reserved32 [1]uint32
|
|
Reserved64 [2]uint64
|
|
// 504 bytes
|
|
}
|
|
|
|
type FSP_FSCTL_FILE_INFO struct {
|
|
FileAttributes uint32
|
|
ReparseTag uint32
|
|
AllocationSize uint64
|
|
FileSize uint64
|
|
CreationTime uint64
|
|
LastAccessTime uint64
|
|
LastWriteTime uint64
|
|
ChangeTime uint64
|
|
IndexNumber uint64
|
|
HardLinks uint32 // unimplemented: set to 0
|
|
EaSize uint32
|
|
}
|
|
|
|
type FSP_FSCTL_OPEN_FILE_INFO struct {
|
|
FileInfo FSP_FSCTL_FILE_INFO
|
|
NormalizedName *uint16
|
|
NormalizedNameSize uint16
|
|
}
|
|
|
|
type FSP_FSCTL_DIR_INFO struct {
|
|
Size uint16
|
|
FileInfo FSP_FSCTL_FILE_INFO
|
|
NextOffset uint64
|
|
Padding0 uint64
|
|
Padding1 uint64
|
|
}
|
|
|
|
type FSP_FSCTL_STREAM_INFO struct {
|
|
Size uint16
|
|
StreamSize uint64
|
|
StreamAllocationSize uint64
|
|
StreamNameBuf *uint16
|
|
}
|
|
|
|
type FSP_FSCTL_NOTIFY_INFO struct {
|
|
Size uint16
|
|
Filter uint32
|
|
Action uint32
|
|
FileNameBuf *uint16
|
|
}
|
|
|
|
type FSP_FSCTL_TRANSACT_FULL_CONTEXT struct {
|
|
UserContext uint64
|
|
UserContext2 uint64
|
|
}
|
|
|
|
type FSP_FSCTL_TRANSACT_BUF struct {
|
|
Offset uint16
|
|
Size uint16
|
|
}
|
|
|
|
type FSP_IO_STATUS struct {
|
|
Information uint32
|
|
Status uint32
|
|
}
|