]> git.proxmox.com Git - pve-storage.git/commitdiff
CephFSPlugin: copy over systemd_escape
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 29 Jan 2020 17:00:34 +0000 (18:00 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 29 Jan 2020 17:00:37 +0000 (18:00 +0100)
This is but a hack, but we have no general helper/tools module here
and I do not want to do versioned dependencies for this fast-tracked
bugfix to pve-common, so I'll have to live with the shame for now.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
PVE/Storage/CephFSPlugin.pm

index c18f8c937029d46b68aeafded5ec8d0a9d9c30ad..dcf961c073b6042248ed4d93b756f1ae87007f31 100644 (file)
@@ -37,6 +37,24 @@ sub cephfs_is_mounted {
     return undef;
 }
 
+# FIXME: duplicate of api/diskmanage one, move to common helper (pve-common's
+#        Tools or Systemd ?)
+sub systemd_escape {
+    my ($val, $is_path) = @_;
+
+    # NOTE: this is not complete, but enough for our needs. normally all
+    # characters which are not alpha-numerical, '.' or '_' would need escaping
+    $val =~ s/\-/\\x2d/g;
+
+    if ($is_path) {
+       $val =~ s/^\///g;
+       $val =~ s/\/$//g;
+    }
+    $val =~ s/\//-/g;
+
+    return $val;
+}
+
 sub cephfs_mount {
     my ($scfg, $storeid) = @_;