X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fcryptsetup%2Fcryptsetup.c;h=b26fcca836993c73019f56f351793bf8f8ad3354;hb=ac7019f33f1618f5b69ed44a8623e2596f1e3856;hp=ac7b6d6c38440838dbf8db643fd096fd65773152;hpb=b4d0195b0598df76d30f006507fa8466f5a5d330;p=elogind.git diff --git a/src/cryptsetup/cryptsetup.c b/src/cryptsetup/cryptsetup.c index ac7b6d6c3..b26fcca83 100644 --- a/src/cryptsetup/cryptsetup.c +++ b/src/cryptsetup/cryptsetup.c @@ -6,16 +6,16 @@ Copyright 2010 Lennart Poettering systemd is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. systemd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. + Lesser General Public License for more details. - You should have received a copy of the GNU General Public License + You should have received a copy of the GNU Lesser General Public License along with systemd; If not, see . ***/ @@ -29,6 +29,7 @@ #include "log.h" #include "util.h" +#include "path-util.h" #include "strv.h" #include "ask-password-api.h" #include "def.h" @@ -40,6 +41,7 @@ static char *opt_hash = NULL; static unsigned opt_tries = 0; static bool opt_readonly = false; static bool opt_verify = false; +static bool opt_discards = false; static usec_t opt_timeout = DEFAULT_TIMEOUT_USEC; /* Options Debian's crypttab knows we don't: @@ -97,6 +99,8 @@ static int parse_one_option(const char *option) { opt_readonly = true; else if (streq(option, "verify")) opt_verify = true; + else if (streq(option, "allow-discards")) + opt_discards = true; else if (streq(option, "luks")) opt_type = CRYPT_LUKS1; else if (streq(option, "plain") || @@ -190,7 +194,8 @@ static char *disk_mount_point(const char *label) { if (asprintf(&device, "/dev/mapper/%s", label) < 0) goto finish; - if (!(f = setmntent("/etc/fstab", "r"))) + f = setmntent("/etc/fstab", "r"); + if (!f) goto finish; while ((m = getmntent(f))) @@ -312,6 +317,9 @@ int main(int argc, char *argv[]) { if (opt_readonly) flags |= CRYPT_ACTIVATE_READONLY; + if (opt_discards) + flags |= CRYPT_ACTIVATE_ALLOW_DISCARDS; + if (opt_timeout > 0) until = now(CLOCK_MONOTONIC) + opt_timeout; else