From 8c356d4f5afcc30ca6d21df4f856334d095ddc39 Mon Sep 17 00:00:00 2001 From: "Anand Babu (AB) Periasamy" Date: Wed, 23 Sep 2015 12:16:18 -0700 Subject: [PATCH] remove mount-point requirement --- donut-disks.go | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/donut-disks.go b/donut-disks.go index 1b63b30f9..2bd5007c7 100644 --- a/donut-disks.go +++ b/donut-disks.go @@ -17,39 +17,31 @@ package main import ( - "fmt" "io/ioutil" "os" - "syscall" "github.com/minio/minio/pkg/probe" ) // isUsable provides a comprehensive way of knowing if the provided mountPath is mounted and writable func isUsable(mountPath string) (bool, *probe.Error) { - mntpoint, err := os.Stat(mountPath) - if err != nil { - return false, probe.NewError(err) + _, e := os.Stat(mountPath) + if e != nil { + 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 { - return false, probe.NewError(fmt.Errorf("Not mounted %s", mountPath)) - } - testFile, err := ioutil.TempFile(mountPath, "writetest-") - if err != nil { - return false, probe.NewError(err) + testFile, e := ioutil.TempFile(mountPath, "writetest-") + if e != nil { + return false, probe.NewError(e) } - // close the file, to avoid leaky fd's defer testFile.Close() + testFileName := testFile.Name() - if err := os.Remove(testFileName); err != nil { - return false, probe.NewError(err) + if e := os.Remove(testFileName); e != nil { + return false, probe.NewError(e) } return true, nil }