diff options
author | Milan Broz <gmazyland@gmail.com> | 2013-06-23 15:24:01 +0200 |
---|---|---|
committer | Milan Broz <gmazyland@gmail.com> | 2013-06-23 15:24:01 +0200 |
commit | a36de633d50d1e047cf5c0c3bc5e4d16a411fb62 (patch) | |
tree | 8250fea3ec43c3fd867ddd5644642c8dd80d779c | |
parent | 8a43d49b896a434b3ef453fd1b1c8f087d70fa70 (diff) | |
download | cryptsetup-a36de633d50d1e047cf5c0c3bc5e4d16a411fb62.tar.gz cryptsetup-a36de633d50d1e047cf5c0c3bc5e4d16a411fb62.tar.bz2 cryptsetup-a36de633d50d1e047cf5c0c3bc5e4d16a411fb62.zip |
Fix mapping of TCRYPT system encryption for more partitions.
If TCRYPT system encryption uses only partition (not the whole device)
some other partitions could be in use and we have to use
more relaxed check to allow device activation.
-rw-r--r-- | lib/tcrypt/tcrypt.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/tcrypt/tcrypt.c b/lib/tcrypt/tcrypt.c index 811794c..3bab4ba 100644 --- a/lib/tcrypt/tcrypt.c +++ b/lib/tcrypt/tcrypt.c @@ -640,6 +640,7 @@ int TCRYPT_activate(struct crypt_device *cd, unsigned int i; int r; struct tcrypt_algs *algs; + enum devcheck device_check; struct crypt_dm_active_device dmd = { .target = DM_CRYPT, .size = 0, @@ -676,7 +677,18 @@ int TCRYPT_activate(struct crypt_device *cd, else dmd.size = hdr->d.volume_size / hdr->d.sector_size; - r = device_block_adjust(cd, dmd.data_device, DEV_EXCL, + /* + * System encryption use the whole device mapping, there can + * be active partitions. + * FIXME: This will allow multiple mappings unexpectedly. + */ + if ((dmd.flags & CRYPT_ACTIVATE_SHARED) || + (params->flags & CRYPT_TCRYPT_SYSTEM_HEADER)) + device_check = DEV_SHARED; + else + device_check = DEV_EXCL; + + r = device_block_adjust(cd, dmd.data_device, device_check, dmd.u.crypt.offset, &dmd.size, &dmd.flags); if (r) return r; |