本文整理匯總了Golang中github.com/hanwen/go-fuse/fuse.Attr類的典型用法代碼示例。如果您正苦於以下問題:Golang Attr類的具體用法?Golang Attr怎麽用?Golang Attr使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Attr類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: GetAttr
func (n *pathInode) GetAttr(out *fuse.Attr, file nodefs.File, context *fuse.Context) (code fuse.Status) {
var fi *fuse.Attr
if file == nil {
// called on a deleted files.
file = n.Inode().AnyFile()
}
if file != nil {
code = file.GetAttr(out)
}
if file == nil || code == fuse.ENOSYS || code == fuse.EBADF {
fi, code = n.fs.GetAttr(n.GetPath(), context)
}
if fi != nil {
n.setClientInode(fi.Ino)
}
if fi != nil && !fi.IsDir() && fi.Nlink == 0 {
fi.Nlink = 1
}
if fi != nil {
*out = *fi
}
return code
}
示例2: GetAttr
func (n *defaultNode) GetAttr(out *fuse.Attr, file File, context *fuse.Context) (code fuse.Status) {
if n.Inode().IsDir() {
out.Mode = fuse.S_IFDIR | 0755
} else {
out.Mode = fuse.S_IFREG | 0644
}
return fuse.OK
}
示例3: GetAttr
func (n *nodeReadNode) GetAttr(out *fuse.Attr, file File, context *fuse.Context) (code fuse.Status) {
if n.dir {
out.Mode = fuse.S_IFDIR | 0755
} else {
out.Mode = fuse.S_IFREG | 0644
}
out.Size = uint64(len(n.data))
return fuse.OK
}
示例4: GetAttr
func (f *AzukiFile) GetAttr(a *fuse.Attr) fuse.Status {
st := syscall.Stat_t{}
f.lock.Lock()
err := syscall.Fstat(int(f.File.Fd()), &st)
f.lock.Unlock()
if err != nil {
return fuse.ToStatus(err)
}
a.FromStat(&st)
return fuse.OK
}
示例5: GetAttr
func (f *p4File) GetAttr(out *fuse.Attr, file nodefs.File, c *fuse.Context) fuse.Status {
if m, ok := modes[f.stat.HeadType]; ok {
out.Mode = m
} else {
out.Mode = fuse.S_IFREG | 0644
}
out.Mtime = uint64(f.stat.HeadTime)
out.Size = uint64(f.stat.FileSize)
return fuse.OK
}
示例6: GetAttr
func (n *mtpNodeImpl) GetAttr(out *fuse.Attr, file nodefs.File, context *fuse.Context) (code fuse.Status) {
out.Mode = fuse.S_IFREG | 0644
f := n.obj
if f != nil {
out.Size = uint64(n.Size)
t := f.ModificationDate
out.SetTimes(&t, &t, &t)
}
return fuse.OK
}
示例7: GetAttr
func (sn *StrNode) GetAttr(
out *fuse.Attr,
file nodefs.File,
context *fuse.Context) (code fuse.Status) {
out.Mode = 0444 | syscall.S_IFREG
owner := getDefaultOwner()
out.Uid = owner.Uid
out.Gid = owner.Gid
out.Nlink = 1
out.Size = uint64(len(sn.s))
return fuse.OK
}
示例8: GetAttr
func (f *etcdFile) GetAttr(out *fuse.Attr) fuse.Status {
res, err := f.etcdClient.Get(f.path, false, false)
if err != nil {
log.Println("Error:", err)
return fuse.EIO
}
out.Mode = fuse.S_IFREG | 0666
out.Size = uint64(len(res.Node.Value))
return fuse.OK
}
示例9: GetAttr
func (fs *FSetAttrFs) GetAttr(name string, context *fuse.Context) (*fuse.Attr, fuse.Status) {
if name == "" {
return &fuse.Attr{Mode: fuse.S_IFDIR | 0700}, fuse.OK
}
if name == "file" && fs.file != nil {
var a fuse.Attr
fs.file.getAttr(&a)
a.Mode |= fuse.S_IFREG
return &a, fuse.OK
}
return nil, fuse.ENOENT
}
示例10: fileAttr
// fileAttr constructs a generic file fuse.Attr with the given parameters.
func (kwfs KeywhizFs) fileAttr(size uint64, mode uint32) *fuse.Attr {
created := uint64(kwfs.StartTime.Unix())
attr := fuse.Attr{
Size: size,
Atime: created,
Mtime: created,
Ctime: created,
Mode: fuse.S_IFREG | mode,
}
attr.Uid = kwfs.Ownership.Uid
attr.Gid = kwfs.Ownership.Gid
return &attr
}
示例11: GetAttr
func (m *MNode) GetAttr(out *fuse.Attr, file nodefs.File, context *fuse.Context) (code fuse.Status) {
/*if file!=nil {
return file.GetAttr(out)
}*/
reg,isReg := m.obj.Obj.(*joinf.JoinFile)
if isReg {
out.Mode = fuse.S_IFREG | 0666
out.Size = uint64(reg.F.FLength)
}else{
out.Mode = fuse.S_IFDIR | 0777
}
return fuse.OK
}
示例12: GetAttr
func (f *file) GetAttr(a *fuse.Attr) fuse.Status {
cryptfs.Debug.Printf("file.GetAttr()\n")
st := syscall.Stat_t{}
f.lock.Lock()
err := syscall.Fstat(int(f.fd.Fd()), &st)
f.lock.Unlock()
if err != nil {
return fuse.ToStatus(err)
}
a.FromStat(&st)
a.Size = f.cfs.PlainSize(a.Size)
return fuse.OK
}
示例13: GetAttr
// GetAttr - FUSE call
func (f *virtualFile) GetAttr(a *fuse.Attr) fuse.Status {
var st syscall.Stat_t
err := syscall.Lstat(f.parentFile, &st)
if err != nil {
fmt.Printf("Lstat %q: %v\n", f.parentFile, err)
return fuse.ToStatus(err)
}
st.Ino = f.ino
st.Size = int64(len(f.content))
st.Mode = syscall.S_IFREG | 0400
st.Nlink = 1
a.FromStat(&st)
return fuse.OK
}
示例14: GetAttr
func (me *DropboxFs) GetAttr(name string, context *fuse.Context) (*fuse.Attr, fuse.Status) {
path := get_path(name)
log.Printf("GetAttr: '%s'\n", name)
attr := fuse.Attr{}
// XXX: handle this error
data, _ := Cache.Metadata.Get(path)
if data.IsDir {
attr.Mode = fuse.S_IFDIR | 0755
} else {
attr.Mode = fuse.S_IFREG | 0644
attr.Size = uint64(len(path))
}
return &attr, fuse.OK
}
示例15: GetAttr
func (f *file) GetAttr(a *fuse.Attr) fuse.Status {
f.fdLock.RLock()
defer f.fdLock.RUnlock()
tlog.Debug.Printf("file.GetAttr()")
st := syscall.Stat_t{}
err := syscall.Fstat(int(f.fd.Fd()), &st)
if err != nil {
return fuse.ToStatus(err)
}
a.FromStat(&st)
a.Size = f.contentEnc.CipherSizeToPlainSize(a.Size)
return fuse.OK
}