summaryrefslogtreecommitdiff
path: root/internal/fusefrontend
diff options
context:
space:
mode:
Diffstat (limited to 'internal/fusefrontend')
-rw-r--r--internal/fusefrontend/node.go10
-rw-r--r--internal/fusefrontend/node_helpers.go20
2 files changed, 26 insertions, 4 deletions
diff --git a/internal/fusefrontend/node.go b/internal/fusefrontend/node.go
index aa9bd51..5b42ddc 100644
--- a/internal/fusefrontend/node.go
+++ b/internal/fusefrontend/node.go
@@ -138,6 +138,7 @@ func (n *Node) Create(ctx context.Context, name string, flags uint32, mode uint3
}
newFlags := rn.mangleOpenFlags(flags)
// Handle long file name
+ ctx2 := toFuseCtx(ctx)
if !rn.args.PlaintextNames && nametransform.IsLongContent(cName) {
// Create ".name"
err = rn.nameTransform.WriteLongNameAt(dirfd, cName, name)
@@ -145,13 +146,13 @@ func (n *Node) Create(ctx context.Context, name string, flags uint32, mode uint3
return nil, nil, 0, fs.ToErrno(err)
}
// Create content
- fd, err = syscallcompat.OpenatUserCtx(dirfd, cName, newFlags|syscall.O_CREAT|syscall.O_EXCL, mode, ctx)
+ fd, err = syscallcompat.OpenatUser(dirfd, cName, newFlags|syscall.O_CREAT|syscall.O_EXCL, mode, ctx2)
if err != nil {
nametransform.DeleteLongNameAt(dirfd, cName)
}
} else {
// Create content, normal (short) file name
- fd, err = syscallcompat.OpenatUserCtx(dirfd, cName, newFlags|syscall.O_CREAT|syscall.O_EXCL, mode, ctx)
+ fd, err = syscallcompat.OpenatUser(dirfd, cName, newFlags|syscall.O_CREAT|syscall.O_EXCL, mode, ctx2)
}
if err != nil {
// xfstests generic/488 triggers this
@@ -322,6 +323,7 @@ func (n *Node) Mknod(ctx context.Context, name string, mode, rdev uint32, out *f
// Create ".name" file to store long file name (except in PlaintextNames mode)
var err error
+ ctx2 := toFuseCtx(ctx)
if !rn.args.PlaintextNames && nametransform.IsLongContent(cName) {
err := rn.nameTransform.WriteLongNameAt(dirfd, cName, name)
if err != nil {
@@ -329,13 +331,13 @@ func (n *Node) Mknod(ctx context.Context, name string, mode, rdev uint32, out *f
return
}
// Create "gocryptfs.longfile." device node
- err = syscallcompat.MknodatUserCtx(dirfd, cName, mode, int(rdev), ctx)
+ err = syscallcompat.MknodatUser(dirfd, cName, mode, int(rdev), ctx2)
if err != nil {
nametransform.DeleteLongNameAt(dirfd, cName)
}
} else {
// Create regular device node
- err = syscallcompat.MknodatUserCtx(dirfd, cName, mode, int(rdev), ctx)
+ err = syscallcompat.MknodatUser(dirfd, cName, mode, int(rdev), ctx2)
}
if err != nil {
errno = fs.ToErrno(err)
diff --git a/internal/fusefrontend/node_helpers.go b/internal/fusefrontend/node_helpers.go
new file mode 100644
index 0000000..1eb6d4a
--- /dev/null
+++ b/internal/fusefrontend/node_helpers.go
@@ -0,0 +1,20 @@
+package fusefrontend
+
+import (
+ "context"
+
+ "github.com/hanwen/go-fuse/v2/fuse"
+)
+
+// toFuseCtx tries to extract a fuse.Context from a generic context.Context.
+func toFuseCtx(ctx context.Context) (ctx2 *fuse.Context) {
+ if ctx == nil {
+ return nil
+ }
+ if caller, ok := fuse.FromContext(ctx); ok {
+ ctx2 = &fuse.Context{
+ Caller: *caller,
+ }
+ }
+ return ctx2
+}