|
@@ -32,12 +32,12 @@ type StoragePool struct {
|
|
|
3. denied
|
|
|
*/
|
|
|
|
|
|
-//Create all the required folder structure if it didn't exists
|
|
|
+// Create all the required folder structure if it didn't exists
|
|
|
func init() {
|
|
|
os.MkdirAll("./system/storage", 0755)
|
|
|
}
|
|
|
|
|
|
-//Create a new StoragePool objects with given uuids
|
|
|
+// Create a new StoragePool objects with given uuids
|
|
|
func NewStoragePool(fsHandlers []*fs.FileSystemHandler, owner string) (*StoragePool, error) {
|
|
|
//Move all fshandler into the storageHandler
|
|
|
storageHandlers := []*fs.FileSystemHandler{}
|
|
@@ -53,7 +53,7 @@ func NewStoragePool(fsHandlers []*fs.FileSystemHandler, owner string) (*StorageP
|
|
|
}, nil
|
|
|
}
|
|
|
|
|
|
-//Check if this storage pool contain this particular disk ID
|
|
|
+// Check if this storage pool contain this particular disk ID
|
|
|
func (s *StoragePool) ContainDiskID(diskID string) bool {
|
|
|
for _, fsh := range s.Storages {
|
|
|
if fsh.UUID == diskID {
|
|
@@ -64,7 +64,7 @@ func (s *StoragePool) ContainDiskID(diskID string) bool {
|
|
|
return false
|
|
|
}
|
|
|
|
|
|
-//Use to compare two StoragePool permissions leve
|
|
|
+// Use to compare two StoragePool permissions leve
|
|
|
func (s *StoragePool) HasHigherOrEqualPermissionThan(a *StoragePool) bool {
|
|
|
if s.OtherPermission == arozfs.FsReadOnly && a.OtherPermission == arozfs.FsReadWrite {
|
|
|
return false
|
|
@@ -74,7 +74,7 @@ func (s *StoragePool) HasHigherOrEqualPermissionThan(a *StoragePool) bool {
|
|
|
return true
|
|
|
}
|
|
|
|
|
|
-//Get fsh from virtual path
|
|
|
+// Get fsh from virtual path
|
|
|
func (s *StoragePool) GetFSHandlerFromVirtualPath(vpath string) (*fs.FileSystemHandler, string, error) {
|
|
|
fshid, subpath, err := filesystem.GetIDFromVirtualPath(vpath)
|
|
|
if err != nil {
|
|
@@ -104,7 +104,7 @@ func (s *StoragePool) GetFsHandlerByUUID(uuid string) (*fs.FileSystemHandler, er
|
|
|
return nil, arozfs.ErrFSHNotFOund
|
|
|
}
|
|
|
|
|
|
-//Attach a file system handler to this pool
|
|
|
+// Attach a file system handler to this pool
|
|
|
func (s *StoragePool) AttachFsHandler(fsh *filesystem.FileSystemHandler) error {
|
|
|
if s.ContainDiskID(fsh.UUID) {
|
|
|
return errors.New("file system handler with same uuid already exists in this pool")
|
|
@@ -114,7 +114,7 @@ func (s *StoragePool) AttachFsHandler(fsh *filesystem.FileSystemHandler) error {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
-//Detech a file system handler from this pool array
|
|
|
+// Detech a file system handler from this pool array
|
|
|
func (s *StoragePool) DetachFsHandler(uuid string) {
|
|
|
newFshList := []*fs.FileSystemHandler{}
|
|
|
for _, fsh := range s.Storages {
|
|
@@ -126,7 +126,7 @@ func (s *StoragePool) DetachFsHandler(uuid string) {
|
|
|
s.Storages = newFshList
|
|
|
}
|
|
|
|
|
|
-//Close all fsHandler under this storage pool
|
|
|
+// Close all fsHandler under this storage pool
|
|
|
func (s *StoragePool) Close() {
|
|
|
//For each storage pool, close it
|
|
|
for _, fsh := range s.Storages {
|