teknoraver / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone

Blame 0006-cryptsetup-generator-don-t-create-tmp-swap-units.patch

Harald Hoyer d4ee25
From d12ed80037b482f7da136abbd7abce9c9219ef8e Mon Sep 17 00:00:00 2001
Harald Hoyer d4ee25
From: Tom Gundersen <teg@jklm.no>
Harald Hoyer d4ee25
Date: Thu, 15 Aug 2013 08:47:59 +0800
Harald Hoyer d4ee25
Subject: [PATCH] cryptsetup-generator: don't create tmp+swap units
Harald Hoyer d4ee25
Harald Hoyer d4ee25
---
Harald Hoyer d4ee25
 src/cryptsetup/cryptsetup-generator.c | 13 ++++++++++---
Harald Hoyer d4ee25
 1 file changed, 10 insertions(+), 3 deletions(-)
Harald Hoyer d4ee25
Harald Hoyer d4ee25
diff --git a/src/cryptsetup/cryptsetup-generator.c b/src/cryptsetup/cryptsetup-generator.c
Harald Hoyer d4ee25
index 81b7708..967c5e6 100644
Harald Hoyer d4ee25
--- a/src/cryptsetup/cryptsetup-generator.c
Harald Hoyer d4ee25
+++ b/src/cryptsetup/cryptsetup-generator.c
Harald Hoyer d4ee25
@@ -72,13 +72,20 @@ static int create_disk(
Harald Hoyer d4ee25
 
Harald Hoyer d4ee25
         _cleanup_free_ char *p = NULL, *n = NULL, *d = NULL, *u = NULL, *from = NULL, *to = NULL, *e = NULL;
Harald Hoyer d4ee25
         _cleanup_fclose_ FILE *f = NULL;
Harald Hoyer d4ee25
-        bool noauto, nofail;
Harald Hoyer d4ee25
+        bool noauto, nofail, tmp, swap;
Harald Hoyer d4ee25
 
Harald Hoyer d4ee25
         assert(name);
Harald Hoyer d4ee25
         assert(device);
Harald Hoyer d4ee25
 
Harald Hoyer d4ee25
         noauto = has_option(options, "noauto");
Harald Hoyer d4ee25
         nofail = has_option(options, "nofail");
Harald Hoyer d4ee25
+        tmp = has_option(options, "tmp");
Harald Hoyer d4ee25
+        swap = has_option(options, "swap");
Harald Hoyer d4ee25
+
Harald Hoyer d4ee25
+        if (tmp && swap) {
Harald Hoyer d4ee25
+                log_error("Device '%s' cannot be both 'tmp' and 'swap'. Ignoring.", name);
Harald Hoyer d4ee25
+                return -EINVAL;
Harald Hoyer d4ee25
+        }
Harald Hoyer d4ee25
 
Harald Hoyer d4ee25
         n = unit_name_from_path_instance("systemd-cryptsetup", name, ".service");
Harald Hoyer d4ee25
         if (!n)
Harald Hoyer d4ee25
@@ -151,12 +158,12 @@ static int create_disk(
Harald Hoyer d4ee25
                 name, u, strempty(password), strempty(options),
Harald Hoyer d4ee25
                 name);
Harald Hoyer d4ee25
 
Harald Hoyer d4ee25
-        if (has_option(options, "tmp"))
Harald Hoyer d4ee25
+        if (tmp)
Harald Hoyer d4ee25
                 fprintf(f,
Harald Hoyer d4ee25
                         "ExecStartPost=/sbin/mke2fs '/dev/mapper/%s'\n",
Harald Hoyer d4ee25
                         name);
Harald Hoyer d4ee25
 
Harald Hoyer d4ee25
-        if (has_option(options, "swap"))
Harald Hoyer d4ee25
+        if (swap)
Harald Hoyer d4ee25
                 fprintf(f,
Harald Hoyer d4ee25
                         "ExecStartPost=/sbin/mkswap '/dev/mapper/%s'\n",
Harald Hoyer d4ee25
                         name);