|
|
@ -73,6 +73,7 @@ type posix struct { |
|
|
|
diskMount bool // indicates if the path is an actual mount.
|
|
|
|
diskMount bool // indicates if the path is an actual mount.
|
|
|
|
driveSync bool // indicates if the backend is synchronous.
|
|
|
|
driveSync bool // indicates if the backend is synchronous.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
diskFileInfo os.FileInfo |
|
|
|
// Disk usage metrics
|
|
|
|
// Disk usage metrics
|
|
|
|
stopUsageCh chan struct{} |
|
|
|
stopUsageCh chan struct{} |
|
|
|
} |
|
|
|
} |
|
|
@ -177,7 +178,10 @@ func newPosix(path string) (*posix, error) { |
|
|
|
if path, err = getValidPath(path); err != nil { |
|
|
|
if path, err = getValidPath(path); err != nil { |
|
|
|
return nil, err |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
fi, err := os.Stat(path) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
return nil, err |
|
|
|
|
|
|
|
} |
|
|
|
p := &posix{ |
|
|
|
p := &posix{ |
|
|
|
connected: true, |
|
|
|
connected: true, |
|
|
|
diskPath: path, |
|
|
|
diskPath: path, |
|
|
@ -189,6 +193,7 @@ func newPosix(path string) (*posix, error) { |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
stopUsageCh: make(chan struct{}), |
|
|
|
stopUsageCh: make(chan struct{}), |
|
|
|
|
|
|
|
diskFileInfo: fi, |
|
|
|
diskMount: mountinfo.IsLikelyMountPoint(path), |
|
|
|
diskMount: mountinfo.IsLikelyMountPoint(path), |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -351,7 +356,7 @@ func (s *posix) checkDiskFound() (err error) { |
|
|
|
if !s.IsOnline() { |
|
|
|
if !s.IsOnline() { |
|
|
|
return errDiskNotFound |
|
|
|
return errDiskNotFound |
|
|
|
} |
|
|
|
} |
|
|
|
_, err = os.Stat(s.diskPath) |
|
|
|
fi, err := os.Stat(s.diskPath) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
switch { |
|
|
|
switch { |
|
|
|
case os.IsNotExist(err): |
|
|
|
case os.IsNotExist(err): |
|
|
@ -364,6 +369,10 @@ func (s *posix) checkDiskFound() (err error) { |
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if !os.SameFile(s.diskFileInfo, fi) { |
|
|
|
|
|
|
|
s.connected = false |
|
|
|
|
|
|
|
return errDiskNotFound |
|
|
|
|
|
|
|
} |
|
|
|
return nil |
|
|
|
return nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|