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
8b4fc94a
Commit
8b4fc94a
authored
Jun 30, 2013
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fuse: drop RawFsInit method; expose Notify functions directly in Server.
parent
7e41a9d5
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
33 additions
and
44 deletions
+33
-44
fuse/api.go
fuse/api.go
+4
-11
fuse/defaultraw.go
fuse/defaultraw.go
+1
-1
fuse/lockingfs.go
fuse/lockingfs.go
+2
-4
fuse/nodefs/fsconnector.go
fuse/nodefs/fsconnector.go
+5
-10
fuse/nodefs/fsops.go
fuse/nodefs/fsops.go
+2
-2
fuse/server.go
fuse/server.go
+19
-16
No files found.
fuse/api.go
View file @
8b4fc94a
...
...
@@ -126,23 +126,16 @@ type RawFileSystem interface {
//
StatFs
(
out
*
raw
.
StatfsOut
,
context
*
Context
)
(
code
Status
)
// Provide callbacks for pushing notifications to the kernel.
Init
(
params
*
RawFsInit
)
// This is called on processing the first request. This call
// is intended so the filesystem can talk back to the kernel
// (through notify methods) and has access to debug data.
Init
(
*
Server
)
}
// Talk back to FUSE.
//
// InodeNotify invalidates the information associated with the inode
// (ie. data cache, attributes, etc.)
//
// EntryNotify should be used if the existence status of an entry changes,
// (ie. to notify of creation or deletion of the file).
//
// Somewhat confusingly, InodeNotify for a file that stopped to exist
// will give the correct result for Lstat (ENOENT), but the kernel
// will still issue file Open() on the inode.
type
RawFsInit
struct
{
InodeNotify
func
(
*
raw
.
NotifyInvalInodeOut
)
Status
EntryNotify
func
(
parent
uint64
,
name
string
)
Status
DeleteNotify
func
(
parent
uint64
,
child
uint64
,
name
string
)
Status
}
fuse/defaultraw.go
View file @
8b4fc94a
...
...
@@ -14,7 +14,7 @@ func NewDefaultRawFileSystem() RawFileSystem {
type
defaultRawFileSystem
struct
{}
func
(
fs
*
defaultRawFileSystem
)
Init
(
init
*
RawFsInit
)
{
func
(
fs
*
defaultRawFileSystem
)
Init
(
*
Server
)
{
}
func
(
fs
*
defaultRawFileSystem
)
String
()
string
{
...
...
fuse/lockingfs.go
View file @
8b4fc94a
...
...
@@ -15,8 +15,6 @@ type lockingRawFileSystem struct {
lock
sync
.
Mutex
}
var
_
=
(
RawFileSystem
)((
*
lockingRawFileSystem
)(
nil
))
// Returns a Wrap
func
NewLockingRawFileSystem
(
fs
RawFileSystem
)
RawFileSystem
{
return
&
lockingRawFileSystem
{
...
...
@@ -189,9 +187,9 @@ func (fs *lockingRawFileSystem) FsyncDir(header *Context, input *raw.FsyncIn) (c
return
fs
.
RawFS
.
FsyncDir
(
header
,
input
)
}
func
(
fs
*
lockingRawFileSystem
)
Init
(
params
*
RawFsInit
)
{
func
(
fs
*
lockingRawFileSystem
)
Init
(
s
*
Server
)
{
defer
fs
.
locked
()()
fs
.
RawFS
.
Init
(
param
s
)
fs
.
RawFS
.
Init
(
s
)
}
func
(
fs
*
lockingRawFileSystem
)
StatFs
(
out
*
raw
.
StatfsOut
,
context
*
Context
)
(
code
Status
)
{
...
...
fuse/nodefs/fsconnector.go
View file @
8b4fc94a
...
...
@@ -36,7 +36,7 @@ type FileSystemConnector struct {
debug
bool
// Callbacks for talking back to the kernel.
fsInit
fuse
.
RawFsInit
server
*
fuse
.
Server
nodeFs
FileSystem
...
...
@@ -340,7 +340,7 @@ func (c *FileSystemConnector) Unmount(node *Inode) fuse.Status {
// We have to wait until the kernel has forgotten the
// mountpoint, so the write to node.mountPoint is no longer
// racy.
code
:=
c
.
fsInit
.
DeleteNotify
(
parentId
,
c
.
inodeMap
.
Handle
(
&
node
.
handled
),
name
)
code
:=
c
.
server
.
DeleteNotify
(
parentId
,
c
.
inodeMap
.
Handle
(
&
node
.
handled
),
name
)
if
code
.
Ok
()
{
mount
.
treeLock
.
Unlock
()
parentNode
.
mount
.
treeLock
.
Unlock
()
...
...
@@ -375,12 +375,7 @@ func (c *FileSystemConnector) FileNotify(node *Inode, off int64, length int64) f
if
nId
==
0
{
return
fuse
.
OK
}
out
:=
raw
.
NotifyInvalInodeOut
{
Length
:
length
,
Off
:
off
,
Ino
:
nId
,
}
return
c
.
fsInit
.
InodeNotify
(
&
out
)
return
c
.
server
.
InodeNotify
(
nId
,
off
,
length
)
}
func
(
c
*
FileSystemConnector
)
EntryNotify
(
node
*
Inode
,
name
string
)
fuse
.
Status
{
...
...
@@ -394,7 +389,7 @@ func (c *FileSystemConnector) EntryNotify(node *Inode, name string) fuse.Status
if
nId
==
0
{
return
fuse
.
OK
}
return
c
.
fsInit
.
EntryNotify
(
nId
,
name
)
return
c
.
server
.
EntryNotify
(
nId
,
name
)
}
func
(
c
*
FileSystemConnector
)
DeleteNotify
(
dir
*
Inode
,
child
*
Inode
,
name
string
)
fuse
.
Status
{
...
...
@@ -412,5 +407,5 @@ func (c *FileSystemConnector) DeleteNotify(dir *Inode, child *Inode, name string
chId
:=
c
.
inodeMap
.
Handle
(
&
child
.
handled
)
return
c
.
fsInit
.
DeleteNotify
(
nId
,
chId
,
name
)
return
c
.
server
.
DeleteNotify
(
nId
,
chId
,
name
)
}
fuse/nodefs/fsops.go
View file @
8b4fc94a
...
...
@@ -53,8 +53,8 @@ func (c *rawBridge) String() string {
return
name
}
func
(
c
*
rawBridge
)
Init
(
fsInit
*
fuse
.
RawFsInit
)
{
c
.
fsInit
=
*
fsInit
func
(
c
*
rawBridge
)
Init
(
s
*
fuse
.
Server
)
{
c
.
server
=
s
}
func
(
c
*
FileSystemConnector
)
lookupMountUpdate
(
out
*
fuse
.
Attr
,
mount
*
fileSystemMount
)
(
node
*
Inode
,
code
fuse
.
Status
)
{
...
...
fuse/server.go
View file @
8b4fc94a
...
...
@@ -166,18 +166,8 @@ func NewServer(fs RawFileSystem, mountPoint string, opts *MountOptions) (*Server
if
err
!=
nil
{
return
nil
,
err
}
initParams
:=
RawFsInit
{
InodeNotify
:
func
(
n
*
raw
.
NotifyInvalInodeOut
)
Status
{
return
ms
.
writeInodeNotify
(
n
)
},
EntryNotify
:
func
(
parent
uint64
,
n
string
)
Status
{
return
ms
.
writeEntryNotify
(
parent
,
n
)
},
DeleteNotify
:
func
(
parent
uint64
,
child
uint64
,
n
string
)
Status
{
return
ms
.
writeDeleteNotify
(
parent
,
child
,
n
)
},
}
ms
.
fileSystem
.
Init
(
&
initParams
)
ms
.
fileSystem
.
Init
(
ms
)
ms
.
mountPoint
=
mountPoint
ms
.
mountFd
=
fd
return
ms
,
nil
...
...
@@ -388,7 +378,14 @@ func (ms *Server) write(req *request) Status {
return
s
}
func
(
ms
*
Server
)
writeInodeNotify
(
entry
*
raw
.
NotifyInvalInodeOut
)
Status
{
// InodeNotify invalidates the information associated with the inode
// (ie. data cache, attributes, etc.)
func
(
ms
*
Server
)
InodeNotify
(
node
uint64
,
off
int64
,
length
int64
)
Status
{
entry
:=
&
raw
.
NotifyInvalInodeOut
{
Ino
:
node
,
Off
:
off
,
Length
:
length
,
}
req
:=
request
{
inHeader
:
&
raw
.
InHeader
{
Opcode
:
_OP_NOTIFY_INODE
,
...
...
@@ -409,9 +406,13 @@ func (ms *Server) writeInodeNotify(entry *raw.NotifyInvalInodeOut) Status {
return
result
}
func
(
ms
*
Server
)
writeDeleteNotify
(
parent
uint64
,
child
uint64
,
name
string
)
Status
{
// DeleteNotify notifies the kernel that an entry is removed from a
// directory. In many cases, this is equivalent to EntryNotify,
// except when the directory is in use, eg. as working directory of
// some process.
func
(
ms
*
Server
)
DeleteNotify
(
parent
uint64
,
child
uint64
,
name
string
)
Status
{
if
ms
.
kernelSettings
.
Minor
<
18
{
return
ms
.
write
EntryNotify
(
parent
,
name
)
return
ms
.
EntryNotify
(
parent
,
name
)
}
req
:=
request
{
...
...
@@ -446,7 +447,9 @@ func (ms *Server) writeDeleteNotify(parent uint64, child uint64, name string) St
return
result
}
func
(
ms
*
Server
)
writeEntryNotify
(
parent
uint64
,
name
string
)
Status
{
// EntryNotify should be used if the existence status of an entry
// within a directory changes.
func
(
ms
*
Server
)
EntryNotify
(
parent
uint64
,
name
string
)
Status
{
req
:=
request
{
inHeader
:
&
raw
.
InHeader
{
Opcode
:
_OP_NOTIFY_ENTRY
,
...
...
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