Copied unmount files from fuseshim.

geesefs-0-30-9
Aaron Jacobs 2015-07-24 16:20:11 +10:00
parent 2ed9350a1b
commit c48e561e20
3 changed files with 41 additions and 20 deletions

View File

@ -1,23 +1,6 @@
// Copyright 2015 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package fuseshim
package fuse
import "github.com/jacobsa/fuse/internal/fuseshim"
// Attempt to unmount the file system whose mount point is the supplied
// directory.
// Unmount tries to unmount the filesystem mounted at dir.
func Unmount(dir string) error {
return fuseshim.Unmount(dir)
return unmount(dir)
}

21
unmount_linux.go Normal file
View File

@ -0,0 +1,21 @@
package fuseshim
import (
"bytes"
"errors"
"os/exec"
)
func unmount(dir string) error {
cmd := exec.Command("fusermount", "-u", dir)
output, err := cmd.CombinedOutput()
if err != nil {
if len(output) > 0 {
output = bytes.TrimRight(output, "\n")
msg := err.Error() + ": " + string(output)
err = errors.New(msg)
}
return err
}
return nil
}

17
unmount_std.go Normal file
View File

@ -0,0 +1,17 @@
// +build !linux
package fuseshim
import (
"os"
"syscall"
)
func unmount(dir string) error {
err := syscall.Unmount(dir, 0)
if err != nil {
err = &os.PathError{Op: "unmount", Path: dir, Err: err}
return err
}
return nil
}