2 * Generic wrapper for storage functions
5 * Copyright (C) 2018-2020, Ondrej Kozina
7 * This file is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This file 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 GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this file; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #ifndef _UTILS_STORAGE_WRAPPERS_H
23 #define _UTILS_STORAGE_WRAPPERS_H
25 struct crypt_storage_wrapper;
30 #define DISABLE_USPACE (1 << 0)
31 #define DISABLE_KCAPI (1 << 1)
32 #define DISABLE_DMCRYPT (1 << 2)
33 #define OPEN_READONLY (1 << 3)
39 } crypt_storage_wrapper_type;
41 int crypt_storage_wrapper_init(struct crypt_device *cd,
42 struct crypt_storage_wrapper **cw,
43 struct device *device,
48 struct volume_key *vk,
51 void crypt_storage_wrapper_destroy(struct crypt_storage_wrapper *cw);
53 /* !!! when doing 'read' or 'write' all offset values are RELATIVE to data_offset !!! */
54 ssize_t crypt_storage_wrapper_read(struct crypt_storage_wrapper *cw,
55 off_t offset, void *buffer, size_t buffer_length);
56 ssize_t crypt_storage_wrapper_read_decrypt(struct crypt_storage_wrapper *cw,
57 off_t offset, void *buffer, size_t buffer_length);
58 ssize_t crypt_storage_wrapper_decrypt(struct crypt_storage_wrapper *cw,
59 off_t offset, void *buffer, size_t buffer_length);
61 ssize_t crypt_storage_wrapper_write(struct crypt_storage_wrapper *cw,
62 off_t offset, void *buffer, size_t buffer_length);
63 ssize_t crypt_storage_wrapper_encrypt_write(struct crypt_storage_wrapper *cw,
64 off_t offset, void *buffer, size_t buffer_length);
65 ssize_t crypt_storage_wrapper_encrypt(struct crypt_storage_wrapper *cw,
66 off_t offset, void *buffer, size_t buffer_length);
68 int crypt_storage_wrapper_datasync(const struct crypt_storage_wrapper *cw);
70 crypt_storage_wrapper_type crypt_storage_wrapper_get_type(const struct crypt_storage_wrapper *cw);