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
b62be963
Commit
b62be963
authored
Mar 24, 2015
by
Aaron Jacobs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pass report files by file descriptor.
parent
a4384665
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
22 deletions
+30
-22
samples/flushfs/flush_fs_test.go
samples/flushfs/flush_fs_test.go
+5
-6
samples/mount_sample/mount.go
samples/mount_sample/mount.go
+6
-15
samples/subprocess.go
samples/subprocess.go
+19
-1
No files found.
samples/flushfs/flush_fs_test.go
View file @
b62be963
...
...
@@ -66,12 +66,6 @@ func (t *flushFSTest) setUp(
// Set up test config.
t
.
MountType
=
"flushfs"
t
.
MountFlags
=
[]
string
{
"--flushfs.flushes_file"
,
t
.
flushes
.
Name
(),
"--flushfs.fsyncs_file"
,
t
.
fsyncs
.
Name
(),
"--flushfs.flush_error"
,
fmt
.
Sprintf
(
"%d"
,
int
(
flushErr
)),
...
...
@@ -79,6 +73,11 @@ func (t *flushFSTest) setUp(
fmt
.
Sprintf
(
"%d"
,
int
(
fsyncErr
)),
}
t
.
MountFiles
=
map
[
string
]
*
os
.
File
{
"flushfs.flushes_file"
:
t
.
flushes
,
"flushfs.fsyncs_file"
:
t
.
fsyncs
,
}
t
.
SubprocessTest
.
SetUp
(
ti
)
}
...
...
samples/mount_sample/mount.go
View file @
b62be963
...
...
@@ -31,30 +31,21 @@ import (
var
fType
=
flag
.
String
(
"type"
,
""
,
"The name of the samples/ sub-dir."
)
var
fMountPoint
=
flag
.
String
(
"mount_point"
,
""
,
"Path to mount point."
)
var
fFlushesFile
=
flag
.
String
(
"flushfs.flushes_file"
,
""
,
""
)
var
fFsyncsFile
=
flag
.
String
(
"flushfs.fsyncs_file"
,
""
,
""
)
var
fFlushesFile
=
flag
.
Uint64
(
"flushfs.flushes_file"
,
0
,
""
)
var
fFsyncsFile
=
flag
.
Uint64
(
"flushfs.fsyncs_file"
,
0
,
""
)
var
fFlushError
=
flag
.
Int
(
"flushfs.flush_error"
,
0
,
""
)
var
fFsyncError
=
flag
.
Int
(
"flushfs.fsync_error"
,
0
,
""
)
func
makeFlushFS
()
(
fs
fuse
.
FileSystem
,
err
error
)
{
// Check the flags.
if
*
fFlushesFile
==
""
||
*
fFsyncsFile
==
""
{
if
*
fFlushesFile
==
0
||
*
fFsyncsFile
==
0
{
err
=
fmt
.
Errorf
(
"You must set the flushfs flags."
)
return
}
// Open the files.
flushes
,
err
:=
os
.
OpenFile
(
*
fFlushesFile
,
os
.
O_RDWR
,
0
)
if
err
!=
nil
{
err
=
fmt
.
Errorf
(
"Opening %s: %v"
,
*
fFlushesFile
,
err
)
return
}
fsyncs
,
err
:=
os
.
OpenFile
(
*
fFsyncsFile
,
os
.
O_RDWR
,
0
)
if
err
!=
nil
{
err
=
fmt
.
Errorf
(
"Opening %s: %v"
,
*
fFsyncsFile
,
err
)
return
}
// Set up the files.
flushes
:=
os
.
NewFile
(
uintptr
(
*
fFlushesFile
),
"(flushes file)"
)
fsyncs
:=
os
.
NewFile
(
uintptr
(
*
fFsyncsFile
),
"(fsyncs file)"
)
// Set up errors.
var
flushErr
error
...
...
samples/subprocess.go
View file @
b62be963
...
...
@@ -20,6 +20,7 @@ import (
"io"
"io/ioutil"
"log"
"os"
"os/exec"
"path"
"sync"
...
...
@@ -40,6 +41,10 @@ type SubprocessTest struct {
// Additional flags to be passed to the mount_sample tool.
MountFlags
[]
string
// A list of files to pass to mount_sample. The given string flag will be
// used to pass the file descriptor number.
MountFiles
map
[
string
]
*
os
.
File
// A context object that can be used for long-running operations.
Ctx
context
.
Context
...
...
@@ -132,7 +137,7 @@ func (t *SubprocessTest) initialize() (err error) {
return
}
// Set up
a command
.
// Set up
basic args for the subprocess
.
args
:=
[]
string
{
"--type"
,
t
.
MountType
,
...
...
@@ -142,9 +147,22 @@ func (t *SubprocessTest) initialize() (err error) {
args
=
append
(
args
,
t
.
MountFlags
...
)
// Set up inherited files and appropriate flags.
var
extraFiles
[]
*
os
.
File
for
flag
,
file
:=
range
t
.
MountFiles
{
// Cf. os/exec.Cmd.ExtraFiles
fd
:=
3
+
len
(
extraFiles
)
extraFiles
=
append
(
extraFiles
,
file
)
args
=
append
(
args
,
"--"
+
flag
)
args
=
append
(
args
,
fmt
.
Sprintf
(
"%d"
,
fd
))
}
// Set up a command.
t
.
mountCmd
=
exec
.
Command
(
toolPath
,
args
...
)
t
.
mountCmd
.
Stdout
=
&
t
.
mountStdout
t
.
mountCmd
.
Stderr
=
&
t
.
mountStderr
t
.
mountCmd
.
ExtraFiles
=
extraFiles
// Start it.
if
err
=
t
.
mountCmd
.
Start
();
err
!=
nil
{
...
...
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