Support init_by_name for verity.
[platform/upstream/cryptsetup.git] / lib / luks1 / keyencryption.c
index 680d2e9..c634b68 100644 (file)
@@ -2,6 +2,7 @@
  * LUKS - Linux Unified Key Setup
  *
  * Copyright (C) 2004-2006, Clemens Fruhwirth <clemens@endorphin.org>
+ * Copyright (C) 2009-2012, Red Hat, Inc. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -57,16 +58,22 @@ static int setup_mapping(const char *cipher, const char *name,
 {
        int device_sector_size = sector_size_for_device(device);
        struct crypt_dm_active_device dmd = {
-               .device = device,
-               .cipher = cipher,
+               .target = DM_CRYPT,
                .uuid   = NULL,
-               .vk     = vk,
-               .offset = sector,
-               .iv_offset = 0,
                .size   = 0,
-               .flags  = (mode == O_RDONLY) ? CRYPT_ACTIVATE_READONLY : 0
+               .flags  = 0,
+               .data_device = device,
+               .u.crypt = {
+                       .cipher = cipher,
+                       .vk     = vk,
+                       .offset = sector,
+                       .iv_offset = 0,
+               }
        };
 
+       dmd.flags = CRYPT_ACTIVATE_PRIVATE;
+       if (mode == O_RDONLY)
+               dmd.flags |= CRYPT_ACTIVATE_READONLY;
        /*
         * we need to round this to nearest multiple of the underlying
         * device's sector size, otherwise the mapping will be refused.