Browse Source

Added Network drive check in mount point option

Toby Chui 2 years ago
parent
commit
9e86959d4b
2 changed files with 12 additions and 12 deletions
  1. 4 4
      mod/filesystem/config.go
  2. 8 8
      mod/storage/storage.go

+ 4 - 4
mod/filesystem/config.go

@@ -7,7 +7,7 @@ import (
 	"imuslab.com/arozos/mod/filesystem/arozfs"
 )
 
-//FileSystem configuration. Append more lines if required.
+// FileSystem configuration. Append more lines if required.
 type FileSystemOption struct {
 	Name       string `json:"name"`                 //Display name of this device
 	Uuid       string `json:"uuid"`                 //UUID of this device, e.g. S1
@@ -23,7 +23,7 @@ type FileSystemOption struct {
 	Password string `json:"password,omitempty"` //Password if the storage require auth
 }
 
-//Parse a list of StorageConfig from the given json content
+// Parse a list of StorageConfig from the given json content
 func loadConfigFromJSON(jsonContent []byte) ([]FileSystemOption, error) {
 	storageInConfig := []FileSystemOption{}
 	//Try to parse the JSON content
@@ -31,7 +31,7 @@ func loadConfigFromJSON(jsonContent []byte) ([]FileSystemOption, error) {
 	return storageInConfig, err
 }
 
-//Validate if the given options are correct
+// Validate if the given options are correct
 func ValidateOption(options *FileSystemOption) error {
 	//Check if path exists
 	if options.Name == "" {
@@ -66,7 +66,7 @@ func ValidateOption(options *FileSystemOption) error {
 	}
 
 	//Check if mount point exists
-	if options.Mountpt != "" {
+	if options.Mountpt != "" && !arozfs.IsNetworkDrive(options.Filesystem) {
 		return errors.New("Mount point cannot be empty")
 	}
 

+ 8 - 8
mod/storage/storage.go

@@ -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 {