Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
9012863a
Commit
9012863a
authored
Jun 21, 2017
by
Péter Szilágyi
Committed by
GitHub
Jun 21, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #14667 from fjl/swarm-fuse-cleanup
swarm/fuse: simplify externalUnmount, use subtests
parents
a5d08c89
98e101ef
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
132 additions
and
206 deletions
+132
-206
swarmfs_test.go
swarm/fuse/swarmfs_test.go
+112
-171
swarmfs_unix.go
swarm/fuse/swarmfs_unix.go
+7
-6
swarmfs_util.go
swarm/fuse/swarmfs_util.go
+13
-29
No files found.
swarm/fuse/swarmfs_test.go
View file @
9012863a
This diff is collapsed.
Click to expand it.
swarm/fuse/swarmfs_unix.go
View file @
9012863a
...
@@ -19,18 +19,19 @@
...
@@ -19,18 +19,19 @@
package
fuse
package
fuse
import
(
import
(
"bazil.org/fuse"
"bazil.org/fuse/fs"
"errors"
"errors"
"fmt"
"fmt"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/swarm/api"
"os"
"os"
"path/filepath"
"path/filepath"
"strings"
"strings"
"sync"
"sync"
"time"
"time"
"bazil.org/fuse"
"bazil.org/fuse/fs"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/swarm/api"
)
)
var
(
var
(
...
@@ -203,7 +204,7 @@ func (self *SwarmFS) Unmount(mountpoint string) (*MountInfo, error) {
...
@@ -203,7 +204,7 @@ func (self *SwarmFS) Unmount(mountpoint string) (*MountInfo, error) {
}
}
err
=
fuse
.
Unmount
(
cleanedMountPoint
)
err
=
fuse
.
Unmount
(
cleanedMountPoint
)
if
err
!=
nil
{
if
err
!=
nil
{
err1
:=
externalUn
M
ount
(
cleanedMountPoint
)
err1
:=
externalUn
m
ount
(
cleanedMountPoint
)
if
err1
!=
nil
{
if
err1
!=
nil
{
errStr
:=
fmt
.
Sprintf
(
"UnMount error: %v"
,
err
)
errStr
:=
fmt
.
Sprintf
(
"UnMount error: %v"
,
err
)
log
.
Warn
(
errStr
)
log
.
Warn
(
errStr
)
...
...
swarm/fuse/swarmfs_util.go
View file @
9012863a
...
@@ -19,47 +19,31 @@
...
@@ -19,47 +19,31 @@
package
fuse
package
fuse
import
(
import
(
"context"
"fmt"
"fmt"
"github.com/ethereum/go-ethereum/log"
"os/exec"
"os/exec"
"runtime"
"runtime"
"time"
)
func
externalUnMount
(
mountPoint
string
)
error
{
"github.com/ethereum/go-ethereum/log"
)
var
cmd
*
exec
.
Cmd
func
externalUnmount
(
mountPoint
string
)
error
{
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
unmountTimeout
)
defer
cancel
()
// Try generic umount.
if
err
:=
exec
.
CommandContext
(
ctx
,
"umount"
,
mountPoint
)
.
Run
();
err
==
nil
{
return
nil
}
// Try FUSE-specific commands if umount didn't work.
switch
runtime
.
GOOS
{
switch
runtime
.
GOOS
{
case
"darwin"
:
case
"darwin"
:
cmd
=
exec
.
Command
(
"/usr/bin/diskutil"
,
"umount"
,
"force"
,
mountPoint
)
return
exec
.
CommandContext
(
ctx
,
"diskutil"
,
"umount"
,
"force"
,
mountPoint
)
.
Run
()
case
"linux"
:
case
"linux"
:
cmd
=
exec
.
Command
(
"fusermount"
,
"-u"
,
mountPoint
)
return
exec
.
CommandContext
(
ctx
,
"fusermount"
,
"-u"
,
mountPoint
)
.
Run
()
default
:
default
:
return
fmt
.
Errorf
(
"unmount: unimplemented"
)
return
fmt
.
Errorf
(
"unmount: unimplemented"
)
}
}
errc
:=
make
(
chan
error
,
1
)
go
func
()
{
defer
close
(
errc
)
if
err
:=
exec
.
Command
(
"umount"
,
mountPoint
)
.
Run
();
err
==
nil
{
return
}
errc
<-
cmd
.
Run
()
}()
select
{
case
<-
time
.
After
(
unmountTimeout
)
:
return
fmt
.
Errorf
(
"umount timeout"
)
case
err
:=
<-
errc
:
return
err
}
}
}
func
addFileToSwarm
(
sf
*
SwarmFile
,
content
[]
byte
,
size
int
)
error
{
func
addFileToSwarm
(
sf
*
SwarmFile
,
content
[]
byte
,
size
int
)
error
{
...
...
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