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

51 lines
1.8 KiB
Diff
Raw Normal View History

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