github.com/icodeface/tls@v0.0.0-20230910023335-34df9250cd12/internal/syscall/unix/at_freebsd.go (about) 1 // Copyright 2018 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package unix 6 7 import ( 8 "syscall" 9 "unsafe" 10 ) 11 12 const ( 13 AT_REMOVEDIR = 0x800 14 AT_SYMLINK_NOFOLLOW = 0x200 15 ) 16 17 func Unlinkat(dirfd int, path string, flags int) error { 18 p, err := syscall.BytePtrFromString(path) 19 if err != nil { 20 return err 21 } 22 23 _, _, errno := syscall.Syscall(syscall.SYS_UNLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(p)), uintptr(flags)) 24 if errno != 0 { 25 return errno 26 } 27 28 return nil 29 } 30 31 func Openat(dirfd int, path string, flags int, perm uint32) (int, error) { 32 p, err := syscall.BytePtrFromString(path) 33 if err != nil { 34 return 0, err 35 } 36 37 fd, _, errno := syscall.Syscall6(syscall.SYS_OPENAT, uintptr(dirfd), uintptr(unsafe.Pointer(p)), uintptr(flags), uintptr(perm), 0, 0) 38 if errno != 0 { 39 return 0, errno 40 } 41 42 return int(fd), nil 43 } 44 45 func Fstatat(dirfd int, path string, stat *syscall.Stat_t, flags int) error { 46 return syscall.Fstatat(dirfd, path, stat, flags) 47 }