mirror of
https://github.com/rwinkhart/sys.git
synced 2026-09-01 06:46:44 -04:00
unix/amd64: add Utimensat call, pass 0 for flags
This CL adds the Utimensat syscall and AT_SYMLINK_NOFOLLOW constant. This is required for setting the access/modification times on symlinks. In addition, it updates the UtimesNano function to pass 0 as the flags parameter, to avoid potentially passing junk. Change-Id: I280645f3f53173628b1e1986bc7a47bac254fcf8 Reviewed-on: https://go-review.googlesource.com/9379 Reviewed-by: Rob Pike <r@golang.org>
This commit is contained in:
@@ -67,13 +67,13 @@ func Utimes(path string, tv []Timeval) (err error) {
|
|||||||
return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
|
return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
|
||||||
}
|
}
|
||||||
|
|
||||||
//sys utimensat(dirfd int, path string, times *[2]Timespec) (err error)
|
//sys utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error)
|
||||||
|
|
||||||
func UtimesNano(path string, ts []Timespec) (err error) {
|
func UtimesNano(path string, ts []Timespec) (err error) {
|
||||||
if len(ts) != 2 {
|
if len(ts) != 2 {
|
||||||
return EINVAL
|
return EINVAL
|
||||||
}
|
}
|
||||||
err = utimensat(_AT_FDCWD, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])))
|
err = utimensat(AT_FDCWD, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0)
|
||||||
if err != ENOSYS {
|
if err != ENOSYS {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -87,6 +87,13 @@ func UtimesNano(path string, ts []Timespec) (err error) {
|
|||||||
return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
|
return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func UtimesNanoAt(dirfd int, path string, ts []Timespec, flags int) (err error) {
|
||||||
|
if len(ts) != 2 {
|
||||||
|
return EINVAL
|
||||||
|
}
|
||||||
|
return utimensat(dirfd, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), flags)
|
||||||
|
}
|
||||||
|
|
||||||
//sys futimesat(dirfd int, path *byte, times *[2]Timeval) (err error)
|
//sys futimesat(dirfd int, path *byte, times *[2]Timeval) (err error)
|
||||||
|
|
||||||
func Futimesat(dirfd int, path string, tv []Timeval) (err error) {
|
func Futimesat(dirfd int, path string, tv []Timeval) (err error) {
|
||||||
|
|||||||
+3
-1
@@ -385,7 +385,9 @@ type Ustat_t C.struct_ustat
|
|||||||
type EpollEvent C.struct_my_epoll_event
|
type EpollEvent C.struct_my_epoll_event
|
||||||
|
|
||||||
const (
|
const (
|
||||||
_AT_FDCWD = C.AT_FDCWD
|
AT_FDCWD = C.AT_FDCWD
|
||||||
|
AT_REMOVEDIR = C.AT_REMOVEDIR
|
||||||
|
AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW
|
||||||
)
|
)
|
||||||
|
|
||||||
// Terminal handling
|
// Terminal handling
|
||||||
|
|||||||
@@ -82,13 +82,13 @@ func utimes(path string, times *[2]Timeval) (err error) {
|
|||||||
|
|
||||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
func utimensat(dirfd int, path string, times *[2]Timespec) (err error) {
|
func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) {
|
||||||
var _p0 *byte
|
var _p0 *byte
|
||||||
_p0, err = BytePtrFromString(path)
|
_p0, err = BytePtrFromString(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
_, _, e1 := Syscall(SYS_UTIMENSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)))
|
_, _, e1 := Syscall6(SYS_UTIMENSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flags), 0, 0)
|
||||||
use(unsafe.Pointer(_p0))
|
use(unsafe.Pointer(_p0))
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
err = errnoErr(e1)
|
err = errnoErr(e1)
|
||||||
|
|||||||
@@ -82,13 +82,13 @@ func utimes(path string, times *[2]Timeval) (err error) {
|
|||||||
|
|
||||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
func utimensat(dirfd int, path string, times *[2]Timespec) (err error) {
|
func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) {
|
||||||
var _p0 *byte
|
var _p0 *byte
|
||||||
_p0, err = BytePtrFromString(path)
|
_p0, err = BytePtrFromString(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
_, _, e1 := Syscall(SYS_UTIMENSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)))
|
_, _, e1 := Syscall6(SYS_UTIMENSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flags), 0, 0)
|
||||||
use(unsafe.Pointer(_p0))
|
use(unsafe.Pointer(_p0))
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
err = errnoErr(e1)
|
err = errnoErr(e1)
|
||||||
|
|||||||
@@ -82,13 +82,13 @@ func utimes(path string, times *[2]Timeval) (err error) {
|
|||||||
|
|
||||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
func utimensat(dirfd int, path string, times *[2]Timespec) (err error) {
|
func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) {
|
||||||
var _p0 *byte
|
var _p0 *byte
|
||||||
_p0, err = BytePtrFromString(path)
|
_p0, err = BytePtrFromString(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
_, _, e1 := Syscall(SYS_UTIMENSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)))
|
_, _, e1 := Syscall6(SYS_UTIMENSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flags), 0, 0)
|
||||||
use(unsafe.Pointer(_p0))
|
use(unsafe.Pointer(_p0))
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
err = errnoErr(e1)
|
err = errnoErr(e1)
|
||||||
|
|||||||
@@ -572,7 +572,9 @@ type EpollEvent struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
_AT_FDCWD = -0x64
|
AT_FDCWD = -0x64
|
||||||
|
AT_SYMLINK_NOFOLLOW = 0x100
|
||||||
|
AT_REMOVEDIR = 0x200
|
||||||
)
|
)
|
||||||
|
|
||||||
type Termios struct {
|
type Termios struct {
|
||||||
|
|||||||
@@ -590,7 +590,9 @@ type EpollEvent struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
_AT_FDCWD = -0x64
|
AT_FDCWD = -0x64
|
||||||
|
AT_SYMLINK_NOFOLLOW = 0x100
|
||||||
|
AT_REMOVEDIR = 0x200
|
||||||
)
|
)
|
||||||
|
|
||||||
type Termios struct {
|
type Termios struct {
|
||||||
|
|||||||
@@ -561,7 +561,9 @@ type EpollEvent struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
_AT_FDCWD = -0x64
|
AT_FDCWD = -0x64
|
||||||
|
AT_SYMLINK_NOFOLLOW = 0x100
|
||||||
|
AT_REMOVEDIR = 0x200
|
||||||
)
|
)
|
||||||
|
|
||||||
type Termios struct {
|
type Termios struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user