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 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions fuse/api.go
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
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 = append(args, "-z")
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

	args := []string{"-u", mountPoint}
	if opts.LazyUnmount {
		args[0] = "-uz"
	}

Looks better to me as it avoids re-sizing the slice

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed

cmd := exec.Command(bin, args...)
cmd.Stderr = &errBuf
if opts.Debug {
log.Printf("unmount: executing %q", cmd.Args)
Expand Down