summaryrefslogtreecommitdiff
path: root/internal/fusefrontend/node_helpers.go
blob: 1eb6d4a3c19e218e961017c86b96b8ebfcdf67c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
}