]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/nfs: add a helper to validate cephfs path
authorDhairya Parmar <dparmar@redhat.com>
Mon, 7 Aug 2023 11:12:20 +0000 (16:42 +0530)
committerDhairya Parmar <dparmar@redhat.com>
Thu, 13 Mar 2025 12:51:40 +0000 (18:21 +0530)
Fixes: https://tracker.ceph.com/issues/62077
Signed-off-by: Dhairya Parmar <dparmar@redhat.com>
(cherry picked from commit cc7b69f90387d774c150ab5644b89804cbd9c190)

src/pybind/mgr/nfs/export.py

index c6d5afabfef9a4dcca4c2ae235f723c552e38f8b..0d0a189b916311678d2ff93cc5bbbd399a907cd2 100644 (file)
@@ -65,6 +65,17 @@ def normalize_path(path: str) -> str:
     return path
 
 
+def validate_cephfs_path(mgr: 'Module', fs_name: str, path: str) -> None:
+    try:
+        cephfs_path_is_dir(mgr, fs_name, path)
+    except NotADirectoryError:
+        raise NFSException(f"path {path} is not a dir", -errno.ENOTDIR)
+    except cephfs.ObjectNotFound:
+        raise NFSObjectNotFound(f"path {path} does not exist")
+    except cephfs.Error as e:
+        raise NFSException(e.args[1], -e.args[0])
+
+
 class NFSRados:
     def __init__(self, rados: 'Rados', namespace: str) -> None:
         self.rados = rados