2 * libdevmapper - device-mapper backend for cryptsetup
4 * Copyright (C) 2004, Christophe Saout <christophe@saout.de>
5 * Copyright (C) 2004-2007, Clemens Fruhwirth <clemens@endorphin.org>
6 * Copyright (C) 2009-2012, Red Hat, Inc. All rights reserved.
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 /* device-mapper library helpers */
31 /* Device mapper backend - kernel support flags */
32 #define DM_KEY_WIPE_SUPPORTED (1 << 0) /* key wipe message */
33 #define DM_LMK_SUPPORTED (1 << 1) /* lmk mode */
34 #define DM_SECURE_SUPPORTED (1 << 2) /* wipe (secure) buffer flag */
35 #define DM_PLAIN64_SUPPORTED (1 << 3) /* plain64 IV */
36 #define DM_DISCARDS_SUPPORTED (1 << 4) /* discards/TRIM option is supported */
37 uint32_t dm_flags(void);
39 #define DM_ACTIVE_DEVICE (1 << 0)
40 #define DM_ACTIVE_CIPHER (1 << 1)
41 #define DM_ACTIVE_UUID (1 << 2)
42 #define DM_ACTIVE_KEYSIZE (1 << 3)
43 #define DM_ACTIVE_KEY (1 << 4)
45 struct crypt_dm_active_device {
50 /* Active key for device */
51 struct volume_key *vk;
53 /* struct crypt_active_device */
54 uint64_t offset; /* offset in sectors */
55 uint64_t iv_offset; /* IV initilisation sector */
56 uint64_t size; /* active device size */
57 uint32_t flags; /* activation flags */
60 const char *dm_get_dir(void);
61 int dm_init(struct crypt_device *context, int check_kernel);
63 int dm_remove_device(const char *name, int force, uint64_t size);
64 int dm_status_device(const char *name);
65 int dm_status_suspended(const char *name);
66 int dm_query_device(const char *name, uint32_t get_flags,
67 struct crypt_dm_active_device *dmd);
68 int dm_create_device(const char *name,
70 struct crypt_dm_active_device *dmd,
72 int dm_suspend_and_wipe_key(const char *name);
73 int dm_resume_and_reinstate_key(const char *name,
76 char *dm_device_path(const char *prefix, int major, int minor);
77 int dm_is_dm_device(int major, int minor);
78 int dm_is_dm_kernel_name(const char *name);
79 int dm_check_segment(const char *name, uint64_t offset, uint64_t size);
81 #endif /* _UTILS_DM_H */