2015-11-09 22:57:26 +03:00
|
|
|
// Copyright (c) Microsoft. All rights reserved.
|
|
|
|
// Licensed under the MIT license. See LICENSE file in the project root for details.
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bazil.org/fuse"
|
|
|
|
"os"
|
2015-11-10 03:02:41 +03:00
|
|
|
"time"
|
2015-11-09 22:57:26 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
// Attributes common to the file/directory HDFS nodes
|
|
|
|
type Attrs struct {
|
2015-11-10 03:02:41 +03:00
|
|
|
Inode uint64
|
|
|
|
Name string
|
|
|
|
Mode os.FileMode
|
|
|
|
Size uint64
|
|
|
|
Uid uint32
|
|
|
|
Gid uint32
|
2015-11-20 04:23:44 +03:00
|
|
|
Mtime time.Time
|
|
|
|
Ctime time.Time
|
|
|
|
Crtime time.Time
|
2015-11-10 03:02:41 +03:00
|
|
|
Expires time.Time // indicates when cached attribute information expires
|
2015-11-09 22:57:26 +03:00
|
|
|
}
|
|
|
|
|
2017-03-11 03:51:47 +03:00
|
|
|
// FsInfo provides information about HDFS
|
|
|
|
type FsInfo struct {
|
|
|
|
capacity uint64
|
|
|
|
used uint64
|
|
|
|
remaining uint64
|
|
|
|
}
|
|
|
|
|
2015-11-09 22:57:26 +03:00
|
|
|
// Converts Attrs datastructure into FUSE represnetation
|
|
|
|
func (this *Attrs) Attr(a *fuse.Attr) error {
|
|
|
|
a.Inode = this.Inode
|
|
|
|
a.Mode = this.Mode
|
|
|
|
if (a.Mode & os.ModeDir) == 0 {
|
|
|
|
a.Size = this.Size
|
|
|
|
}
|
2015-11-10 01:29:11 +03:00
|
|
|
a.Uid = this.Uid
|
|
|
|
a.Gid = this.Gid
|
2015-11-20 04:23:44 +03:00
|
|
|
a.Mtime = this.Mtime
|
|
|
|
a.Ctime = this.Ctime
|
|
|
|
a.Crtime = this.Crtime
|
2015-11-09 22:57:26 +03:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// returns fuse.DirentType for this attributes (DT_Dir or DT_File)
|
|
|
|
func (this *Attrs) FuseNodeType() fuse.DirentType {
|
|
|
|
if (this.Mode & os.ModeDir) == os.ModeDir {
|
|
|
|
return fuse.DT_Dir
|
|
|
|
} else {
|
|
|
|
return fuse.DT_File
|
|
|
|
}
|
|
|
|
}
|