-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
simple nofuse build tag #853
+204
−145
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// +build (linux darwin freebsd) and nofuse | ||
|
||
package commands | ||
|
||
import ( | ||
"errors" | ||
|
||
cmds "github.com/jbenet/go-ipfs/commands" | ||
"github.com/jbenet/go-ipfs/core" | ||
) | ||
|
||
var MountCmd = &cmds.Command{ | ||
Helptext: cmds.HelpText{ | ||
Tagline: "Mounts IPFS to the filesystem (disabled)", | ||
ShortDescription: ` | ||
This version of ipfs is compiled without fuse support, which is required | ||
for mounting. If you'd like to be able to mount, please use a version of | ||
ipfs compiled with fuse. | ||
|
||
For the latest instructions, please check the project's repository: | ||
http://github.com/jbenet/go-ipfs | ||
`, | ||
}, | ||
} | ||
|
||
func Mount(node *core.IpfsNode, fsdir, nsdir string) error { | ||
return errors.New("not compiled in") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// +build linux darwin freebsd | ||
// +build (linux darwin freebsd) and !nofuse | ||
|
||
package commands | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package ipns | ||
|
||
import ( | ||
"github.com/jbenet/go-ipfs/core" | ||
mdag "github.com/jbenet/go-ipfs/merkledag" | ||
nsys "github.com/jbenet/go-ipfs/namesys" | ||
ci "github.com/jbenet/go-ipfs/p2p/crypto" | ||
ft "github.com/jbenet/go-ipfs/unixfs" | ||
) | ||
|
||
// InitializeKeyspace sets the ipns record for the given key to | ||
// point to an empty directory. | ||
func InitializeKeyspace(n *core.IpfsNode, key ci.PrivKey) error { | ||
emptyDir := &mdag.Node{Data: ft.FolderPBData()} | ||
nodek, err := n.DAG.Add(emptyDir) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
err = n.Pinning.Pin(emptyDir, false) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
err = n.Pinning.Flush() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
pub := nsys.NewRoutingPublisher(n.Routing) | ||
err = pub.Publish(n.Context(), key, nodek) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// +build !nofuse | ||
|
||
package ipns | ||
|
||
import ( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// +build linux darwin freebsd | ||
// +build (linux darwin freebsd) and !nofuse | ||
|
||
package ipns | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// +build !nofuse | ||
|
||
package ipns | ||
|
||
import "time" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
// +build !nofuse | ||
|
||
package mount | ||
|
||
import ( | ||
"fmt" | ||
"time" | ||
|
||
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/bazil.org/fuse" | ||
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/bazil.org/fuse/fs" | ||
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-ctxgroup" | ||
) | ||
|
||
// mount implements go-ipfs/fuse/mount | ||
type mount struct { | ||
mpoint string | ||
filesys fs.FS | ||
fuseConn *fuse.Conn | ||
// closeErr error | ||
|
||
cg ctxgroup.ContextGroup | ||
} | ||
|
||
// Mount mounts a fuse fs.FS at a given location, and returns a Mount instance. | ||
// parent is a ContextGroup to bind the mount's ContextGroup to. | ||
func NewMount(p ctxgroup.ContextGroup, fsys fs.FS, mountpoint string) (Mount, error) { | ||
conn, err := fuse.Mount(mountpoint) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
m := &mount{ | ||
mpoint: mountpoint, | ||
fuseConn: conn, | ||
filesys: fsys, | ||
cg: ctxgroup.WithParent(p), // link it to parent. | ||
} | ||
m.cg.SetTeardown(m.unmount) | ||
|
||
// launch the mounting process. | ||
if err := m.mount(); err != nil { | ||
m.Unmount() // just in case. | ||
return nil, err | ||
} | ||
|
||
return m, nil | ||
} | ||
|
||
func (m *mount) mount() error { | ||
log.Infof("Mounting %s", m.MountPoint()) | ||
|
||
errs := make(chan error, 1) | ||
go func() { | ||
err := fs.Serve(m.fuseConn, m.filesys) | ||
log.Debugf("Mounting %s -- fs.Serve returned (%s)", err) | ||
errs <- err | ||
close(errs) | ||
}() | ||
|
||
// wait for the mount process to be done, or timed out. | ||
select { | ||
case <-time.After(MountTimeout): | ||
return fmt.Errorf("Mounting %s timed out.", m.MountPoint()) | ||
case err := <-errs: | ||
return err | ||
case <-m.fuseConn.Ready: | ||
} | ||
|
||
// check if the mount process has an error to report | ||
if err := m.fuseConn.MountError; err != nil { | ||
return err | ||
} | ||
|
||
log.Infof("Mounted %s", m.MountPoint()) | ||
return nil | ||
} | ||
|
||
// umount is called exactly once to unmount this service. | ||
// note that closing the connection will not always unmount | ||
// properly. If that happens, we bring out the big guns | ||
// (mount.ForceUnmountManyTimes, exec unmount). | ||
func (m *mount) unmount() error { | ||
log.Infof("Unmounting %s", m.MountPoint()) | ||
|
||
// try unmounting with fuse lib | ||
err := fuse.Unmount(m.MountPoint()) | ||
if err == nil { | ||
return nil | ||
} | ||
log.Debug("fuse unmount err: %s", err) | ||
|
||
// try closing the fuseConn | ||
err = m.fuseConn.Close() | ||
if err == nil { | ||
return nil | ||
} | ||
if err != nil { | ||
log.Debug("fuse conn error: %s", err) | ||
} | ||
|
||
// try mount.ForceUnmountManyTimes | ||
if err := ForceUnmountManyTimes(m, 10); err != nil { | ||
return err | ||
} | ||
|
||
log.Infof("Seemingly unmounted %s", m.MountPoint()) | ||
return nil | ||
} | ||
|
||
func (m *mount) CtxGroup() ctxgroup.ContextGroup { | ||
return m.cg | ||
} | ||
|
||
func (m *mount) MountPoint() string { | ||
return m.mpoint | ||
} | ||
|
||
func (m *mount) Unmount() error { | ||
// call ContextCloser Close(), which calls unmount() exactly once. | ||
return m.cg.Close() | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe: