File: bridge_linux.go

package info (click to toggle)
golang-github-hanwen-go-fuse 2.8.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,584 kB
  • sloc: cpp: 78; sh: 47; makefile: 16
file content (60 lines) | stat: -rw-r--r-- 1,489 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package fs

import (
	"syscall"

	"github.com/hanwen/go-fuse/v2/fuse"
)

// see rawBridge.setAttr
func (b *rawBridge) setStatx(out *fuse.Statx) {
	if !b.options.NullPermissions && out.Mode&07777 == 0 {
		out.Mode |= 0644
		if out.Mode&syscall.S_IFDIR != 0 {
			out.Mode |= 0111
		}
	}
	if b.options.UID != 0 && out.Uid == 0 {
		out.Uid = b.options.UID
	}
	if b.options.GID != 0 && out.Gid == 0 {
		out.Gid = b.options.GID
	}
	setStatxBlocks(out)
}

// see rawBridge.setAttrTimeout
func (b *rawBridge) setStatxTimeout(out *fuse.StatxOut) {
	if b.options.AttrTimeout != nil && out.Timeout() == 0 {
		out.SetTimeout(*b.options.AttrTimeout)
	}
}

func (b *rawBridge) Statx(cancel <-chan struct{}, in *fuse.StatxIn, out *fuse.StatxOut) fuse.Status {
	n, fe := b.inode(in.NodeId, in.Fh)
	var fh FileHandle
	if fe != nil {
		fh = fe.file
	}

	ctx := &fuse.Context{Caller: in.Caller, Cancel: cancel}

	errno := syscall.ENOSYS
	if sx, ok := n.ops.(NodeStatxer); ok {
		errno = sx.Statx(ctx, fh, in.SxFlags, in.SxMask, out)
	} else if fsx, ok := n.ops.(FileStatxer); ok {
		errno = fsx.Statx(ctx, in.SxFlags, in.SxMask, out)
	}

	if errno == 0 {
		if out.Ino != 0 && n.stableAttr.Ino > 1 && out.Ino != n.stableAttr.Ino {
			b.logf("warning: rawBridge.getattr: overriding ino %d with %d", out.Ino, n.stableAttr.Ino)
		}
		out.Ino = n.stableAttr.Ino
		out.Mode = (out.Statx.Mode & 07777) | uint16(n.stableAttr.Mode)
		b.setStatx(&out.Statx)
		b.setStatxTimeout(out)
	}

	return errnoToStatus(errno)
}