Skip to content

Commit

Permalink
Optimize bfGetMappings signature
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
  • Loading branch information
gabriel-samfira committed Feb 7, 2023
1 parent e1b82b1 commit 258cf20
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions pkg/bindfilter/bind_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
//go:generate go run github.com/Microsoft/go-winio/tools/mkwinsyscall -output zsyscall_windows.go ./bind_filter.go
//sys bfSetupFilter(jobHandle windows.Handle, flags uint32, virtRootPath string, virtTargetPath string, virtExceptions **uint16, virtExceptionPathCount uint32) (hr error) = bindfltapi.BfSetupFilter?
//sys bfRemoveMapping(jobHandle windows.Handle, virtRootPath string) (hr error) = bindfltapi.BfRemoveMapping?
//sys bfGetMappings(flags uint32, jobHandle windows.Handle, virtRootPath *uint16, sid *windows.SID, bufferSize *uint32, outBuffer uintptr) (hr error) = bindfltapi.BfGetMappings?
//sys bfGetMappings(flags uint32, jobHandle windows.Handle, virtRootPath *uint16, sid *windows.SID, bufferSize *uint32, outBuffer *byte) (hr error) = bindfltapi.BfGetMappings?

// BfSetupFilter flags. See:
// https://github.com/microsoft/BuildXL/blob/a6dce509f0d4f774255e5fbfb75fa6d5290ed163/Public/Src/Utilities/Native/Processes/Windows/NativeContainerUtilities.cs#L193-L240
Expand Down Expand Up @@ -122,7 +122,7 @@ func GetBindMappings(volumePath string) ([]BindMapping, error) {
var outBuffSize uint32 = 256 * 1024
buf := make([]byte, outBuffSize)

if err := bfGetMappings(flags, 0, rootPtr, nil, &outBuffSize, uintptr(unsafe.Pointer(&buf[0]))); err != nil {
if err := bfGetMappings(flags, 0, rootPtr, nil, &outBuffSize, &buf[0]); err != nil {
return nil, err
}

Expand Down Expand Up @@ -239,7 +239,9 @@ func getFinalPath(pth string) (string, error) {
if err != nil {
return "", fmt.Errorf("fetching file handle: %w", err)
}
defer syscall.CloseHandle(han)
defer func() {
_ = syscall.CloseHandle(han)
}()

buf := make([]uint16, 100)
var flags uint32 = 0x0
Expand Down
4 changes: 2 additions & 2 deletions pkg/bindfilter/zsyscall_windows.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 258cf20

Please sign in to comment.