Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ jobs:
run: |
go test -coverprofile="coverage.out" -v ./...

- name: "run tests (386)"
env:
GOARCH: "386"
run: |
go test -v ./...

- name: "generate coverage report"
run: |
go tool cover -html="coverage.out" -o "coverage.html"
Expand Down
91 changes: 0 additions & 91 deletions filesystem_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,20 +366,6 @@ func delegateCreate(
return windows.STATUS_SUCCESS
}

var go_delegateCreate = syscall.NewCallbackCDecl(func(
fileSystem, fileName uintptr,
createOptions, grantedAccess, fileAttributes uint32,
securityDescriptor uintptr, allocationSize uint64,
file *uintptr, fileInfoAddr uintptr,
) uintptr {
return uintptr(delegateCreate(
fileSystem, fileName,
createOptions, grantedAccess, fileAttributes,
securityDescriptor, allocationSize,
file, fileInfoAddr,
))
})

// BehaviourOverwrite overwrites a file's attribute.
type BehaviourOverwrite interface {
Overwrite(
Expand All @@ -406,18 +392,6 @@ func delegateOverwrite(
))
}

var go_delegateOverwrite = syscall.NewCallbackCDecl(func(
fileSystem, file uintptr,
attributes uint32, replaceAttributes uint8,
allocationSize uint64, fileInfoAddr uintptr,
) uintptr {
return uintptr(delegateOverwrite(
fileSystem, file,
attributes, replaceAttributes,
allocationSize, fileInfoAddr,
))
})

