-
Notifications
You must be signed in to change notification settings - Fork 0
/
attr_freebsd.go
51 lines (42 loc) · 1.07 KB
/
attr_freebsd.go
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
// +build freebsd
package resonatefuse
import (
"context"
"log"
"os"
"syscall"
"time"
"bazil.org/fuse"
"github.com/pkg/errors"
)
// Attr returns some attributes about the file
func (f *File) Attr(ctx context.Context, a *fuse.Attr) error {
f.FFNode.fs.mu.Lock()
defer f.FFNode.fs.mu.Unlock()
log.Println("Attring", f.FFNode.Name())
info, err := os.Lstat(f.FFNode.fs.realify(f.FFNode.Path()))
if err != nil {
err = errors.Wrapf(err, "could not retrieve file (%v) info", f.FFNode.fs.realify(f.FFNode.Path()))
log.Println(err)
return fuse.ENOENT
}
stat, ok := info.Sys().(*syscall.Stat_t)
if !ok {
err = errors.New("file system not supported")
log.Println(err)
return fuse.ENOENT
}
a.Inode = stat.Ino
a.Nlink = uint32(stat.Nlink)
a.Uid = stat.Uid
a.Gid = stat.Gid
a.Rdev = uint32(stat.Rdev)
a.Mode = info.Mode()
a.Size = uint64(info.Size())
a.Atime = time.Unix(stat.Atimespec.Unix())
a.Mtime = time.Unix(stat.Mtimespec.Unix())
a.Ctime = time.Unix(stat.Ctimespec.Unix())
a.Blocks = uint64(stat.Blocks)
a.BlockSize = uint32(stat.Blksize)
return nil
}