...

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

Documentation: internal/syscall/unix

     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  //go:build dragonfly || freebsd || linux || netbsd || (openbsd && mips64)
     6  
     7  package unix
     8  
     9  import (
    10  	"syscall"
    11  	"unsafe"
    12  )
    13  
    14  func Unlinkat(dirfd int, path string, flags int) error {
    15  	p, err := syscall.BytePtrFromString(path)
    16  	if err != nil {
    17  		return err
    18  	}
    19  
    20  	_, _, errno := syscall.Syscall(unlinkatTrap, uintptr(dirfd), uintptr(unsafe.Pointer(p)), uintptr(flags))
    21  	if errno != 0 {
    22  		return errno
    23  	}
    24  
    25  	return nil
    26  }
    27  
    28  func Openat(dirfd int, path string, flags int, perm uint32) (int, error) {
    29  	p, err := syscall.BytePtrFromString(path)
    30  	if err != nil {
    31  		return 0, err
    32  	}
    33  
    34  	fd, _, errno := syscall.Syscall6(openatTrap, uintptr(dirfd), uintptr(unsafe.Pointer(p)), uintptr(flags), uintptr(perm), 0, 0)
    35  	if errno != 0 {
    36  		return 0, errno
    37  	}
    38  
    39  	return int(fd), nil
    40  }
    41  

View as plain text