// BehaviourCleanup performs the cleanup behaviour.
type BehaviourCleanup interface {
Cleanup(
Expand Down Expand Up @@ -479,16 +453,6 @@ func delegateRead(
return convertNTStatus(err)
}

var go_delegateRead = syscall.NewCallbackCDecl(func(
fileSystem, fileContext, buffer uintptr,
offset uint64, length uint32, bytesRead *uint32,
) uintptr {
return uintptr(delegateRead(
fileSystem, fileContext, buffer,
offset, length, bytesRead,
))
})

// BehaviourWrite writes an open file.
type BehaviourWrite interface {
Write(
Expand Down Expand Up @@ -520,20 +484,6 @@ func delegateWrite(
return convertNTStatus(err)
}

var go_delegateWrite = syscall.NewCallbackCDecl(func(
fileSystem, fileContext, buffer uintptr,
offset uint64, length uint32,
writeToEndOfFile, constrainedIo uint8,
bytesWritten *uint32, fileInfoAddr uintptr,
) uintptr {
return uintptr(delegateWrite(
fileSystem, fileContext, buffer,
offset, length,
writeToEndOfFile, constrainedIo,
bytesWritten, fileInfoAddr,
))
})

// BehaviourFlush flushes a file or volume.
//
// When file is not NULL, the specific file will be flushed,
Expand Down Expand Up @@ -650,19 +600,6 @@ func delegateSetBasicInfo(
))
}

var go_delegateSetBasicInfo = syscall.NewCallbackCDecl(func(
fileSystem, fileContext uintptr,
attributes uint32,
creationTime, lastAccessTime, lastWriteTime, changeTime uint64,
fileInfoAddr uintptr,
) uintptr {
return uintptr(delegateSetBasicInfo(
fileSystem, fileContext, attributes,
creationTime, lastAccessTime, lastWriteTime, changeTime,
fileInfoAddr,
))
})

// BehaviourSetFileSize sets file's size or allocation size.
type BehaviourSetFileSize interface {
SetFileSize(
Expand All @@ -687,18 +624,6 @@ func delegateSetFileSize(
))
}

var go_delegateSetFileSize = syscall.NewCallbackCDecl(func(
fileSystem, fileContext uintptr,
newSize uint64, setAllocationSize uint8,
fileInfoAddr uintptr,
) uintptr {
return uintptr(delegateSetFileSize(
fileSystem, fileContext,
newSize, setAllocationSize,
fileInfoAddr,
))
})

// BehaviourCanDelete detects whether the file can be deleted.
type BehaviourCanDelete interface {
CanDelete(
Expand Down Expand Up @@ -1236,22 +1161,6 @@ func delegateCreateEx(
return windows.STATUS_SUCCESS
}

var go_delegateCreateEx = syscall.NewCallbackCDecl(func(
fileSystem, fileName uintptr,
createOptions, grantedAccess, fileAttributes uint32,
securityDescriptor uintptr, allocationSize uint64,
extraBuffer uintptr, extraLength uint32, isReparse uint8,
file *uintptr, fileInfoAddr uintptr,
) uintptr {
return uintptr(delegateCreateEx(
fileSystem, fileName,
createOptions, grantedAccess, fileAttributes,
securityDescriptor, allocationSize,
extraBuffer, extraLength, isReparse,
file, fileInfoAddr,
))
})

var (
fileSystemResolveReparsePoints dllProc
)
Expand Down
105 changes: 105 additions & 0 deletions filesystem_windows_386.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
package winfsp

import "syscall"

// makeUint64 joins a 64-bit argument passed as two 32-bit halves.
func makeUint64(lo, hi uint32) uint64 {
return uint64(hi)<<32 | uint64(lo)
}

var go_delegateCreate = syscall.NewCallbackCDecl(func(
fileSystem, fileName uintptr,
createOptions, grantedAccess, fileAttributes uint32,
securityDescriptor uintptr, allocationSizeLo, allocationSizeHi uint32,
file *uintptr, fileInfoAddr uintptr,
) uintptr {
return uintptr(delegateCreate(
fileSystem, fileName,
createOptions, grantedAccess, fileAttributes,
securityDescriptor, makeUint64(allocationSizeLo, allocationSizeHi),
file, fileInfoAddr,
))
})

var go_delegateOverwrite = syscall.NewCallbackCDecl(func(
fileSystem, file uintptr,
attributes uint32, replaceAttributes uint8,
allocationSizeLo, allocationSizeHi uint32, fileInfoAddr uintptr,
) uintptr {
return uintptr(delegateOverwrite(
fileSystem, file,
attributes, replaceAttributes,
makeUint64(allocationSizeLo, allocationSizeHi), fileInfoAddr,
))
})

var go_delegateRead = syscall.NewCallbackCDecl(func(
fileSystem, fileContext, buffer uintptr,
offsetLo, offsetHi uint32, length uint32, bytesRead *uint32,
) uintptr {
return uintptr(delegateRead(
fileSystem, fileContext, buffer,
makeUint64(offsetLo, offsetHi), length, bytesRead,
))
})

var go_delegateWrite = syscall.NewCallbackCDecl(func(
fileSystem, fileContext, buffer uintptr,
offsetLo, offsetHi uint32, length uint32,
writeToEndOfFile, constrainedIo uint8,
bytesWritten *uint32, fileInfoAddr uintptr,
) uintptr {
return uintptr(delegateWrite(
fileSystem, fileContext, buffer,
makeUint64(offsetLo, offsetHi), length,
writeToEndOfFile, constrainedIo,
bytesWritten, fileInfoAddr,
))
})

var go_delegateSetBasicInfo = syscall.NewCallbackCDecl(func(
fileSystem, fileContext uintptr,
attributes uint32,
creationTimeLo, creationTimeHi uint32,
lastAccessTimeLo, lastAccessTimeHi uint32,
lastWriteTimeLo, lastWriteTimeHi uint32,
changeTimeLo, changeTimeHi uint32,
fileInfoAddr uintptr,
) uintptr {
return uintptr(delegateSetBasicInfo(
fileSystem, fileContext, attributes,
makeUint64(creationTimeLo, creationTimeHi),
makeUint64(lastAccessTimeLo, lastAccessTimeHi),
makeUint64(lastWriteTimeLo, lastWriteTimeHi),
makeUint64(changeTimeLo, changeTimeHi),
fileInfoAddr,
))
})

var go_delegateSetFileSize = syscall.NewCallbackCDecl(func(
fileSystem, fileContext uintptr,
newSizeLo, newSizeHi uint32, setAllocationSize uint8,
fileInfoAddr uintptr,
) uintptr {
return uintptr(delegateSetFileSize(
fileSystem, fileContext,
makeUint64(newSizeLo, newSizeHi), setAllocationSize,
fileInfoAddr,
))
})

var go_delegateCreateEx = syscall.NewCallbackCDecl(func(
fileSystem, fileName uintptr,
createOptions, grantedAccess, fileAttributes uint32,
securityDescriptor uintptr, allocationSizeLo, allocationSizeHi uint32,
extraBuffer uintptr, extraLength uint32, isReparse uint8,
file *uintptr, fileInfoAddr uintptr,
) uintptr {
return uintptr(delegateCreateEx(
fileSystem, fileName,
createOptions, grantedAccess, fileAttributes,
securityDescriptor, makeUint64(allocationSizeLo, allocationSizeHi),
extraBuffer, extraLength, isReparse,
file, fileInfoAddr,
))
})
96 changes: 96 additions & 0 deletions filesystem_windows_64bits.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
//go:build windows && (amd64 || arm64)

package winfsp

import "syscall"

var go_delegateCreate = syscall.NewCallbackCDecl(func(
fileSystem, fileName uintptr,
createOptions, grantedAccess, fileAttributes uint32,
securityDescriptor uintptr, allocationSize uint64,
file *uintptr, fileInfoAddr uintptr,
) uintptr {
return uintptr(delegateCreate(
fileSystem, fileName,
createOptions, grantedAccess, fileAttributes,
securityDescriptor, allocationSize,
file, fileInfoAddr,
))
})

var go_delegateOverwrite = syscall.NewCallbackCDecl(func(
fileSystem, file uintptr,
attributes uint32, replaceAttributes uint8,
allocationSize uint64, fileInfoAddr uintptr,
) uintptr {
return uintptr(delegateOverwrite(
fileSystem, file,
attributes, replaceAttributes,
allocationSize, fileInfoAddr,
))
})

var go_delegateRead = syscall.NewCallbackCDecl(func(
fileSystem, fileContext, buffer uintptr,
offset uint64, length uint32, bytesRead *uint32,
) uintptr {
return uintptr(delegateRead(
fileSystem, fileContext, buffer,
offset, length, bytesRead,
))
})

var go_delegateWrite = syscall.NewCallbackCDecl(func(
fileSystem, fileContext, buffer uintptr,
offset uint64, length uint32,
writeToEndOfFile, constrainedIo uint8,
bytesWritten *uint32, fileInfoAddr uintptr,
) uintptr {
return uintptr(delegateWrite(
fileSystem, fileContext, buffer,
offset, length,
writeToEndOfFile, constrainedIo,
bytesWritten, fileInfoAddr,
))
})

var go_delegateSetBasicInfo = syscall.NewCallbackCDecl(func(
fileSystem, fileContext uintptr,
attributes uint32,
creationTime, lastAccessTime, lastWriteTime, changeTime uint64,
fileInfoAddr uintptr,
) uintptr {
return uintptr(delegateSetBasicInfo(
fileSystem, fileContext, attributes,
creationTime, lastAccessTime, lastWriteTime, changeTime,
fileInfoAddr,
))
})

var go_delegateSetFileSize = syscall.NewCallbackCDecl(func(
fileSystem, fileContext uintptr,
newSize uint64, setAllocationSize uint8,
fileInfoAddr uintptr,
) uintptr {
return uintptr(delegateSetFileSize(
fileSystem, fileContext,
newSize, setAllocationSize,
fileInfoAddr,
))
})

var go_delegateCreateEx = syscall.NewCallbackCDecl(func(
fileSystem, fileName uintptr,
createOptions, grantedAccess, fileAttributes uint32,
securityDescriptor uintptr, allocationSize uint64,
extraBuffer uintptr, extraLength uint32, isReparse uint8,
file *uintptr, fileInfoAddr uintptr,
) uintptr {
return uintptr(delegateCreateEx(
fileSystem, fileName,
createOptions, grantedAccess, fileAttributes,
securityDescriptor, allocationSize,
extraBuffer, extraLength, isReparse,
file, fileInfoAddr,
))
})
1 change: 1 addition & 0 deletions fsctl_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ type FSP_FSCTL_OPEN_FILE_INFO struct {

type FSP_FSCTL_DIR_INFO struct {
Size uint16
_ [6]byte // FileInfo is 8-byte aligned in C, also on 386
FileInfo FSP_FSCTL_FILE_INFO
NextOffset uint64
Padding0 uint64
Expand Down
Loading
Loading