From edaaf47aec2a990f98ecf87e38d400ccd3266bf3 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Wed, 29 Jan 2020 18:00:34 +0100 Subject: [PATCH] CephFSPlugin: copy over systemd_escape 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 --- PVE/Storage/CephFSPlugin.pm | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/PVE/Storage/CephFSPlugin.pm b/PVE/Storage/CephFSPlugin.pm index c18f8c9..dcf961c 100644 --- a/PVE/Storage/CephFSPlugin.pm +++ b/PVE/Storage/CephFSPlugin.pm @@ -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) = @_;