mirror of https://github.com/perkeep/perkeep.git
cammount: more FUSE work: basic GetAttr support
This commit is contained in:
parent
0707a092e0
commit
9771c314e3
|
@ -22,7 +22,9 @@ import (
|
||||||
"json"
|
"json"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
|
"syscall"
|
||||||
|
|
||||||
"camli/blobref"
|
"camli/blobref"
|
||||||
"camli/client"
|
"camli/client"
|
||||||
|
@ -173,14 +175,51 @@ func (fs *CamliFileSystem) Unmount() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fs *CamliFileSystem) GetAttr(name string) (*fuse.Attr, fuse.Status) {
|
func (fs *CamliFileSystem) GetAttr(name string) (*fuse.Attr, fuse.Status) {
|
||||||
|
log.Printf("cammount: GetAttr(%q)", name)
|
||||||
blobref, errStatus := fs.blobRefFromName(name)
|
blobref, errStatus := fs.blobRefFromName(name)
|
||||||
log.Printf("cammount: GetAttr(%q) (%s, %v)", name, blobref, errStatus)
|
log.Printf("cammount: GetAttr(%q), blobRefFromName err=%v", name, errStatus)
|
||||||
if errStatus != fuse.OK {
|
if errStatus != fuse.OK {
|
||||||
return nil, errStatus
|
return nil, errStatus
|
||||||
}
|
}
|
||||||
|
log.Printf("cammount: got blob %s", blobref)
|
||||||
|
|
||||||
|
// TODO: this is redundant with what blobRefFromName already
|
||||||
|
// did. we should at least keep this in RAM (pre-de-JSON'd)
|
||||||
|
// so we don't have to fetch + unmarshal it again.
|
||||||
|
ss, err := fs.fetchSchemaSuperset(blobref)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("cammount: GetAttr(%q, %s): fetch schema error: %v", name, blobref, err)
|
||||||
|
return nil, fuse.EIO
|
||||||
|
}
|
||||||
|
|
||||||
out := new(fuse.Attr)
|
out := new(fuse.Attr)
|
||||||
var fi os.FileInfo
|
var fi os.FileInfo
|
||||||
// TODO
|
|
||||||
|
if ss.UnixPermission != "" {
|
||||||
|
// Convert from octal
|
||||||
|
mode, err := strconv.Btoui64(ss.UnixPermission, 8)
|
||||||
|
if err != nil {
|
||||||
|
fi.Mode = uint32(mode)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: have a mode to set permissions equal to mounting user?
|
||||||
|
fi.Uid = ss.UnixOwnerId
|
||||||
|
fi.Gid = ss.UnixGroupId
|
||||||
|
|
||||||
|
// TODO: other types
|
||||||
|
switch ss.Type {
|
||||||
|
case "directory":
|
||||||
|
fi.Mode = fi.Mode | syscall.S_IFDIR
|
||||||
|
case "file":
|
||||||
|
fi.Mode = fi.Mode | syscall.S_IFREG
|
||||||
|
fi.Size = ss.Size
|
||||||
|
case "symlink":
|
||||||
|
fi.Mode = fi.Mode | syscall.S_IFLNK
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: mtime and such
|
||||||
|
|
||||||
fuse.CopyFileInfo(&fi, out)
|
fuse.CopyFileInfo(&fi, out)
|
||||||
return out, fuse.OK
|
return out, fuse.OK
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,6 +67,8 @@ type Superset struct {
|
||||||
UnixCtime string "unixCtime"
|
UnixCtime string "unixCtime"
|
||||||
UnixAtime string "unixAtime"
|
UnixAtime string "unixAtime"
|
||||||
|
|
||||||
|
Size int64 "size" // for files
|
||||||
|
|
||||||
Entries string "entries" // for directories, a blobref to a static-set
|
Entries string "entries" // for directories, a blobref to a static-set
|
||||||
Members []string "members" // for static sets (for directory static-sets:
|
Members []string "members" // for static sets (for directory static-sets:
|
||||||
// blobrefs to child dirs/files)
|
// blobrefs to child dirs/files)
|
||||||
|
|
Loading…
Reference in New Issue