diff options
Diffstat (limited to 'internal/syscallcompat/sys_linux.go')
-rw-r--r-- | internal/syscallcompat/sys_linux.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/internal/syscallcompat/sys_linux.go b/internal/syscallcompat/sys_linux.go index e2b19bb..02064ac 100644 --- a/internal/syscallcompat/sys_linux.go +++ b/internal/syscallcompat/sys_linux.go @@ -2,6 +2,7 @@ package syscallcompat import ( + "context" "fmt" "io/ioutil" "runtime" @@ -88,6 +89,20 @@ func getSupplementaryGroups(pid uint32) (gids []int) { return nil } +// OpenatUserCtx is a tries to extract a fuse.Context from the generic ctx and +// calls OpenatUser. +func OpenatUserCtx(dirfd int, path string, flags int, mode uint32, ctx context.Context) (fd int, err error) { + var ctx2 *fuse.Context + if ctx != nil { + if caller, ok := fuse.FromContext(ctx); ok { + ctx2 = &fuse.Context{ + Caller: *caller, + } + } + } + return OpenatUser(dirfd, path, flags, mode, ctx2) +} + // OpenatUser runs the Openat syscall in the context of a different user. func OpenatUser(dirfd int, path string, flags int, mode uint32, context *fuse.Context) (fd int, err error) { if context != nil { |