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
94f9b193
Commit
94f9b193
authored
Aug 15, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement entry notify.
parent
25145ebb
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
81 additions
and
0 deletions
+81
-0
fuse/api.go
fuse/api.go
+1
-0
fuse/mountstate.go
fuse/mountstate.go
+33
-0
fuse/notify_test.go
fuse/notify_test.go
+33
-0
fuse/pathfilesystem.go
fuse/pathfilesystem.go
+14
-0
No files found.
fuse/api.go
View file @
94f9b193
...
...
@@ -187,4 +187,5 @@ type DefaultRawFileSystem struct{}
// kernel error.
type
RawFsInit
struct
{
InodeNotify
func
(
*
NotifyInvalInodeOut
)
Status
EntryNotify
func
(
parent
uint64
,
name
string
)
Status
}
fuse/mountstate.go
View file @
94f9b193
...
...
@@ -68,6 +68,9 @@ func (me *MountState) Mount(mountPoint string, opts *MountOptions) os.Error {
InodeNotify
:
func
(
n
*
NotifyInvalInodeOut
)
Status
{
return
me
.
writeInodeNotify
(
n
)
},
EntryNotify
:
func
(
parent
uint64
,
n
string
)
Status
{
return
me
.
writeEntryNotify
(
parent
,
n
)
},
}
me
.
fileSystem
.
Init
(
&
initParams
)
me
.
mountPoint
=
mp
...
...
@@ -275,3 +278,33 @@ func (me *MountState) writeInodeNotify(entry *NotifyInvalInodeOut) Status {
}
return
result
}
func
(
me
*
MountState
)
writeEntryNotify
(
parent
uint64
,
name
string
)
Status
{
req
:=
request
{
inHeader
:
&
InHeader
{
opcode
:
_OP_NOTIFY_ENTRY
,
},
handler
:
operationHandlers
[
_OP_NOTIFY_ENTRY
],
status
:
NOTIFY_INVAL_ENTRY
,
}
entry
:=
&
NotifyInvalEntryOut
{
Parent
:
parent
,
NameLen
:
uint32
(
len
(
name
)),
}
// Many versions of FUSE generate stacktraces if the
// terminating null byte is missing.
nameBytes
:=
[]
byte
(
name
+
"
\0
00"
)
req
.
outData
=
unsafe
.
Pointer
(
entry
)
req
.
flatData
=
nameBytes
req
.
serialize
()
log
.
Println
([][]
byte
{
req
.
outHeaderBytes
,
req
.
flatData
})
result
:=
me
.
write
(
&
req
)
if
me
.
Debug
{
log
.
Printf
(
"ENTRY_NOTIFY: %v"
,
result
)
}
return
result
}
fuse/notify_test.go
View file @
94f9b193
...
...
@@ -15,6 +15,9 @@ type NotifyFs struct {
}
func
(
me
*
NotifyFs
)
GetAttr
(
name
string
)
(
*
os
.
FileInfo
,
Status
)
{
if
name
==
""
{
return
&
os
.
FileInfo
{
Mode
:
S_IFDIR
|
0755
},
OK
}
if
name
==
"file"
||
(
name
==
"dir/file"
&&
me
.
exist
)
{
return
&
os
.
FileInfo
{
Mode
:
S_IFREG
|
0644
,
Size
:
me
.
size
},
OK
}
...
...
@@ -119,3 +122,33 @@ func TestInodeNotifyRemoval(t *testing.T) {
t
.
Error
(
"should have been removed"
,
fi
)
}
}
func
TestEntryNotify
(
t
*
testing
.
T
)
{
test
:=
NewNotifyTest
()
defer
test
.
Clean
()
dir
:=
test
.
dir
test
.
fs
.
size
=
42
test
.
fs
.
exist
=
false
fn
:=
dir
+
"/dir/file"
fi
,
_
:=
os
.
Lstat
(
fn
)
if
fi
!=
nil
{
t
.
Errorf
(
"File should not exist, %#v"
,
fi
)
}
test
.
fs
.
exist
=
true
fi
,
_
=
os
.
Lstat
(
fn
)
if
fi
!=
nil
{
t
.
Errorf
(
"negative entry should have been cached: %#v"
,
fi
)
}
code
:=
test
.
connector
.
EntryNotify
(
"dir"
,
"file"
)
if
!
code
.
Ok
()
{
t
.
Errorf
(
"EntryNotify returns error: %v"
,
code
)
}
fi
,
err
:=
os
.
Lstat
(
fn
)
CheckSuccess
(
err
)
}
fuse/pathfilesystem.go
View file @
94f9b193
...
...
@@ -460,6 +460,10 @@ func (me *FileSystemConnector) unlinkUpdate(parent *inode, name string) {
// Walk the file system starting from the root. Will return nil if
// node not found.
func
(
me
*
FileSystemConnector
)
findInode
(
fullPath
string
)
*
inode
{
if
fullPath
==
""
{
return
me
.
rootNode
}
fullPath
=
strings
.
TrimLeft
(
filepath
.
Clean
(
fullPath
),
"/"
)
comps
:=
strings
.
Split
(
fullPath
,
"/"
)
...
...
@@ -667,3 +671,13 @@ func (me *FileSystemConnector) FileNotify(path string, off int64, length int64)
}
return
me
.
fsInit
.
InodeNotify
(
&
out
)
}
func
(
me
*
FileSystemConnector
)
EntryNotify
(
dir
string
,
name
string
)
Status
{
node
:=
me
.
findInode
(
dir
)
if
node
==
nil
{
log
.
Printf
(
"dir not found, %q"
,
dir
)
return
ENOENT
}
return
me
.
fsInit
.
EntryNotify
(
node
.
NodeId
,
name
)
}
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