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
|
// Copyright 2017 Keybase Inc. All rights reserved.
// Use of this source code is governed by a BSD
// license that can be found in the LICENSE file.
//go:build darwin
// +build darwin
package main
import (
"context"
"log"
"os"
"syscall"
"time"
"github.com/anacrolix/fuse"
)
func fillAttrWithFileInfo(a *fuse.Attr, fi os.FileInfo) {
s := fi.Sys().(*syscall.Stat_t)
a.Valid = attrValidDuration
a.Inode = s.Ino
a.Size = uint64(s.Size)
a.Blocks = uint64(s.Blocks)
a.Atime = time.Unix(s.Atimespec.Unix())
a.Mtime = time.Unix(s.Mtimespec.Unix())
a.Ctime = time.Unix(s.Ctimespec.Unix())
a.Crtime = time.Unix(s.Birthtimespec.Unix())
a.Mode = fi.Mode()
a.Nlink = uint32(s.Nlink)
a.Uid = s.Uid
a.Gid = s.Gid
a.Flags = s.Flags
a.BlockSize = uint32(s.Blksize)
}
func (n *Node) setattrPlatformSpecific(ctx context.Context,
req *fuse.SetattrRequest, resp *fuse.SetattrResponse) (err error) {
if req.Valid.Flags() {
log.Printf("Flags: %x", req.Flags)
if err = syscall.Chflags(n.realPath, int(req.Flags)); err != nil {
return err
}
}
return nil
}
|