forked from microsoft/hdfs-mount
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathAttrs.go
55 lines (49 loc) · 1.15 KB
/
Attrs.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
52
53
54
55
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for details.
package main
import (
"os"
"time"
"bazil.org/fuse"
)
// Attributes common to the file/directory HDFS nodes
type Attrs struct {
Inode uint64
Name string
Mode os.FileMode
Size uint64
Uid uint32
Gid uint32
Mtime time.Time
Ctime time.Time
Crtime time.Time
Expires time.Time // indicates when cached attribute information expires
}
// FsInfo provides information about HDFS
type FsInfo struct {
capacity uint64
used uint64
remaining uint64
}
// Converts Attrs datastructure into FUSE represnetation
func (attrs *Attrs) Attr(a *fuse.Attr) error {
a.Inode = attrs.Inode
a.Mode = attrs.Mode
if (a.Mode & os.ModeDir) == 0 {
a.Size = attrs.Size
}
a.Uid = attrs.Uid
a.Gid = attrs.Gid
a.Mtime = attrs.Mtime
a.Ctime = attrs.Ctime
a.Crtime = attrs.Crtime
return nil
}
// returns fuse.DirentType for this attributes (DT_Dir or DT_File)
func (attrs *Attrs) FuseNodeType() fuse.DirentType {
if (attrs.Mode & os.ModeDir) == os.ModeDir {
return fuse.DT_Dir
} else {
return fuse.DT_File
}
}