mirror of
https://github.com/jkl1337/duplicacy.git
synced 2026-01-04 04:34:45 -06:00
Fix Linux, Darwin, and other BSD (untested) to allow proper handling of xattrs with symlinks. On Linux we cannot use the f* syscalls for symlinks because symlinks cannot be opened. File flags must be handled differently on darwin and other BSD due to the lack of the LCHFLAGS syscall on darwin, and the fact that it is emulated in libc. However, we do have O_SYMLINK on darwin.
31 lines
732 B
Go
31 lines
732 B
Go
// Copyright (c) Acrosync LLC. All rights reserved.
|
|
// Free for personal use and commercial trial
|
|
// Commercial use requires per-user licenses available from https://duplicacy.com
|
|
|
|
//go:build freebsd || netbsd
|
|
// +build freebsd netbsd
|
|
|
|
package duplicacy
|
|
|
|
import (
|
|
"bytes"
|
|
"encoding/binary"
|
|
"os"
|
|
"path/filepath"
|
|
"syscall"
|
|
|
|
"github.com/pkg/xattr"
|
|
)
|
|
|
|
func (entry *Entry) restoreLateFileFlags(path string) error {
|
|
if entry.Attributes == nil {
|
|
return nil
|
|
}
|
|
if v, have := (*entry.Attributes)[bsdFileFlagsKey]; have {
|
|
if _, _, errno := syscall.Syscall(syscall.SYS_LCHFLAGS, uintptr(unsafe.Pointer(syscall.StringBytePtr(path))), uintptr(v), 0); errno != 0 {
|
|
return os.NewSyscallError("lchflags", errno)
|
|
}
|
|
}
|
|
return nil
|
|
}
|