Skip to content
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.
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 = append(args, "-z")
}
Comment on lines +192 to +195

@marius-enlock marius-enlock Apr 25, 2024

Copy link
Copy Markdown

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
Copy Markdown
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