summaryrefslogtreecommitdiff
path: root/src/cryptsetup
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2019-03-19 21:42:21 +0100
committerLennart Poettering <lennart@poettering.net>2019-03-20 10:48:33 +0100
commitd5d1ae153f394aa08e436a747d20702b18e79f00 (patch)
treea5af25604d240671a38e6569a9413be3cba5c610 /src/cryptsetup
parentdc502f89167e4b0738f77e090d18694e4ca38386 (diff)
downloadsystemd-d5d1ae153f394aa08e436a747d20702b18e79f00.tar.gz
cryptsetup: small refactoring
Diffstat (limited to 'src/cryptsetup')
-rw-r--r--src/cryptsetup/cryptsetup.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/src/cryptsetup/cryptsetup.c b/src/cryptsetup/cryptsetup.c
index 87e0cefbab..1f0e34b038 100644
--- a/src/cryptsetup/cryptsetup.c
+++ b/src/cryptsetup/cryptsetup.c
@@ -612,6 +612,24 @@ static int help(void) {
return 0;
}
+static uint32_t determine_flags(void) {
+ uint32_t flags = 0;
+
+ if (arg_readonly)
+ flags |= CRYPT_ACTIVATE_READONLY;
+
+ if (arg_discards)
+ flags |= CRYPT_ACTIVATE_ALLOW_DISCARDS;
+
+ if (arg_same_cpu_crypt)
+ flags |= CRYPT_ACTIVATE_SAME_CPU_CRYPT;
+
+ if (arg_submit_from_crypt_cpus)
+ flags |= CRYPT_ACTIVATE_SUBMIT_FROM_CRYPT_CPUS;
+
+ return flags;
+}
+
static int run(int argc, char *argv[]) {
_cleanup_(crypt_freep) struct crypt_device *cd = NULL;
int r;
@@ -676,17 +694,7 @@ static int run(int argc, char *argv[]) {
return 0;
}
- if (arg_readonly)
- flags |= CRYPT_ACTIVATE_READONLY;
-
- if (arg_discards)
- flags |= CRYPT_ACTIVATE_ALLOW_DISCARDS;
-
- if (arg_same_cpu_crypt)
- flags |= CRYPT_ACTIVATE_SAME_CPU_CRYPT;
-
- if (arg_submit_from_crypt_cpus)
- flags |= CRYPT_ACTIVATE_SUBMIT_FROM_CRYPT_CPUS;
+ flags = determine_flags();
if (arg_timeout == USEC_INFINITY)
until = 0;