Source file src/internal/syscall/unix/at_openbsd.go

     1  // Copyright 2024 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  //go:build openbsd && !mips64
     6  
     7  package unix
     8  
     9  import (
    10  	"internal/abi"
    11  	"syscall"
    12  	"unsafe"
    13  )
    14  
    15  //go:cgo_import_dynamic libc_readlinkat readlinkat "libc.so"
    16  
    17  func libc_readlinkat_trampoline()
    18  
    19  func Readlinkat(dirfd int, path string, buf []byte) (int, error) {
    20  	p0, err := syscall.BytePtrFromString(path)
    21  	if err != nil {
    22  		return 0, err
    23  	}
    24  	var p1 unsafe.Pointer
    25  	if len(buf) > 0 {
    26  		p1 = unsafe.Pointer(&buf[0])
    27  	} else {
    28  		p1 = unsafe.Pointer(&_zero)
    29  	}
    30  	n, _, errno := syscall_syscall6(abi.FuncPCABI0(libc_readlinkat_trampoline), uintptr(dirfd), uintptr(unsafe.Pointer(p0)), uintptr(p1), uintptr(len(buf)), 0, 0)
    31  	if errno != 0 {
    32  		return 0, errno
    33  	}
    34  	return int(n), nil
    35  }
    36  
    37  //go:cgo_import_dynamic libc_mkdirat mkdirat "libc.so"
    38  
    39  func libc_mkdirat_trampoline()
    40  
    41  func Mkdirat(dirfd int, path string, mode uint32) error {
    42  	p, err := syscall.BytePtrFromString(path)
    43  	if err != nil {
    44  		return err
    45  	}
    46  	_, _, errno := syscall_syscall6(abi.FuncPCABI0(libc_mkdirat_trampoline), uintptr(dirfd), uintptr(unsafe.Pointer(p)), 0, 0, 0, 0)
    47  	if errno != 0 {
    48  		return errno
    49  	}
    50  	return nil
    51  }
    52  

View as plain text