Skip to content
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

Add option for lazy unmount #459

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions fuse/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,10 @@ type MountOptions struct {
// directory queries (i.e. 'ls' without '-l') can be faster with
// ReadDir, as no per-file stat calls are needed
DisableReadDirPlus bool

// LazyUnmount is used to calling fusermount with -z flag which make unmount
// works even if resource is still busy
LazyUnmount bool
}

// RawFileSystem is an interface close to the FUSE wire protocol.
Expand Down
6 changes: 5 additions & 1 deletion fuse/mount_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,11 @@ func unmount(mountPoint string, opts *MountOptions) (err error) {
return err
}
errBuf := bytes.Buffer{}
cmd := exec.Command(bin, "-u", mountPoint)
args := []string{"-u", mountPoint}
if opts.LazyUnmount {
args[0] = "-uz"
}
cmd := exec.Command(bin, args...)
cmd.Stderr = &errBuf
if opts.Debug {
log.Printf("unmount: executing %q", cmd.Args)
Expand Down