summary refs log tree commit diff
path: root/nixos/modules/system/activation
diff options
context:
space:
mode:
authorzimbatm <zimbatm@zimbatm.com>2016-02-26 00:33:49 +0000
committerzimbatm <zimbatm@zimbatm.com>2016-02-26 00:33:49 +0000
commitb73c5ae29135a37e6342e84a0623a3a43d256b2d (patch)
tree0fbdcb3c69621576dd21473ce5bb80675459e82e /nixos/modules/system/activation
parent30891166be9156c65a50c52cd08f3c7a0f5492da (diff)
parent80fb17b251d163345ddf8aa14be283dd2f9cbcc5 (diff)
downloadnixlib-b73c5ae29135a37e6342e84a0623a3a43d256b2d.tar
nixlib-b73c5ae29135a37e6342e84a0623a3a43d256b2d.tar.gz
nixlib-b73c5ae29135a37e6342e84a0623a3a43d256b2d.tar.bz2
nixlib-b73c5ae29135a37e6342e84a0623a3a43d256b2d.tar.lz
nixlib-b73c5ae29135a37e6342e84a0623a3a43d256b2d.tar.xz
nixlib-b73c5ae29135a37e6342e84a0623a3a43d256b2d.tar.zst
nixlib-b73c5ae29135a37e6342e84a0623a3a43d256b2d.zip
Merge pull request #10546 from aszlig/nixops-issue-350
Fixes for NixOps issue #350
Diffstat (limited to 'nixos/modules/system/activation')
-rw-r--r--nixos/modules/system/activation/switch-to-configuration.pl14
1 files changed, 7 insertions, 7 deletions
diff --git a/nixos/modules/system/activation/switch-to-configuration.pl b/nixos/modules/system/activation/switch-to-configuration.pl
index d9048427801f..093b7f1ff225 100644
--- a/nixos/modules/system/activation/switch-to-configuration.pl
+++ b/nixos/modules/system/activation/switch-to-configuration.pl
@@ -261,12 +261,12 @@ while (my ($unit, $state) = each %{$activePrev}) {
 
 sub pathToUnitName {
     my ($path) = @_;
-    die unless substr($path, 0, 1) eq "/";
-    return "-" if $path eq "/";
-    $path = substr($path, 1);
-    $path =~ s/\//-/g;
-    # FIXME: handle - and unprintable characters.
-    return $path;
+    open my $cmd, "-|", "systemd-escape", "--suffix=mount", "-p", $path
+        or die "Unable to escape $path!\n";
+    my $escaped = join "", <$cmd>;
+    chomp $escaped;
+    close $cmd or die;
+    return $escaped;
 }
 
 sub unique {
@@ -290,7 +290,7 @@ my ($newFss, $newSwaps) = parseFstab "$out/etc/fstab";
 foreach my $mountPoint (keys %$prevFss) {
     my $prev = $prevFss->{$mountPoint};
     my $new = $newFss->{$mountPoint};
-    my $unit = pathToUnitName($mountPoint) . ".mount";
+    my $unit = pathToUnitName($mountPoint);
     if (!defined $new) {
         # Filesystem entry disappeared, so unmount it.
         $unitsToStop{$unit} = 1;