"Fossies" - the Fresh Open Source Software Archive

Member "cryptsetup-2.4.3/lib/utils_storage_wrappers.h" (13 Jan 2022, 2621 Bytes) of package /linux/misc/cryptsetup-2.4.3.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "utils_storage_wrappers.h" see the Fossies "Dox" file reference documentation.

    1 /*
    2  * Generic wrapper for storage functions
    3  * (experimental only)
    4  *
    5  * Copyright (C) 2018-2021, Ondrej Kozina
    6  *
    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.
   11  *
   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.
   16  *
   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.
   20  */
   21 
   22 #ifndef _UTILS_STORAGE_WRAPPERS_H
   23 #define _UTILS_STORAGE_WRAPPERS_H
   24 
   25 #include <stdint.h>
   26 #include <sys/types.h>
   27 
   28 struct crypt_storage_wrapper;
   29 struct device;
   30 struct volume_key;
   31 struct crypt_device;
   32 
   33 #define DISABLE_USPACE  (1 << 0)
   34 #define DISABLE_KCAPI   (1 << 1)
   35 #define DISABLE_DMCRYPT (1 << 2)
   36 #define OPEN_READONLY   (1 << 3)
   37 #define LARGE_IV    (1 << 4)
   38 
   39 typedef enum {
   40     NONE = 0,
   41     USPACE,
   42     DMCRYPT
   43 } crypt_storage_wrapper_type;
   44 
   45 int crypt_storage_wrapper_init(struct crypt_device *cd,
   46     struct crypt_storage_wrapper **cw,
   47     struct device *device,
   48     uint64_t data_offset,
   49     uint64_t iv_start,
   50     int sector_size,
   51     const char *cipher,
   52     struct volume_key *vk,
   53     uint32_t flags);
   54 
   55 void crypt_storage_wrapper_destroy(struct crypt_storage_wrapper *cw);
   56 
   57 /* !!! when doing 'read' or 'write' all offset values are RELATIVE to data_offset !!! */
   58 ssize_t crypt_storage_wrapper_read(struct crypt_storage_wrapper *cw,
   59         off_t offset, void *buffer, size_t buffer_length);
   60 ssize_t crypt_storage_wrapper_read_decrypt(struct crypt_storage_wrapper *cw,
   61         off_t offset, void *buffer, size_t buffer_length);
   62 ssize_t crypt_storage_wrapper_decrypt(struct crypt_storage_wrapper *cw,
   63         off_t offset, void *buffer, size_t buffer_length);
   64 
   65 ssize_t crypt_storage_wrapper_write(struct crypt_storage_wrapper *cw,
   66         off_t offset, void *buffer, size_t buffer_length);
   67 ssize_t crypt_storage_wrapper_encrypt_write(struct crypt_storage_wrapper *cw,
   68         off_t offset, void *buffer, size_t buffer_length);
   69 ssize_t crypt_storage_wrapper_encrypt(struct crypt_storage_wrapper *cw,
   70         off_t offset, void *buffer, size_t buffer_length);
   71 
   72 int crypt_storage_wrapper_datasync(const struct crypt_storage_wrapper *cw);
   73 
   74 crypt_storage_wrapper_type crypt_storage_wrapper_get_type(const struct crypt_storage_wrapper *cw);
   75 #endif