Support discard option even for TCRYPT devices.

This commit is contained in:
Milan Broz
2014-01-11 22:13:37 +01:00
parent 3ba95a822f
commit bec86e3d5a
2 changed files with 16 additions and 1 deletions

View File

@@ -458,11 +458,18 @@ Opens the TCRYPT (a TrueCrypt-compatible) <device> and sets up
a mapping <name>. a mapping <name>.
\fB<options>\fR can be [\-\-key\-file, \-\-tcrypt\-hidden, \fB<options>\fR can be [\-\-key\-file, \-\-tcrypt\-hidden,
\-\-tcrypt\-system, \-\-tcrypt\-backup, \-\-readonly, \-\-test\-passphrase]. \-\-tcrypt\-system, \-\-tcrypt\-backup, \-\-readonly, \-\-test\-passphrase,
\-\-allow-discards].
The keyfile parameter allows combination of file content with the The keyfile parameter allows combination of file content with the
passphrase and can be repeated. Note that using keyfiles is compatible passphrase and can be repeated. Note that using keyfiles is compatible
with TCRYPT and is different from LUKS keyfile logic. with TCRYPT and is different from LUKS keyfile logic.
\fBWARNING:\fR Option \fB\-\-allow\-discards\fR cannot be combined with
option \fB\-\-tcrypt\-hidden\fR. For normal mapping it can cause
\fBdestruction of hidden volume\fR (hidden volume appears as unused space
for outer volume so this space can be discarded).
.PP .PP
\fItcryptDump\fR <device> \fItcryptDump\fR <device>
.IP .IP

View File

@@ -251,6 +251,9 @@ static int action_open_tcrypt(void)
if (opt_readonly) if (opt_readonly)
flags |= CRYPT_ACTIVATE_READONLY; flags |= CRYPT_ACTIVATE_READONLY;
if (opt_allow_discards)
flags |= CRYPT_ACTIVATE_ALLOW_DISCARDS;
if (activated_name) if (activated_name)
r = crypt_activate_by_volume_key(cd, activated_name, NULL, 0, flags); r = crypt_activate_by_volume_key(cd, activated_name, NULL, 0, flags);
out: out:
@@ -1628,6 +1631,11 @@ int main(int argc, const char **argv)
_("Option --tcrypt-hidden, --tcrypt-system or --tcrypt-backup is supported only for TCRYPT device.\n"), _("Option --tcrypt-hidden, --tcrypt-system or --tcrypt-backup is supported only for TCRYPT device.\n"),
poptGetInvocationName(popt_context)); poptGetInvocationName(popt_context));
if (opt_tcrypt_hidden && opt_allow_discards)
usage(popt_context, EXIT_FAILURE,
_("Option --tcrypt-hidden cannot be combined with --allow-discards.\n"),
poptGetInvocationName(popt_context));
if (opt_debug) { if (opt_debug) {
opt_verbose = 1; opt_verbose = 1;
crypt_set_debug_level(-1); crypt_set_debug_level(-1);