mirror of
https://github.com/tailscale/tailscale.git
synced 2025-04-24 01:41:42 +00:00
28 lines
574 B
Go
28 lines
574 B
Go
![]() |
// Copyright (c) 2021 Tailscale Inc & AUTHORS All rights reserved.
|
||
|
// Use of this source code is governed by a BSD-style
|
||
|
// license that can be found in the LICENSE file.
|
||
|
|
||
|
//+build darwin
|
||
|
|
||
|
package filch
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"os"
|
||
|
"syscall"
|
||
|
|
||
|
"golang.org/x/sys/unix"
|
||
|
)
|
||
|
|
||
|
func openFileSync(path string, flag int, perm os.FileMode) (*os.File, error) {
|
||
|
f, err := os.OpenFile(path, flag, perm)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
_, err = unix.FcntlInt(uintptr(f.Fd()), syscall.F_NOCACHE, 1)
|
||
|
if err != nil {
|
||
|
return nil, fmt.Errorf("openFileSync: %w", err)
|
||
|
}
|
||
|
return f, nil
|
||
|
}
|