mirror of
https://github.com/minio/minio.git
synced 2024-12-26 07:05:55 -05:00
Merge pull request #869 from abperiasamy/donut-check
remove mount-point requirement
This commit is contained in:
commit
7b934a7c6c
@ -17,39 +17,31 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"syscall"
|
|
||||||
|
|
||||||
"github.com/minio/minio/pkg/probe"
|
"github.com/minio/minio/pkg/probe"
|
||||||
)
|
)
|
||||||
|
|
||||||
// isUsable provides a comprehensive way of knowing if the provided mountPath is mounted and writable
|
// isUsable provides a comprehensive way of knowing if the provided mountPath is mounted and writable
|
||||||
func isUsable(mountPath string) (bool, *probe.Error) {
|
func isUsable(mountPath string) (bool, *probe.Error) {
|
||||||
mntpoint, err := os.Stat(mountPath)
|
_, e := os.Stat(mountPath)
|
||||||
if err != nil {
|
if e != nil {
|
||||||
return false, probe.NewError(err)
|
e := os.MkdirAll(mountPath, 0700)
|
||||||
|
if e != nil {
|
||||||
|
return false, probe.NewError(e)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
parent, err := os.Stat("/")
|
|
||||||
if err != nil {
|
|
||||||
return false, probe.NewError(err)
|
|
||||||
}
|
|
||||||
mntpointSt := mntpoint.Sys().(*syscall.Stat_t)
|
|
||||||
parentSt := parent.Sys().(*syscall.Stat_t)
|
|
||||||
|
|
||||||
if mntpointSt.Dev == parentSt.Dev {
|
testFile, e := ioutil.TempFile(mountPath, "writetest-")
|
||||||
return false, probe.NewError(fmt.Errorf("Not mounted %s", mountPath))
|
if e != nil {
|
||||||
|
return false, probe.NewError(e)
|
||||||
}
|
}
|
||||||
testFile, err := ioutil.TempFile(mountPath, "writetest-")
|
|
||||||
if err != nil {
|
|
||||||
return false, probe.NewError(err)
|
|
||||||
}
|
|
||||||
// close the file, to avoid leaky fd's
|
|
||||||
defer testFile.Close()
|
defer testFile.Close()
|
||||||
|
|
||||||
testFileName := testFile.Name()
|
testFileName := testFile.Name()
|
||||||
if err := os.Remove(testFileName); err != nil {
|
if e := os.Remove(testFileName); e != nil {
|
||||||
return false, probe.NewError(err)
|
return false, probe.NewError(e)
|
||||||
}
|
}
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user