diff --git a/lib/backend.py b/lib/backend.py index 4e9d8958ae4d689d6a547b318a3ff323789865fd..0a3f2dc8942169652f3e81b4ed6a37f51160ced1 100644 --- a/lib/backend.py +++ b/lib/backend.py @@ -2743,16 +2743,10 @@ def _TransformFileStorageDir(fs_dir): if not (constants.ENABLE_FILE_STORAGE or constants.ENABLE_SHARED_FILE_STORAGE): _Fail("File storage disabled at configure time") - cfg = _GetConfig() - fs_dir = os.path.normpath(fs_dir) - base_fstore = cfg.GetFileStorageDir() - base_shared = cfg.GetSharedFileStorageDir() - if not (utils.IsBelowDir(base_fstore, fs_dir) or - utils.IsBelowDir(base_shared, fs_dir)): - _Fail("File storage directory '%s' is not under base file" - " storage directory '%s' or shared storage directory '%s'", - fs_dir, base_fstore, base_shared) - return fs_dir + + bdev.CheckFileStoragePath(fs_dir) + + return os.path.normpath(fs_dir) def CreateFileStorageDir(file_storage_dir): diff --git a/lib/bdev.py b/lib/bdev.py index 725c9521bd09cfed5960d27859e6b6e581339ce8..6c20b4bbd42af1d4702dfb36a52fce891585a7bc 100644 --- a/lib/bdev.py +++ b/lib/bdev.py @@ -2245,6 +2245,9 @@ class FileStorage(BlockDev): raise ValueError("Invalid configuration data %s" % str(unique_id)) self.driver = unique_id[0] self.dev_path = unique_id[1] + + CheckFileStoragePath(self.dev_path) + self.Attach() def Assemble(self): @@ -2361,7 +2364,11 @@ class FileStorage(BlockDev): """ if not isinstance(unique_id, (tuple, list)) or len(unique_id) != 2: raise ValueError("Invalid configuration data %s" % str(unique_id)) + dev_path = unique_id[1] + + CheckFileStoragePath(dev_path) + try: fd = os.open(dev_path, os.O_RDWR | os.O_CREAT | os.O_EXCL) f = os.fdopen(fd, "w")