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