Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jacobsa-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
jacobsa-fuse
Commits
096c3fa6
Commit
096c3fa6
authored
Mar 24, 2015
by
Aaron Jacobs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a test for directories.
parent
38862e86
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
81 additions
and
8 deletions
+81
-8
samples/flushfs/flush_fs.go
samples/flushfs/flush_fs.go
+56
-6
samples/flushfs/flush_fs_test.go
samples/flushfs/flush_fs_test.go
+23
-1
samples/subprocess.go
samples/subprocess.go
+2
-1
No files found.
samples/flushfs/flush_fs.go
View file @
096c3fa6
...
@@ -24,11 +24,14 @@ import (
...
@@ -24,11 +24,14 @@ import (
"golang.org/x/net/context"
"golang.org/x/net/context"
)
)
// Create a file system containing a single file named "foo".
// Create a file system whose sole contents are a file named "foo" and a
// directory named "bar".
//
//
// The file may be opened for reading and/or writing. Its initial contents are
// The file may be opened for reading and/or writing. Its initial contents are
// empty. Whenever a flush or fsync is received, the supplied function will be
// empty. Whenever a flush or fsync is received, the supplied function will be
// called with the current contents of the file and its status returned.
// called with the current contents of the file and its status returned.
//
// The directory cannot be modified.
func
NewFileSystem
(
func
NewFileSystem
(
reportFlush
func
(
string
)
error
,
reportFlush
func
(
string
)
error
,
reportFsync
func
(
string
)
error
)
(
fs
fuse
.
FileSystem
,
err
error
)
{
reportFsync
func
(
string
)
error
)
(
fs
fuse
.
FileSystem
,
err
error
)
{
...
@@ -40,7 +43,10 @@ func NewFileSystem(
...
@@ -40,7 +43,10 @@ func NewFileSystem(
return
return
}
}
const
fooID
=
fuse
.
RootInodeID
+
1
const
(
fooID
=
fuse
.
RootInodeID
+
1
+
iota
barID
)
type
flushFS
struct
{
type
flushFS
struct
{
fuseutil
.
NotImplementedFileSystem
fuseutil
.
NotImplementedFileSystem
...
@@ -72,6 +78,14 @@ func (fs *flushFS) fooAttributes() fuse.InodeAttributes {
...
@@ -72,6 +78,14 @@ func (fs *flushFS) fooAttributes() fuse.InodeAttributes {
}
}
}
}
// LOCKS_REQUIRED(fs.mu)
func
(
fs
*
flushFS
)
barAttributes
()
fuse
.
InodeAttributes
{
return
fuse
.
InodeAttributes
{
Nlink
:
1
,
Mode
:
0777
|
os
.
ModeDir
,
}
}
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
// File system methods
// File system methods
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
...
@@ -94,14 +108,28 @@ func (fs *flushFS) LookUpInode(
...
@@ -94,14 +108,28 @@ func (fs *flushFS) LookUpInode(
defer
fs
.
mu
.
Unlock
()
defer
fs
.
mu
.
Unlock
()
// Sanity check.
// Sanity check.
if
req
.
Parent
!=
fuse
.
RootInodeID
||
req
.
Name
!=
"foo"
{
if
req
.
Parent
!=
fuse
.
RootInodeID
{
err
=
fuse
.
ENOENT
err
=
fuse
.
ENOENT
return
return
}
}
resp
.
Entry
=
fuse
.
ChildInodeEntry
{
// Set up the entry.
Child
:
fooID
,
switch
req
.
Name
{
Attributes
:
fs
.
fooAttributes
(),
case
"foo"
:
resp
.
Entry
=
fuse
.
ChildInodeEntry
{
Child
:
fooID
,
Attributes
:
fs
.
fooAttributes
(),
}
case
"bar"
:
resp
.
Entry
=
fuse
.
ChildInodeEntry
{
Child
:
barID
,
Attributes
:
fs
.
barAttributes
(),
}
default
:
err
=
fuse
.
ENOENT
return
}
}
return
return
...
@@ -125,6 +153,10 @@ func (fs *flushFS) GetInodeAttributes(
...
@@ -125,6 +153,10 @@ func (fs *flushFS) GetInodeAttributes(
resp
.
Attributes
=
fs
.
fooAttributes
()
resp
.
Attributes
=
fs
.
fooAttributes
()
return
return
case
barID
:
resp
.
Attributes
=
fs
.
barAttributes
()
return
default
:
default
:
err
=
fuse
.
ENOENT
err
=
fuse
.
ENOENT
return
return
...
@@ -222,3 +254,21 @@ func (fs *flushFS) FlushFile(
...
@@ -222,3 +254,21 @@ func (fs *flushFS) FlushFile(
err
=
fs
.
reportFlush
(
string
(
fs
.
fooContents
))
err
=
fs
.
reportFlush
(
string
(
fs
.
fooContents
))
return
return
}
}
func
(
fs
*
flushFS
)
OpenDir
(
ctx
context
.
Context
,
req
*
fuse
.
OpenDirRequest
)
(
resp
*
fuse
.
OpenDirResponse
,
err
error
)
{
resp
=
&
fuse
.
OpenDirResponse
{}
fs
.
mu
.
Lock
()
defer
fs
.
mu
.
Unlock
()
// Sanity check.
if
req
.
Inode
!=
barID
{
err
=
fuse
.
ENOSYS
return
}
return
}
samples/flushfs/flush_fs_test.go
View file @
096c3fa6
...
@@ -614,7 +614,29 @@ func (t *NoErrorsTest) Mmap_CloseBeforeMunmap() {
...
@@ -614,7 +614,29 @@ func (t *NoErrorsTest) Mmap_CloseBeforeMunmap() {
}
}
func
(
t
*
NoErrorsTest
)
Directory
()
{
func
(
t
*
NoErrorsTest
)
Directory
()
{
AssertTrue
(
false
,
"TODO"
)
var
err
error
// Open the directory.
t
.
f1
,
err
=
os
.
Open
(
path
.
Join
(
t
.
Dir
,
"bar"
))
AssertEq
(
nil
,
err
)
// Sanity check: stat it.
fi
,
err
:=
t
.
f1
.
Stat
()
AssertEq
(
nil
,
err
)
AssertEq
(
0777
|
os
.
ModeDir
,
fi
.
Mode
())
// Sync it.
err
=
t
.
f1
.
Sync
()
AssertEq
(
nil
,
err
)
// Close it.
err
=
t
.
f1
.
Close
()
t
.
f1
=
nil
AssertEq
(
nil
,
err
)
// No flushes or fsync requests should have been received.
ExpectThat
(
t
.
getFlushes
(),
ElementsAre
())
ExpectThat
(
t
.
getFsyncs
(),
ElementsAre
())
}
}
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
...
...
samples/subprocess.go
View file @
096c3fa6
...
@@ -236,6 +236,7 @@ func (t *SubprocessTest) initialize() (err error) {
...
@@ -236,6 +236,7 @@ func (t *SubprocessTest) initialize() (err error) {
// Set up basic args for the subprocess.
// Set up basic args for the subprocess.
args
:=
[]
string
{
args
:=
[]
string
{
"--fuse.debug"
,
"--type"
,
"--type"
,
t
.
MountType
,
t
.
MountType
,
"--mount_point"
,
"--mount_point"
,
...
@@ -270,7 +271,7 @@ func (t *SubprocessTest) initialize() (err error) {
...
@@ -270,7 +271,7 @@ func (t *SubprocessTest) initialize() (err error) {
// Set up a command.
// Set up a command.
var
stderr
bytes
.
Buffer
var
stderr
bytes
.
Buffer
mountCmd
:=
exec
.
Command
(
toolPath
,
args
...
)
mountCmd
:=
exec
.
Command
(
toolPath
,
args
...
)
mountCmd
.
Stderr
=
&
s
tderr
mountCmd
.
Stderr
=
os
.
S
tderr
mountCmd
.
ExtraFiles
=
extraFiles
mountCmd
.
ExtraFiles
=
extraFiles
// Start it.
// Start it.
...
...
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