1
0
Fork 0
mirror of https://github.com/restic/restic.git synced 2025-01-21 06:48:35 +00:00
restic/internal/fs/meta_linux.go

26 lines
442 B
Go
Raw Normal View History

2024-11-03 15:38:34 +00:00
package fs
import (
"os"
"golang.org/x/sys/unix"
)
func openMetadataHandle(path string, flag int) (*os.File, error) {
// O_PATH|O_NOFOLLOW is necessary to also be able to get a handle to symlinks
flags := unix.O_PATH
if flag&O_NOFOLLOW != 0 {
flags |= O_NOFOLLOW
}
if flag&O_DIRECTORY != 0 {
flags |= O_DIRECTORY
}
f, err := os.OpenFile(path, flags, 0)
if err != nil {
return nil, err
}
_ = setFlags(f)
return f, nil
}