mirror of
https://github.com/restic/restic.git
synced 2025-01-21 06:48:35 +00:00
2a5bbf170d
The implementations are 90% copy&paste from the go standard library as the existing code does not offer any way to read the symlink target based on a filehandle. Fall back to a standard readlink on platforms other than Linux and Windows as those either don't even provide the necessary syscall or in case of macOS are not yet available in Go.
24 lines
475 B
Go
24 lines
475 B
Go
//go:build linux || windows || darwin
|
|
// +build linux windows darwin
|
|
|
|
package fs
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
rtest "github.com/restic/restic/internal/test"
|
|
)
|
|
|
|
func TestFreadlink(t *testing.T) {
|
|
tmpdir := t.TempDir()
|
|
link := filepath.Join(tmpdir, "link")
|
|
rtest.OK(t, os.Symlink("other", link))
|
|
|
|
f, err := openMetadataHandle(link, O_NOFOLLOW)
|
|
rtest.OK(t, err)
|
|
target, err := Freadlink(f.Fd(), link)
|
|
rtest.OK(t, err)
|
|
rtest.Equals(t, "other", target)
|
|
}
|