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
Kirill Smelkov
go-fuse
Commits
18e0e322
Commit
18e0e322
authored
Mar 15, 2019
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nodefs: more method documentation
parent
2f9c4b1d
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
74 additions
and
66 deletions
+74
-66
nodefs/README.md
nodefs/README.md
+1
-0
nodefs/api.go
nodefs/api.go
+2
-3
nodefs/default.go
nodefs/default.go
+65
-58
nodefs/dirstream_linux.go
nodefs/dirstream_linux.go
+1
-0
nodefs/files.go
nodefs/files.go
+3
-2
nodefs/loopback.go
nodefs/loopback.go
+2
-3
No files found.
nodefs/README.md
View file @
18e0e322
...
@@ -85,3 +85,4 @@ or
...
@@ -85,3 +85,4 @@ or
*
Merge Fsync/FsyncDir?
*
Merge Fsync/FsyncDir?
*
OnMount in Operations or in Options? Or argument to NewNodeFS ?
nodefs/api.go
View file @
18e0e322
...
@@ -67,8 +67,8 @@ func InodeOf(node Operations) *Inode {
...
@@ -67,8 +67,8 @@ func InodeOf(node Operations) *Inode {
return
node
.
inode
()
return
node
.
inode
()
}
}
// Operations is the interface that implements the filesystem
. Each
// Operations is the interface that implements the filesystem
inode.
// Operations instance must embed DefaultNode.
//
Each
Operations instance must embed DefaultNode.
type
Operations
interface
{
type
Operations
interface
{
// setInode and inode are used by nodefs internally to link Inode to a Node.
// setInode and inode are used by nodefs internally to link Inode to a Node.
//
//
...
@@ -293,7 +293,6 @@ type FileHandle interface {
...
@@ -293,7 +293,6 @@ type FileHandle interface {
// Options sets options for the entire filesystem
// Options sets options for the entire filesystem
type
Options
struct
{
type
Options
struct
{
// Debug toggles debug output
// Debug toggles debug output
Debug
bool
Debug
bool
...
...
nodefs/default.go
View file @
18e0e322
...
@@ -13,9 +13,10 @@ import (
...
@@ -13,9 +13,10 @@ import (
"github.com/hanwen/go-fuse/fuse"
"github.com/hanwen/go-fuse/fuse"
)
)
// DefaultOperations provides stubs that return ENOSYS for all functions
// DefaultOperations provides stubs that return ENOENT for almost all
// functions.
//
//
// It must be embedded in any
Node
implementation.
// It must be embedded in any
Operations
implementation.
type
DefaultOperations
struct
{
type
DefaultOperations
struct
{
inode_
*
Inode
inode_
*
Inode
}
}
...
@@ -51,6 +52,8 @@ func (n *DefaultOperations) inode() *Inode {
...
@@ -51,6 +52,8 @@ func (n *DefaultOperations) inode() *Inode {
(
*
unsafe
.
Pointer
)(
unsafe
.
Pointer
(
&
n
.
inode_
))))
(
*
unsafe
.
Pointer
)(
unsafe
.
Pointer
(
&
n
.
inode_
))))
}
}
// StatFs zeroes the out argument and returns OK. This is because OSX
// filesystems must define this, or the mount will not work.
func
(
n
*
DefaultOperations
)
StatFs
(
ctx
context
.
Context
,
out
*
fuse
.
StatfsOut
)
fuse
.
Status
{
func
(
n
*
DefaultOperations
)
StatFs
(
ctx
context
.
Context
,
out
*
fuse
.
StatfsOut
)
fuse
.
Status
{
// this should be defined on OSX, or the FS won't mount
// this should be defined on OSX, or the FS won't mount
*
out
=
fuse
.
StatfsOut
{}
*
out
=
fuse
.
StatfsOut
{}
...
@@ -58,78 +61,78 @@ func (n *DefaultOperations) StatFs(ctx context.Context, out *fuse.StatfsOut) fus
...
@@ -58,78 +61,78 @@ func (n *DefaultOperations) StatFs(ctx context.Context, out *fuse.StatfsOut) fus
}
}
func
(
n
*
DefaultOperations
)
GetAttr
(
ctx
context
.
Context
,
out
*
fuse
.
AttrOut
)
fuse
.
Status
{
func
(
n
*
DefaultOperations
)
GetAttr
(
ctx
context
.
Context
,
out
*
fuse
.
AttrOut
)
fuse
.
Status
{
return
fuse
.
ENO
SYS
return
fuse
.
ENO
ENT
}
}
func
(
n
*
DefaultOperations
)
SetAttr
(
ctx
context
.
Context
,
in
*
fuse
.
SetAttrIn
,
out
*
fuse
.
AttrOut
)
fuse
.
Status
{
func
(
n
*
DefaultOperations
)
SetAttr
(
ctx
context
.
Context
,
in
*
fuse
.
SetAttrIn
,
out
*
fuse
.
AttrOut
)
fuse
.
Status
{
return
fuse
.
ENO
SYS
return
fuse
.
ENO
ENT
}
}
func
(
n
*
DefaultOperations
)
Access
(
ctx
context
.
Context
,
mask
uint32
)
fuse
.
Status
{
func
(
n
*
DefaultOperations
)
Access
(
ctx
context
.
Context
,
mask
uint32
)
fuse
.
Status
{
return
fuse
.
ENO
SYS
return
fuse
.
ENO
ENT
}
}
//
****************************************************************
//
FSetAttr delegates to the FileHandle's if f is not nil, or else to the
// Inode's SetAttr method.
func
(
n
*
DefaultOperations
)
FSetAttr
(
ctx
context
.
Context
,
f
FileHandle
,
in
*
fuse
.
SetAttrIn
,
out
*
fuse
.
AttrOut
)
fuse
.
Status
{
func
(
n
*
DefaultOperations
)
FSetAttr
(
ctx
context
.
Context
,
f
FileHandle
,
in
*
fuse
.
SetAttrIn
,
out
*
fuse
.
AttrOut
)
fuse
.
Status
{
if
f
!=
nil
{
if
f
!=
nil
{
return
f
.
SetAttr
(
ctx
,
in
,
out
)
return
f
.
SetAttr
(
ctx
,
in
,
out
)
}
}
return
fuse
.
ENOSYS
return
n
.
inode_
.
Operations
()
.
SetAttr
(
ctx
,
in
,
out
)
}
}
func
(
n
*
DefaultOperations
)
Lookup
(
ctx
context
.
Context
,
name
string
,
out
*
fuse
.
EntryOut
)
(
*
Inode
,
fuse
.
Status
)
{
func
(
n
*
DefaultOperations
)
Lookup
(
ctx
context
.
Context
,
name
string
,
out
*
fuse
.
EntryOut
)
(
*
Inode
,
fuse
.
Status
)
{
return
nil
,
fuse
.
ENO
SYS
return
nil
,
fuse
.
ENO
ENT
}
}
func
(
n
*
DefaultOperations
)
Mkdir
(
ctx
context
.
Context
,
name
string
,
mode
uint32
,
out
*
fuse
.
EntryOut
)
(
*
Inode
,
fuse
.
Status
)
{
func
(
n
*
DefaultOperations
)
Mkdir
(
ctx
context
.
Context
,
name
string
,
mode
uint32
,
out
*
fuse
.
EntryOut
)
(
*
Inode
,
fuse
.
Status
)
{
return
nil
,
fuse
.
ENO
SYS
return
nil
,
fuse
.
ENO
ENT
}
}
func
(
n
*
DefaultOperations
)
Mknod
(
ctx
context
.
Context
,
name
string
,
mode
uint32
,
dev
uint32
,
out
*
fuse
.
EntryOut
)
(
*
Inode
,
fuse
.
Status
)
{
func
(
n
*
DefaultOperations
)
Mknod
(
ctx
context
.
Context
,
name
string
,
mode
uint32
,
dev
uint32
,
out
*
fuse
.
EntryOut
)
(
*
Inode
,
fuse
.
Status
)
{
return
nil
,
fuse
.
ENO
SYS
return
nil
,
fuse
.
ENO
ENT
}
}
func
(
n
*
DefaultOperations
)
Rmdir
(
ctx
context
.
Context
,
name
string
)
fuse
.
Status
{
func
(
n
*
DefaultOperations
)
Rmdir
(
ctx
context
.
Context
,
name
string
)
fuse
.
Status
{
return
fuse
.
ENO
SYS
return
fuse
.
ENO
ENT
}
}
func
(
n
*
DefaultOperations
)
Unlink
(
ctx
context
.
Context
,
name
string
)
fuse
.
Status
{
func
(
n
*
DefaultOperations
)
Unlink
(
ctx
context
.
Context
,
name
string
)
fuse
.
Status
{
return
fuse
.
ENO
SYS
return
fuse
.
ENO
ENT
}
}
func
(
n
*
DefaultOperations
)
OpenDir
(
ctx
context
.
Context
)
fuse
.
Status
{
func
(
n
*
DefaultOperations
)
OpenDir
(
ctx
context
.
Context
)
fuse
.
Status
{
return
fuse
.
ENO
SYS
return
fuse
.
ENO
ENT
}
}
func
(
n
*
DefaultOperations
)
ReadDir
(
ctx
context
.
Context
)
(
DirStream
,
fuse
.
Status
)
{
func
(
n
*
DefaultOperations
)
ReadDir
(
ctx
context
.
Context
)
(
DirStream
,
fuse
.
Status
)
{
return
nil
,
fuse
.
ENO
SYS
return
nil
,
fuse
.
ENO
ENT
}
}
func
(
n
*
DefaultOperations
)
Rename
(
ctx
context
.
Context
,
name
string
,
newParent
Operations
,
newName
string
,
flags
uint32
)
fuse
.
Status
{
func
(
n
*
DefaultOperations
)
Rename
(
ctx
context
.
Context
,
name
string
,
newParent
Operations
,
newName
string
,
flags
uint32
)
fuse
.
Status
{
return
fuse
.
ENO
SYS
return
fuse
.
ENO
ENT
}
}
func
(
n
*
DefaultOperations
)
Read
(
ctx
context
.
Context
,
f
FileHandle
,
dest
[]
byte
,
off
int64
)
(
fuse
.
ReadResult
,
fuse
.
Status
)
{
func
(
n
*
DefaultOperations
)
Read
(
ctx
context
.
Context
,
f
FileHandle
,
dest
[]
byte
,
off
int64
)
(
fuse
.
ReadResult
,
fuse
.
Status
)
{
if
f
!=
nil
{
if
f
!=
nil
{
return
f
.
Read
(
ctx
,
dest
,
off
)
return
f
.
Read
(
ctx
,
dest
,
off
)
}
}
return
nil
,
fuse
.
ENO
SYS
return
nil
,
fuse
.
ENO
ENT
}
}
func
(
n
*
DefaultOperations
)
Symlink
(
ctx
context
.
Context
,
target
,
name
string
,
out
*
fuse
.
EntryOut
)
(
node
*
Inode
,
status
fuse
.
Status
)
{
func
(
n
*
DefaultOperations
)
Symlink
(
ctx
context
.
Context
,
target
,
name
string
,
out
*
fuse
.
EntryOut
)
(
node
*
Inode
,
status
fuse
.
Status
)
{
log
.
Println
(
"defsyml"
)
log
.
Println
(
"defsyml"
)
return
nil
,
fuse
.
ENO
SYS
return
nil
,
fuse
.
ENO
ENT
}
}
func
(
n
*
DefaultOperations
)
Readlink
(
ctx
context
.
Context
)
(
string
,
fuse
.
Status
)
{
func
(
n
*
DefaultOperations
)
Readlink
(
ctx
context
.
Context
)
(
string
,
fuse
.
Status
)
{
return
""
,
fuse
.
ENO
SYS
return
""
,
fuse
.
ENO
ENT
}
}
func
(
n
*
DefaultOperations
)
Fsync
(
ctx
context
.
Context
,
f
FileHandle
,
flags
uint32
)
fuse
.
Status
{
func
(
n
*
DefaultOperations
)
Fsync
(
ctx
context
.
Context
,
f
FileHandle
,
flags
uint32
)
fuse
.
Status
{
if
f
!=
nil
{
if
f
!=
nil
{
return
f
.
Fsync
(
ctx
,
flags
)
return
f
.
Fsync
(
ctx
,
flags
)
}
}
return
fuse
.
ENO
SYS
return
fuse
.
ENO
ENT
}
}
func
(
n
*
DefaultOperations
)
Write
(
ctx
context
.
Context
,
f
FileHandle
,
data
[]
byte
,
off
int64
)
(
written
uint32
,
status
fuse
.
Status
)
{
func
(
n
*
DefaultOperations
)
Write
(
ctx
context
.
Context
,
f
FileHandle
,
data
[]
byte
,
off
int64
)
(
written
uint32
,
status
fuse
.
Status
)
{
...
@@ -137,7 +140,7 @@ func (n *DefaultOperations) Write(ctx context.Context, f FileHandle, data []byte
...
@@ -137,7 +140,7 @@ func (n *DefaultOperations) Write(ctx context.Context, f FileHandle, data []byte
return
f
.
Write
(
ctx
,
data
,
off
)
return
f
.
Write
(
ctx
,
data
,
off
)
}
}
return
0
,
fuse
.
ENO
SYS
return
0
,
fuse
.
ENO
ENT
}
}
func
(
n
*
DefaultOperations
)
GetLk
(
ctx
context
.
Context
,
f
FileHandle
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
,
out
*
fuse
.
FileLock
)
(
status
fuse
.
Status
)
{
func
(
n
*
DefaultOperations
)
GetLk
(
ctx
context
.
Context
,
f
FileHandle
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
,
out
*
fuse
.
FileLock
)
(
status
fuse
.
Status
)
{
...
@@ -145,7 +148,7 @@ func (n *DefaultOperations) GetLk(ctx context.Context, f FileHandle, owner uint6
...
@@ -145,7 +148,7 @@ func (n *DefaultOperations) GetLk(ctx context.Context, f FileHandle, owner uint6
return
f
.
GetLk
(
ctx
,
owner
,
lk
,
flags
,
out
)
return
f
.
GetLk
(
ctx
,
owner
,
lk
,
flags
,
out
)
}
}
return
fuse
.
ENO
SYS
return
fuse
.
ENO
ENT
}
}
func
(
n
*
DefaultOperations
)
SetLk
(
ctx
context
.
Context
,
f
FileHandle
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
(
status
fuse
.
Status
)
{
func
(
n
*
DefaultOperations
)
SetLk
(
ctx
context
.
Context
,
f
FileHandle
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
(
status
fuse
.
Status
)
{
...
@@ -153,7 +156,7 @@ func (n *DefaultOperations) SetLk(ctx context.Context, f FileHandle, owner uint6
...
@@ -153,7 +156,7 @@ func (n *DefaultOperations) SetLk(ctx context.Context, f FileHandle, owner uint6
return
f
.
SetLk
(
ctx
,
owner
,
lk
,
flags
)
return
f
.
SetLk
(
ctx
,
owner
,
lk
,
flags
)
}
}
return
fuse
.
ENO
SYS
return
fuse
.
ENO
ENT
}
}
func
(
n
*
DefaultOperations
)
SetLkw
(
ctx
context
.
Context
,
f
FileHandle
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
(
status
fuse
.
Status
)
{
func
(
n
*
DefaultOperations
)
SetLkw
(
ctx
context
.
Context
,
f
FileHandle
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
(
status
fuse
.
Status
)
{
...
@@ -161,21 +164,21 @@ func (n *DefaultOperations) SetLkw(ctx context.Context, f FileHandle, owner uint
...
@@ -161,21 +164,21 @@ func (n *DefaultOperations) SetLkw(ctx context.Context, f FileHandle, owner uint
return
f
.
SetLkw
(
ctx
,
owner
,
lk
,
flags
)
return
f
.
SetLkw
(
ctx
,
owner
,
lk
,
flags
)
}
}
return
fuse
.
ENO
SYS
return
fuse
.
ENO
ENT
}
}
func
(
n
*
DefaultOperations
)
Flush
(
ctx
context
.
Context
,
f
FileHandle
)
fuse
.
Status
{
func
(
n
*
DefaultOperations
)
Flush
(
ctx
context
.
Context
,
f
FileHandle
)
fuse
.
Status
{
if
f
!=
nil
{
if
f
!=
nil
{
return
f
.
Flush
(
ctx
)
return
f
.
Flush
(
ctx
)
}
}
return
fuse
.
ENO
SYS
return
fuse
.
ENO
ENT
}
}
func
(
n
*
DefaultOperations
)
Release
(
ctx
context
.
Context
,
f
FileHandle
)
fuse
.
Status
{
func
(
n
*
DefaultOperations
)
Release
(
ctx
context
.
Context
,
f
FileHandle
)
fuse
.
Status
{
if
f
!=
nil
{
if
f
!=
nil
{
return
f
.
Release
(
ctx
)
return
f
.
Release
(
ctx
)
}
}
return
fuse
.
ENO
SYS
return
fuse
.
ENO
ENT
}
}
func
(
n
*
DefaultOperations
)
Allocate
(
ctx
context
.
Context
,
f
FileHandle
,
off
uint64
,
size
uint64
,
mode
uint32
)
(
status
fuse
.
Status
)
{
func
(
n
*
DefaultOperations
)
Allocate
(
ctx
context
.
Context
,
f
FileHandle
,
off
uint64
,
size
uint64
,
mode
uint32
)
(
status
fuse
.
Status
)
{
...
@@ -183,88 +186,92 @@ func (n *DefaultOperations) Allocate(ctx context.Context, f FileHandle, off uint
...
@@ -183,88 +186,92 @@ func (n *DefaultOperations) Allocate(ctx context.Context, f FileHandle, off uint
return
f
.
Allocate
(
ctx
,
off
,
size
,
mode
)
return
f
.
Allocate
(
ctx
,
off
,
size
,
mode
)
}
}
return
fuse
.
ENO
SYS
return
fuse
.
ENO
ENT
}
}
// FGetAttr delegates to the FileHandle's if f is not nil, or else to the
// Inode's GetAttr method.
func
(
n
*
DefaultOperations
)
FGetAttr
(
ctx
context
.
Context
,
f
FileHandle
,
out
*
fuse
.
AttrOut
)
fuse
.
Status
{
func
(
n
*
DefaultOperations
)
FGetAttr
(
ctx
context
.
Context
,
f
FileHandle
,
out
*
fuse
.
AttrOut
)
fuse
.
Status
{
if
f
!=
nil
{
if
f
!=
nil
{
f
.
GetAttr
(
ctx
,
out
)
f
.
GetAttr
(
ctx
,
out
)
}
}
return
fuse
.
ENOSYS
return
n
.
inode_
.
ops
.
GetAttr
(
ctx
,
out
)
}
}
func
(
n
*
DefaultOperations
)
Open
(
ctx
context
.
Context
,
flags
uint32
)
(
fh
FileHandle
,
fuseFlags
uint32
,
status
fuse
.
Status
)
{
func
(
n
*
DefaultOperations
)
Open
(
ctx
context
.
Context
,
flags
uint32
)
(
fh
FileHandle
,
fuseFlags
uint32
,
status
fuse
.
Status
)
{
return
nil
,
0
,
fuse
.
ENO
SYS
return
nil
,
0
,
fuse
.
ENO
ENT
}
}
func
(
n
*
DefaultOperations
)
Create
(
ctx
context
.
Context
,
name
string
,
flags
uint32
,
mode
uint32
)
(
node
*
Inode
,
fh
FileHandle
,
fuseFlags
uint32
,
status
fuse
.
Status
)
{
func
(
n
*
DefaultOperations
)
Create
(
ctx
context
.
Context
,
name
string
,
flags
uint32
,
mode
uint32
)
(
node
*
Inode
,
fh
FileHandle
,
fuseFlags
uint32
,
status
fuse
.
Status
)
{
return
nil
,
nil
,
0
,
fuse
.
ENO
SYS
return
nil
,
nil
,
0
,
fuse
.
ENO
ENT
}
}
func
(
n
*
DefaultOperations
)
Link
(
ctx
context
.
Context
,
target
Operations
,
name
string
,
out
*
fuse
.
EntryOut
)
(
node
*
Inode
,
status
fuse
.
Status
)
{
func
(
n
*
DefaultOperations
)
Link
(
ctx
context
.
Context
,
target
Operations
,
name
string
,
out
*
fuse
.
EntryOut
)
(
node
*
Inode
,
status
fuse
.
Status
)
{
return
nil
,
fuse
.
ENO
SYS
return
nil
,
fuse
.
ENO
ENT
}
}
func
(
n
*
DefaultOperations
)
GetXAttr
(
ctx
context
.
Context
,
attr
string
,
dest
[]
byte
)
(
uint32
,
fuse
.
Status
)
{
func
(
n
*
DefaultOperations
)
GetXAttr
(
ctx
context
.
Context
,
attr
string
,
dest
[]
byte
)
(
uint32
,
fuse
.
Status
)
{
return
0
,
fuse
.
ENO
ATTR
return
0
,
fuse
.
ENO
ENT
}
}
func
(
n
*
DefaultOperations
)
SetXAttr
(
ctx
context
.
Context
,
attr
string
,
data
[]
byte
,
flags
uint32
)
fuse
.
Status
{
func
(
n
*
DefaultOperations
)
SetXAttr
(
ctx
context
.
Context
,
attr
string
,
data
[]
byte
,
flags
uint32
)
fuse
.
Status
{
return
fuse
.
ENO
ATTR
return
fuse
.
ENO
ENT
}
}
func
(
n
*
DefaultOperations
)
RemoveXAttr
(
ctx
context
.
Context
,
attr
string
)
fuse
.
Status
{
func
(
n
*
DefaultOperations
)
RemoveXAttr
(
ctx
context
.
Context
,
attr
string
)
fuse
.
Status
{
return
fuse
.
ENO
ATTR
return
fuse
.
ENO
ENT
}
}
func
(
n
*
DefaultOperations
)
ListXAttr
(
ctx
context
.
Context
,
dest
[]
byte
)
(
uint32
,
fuse
.
Status
)
{
func
(
n
*
DefaultOperations
)
ListXAttr
(
ctx
context
.
Context
,
dest
[]
byte
)
(
uint32
,
fuse
.
Status
)
{
return
0
,
fuse
.
OK
return
0
,
fuse
.
OK
}
}
type
DefaultFile
struct
{
// DefaultFileHandle satisfies the FileHandle interface, and provides
// stub methods that return ENOENT for all operations.
type
DefaultFileHandle
struct
{
}
}
var
_
=
FileHandle
((
*
DefaultFile
)(
nil
))
var
_
=
FileHandle
((
*
DefaultFile
Handle
)(
nil
))
func
(
f
*
DefaultFile
)
Read
(
ctx
context
.
Context
,
dest
[]
byte
,
off
int64
)
(
fuse
.
ReadResult
,
fuse
.
Status
)
{
func
(
f
*
DefaultFile
Handle
)
Read
(
ctx
context
.
Context
,
dest
[]
byte
,
off
int64
)
(
fuse
.
ReadResult
,
fuse
.
Status
)
{
return
nil
,
fuse
.
ENO
SYS
return
nil
,
fuse
.
ENO
ENT
}
}
func
(
f
*
DefaultFile
)
Write
(
ctx
context
.
Context
,
data
[]
byte
,
off
int64
)
(
written
uint32
,
status
fuse
.
Status
)
{
func
(
f
*
DefaultFile
Handle
)
Write
(
ctx
context
.
Context
,
data
[]
byte
,
off
int64
)
(
written
uint32
,
status
fuse
.
Status
)
{
return
0
,
fuse
.
ENO
SYS
return
0
,
fuse
.
ENO
ENT
}
}
func
(
f
*
DefaultFile
)
GetLk
(
ctx
context
.
Context
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
,
out
*
fuse
.
FileLock
)
(
status
fuse
.
Status
)
{
func
(
f
*
DefaultFile
Handle
)
GetLk
(
ctx
context
.
Context
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
,
out
*
fuse
.
FileLock
)
(
status
fuse
.
Status
)
{
return
fuse
.
ENO
SYS
return
fuse
.
ENO
ENT
}
}
func
(
f
*
DefaultFile
)
SetLk
(
ctx
context
.
Context
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
(
status
fuse
.
Status
)
{
func
(
f
*
DefaultFile
Handle
)
SetLk
(
ctx
context
.
Context
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
(
status
fuse
.
Status
)
{
return
fuse
.
ENO
SYS
return
fuse
.
ENO
ENT
}
}
func
(
f
*
DefaultFile
)
SetLkw
(
ctx
context
.
Context
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
(
status
fuse
.
Status
)
{
func
(
f
*
DefaultFile
Handle
)
SetLkw
(
ctx
context
.
Context
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
(
status
fuse
.
Status
)
{
return
fuse
.
ENO
SYS
return
fuse
.
ENO
ENT
}
}
func
(
f
*
DefaultFile
)
Flush
(
ctx
context
.
Context
)
fuse
.
Status
{
func
(
f
*
DefaultFile
Handle
)
Flush
(
ctx
context
.
Context
)
fuse
.
Status
{
return
fuse
.
ENO
SYS
return
fuse
.
ENO
ENT
}
}
func
(
f
*
DefaultFile
)
Release
(
ctx
context
.
Context
)
fuse
.
Status
{
func
(
f
*
DefaultFile
Handle
)
Release
(
ctx
context
.
Context
)
fuse
.
Status
{
return
fuse
.
ENO
SYS
return
fuse
.
ENO
ENT
}
}
func
(
f
*
DefaultFile
)
GetAttr
(
ctx
context
.
Context
,
out
*
fuse
.
AttrOut
)
fuse
.
Status
{
func
(
f
*
DefaultFile
Handle
)
GetAttr
(
ctx
context
.
Context
,
out
*
fuse
.
AttrOut
)
fuse
.
Status
{
return
fuse
.
ENO
SYS
return
fuse
.
ENO
ENT
}
}
func
(
f
*
DefaultFile
)
SetAttr
(
ctx
context
.
Context
,
in
*
fuse
.
SetAttrIn
,
out
*
fuse
.
AttrOut
)
fuse
.
Status
{
func
(
f
*
DefaultFile
Handle
)
SetAttr
(
ctx
context
.
Context
,
in
*
fuse
.
SetAttrIn
,
out
*
fuse
.
AttrOut
)
fuse
.
Status
{
return
fuse
.
ENO
SYS
return
fuse
.
ENO
ENT
}
}
func
(
f
*
DefaultFile
)
Allocate
(
ctx
context
.
Context
,
off
uint64
,
size
uint64
,
mode
uint32
)
(
status
fuse
.
Status
)
{
func
(
f
*
DefaultFile
Handle
)
Allocate
(
ctx
context
.
Context
,
off
uint64
,
size
uint64
,
mode
uint32
)
(
status
fuse
.
Status
)
{
return
fuse
.
ENO
SYS
return
fuse
.
ENO
ENT
}
}
func
(
f
*
DefaultFile
)
Fsync
(
ctx
context
.
Context
,
flags
uint32
)
(
status
fuse
.
Status
)
{
func
(
f
*
DefaultFile
Handle
)
Fsync
(
ctx
context
.
Context
,
flags
uint32
)
(
status
fuse
.
Status
)
{
return
fuse
.
ENO
SYS
return
fuse
.
ENO
ENT
}
}
nodefs/dirstream_linux.go
View file @
18e0e322
...
@@ -17,6 +17,7 @@ type loopbackDirStream struct {
...
@@ -17,6 +17,7 @@ type loopbackDirStream struct {
fd
int
fd
int
}
}
// NewLoopbackDirStream open a directory for reading as a DirStream
func
NewLoopbackDirStream
(
name
string
)
(
DirStream
,
fuse
.
Status
)
{
func
NewLoopbackDirStream
(
name
string
)
(
DirStream
,
fuse
.
Status
)
{
fd
,
err
:=
syscall
.
Open
(
name
,
syscall
.
O_DIRECTORY
,
0755
)
fd
,
err
:=
syscall
.
Open
(
name
,
syscall
.
O_DIRECTORY
,
0755
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
nodefs/files.go
View file @
18e0e322
...
@@ -14,11 +14,12 @@ import (
...
@@ -14,11 +14,12 @@ import (
"github.com/hanwen/go-fuse/fuse"
"github.com/hanwen/go-fuse/fuse"
)
)
func
newLoopbackFile
(
fd
int
)
*
loopbackFile
{
// NewLoopbackFile creates a FileHandle out of a file descriptor. All
// operations are implemented.
func
NewLoopbackFile
(
fd
int
)
FileHandle
{
return
&
loopbackFile
{
fd
:
fd
}
return
&
loopbackFile
{
fd
:
fd
}
}
}
// loopbackFile delegates all operations back to an underlying file.
type
loopbackFile
struct
{
type
loopbackFile
struct
{
fd
int
fd
int
...
...
nodefs/loopback.go
View file @
18e0e322
...
@@ -95,7 +95,6 @@ func (n *loopbackNode) Mknod(ctx context.Context, name string, mode, rdev uint32
...
@@ -95,7 +95,6 @@ func (n *loopbackNode) Mknod(ctx context.Context, name string, mode, rdev uint32
}
}
func
(
n
*
loopbackNode
)
Mkdir
(
ctx
context
.
Context
,
name
string
,
mode
uint32
,
out
*
fuse
.
EntryOut
)
(
*
Inode
,
fuse
.
Status
)
{
func
(
n
*
loopbackNode
)
Mkdir
(
ctx
context
.
Context
,
name
string
,
mode
uint32
,
out
*
fuse
.
EntryOut
)
(
*
Inode
,
fuse
.
Status
)
{
// NOSUBMIT what about umask
p
:=
filepath
.
Join
(
n
.
path
(),
name
)
p
:=
filepath
.
Join
(
n
.
path
(),
name
)
err
:=
os
.
Mkdir
(
p
,
os
.
FileMode
(
mode
))
err
:=
os
.
Mkdir
(
p
,
os
.
FileMode
(
mode
))
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -172,7 +171,7 @@ func (n *loopbackNode) Create(ctx context.Context, name string, flags uint32, mo
...
@@ -172,7 +171,7 @@ func (n *loopbackNode) Create(ctx context.Context, name string, flags uint32, mo
node
:=
n
.
rootNode
.
newLoopbackNode
()
node
:=
n
.
rootNode
.
newLoopbackNode
()
ch
:=
n
.
inode
()
.
NewInode
(
node
,
uint32
(
st
.
Mode
),
idFromStat
(
&
st
))
ch
:=
n
.
inode
()
.
NewInode
(
node
,
uint32
(
st
.
Mode
),
idFromStat
(
&
st
))
lf
:=
n
ewLoopbackFile
(
fd
)
lf
:=
N
ewLoopbackFile
(
fd
)
return
ch
,
lf
,
0
,
fuse
.
OK
return
ch
,
lf
,
0
,
fuse
.
OK
}
}
...
@@ -236,7 +235,7 @@ func (n *loopbackNode) Open(ctx context.Context, flags uint32) (fh FileHandle, f
...
@@ -236,7 +235,7 @@ func (n *loopbackNode) Open(ctx context.Context, flags uint32) (fh FileHandle, f
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
0
,
fuse
.
ToStatus
(
err
)
return
nil
,
0
,
fuse
.
ToStatus
(
err
)
}
}
lf
:=
n
ewLoopbackFile
(
f
)
lf
:=
N
ewLoopbackFile
(
f
)
return
lf
,
0
,
fuse
.
OK
return
lf
,
0
,
fuse
.
OK
}
}
...
...
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