This repository has been archived by the owner on Jul 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
dat.go
139 lines (122 loc) · 4.32 KB
/
dat.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
package fuse
import (
"clive/x/bazil.org/fuse"
"os"
)
// An FS is the interface required of a file system.
//
// Other FUSE requests can be handled by implementing methods from the
// FS* interfaces, for example FSIniter.
// On normal FUSE filesystems, use Forget of the root Node to
// do actions at unmount time.
interface FS {
// Root is called to obtain the Node for the file system root.
Root() (Node, fuse.Error)
}
// A Node is the interface required of a file or directory.
// See the documentation for type FS for general information
// pertaining to all methods.
//
// Other FUSE requests can be handled by implementing methods from the
// Node* interfaces, for example NodeOpener.
interface Node {
Attr() (*fuse.Attr, fuse.Error)
Open(fuse.OpenFlags, Intr) (Handle, fuse.Error)
}
// NodeRef can be embedded in a Node to recognize the same Node being
// returned from multiple Lookup, Create etc calls.
//
// Without this, each Node will get a new NodeID, causing spurious
// cache invalidations, extra lookups and aliasing anomalies. This may
// not matter for a simple, read-only filesystem.
struct NodeRef {
id fuse.NodeID
generation uint64
}
interface NodeSetAttrer {
// Setattr sets the standard metadata for the receiver.
// EPERM otherwise
SetAttr(*fuse.SetattrRequest, Intr) fuse.Error
}
interface NodeXAttrer {
// get the named attribute
Xattr(name string) ([]byte, fuse.Error)
// set the named attribute (use nil val to remove)
Wxattr(name string, val []byte) fuse.Error
// list named attributes
Xattrs() []string
}
interface NodeRemover {
// Remove removes the entry with the given name from
// the receiver, which must be a directory. The entry to be removed
// may correspond to a file (unlink) or to a directory (rmdir).
Remove(elem string, i Intr) fuse.Error
}
interface NodeLookuper {
// Lookup looks up a specific entry in the receiver,
// which must be a directory. Lookup should return a Node
// corresponding to the entry. If the name does not exist in
// the directory, Lookup should return nil, err.
//
// Lookup need not to handle the names "." and "..".
Lookup(string, Intr) (Node, fuse.Error)
}
interface NodeMkdirer {
// Create dir name with the given mode
Mkdir(name string, mode os.FileMode, i Intr) (Node, fuse.Error)
}
interface NodeCreater {
// Create creates a new directory entry in the receiver, which
// must be a directory.
Create(name string, flag fuse.OpenFlags, mode os.FileMode, i Intr) (Node, Handle, fuse.Error)
}
interface NodePuter {
// Kernel says we can forget node and put it back to where it was.
PutNode()
}
interface NodeRenamer {
// Move to the directory node newDir (which is the type implementing Node)
// so
Rename(oldelem, newelem string, newDir Node, intr Intr) fuse.Error
}
// TODO this should be on Handle not Node
interface NodeFsyncer {
Fsync(intr Intr) fuse.Error
}
// A Handle is the interface required of an opened file or directory.
// See the documentation for type FS for general information
// pertaining to all methods.
//
// Other FUSE requests can be handled by implementing methods from the
// Node* interfaces. The most common to implement are
// HandleReader, HandleReadDirer, and HandleWriter.
//
// TODO implement methods: Getlk, Setlk, Setlkw
//
// NB: We do not use DirectIO as the open mode, because that would require
// aligned buffers or execve will fail.
// However, this might affect append. In a previous version, in some cases,
// append would work only with directIO.
interface Handle {
ReadDir(Intr) ([]fuse.Dirent, fuse.Error)
Read(off int64, sz int, i Intr) ([]byte, fuse.Error)
// Close is called each time the file or directory is closed.
// Because there can be multiple file descriptors referring to a
// single opened file, Close can be called multiple times.
Close(Intr) fuse.Error
}
interface HandleWriter {
Write([]byte, int64, Intr) (int, fuse.Error)
}
interface HandlePuter {
// Put back the handle to where it was and forget about it.
PutHandle()
}
// If a handle implements this, and the method returns true,
// FUSE relies on DirectIO for the file.
// That usually prevents exec() from working on the file but on the other hand
// does not let UNIX assume which one is the file size until the file has been read.
// File trees with control files should implement this and return true for ctl files.
interface HandleIsCtler {
IsCtl() bool
}