Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go-fuse
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Levin Zimmermann
go-fuse
Commits
10a8a773
Commit
10a8a773
authored
May 01, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Put user-serviceable types in api.go, and document.
parent
490d393c
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
152 additions
and
135 deletions
+152
-135
fuse/Makefile
fuse/Makefile
+2
-1
fuse/api.go
fuse/api.go
+142
-0
fuse/pathfilesystem.go
fuse/pathfilesystem.go
+7
-2
fuse/pathops.go
fuse/pathops.go
+1
-1
fuse/types.go
fuse/types.go
+0
-131
No files found.
fuse/Makefile
View file @
10a8a773
...
...
@@ -3,7 +3,8 @@ include $(GOROOT)/src/Make.inc
TARG
=
github.com/hanwen/go-fuse/fuse
GOFILES
=
misc.go
\
GOFILES
=
api.go
\
misc.go
\
request.go
\
fuse.go
\
direntry.go
\
...
...
fuse/api.go
0 → 100644
View file @
10a8a773
package
fuse
// Types for users to implement.
// A filesystem API that uses paths rather than inodes. A minimal
// file system should have at least a functional GetAttr method.
// Typically, each call happens in its own goroutine, so take care to
// make the file system thread-safe.
//
// Include DefaultFileSystem to provide default null implementation of
// required methods.
type
FileSystem
interface
{
// Attributes
GetAttr
(
name
string
)
(
*
Attr
,
Status
)
Chmod
(
name
string
,
mode
uint32
)
(
code
Status
)
Chown
(
name
string
,
uid
uint32
,
gid
uint32
)
(
code
Status
)
Utimens
(
name
string
,
AtimeNs
uint64
,
CtimeNs
uint64
)
(
code
Status
)
Truncate
(
name
string
,
offset
uint64
)
(
code
Status
)
Access
(
name
string
,
mode
uint32
)
(
code
Status
)
// Tree structure
Link
(
oldName
string
,
newName
string
)
(
code
Status
)
Mkdir
(
name
string
,
mode
uint32
)
Status
Mknod
(
name
string
,
mode
uint32
,
dev
uint32
)
Status
Rename
(
oldName
string
,
newName
string
)
(
code
Status
)
Rmdir
(
name
string
)
(
code
Status
)
Unlink
(
name
string
)
(
code
Status
)
// Extended attributes.
GetXAttr
(
name
string
,
attribute
string
)
(
data
[]
byte
,
code
Status
)
ListXAttr
(
name
string
)
(
attributes
[]
string
,
code
Status
)
RemoveXAttr
(
name
string
,
attr
string
)
Status
SetXAttr
(
name
string
,
attr
string
,
data
[]
byte
,
flags
int
)
Status
// Called after mount.
Mount
(
connector
*
FileSystemConnector
)
Status
Unmount
()
// File handling
Open
(
name
string
,
flags
uint32
)
(
file
File
,
code
Status
)
Create
(
name
string
,
flags
uint32
,
mode
uint32
)
(
file
File
,
code
Status
)
// Directory handling
OpenDir
(
name
string
)
(
stream
chan
DirEntry
,
code
Status
)
// Symlinks.
Symlink
(
value
string
,
linkName
string
)
(
code
Status
)
Readlink
(
name
string
)
(
string
,
Status
)
}
// A File object should be returned from FileSystem.Open and
// FileSystem.Create. Include DefaultFile into the struct to inherit
// a default null implementation.
//
// TODO - should File be thread safe?
type
File
interface
{
Read
(
*
ReadIn
,
*
BufferPool
)
([]
byte
,
Status
)
Write
(
*
WriteIn
,
[]
byte
)
(
written
uint32
,
code
Status
)
Flush
()
Status
Release
()
Fsync
(
*
FsyncIn
)
(
code
Status
)
GetAttr
()
(
*
Attr
,
Status
)
Chown
(
uid
uint32
,
gid
uint32
)
Status
Chmod
(
perms
uint32
)
Status
Utimens
(
atimeNs
uint64
,
mtimeNs
uint64
)
Status
Truncate
(
size
uint64
)
Status
}
// MountOptions contains time out options for a FileSystem. The
// default copied from libfuse and set in NewMountOptions() is
// (1s,1s,0s).
type
MountOptions
struct
{
EntryTimeout
float64
AttrTimeout
float64
NegativeTimeout
float64
}
// DefaultFileSystem implements a FileSystem that returns ENOSYS for every operation.
type
DefaultFileSystem
struct
{}
// DefaultFile returns ENOSYS for every operation.
type
DefaultFile
struct
{}
// RawFileSystem is an interface closer to the FUSE wire protocol.
//
// Unless you really know what you are doing, you should not implement
// this, but rather the FileSystem interface; the details of getting
// interactions with open files, renames, and threading right etc. are
// somewhat tricky and not very interesting.
//
// Include DefaultRawFileSystem to inherit a null implementation.
type
RawFileSystem
interface
{
Destroy
(
h
*
InHeader
,
input
*
InitIn
)
Lookup
(
header
*
InHeader
,
name
string
)
(
out
*
EntryOut
,
status
Status
)
Forget
(
header
*
InHeader
,
input
*
ForgetIn
)
// Attributes.
GetAttr
(
header
*
InHeader
,
input
*
GetAttrIn
)
(
out
*
AttrOut
,
code
Status
)
SetAttr
(
header
*
InHeader
,
input
*
SetAttrIn
)
(
out
*
AttrOut
,
code
Status
)
// Modifying structure.
Mknod
(
header
*
InHeader
,
input
*
MknodIn
,
name
string
)
(
out
*
EntryOut
,
code
Status
)
Mkdir
(
header
*
InHeader
,
input
*
MkdirIn
,
name
string
)
(
out
*
EntryOut
,
code
Status
)
Unlink
(
header
*
InHeader
,
name
string
)
(
code
Status
)
Rmdir
(
header
*
InHeader
,
name
string
)
(
code
Status
)
Rename
(
header
*
InHeader
,
input
*
RenameIn
,
oldName
string
,
newName
string
)
(
code
Status
)
Link
(
header
*
InHeader
,
input
*
LinkIn
,
filename
string
)
(
out
*
EntryOut
,
code
Status
)
Symlink
(
header
*
InHeader
,
pointedTo
string
,
linkName
string
)
(
out
*
EntryOut
,
code
Status
)
Readlink
(
header
*
InHeader
)
(
out
[]
byte
,
code
Status
)
Access
(
header
*
InHeader
,
input
*
AccessIn
)
(
code
Status
)
// Extended attributes.
GetXAttr
(
header
*
InHeader
,
attr
string
)
(
data
[]
byte
,
code
Status
)
ListXAttr
(
header
*
InHeader
)
(
attributes
[]
byte
,
code
Status
)
SetXAttr
(
header
*
InHeader
,
input
*
SetXAttrIn
,
attr
string
,
data
[]
byte
)
Status
RemoveXAttr
(
header
*
InHeader
,
attr
string
)
(
code
Status
)
// File handling.
Create
(
header
*
InHeader
,
input
*
CreateIn
,
name
string
)
(
flags
uint32
,
handle
uint64
,
out
*
EntryOut
,
code
Status
)
Open
(
header
*
InHeader
,
input
*
OpenIn
)
(
flags
uint32
,
handle
uint64
,
status
Status
)
Read
(
*
ReadIn
,
*
BufferPool
)
([]
byte
,
Status
)
Release
(
header
*
InHeader
,
input
*
ReleaseIn
)
Write
(
*
WriteIn
,
[]
byte
)
(
written
uint32
,
code
Status
)
Flush
(
*
FlushIn
)
Status
Fsync
(
*
FsyncIn
)
(
code
Status
)
// Directory handling
OpenDir
(
header
*
InHeader
,
input
*
OpenIn
)
(
flags
uint32
,
handle
uint64
,
status
Status
)
ReadDir
(
header
*
InHeader
,
input
*
ReadIn
)
(
*
DirEntryList
,
Status
)
ReleaseDir
(
header
*
InHeader
,
input
*
ReleaseIn
)
FsyncDir
(
header
*
InHeader
,
input
*
FsyncIn
)
(
code
Status
)
}
// DefaultRawFileSystem returns ENOSYS for every operation.
type
DefaultRawFileSystem
struct
{}
fuse/pathfilesystem.go
View file @
10a8a773
...
...
@@ -249,9 +249,14 @@ func (me *FileSystemConnector) decodeFileHandle(h uint64) (interface{}, *mountDa
return
b
.
Iface
,
b
.
mountData
}
func
(
me
*
FileSystemConnector
)
getDir
(
h
uint64
)
(
RawDir
,
*
mountData
)
{
type
rawDir
interface
{
ReadDir
(
input
*
ReadIn
)
(
*
DirEntryList
,
Status
)
Release
()
}
func
(
me
*
FileSystemConnector
)
getDir
(
h
uint64
)
(
rawDir
,
*
mountData
)
{
f
,
m
:=
me
.
decodeFileHandle
(
h
)
return
f
.
(
R
awDir
),
m
return
f
.
(
r
awDir
),
m
}
func
(
me
*
FileSystemConnector
)
getFile
(
h
uint64
)
(
File
,
*
mountData
)
{
...
...
fuse/pathops.go
View file @
10a8a773
...
...
@@ -381,7 +381,7 @@ func (me *FileSystemConnector) Release(header *InHeader, input *ReleaseIn) {
func
(
me
*
FileSystemConnector
)
ReleaseDir
(
header
*
InHeader
,
input
*
ReleaseIn
)
{
node
:=
me
.
getInodeData
(
header
.
NodeId
)
d
:=
me
.
unregisterFile
(
node
,
input
.
Fh
)
.
(
R
awDir
)
d
:=
me
.
unregisterFile
(
node
,
input
.
Fh
)
.
(
r
awDir
)
d
.
Release
()
me
.
considerDropInode
(
node
)
}
...
...
fuse/types.go
View file @
10a8a773
...
...
@@ -454,134 +454,3 @@ type NotifyInvalEntryOut struct {
}
////////////////////////////////////////////////////////////////
// Types for users to implement.
// This is the interface to the file system, mirroring the interface from
//
// /usr/include/fuse/fuse_lowlevel.h
//
// Typically, each call happens in its own goroutine, so any global
// data should be made thread-safe. Unless you really know what you
// are doing, you should not implement this, but FileSystem below;
// the details of getting interactions with open files, renames, and
// threading right etc. are somewhat tricky and not very interesting.
type
RawFileSystem
interface
{
Destroy
(
h
*
InHeader
,
input
*
InitIn
)
Lookup
(
header
*
InHeader
,
name
string
)
(
out
*
EntryOut
,
status
Status
)
Forget
(
header
*
InHeader
,
input
*
ForgetIn
)
GetAttr
(
header
*
InHeader
,
input
*
GetAttrIn
)
(
out
*
AttrOut
,
code
Status
)
SetAttr
(
header
*
InHeader
,
input
*
SetAttrIn
)
(
out
*
AttrOut
,
code
Status
)
Readlink
(
header
*
InHeader
)
(
out
[]
byte
,
code
Status
)
Mknod
(
header
*
InHeader
,
input
*
MknodIn
,
name
string
)
(
out
*
EntryOut
,
code
Status
)
Mkdir
(
header
*
InHeader
,
input
*
MkdirIn
,
name
string
)
(
out
*
EntryOut
,
code
Status
)
Unlink
(
header
*
InHeader
,
name
string
)
(
code
Status
)
Rmdir
(
header
*
InHeader
,
name
string
)
(
code
Status
)
Symlink
(
header
*
InHeader
,
pointedTo
string
,
linkName
string
)
(
out
*
EntryOut
,
code
Status
)
Rename
(
header
*
InHeader
,
input
*
RenameIn
,
oldName
string
,
newName
string
)
(
code
Status
)
Link
(
header
*
InHeader
,
input
*
LinkIn
,
filename
string
)
(
out
*
EntryOut
,
code
Status
)
GetXAttr
(
header
*
InHeader
,
attr
string
)
(
data
[]
byte
,
code
Status
)
ListXAttr
(
header
*
InHeader
)
(
attributes
[]
byte
,
code
Status
)
SetXAttr
(
header
*
InHeader
,
input
*
SetXAttrIn
,
attr
string
,
data
[]
byte
)
Status
RemoveXAttr
(
header
*
InHeader
,
attr
string
)
(
code
Status
)
Access
(
header
*
InHeader
,
input
*
AccessIn
)
(
code
Status
)
Create
(
header
*
InHeader
,
input
*
CreateIn
,
name
string
)
(
flags
uint32
,
handle
uint64
,
out
*
EntryOut
,
code
Status
)
/*
// unimplemented.
Bmap(header *InHeader, input *BmapIn) (out *BmapOut, code Status)
Ioctl(header *InHeader, input *IoctlIn) (out *IoctlOut, code Status)
Poll(header *InHeader, input *PollIn) (out *PollOut, code Status)
*/
// File handling.
Open
(
header
*
InHeader
,
input
*
OpenIn
)
(
flags
uint32
,
handle
uint64
,
status
Status
)
Read
(
*
ReadIn
,
*
BufferPool
)
([]
byte
,
Status
)
Release
(
header
*
InHeader
,
input
*
ReleaseIn
)
Write
(
*
WriteIn
,
[]
byte
)
(
written
uint32
,
code
Status
)
Flush
(
*
FlushIn
)
Status
Fsync
(
*
FsyncIn
)
(
code
Status
)
// Directory handling
OpenDir
(
header
*
InHeader
,
input
*
OpenIn
)
(
flags
uint32
,
handle
uint64
,
status
Status
)
ReadDir
(
header
*
InHeader
,
input
*
ReadIn
)
(
*
DirEntryList
,
Status
)
ReleaseDir
(
header
*
InHeader
,
input
*
ReleaseIn
)
FsyncDir
(
header
*
InHeader
,
input
*
FsyncIn
)
(
code
Status
)
}
type
File
interface
{
Read
(
*
ReadIn
,
*
BufferPool
)
([]
byte
,
Status
)
// u32 <-> u64 ?
Write
(
*
WriteIn
,
[]
byte
)
(
written
uint32
,
code
Status
)
Flush
()
Status
Release
()
Fsync
(
*
FsyncIn
)
(
code
Status
)
GetAttr
()
(
*
Attr
,
Status
)
Chown
(
uid
uint32
,
gid
uint32
)
Status
Chmod
(
perms
uint32
)
Status
Utimens
(
atimeNs
uint64
,
mtimeNs
uint64
)
Status
Truncate
(
size
uint64
)
Status
}
type
RawDir
interface
{
ReadDir
(
input
*
ReadIn
)
(
*
DirEntryList
,
Status
)
Release
()
}
type
FileSystem
interface
{
GetAttr
(
name
string
)
(
*
Attr
,
Status
)
Readlink
(
name
string
)
(
string
,
Status
)
Mknod
(
name
string
,
mode
uint32
,
dev
uint32
)
Status
Mkdir
(
name
string
,
mode
uint32
)
Status
Unlink
(
name
string
)
(
code
Status
)
Rmdir
(
name
string
)
(
code
Status
)
Symlink
(
value
string
,
linkName
string
)
(
code
Status
)
Rename
(
oldName
string
,
newName
string
)
(
code
Status
)
Link
(
oldName
string
,
newName
string
)
(
code
Status
)
Chmod
(
name
string
,
mode
uint32
)
(
code
Status
)
Chown
(
name
string
,
uid
uint32
,
gid
uint32
)
(
code
Status
)
Truncate
(
name
string
,
offset
uint64
)
(
code
Status
)
Open
(
name
string
,
flags
uint32
)
(
file
File
,
code
Status
)
GetXAttr
(
name
string
,
attribute
string
)
(
data
[]
byte
,
code
Status
)
SetXAttr
(
name
string
,
attr
string
,
data
[]
byte
,
flags
int
)
Status
ListXAttr
(
name
string
)
(
attributes
[]
string
,
code
Status
)
RemoveXAttr
(
name
string
,
attr
string
)
Status
// Where to hook up statfs?
OpenDir
(
name
string
)
(
stream
chan
DirEntry
,
code
Status
)
// TODO - what is a good interface?
Mount
(
connector
*
FileSystemConnector
)
Status
Unmount
()
Access
(
name
string
,
mode
uint32
)
(
code
Status
)
Create
(
name
string
,
flags
uint32
,
mode
uint32
)
(
file
File
,
code
Status
)
Utimens
(
name
string
,
AtimeNs
uint64
,
CtimeNs
uint64
)
(
code
Status
)
// unimplemented: poll, ioctl, bmap.
}
// MountOptions contains time out options for a FileSystem. The
// default copied from libfuse and set in NewMountOptions() is
// (1s,1s,0s).
type
MountOptions
struct
{
EntryTimeout
float64
AttrTimeout
float64
NegativeTimeout
float64
}
// Include these structs in your implementation to inherit default nop
// implementations.
type
DefaultFileSystem
struct
{}
type
DefaultFile
struct
{}
type
DefaultRawFileSystem
struct
{}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment