mirror of
https://github.com/rwinkhart/go-winio.git
synced 2026-09-06 00:57:19 -04:00
Add support for LX symlinks (WSL/MSYS2 native symlinks)
- Add reparseTagLxSymlink constant (0xA000001D) - Implement decode logic for LX symlinks (UTF-8 format) - Add IsLxSymlink field to ReparsePoint struct to preserve symlink type - Implement encode logic to recreate LX symlinks on import - Add unit tests for LX symlink round-trip validation Fixes issue where Docker builds with MSYS2 failed with 'unsupported reparse point a000001d' error. Signed-off-by: Varun Gokulnath <vagokuln@microsoft.com> Signed-off-by: Varun Gokulnath <gvarun22@outlook.com>
This commit is contained in:
committed by
Varun Gokulnath
parent
3c9576c934
commit
94113a48c2
@@ -0,0 +1,60 @@
|
||||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
package winio
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestLxSymlinkRoundTrip(t *testing.T) {
|
||||
// Test LX symlink encode/decode
|
||||
original := &ReparsePoint{
|
||||
Target: "/usr/bin/bash",
|
||||
IsMountPoint: false,
|
||||
IsLxSymlink: true,
|
||||
}
|
||||
|
||||
// Encode
|
||||
encoded := EncodeReparsePoint(original)
|
||||
|
||||
// Decode
|
||||
decoded, err := DecodeReparsePoint(encoded)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to decode: %v", err)
|
||||
}
|
||||
|
||||
// Verify
|
||||
if decoded.Target != original.Target {
|
||||
t.Errorf("Target mismatch: got %q, want %q", decoded.Target, original.Target)
|
||||
}
|
||||
if decoded.IsLxSymlink != original.IsLxSymlink {
|
||||
t.Errorf("IsLxSymlink mismatch: got %v, want %v", decoded.IsLxSymlink, original.IsLxSymlink)
|
||||
}
|
||||
if decoded.IsMountPoint != original.IsMountPoint {
|
||||
t.Errorf("IsMountPoint mismatch: got %v, want %v", decoded.IsMountPoint, original.IsMountPoint)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWindowsSymlinkNotLx(t *testing.T) {
|
||||
// Test that regular Windows symlinks are not marked as LX
|
||||
original := &ReparsePoint{
|
||||
Target: `C:\Windows\System32`,
|
||||
IsMountPoint: false,
|
||||
IsLxSymlink: false,
|
||||
}
|
||||
|
||||
// Encode
|
||||
encoded := EncodeReparsePoint(original)
|
||||
|
||||
// Decode
|
||||
decoded, err := DecodeReparsePoint(encoded)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to decode: %v", err)
|
||||
}
|
||||
|
||||
// Verify it's NOT an LX symlink
|
||||
if decoded.IsLxSymlink {
|
||||
t.Errorf("Windows symlink incorrectly marked as LX symlink")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user