Skip to content
This repository has been archived by the owner on Feb 12, 2019. It is now read-only.

Commit

Permalink
redirector: add a /keybase entry when KBFS is not running
Browse files Browse the repository at this point in the history
Having an entry here will prevent other mounts from mounting over it,
since it will be non-empty.  That means future `run_keybase` calls
won't keep spinning up new redirector processes, due to the fact that
the running-as-root mount process sees an empty mountpoint.

For now, I just did the simplest thing: a symlink called
"KBFS_NOT_RUNNING" that points to /dev/null.  In the future, it might
be nice to have it point to a README file somewhere on disk, but that
would be a bigger undertaking.

Issue: #1510
  • Loading branch information
strib committed Mar 14, 2018
1 parent bfb7284 commit 1be284f
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion redirector/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ var kbfusePath = fuse.OSXFUSEPaths{

const (
mountpointTimeout = 5 * time.Second
notRunningName = "KBFS_NOT_RUNNING"
)

type symlink struct {
Expand Down Expand Up @@ -204,7 +205,16 @@ func (r *root) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {
_, err := r.findKBFSMount(ctx)
if err != nil {
if err == fuse.ENOENT {
return []fuse.Dirent{}, nil
// Put a symlink in the directory for someone who's not
// logged in, so that the directory is non-empty and
// future redirector calls as root won't try to mount over
// us.
return []fuse.Dirent{
{
Type: fuse.DT_Link,
Name: notRunningName,
},
}, nil
}
return []fuse.Dirent{}, err
}
Expand Down Expand Up @@ -233,6 +243,9 @@ func (r *root) Lookup(
n fs.Node, err error) {
mountpoint, err := r.findKBFSMount(ctx)
if err != nil {
if req.Name == notRunningName {
return symlink{"/dev/null"}, nil
}
return nil, err
}

Expand Down

0 comments on commit 1be284f

Please sign in to comment.