Add a check to check if disk is writable (#5662)

This check is a pre-emptive check to return
error early before we attempt to use the disk
for any other operations later.

refer #5645
This commit is contained in:
Harshavardhana
2018-04-09 20:56:09 -07:00
committed by Nitish Tiwari
parent eb0deabd73
commit 217fb470a7
3 changed files with 151 additions and 81 deletions

View File

@@ -24,11 +24,9 @@ import (
"io/ioutil"
"os"
"path"
"path/filepath"
"reflect"
"sort"
"sync"
"syscall"
"time"
"github.com/minio/minio-go/pkg/policy"
@@ -104,33 +102,7 @@ func NewFSObjectLayer(fsPath string) (ObjectLayer, error) {
}
var err error
// Disallow relative paths, figure out absolute paths.
fsPath, err = filepath.Abs(fsPath)
if err != nil {
return nil, err
}
fi, err := os.Stat((fsPath))
if err == nil {
if !fi.IsDir() {
return nil, syscall.ENOTDIR
}
}
if os.IsNotExist(err) {
// Disk not found create it.
err = os.MkdirAll(fsPath, 0777)
if err != nil {
return nil, err
}
}
di, err := getDiskInfo((fsPath))
if err != nil {
return nil, err
}
// Check if disk has minimum required total space.
if err = checkDiskMinTotal(di); err != nil {
if fsPath, err = checkPathValid(fsPath); err != nil {
return nil, err
}