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
e7b2ddba
Commit
e7b2ddba
authored
Jun 13, 2012
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add deletion notify.
parent
eb2fc3e9
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
77 additions
and
23 deletions
+77
-23
fuse/api.go
fuse/api.go
+1
-0
fuse/delete_test.go
fuse/delete_test.go
+8
-20
fuse/fsconnector.go
fuse/fsconnector.go
+11
-0
fuse/misc.go
fuse/misc.go
+3
-0
fuse/mountstate.go
fuse/mountstate.go
+36
-0
fuse/opcode.go
fuse/opcode.go
+6
-2
raw/types.go
raw/types.go
+12
-1
No files found.
fuse/api.go
View file @
e7b2ddba
...
...
@@ -349,4 +349,5 @@ type DefaultRawFileSystem struct{}
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/delete_test.go
View file @
e7b2ddba
...
...
@@ -3,7 +3,6 @@ package fuse
import
(
"bytes"
"io/ioutil"
"log"
"os"
"os/exec"
"syscall"
...
...
@@ -79,39 +78,28 @@ func TestDeleteNotify(t *testing.T) {
}
defer
func
()
{
log
.
Println
(
"killing process..."
)
cmd
.
Process
.
Kill
()
cmd
.
Wait
()
log
.
Println
(
"waited"
)
time
.
Sleep
(
100
*
time
.
Millisecond
)
}()
// Wait until we see the subprocess moving.
deadline
:=
time
.
Now
()
.
Add
(
2
*
time
.
Second
)
for
{
_
,
err
:=
os
.
Lstat
(
mnt
+
"/testdir/testfile"
)
if
err
==
nil
{
break
}
if
time
.
Now
()
.
After
(
deadline
)
{
t
.
Fatal
(
"timeout; process did not start?"
)
}
time
.
Sleep
(
10
*
time
.
Millisecond
)
// Wait until tail opened the file.
time
.
Sleep
(
100
*
time
.
Millisecond
)
err
=
os
.
Remove
(
mnt
+
"/testdir/testfile"
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
// Simulate deletion+mkdir coming from the network
close
(
flip
.
ok
)
fs
.
Root
()
.
Inode
()
.
RmChild
(
"testdir"
)
oldCh
:=
fs
.
Root
()
.
Inode
()
.
RmChild
(
"testdir"
)
_
,
code
=
fs
.
Root
()
.
Inode
()
.
FsNode
()
.
Mkdir
(
"testdir"
,
0755
,
nil
)
if
!
code
.
Ok
()
{
t
.
Fatal
(
"mkdir status"
,
code
)
}
conn
.
EntryNotify
(
fs
.
Root
()
.
Inode
()
,
"testdir"
)
conn
.
DeleteNotify
(
fs
.
Root
()
.
Inode
(),
oldCh
,
"testdir"
)
fi
,
err
:=
os
.
Lstat
(
mnt
+
"/testdir"
)
log
.
Println
(
"lsta"
,
fi
,
err
)
_
,
err
=
os
.
Lstat
(
mnt
+
"/testdir"
)
if
err
!=
nil
{
t
.
Fatalf
(
"lstat after del + mkdir failed: %v"
,
err
)
}
t
.
Log
(
fi
)
}
fuse/fsconnector.go
View file @
e7b2ddba
...
...
@@ -370,3 +370,14 @@ func (c *FileSystemConnector) EntryNotify(dir *Inode, name string) Status {
}
return
c
.
fsInit
.
EntryNotify
(
n
,
name
)
}
func
(
c
*
FileSystemConnector
)
DeleteNotify
(
dir
*
Inode
,
child
*
Inode
,
name
string
)
Status
{
n
:=
dir
.
nodeId
if
dir
==
c
.
rootNode
{
n
=
raw
.
FUSE_ROOT_ID
}
if
n
==
0
{
return
OK
}
return
c
.
fsInit
.
DeleteNotify
(
n
,
child
.
nodeId
,
name
)
}
fuse/misc.go
View file @
e7b2ddba
...
...
@@ -20,6 +20,9 @@ func (code Status) String() string {
"NOTIFY_POLL"
,
"NOTIFY_INVAL_INODE"
,
"NOTIFY_INVAL_ENTRY"
,
"NOTIFY_INVAL_STORE"
,
"NOTIFY_INVAL_RETRIEVE"
,
"NOTIFY_INVAL_DELETE"
,
}[
-
code
]
}
return
fmt
.
Sprintf
(
"%d=%v"
,
int
(
code
),
syscall
.
Errno
(
code
))
...
...
fuse/mountstate.go
View file @
e7b2ddba
...
...
@@ -107,6 +107,9 @@ func (ms *MountState) Mount(mountPoint string, opts *MountOptions) error {
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
.
mountPoint
=
mp
...
...
@@ -442,6 +445,39 @@ func (ms *MountState) writeInodeNotify(entry *raw.NotifyInvalInodeOut) Status {
return
result
}
func
(
ms
*
MountState
)
writeDeleteNotify
(
parent
uint64
,
child
uint64
,
name
string
)
Status
{
if
ms
.
kernelSettings
.
Minor
<
18
{
return
ms
.
writeEntryNotify
(
parent
,
name
)
}
req
:=
request
{
inHeader
:
&
raw
.
InHeader
{
Opcode
:
_OP_NOTIFY_DELETE
,
},
handler
:
operationHandlers
[
_OP_NOTIFY_DELETE
],
status
:
raw
.
NOTIFY_INVAL_DELETE
,
}
entry
:=
&
raw
.
NotifyInvalDeleteOut
{
Parent
:
parent
,
Child
:
child
,
NameLen
:
uint32
(
len
(
name
)),
}
// Many versions of FUSE generate stacktraces if the
// terminating null byte is missing.
nameBytes
:=
make
([]
byte
,
len
(
name
)
+
1
)
copy
(
nameBytes
,
name
)
nameBytes
[
len
(
nameBytes
)
-
1
]
=
'\000'
req
.
outData
=
unsafe
.
Pointer
(
entry
)
req
.
flatData
=
nameBytes
result
:=
ms
.
write
(
&
req
)
if
ms
.
Debug
{
log
.
Printf
(
"Response: DELETE_NOTIFY: %v"
,
result
)
}
return
result
}
func
(
ms
*
MountState
)
writeEntryNotify
(
parent
uint64
,
name
string
)
Status
{
req
:=
request
{
inHeader
:
&
raw
.
InHeader
{
...
...
fuse/opcode.go
View file @
e7b2ddba
...
...
@@ -59,8 +59,9 @@ const (
// Ugh - what will happen if FUSE introduces a new opcode here?
_OP_NOTIFY_ENTRY
=
int32
(
51
)
_OP_NOTIFY_INODE
=
int32
(
52
)
_OP_NOTIFY_DELETE
=
int32
(
53
)
_OPCODE_COUNT
=
int32
(
5
3
)
_OPCODE_COUNT
=
int32
(
5
4
)
)
////////////////////////////////////////////////////////////////
...
...
@@ -372,7 +373,7 @@ func init() {
operationHandlers
[
i
]
=
&
operationHandler
{
Name
:
"UNKNOWN"
}
}
fileOps
:=
[]
int32
{
_OP_READLINK
,
_OP_NOTIFY_ENTRY
}
fileOps
:=
[]
int32
{
_OP_READLINK
,
_OP_NOTIFY_ENTRY
,
_OP_NOTIFY_DELETE
}
for
_
,
op
:=
range
fileOps
{
operationHandlers
[
op
]
.
FileNameOut
=
true
}
...
...
@@ -431,6 +432,7 @@ func init() {
_OP_POLL
:
unsafe
.
Sizeof
(
raw
.
PollOut
{}),
_OP_NOTIFY_ENTRY
:
unsafe
.
Sizeof
(
raw
.
NotifyInvalEntryOut
{}),
_OP_NOTIFY_INODE
:
unsafe
.
Sizeof
(
raw
.
NotifyInvalInodeOut
{}),
_OP_NOTIFY_DELETE
:
unsafe
.
Sizeof
(
raw
.
NotifyInvalDeleteOut
{}),
}
{
operationHandlers
[
op
]
.
OutputSize
=
sz
}
...
...
@@ -477,6 +479,7 @@ func init() {
_OP_POLL
:
"POLL"
,
_OP_NOTIFY_ENTRY
:
"NOTIFY_ENTRY"
,
_OP_NOTIFY_INODE
:
"NOTIFY_INODE"
,
_OP_NOTIFY_DELETE
:
"NOTIFY_DELETE"
,
}
{
operationHandlers
[
op
]
.
Name
=
v
}
...
...
@@ -531,6 +534,7 @@ func init() {
_OP_MKDIR
:
func
(
ptr
unsafe
.
Pointer
)
interface
{}
{
return
(
*
raw
.
EntryOut
)(
ptr
)
},
_OP_NOTIFY_ENTRY
:
func
(
ptr
unsafe
.
Pointer
)
interface
{}
{
return
(
*
raw
.
NotifyInvalEntryOut
)(
ptr
)
},
_OP_NOTIFY_INODE
:
func
(
ptr
unsafe
.
Pointer
)
interface
{}
{
return
(
*
raw
.
NotifyInvalInodeOut
)(
ptr
)
},
_OP_NOTIFY_DELETE
:
func
(
ptr
unsafe
.
Pointer
)
interface
{}
{
return
(
*
raw
.
NotifyInvalDeleteOut
)(
ptr
)
},
_OP_STATFS
:
func
(
ptr
unsafe
.
Pointer
)
interface
{}
{
return
(
*
StatfsOut
)(
ptr
)
},
}
{
operationHandlers
[
op
]
.
DecodeOut
=
f
...
...
raw/types.go
View file @
e7b2ddba
...
...
@@ -298,11 +298,22 @@ type NotifyInvalEntryOut struct {
Padding
uint32
}
type
NotifyInvalDeleteOut
struct
{
Parent
uint64
;
Child
uint64
;
NameLen
uint32
;
Padding
uint32
;
}
const
(
NOTIFY_POLL
=
-
1
NOTIFY_INVAL_INODE
=
-
2
NOTIFY_INVAL_ENTRY
=
-
3
NOTIFY_CODE_MAX
=
-
4
NOTIFY_STORE
=
-
4
NOTIFY_RETRIEVE
=
-
5
NOTIFY_INVAL_DELETE
=
-
6
NOTIFY_CODE_MAX
=
-
6
)
type
FlushIn
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