diff options
author | Lennart Poettering <lennart@poettering.net> | 2019-03-19 21:42:21 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2019-03-20 10:48:33 +0100 |
commit | d5d1ae153f394aa08e436a747d20702b18e79f00 (patch) | |
tree | a5af25604d240671a38e6569a9413be3cba5c610 /src/cryptsetup | |
parent | dc502f89167e4b0738f77e090d18694e4ca38386 (diff) | |
download | systemd-d5d1ae153f394aa08e436a747d20702b18e79f00.tar.gz |
cryptsetup: small refactoring
Diffstat (limited to 'src/cryptsetup')
-rw-r--r-- | src/cryptsetup/cryptsetup.c | 30 |
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; |