From 0162392a28b75ccb6c3b26c26f2a83b5973a2d92 Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Wed, 29 Nov 2017 12:54:34 +0100 Subject: fusefrontend: Use Fchmodat to implement Chmod --- internal/syscallcompat/sys_darwin.go | 17 +++++++++++++++++ internal/syscallcompat/sys_linux.go | 5 +++++ 2 files changed, 22 insertions(+) (limited to 'internal/syscallcompat') diff --git a/internal/syscallcompat/sys_darwin.go b/internal/syscallcompat/sys_darwin.go index 527598b..367f67d 100644 --- a/internal/syscallcompat/sys_darwin.go +++ b/internal/syscallcompat/sys_darwin.go @@ -137,6 +137,23 @@ func Dup3(oldfd int, newfd int, flags int) (err error) { return syscall.Dup2(oldfd, newfd) } +// Poor man's Fchmodat. +func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) { + chdirMutex.Lock() + defer chdirMutex.Unlock() + cwd, err := syscall.Open(".", syscall.O_RDONLY, 0) + if err != nil { + return err + } + defer syscall.Close(cwd) + err = syscall.Fchdir(dirfd) + if err != nil { + return err + } + defer syscall.Fchdir(cwd) + return syscall.Chmod(path, mode) +} + // Poor man's Fchownat. func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) { chdirMutex.Lock() diff --git a/internal/syscallcompat/sys_linux.go b/internal/syscallcompat/sys_linux.go index 0e9d6ac..4fe44fd 100644 --- a/internal/syscallcompat/sys_linux.go +++ b/internal/syscallcompat/sys_linux.go @@ -80,6 +80,11 @@ func Dup3(oldfd int, newfd int, flags int) (err error) { return syscall.Dup3(oldfd, newfd, flags) } +// Fchmodat syscall. +func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) { + return syscall.Fchmodat(dirfd, path, mode, flags) +} + // Fchownat syscall. func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) { return syscall.Fchownat(dirfd, path, uid, gid, flags) -- cgit v1.2.3