From 111a2350ac1967b62ffa3024371819c812c46844 Mon Sep 17 00:00:00 2001 From: Manuel Bentele Date: Tue, 13 Oct 2020 16:19:21 +0200 Subject: Added support to keep track of kernel file changes in CMake With this patch, CMake keeps track of changes to original xloop Linux kernel source files. CMake will copy each file if a change is detected without rebuiling the CMake build and cache files. Futhrmore, changed default paths of udev rules and xloop kernel modules to be installed. --- CMakeLists.txt | 18 +++--- README.md | 16 ++--- kernel/CMakeLists.txt | 8 +-- kernel/cmake/kernel.cmake | 29 +++++++-- kernel/tests/CMakeLists.txt | 2 +- kernel/tests/include/lapi/xloop.h | 2 +- kernel/tests/lib/CMakeLists.txt | 1 + kernel/tests/lib/tst_device.c | 2 +- kernel/uapi/linux/xloop.h | 125 -------------------------------------- kernel/uapi_xloop.h | 125 ++++++++++++++++++++++++++++++++++++++ kernel/xloop_main.h | 2 +- 11 files changed, 173 insertions(+), 157 deletions(-) delete mode 100644 kernel/uapi/linux/xloop.h create mode 100644 kernel/uapi_xloop.h diff --git a/CMakeLists.txt b/CMakeLists.txt index e1f8eac..54a949a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,8 +9,6 @@ project(xloop DESCRIPTION "xloop Linux kernel modules and utility" LANGUAGES C) -include(GNUInstallDirs) - # define project specific settings set(BLK_DEV_XLOOP_MIN_COUNT 8 CACHE STRING "Number of xloop devices to pre-create at init time") @@ -20,9 +18,9 @@ set(XLOOP_CTRL_MINOR 15 CACHE STRING "Minor number for the xloop-control device") # set Linux kernel directories -set(KERNEL_BUILD_DIR "/${CMAKE_INSTALL_LIBDIR}/modules/${CMAKE_SYSTEM_VERSION}/build" +set(KERNEL_BUILD_DIR "/lib/modules/${CMAKE_SYSTEM_VERSION}/build" CACHE PATH "Path to Linux kernel modules to compile against") -set(KERNEL_INSTALL_DIR "/${CMAKE_INSTALL_LIBDIR}/modules/${CMAKE_SYSTEM_VERSION}/extra" +set(KERNEL_INSTALL_DIR "/lib/modules/${CMAKE_SYSTEM_VERSION}/extra" CACHE PATH "Path to install Linux kernel modules") # print configured settings @@ -74,12 +72,12 @@ if(${CMAKE_BUILD_TYPE} MATCHES Release) set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA ${CMAKE_CURRENT_BINARY_DIR}/package/deb/postinst ${CMAKE_CURRENT_BINARY_DIR}/package/deb/postrm) # set RPM generator specific packaging options - set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/${CMAKE_INSTALL_LIBDIR}" - "/${CMAKE_INSTALL_LIBDIR}/modules" - "/${CMAKE_INSTALL_LIBDIR}/modules/${CMAKE_SYSTEM_VERSION}" - "/${CMAKE_INSTALL_LIBDIR}/modules/${CMAKE_SYSTEM_VERSION}/extra" - "/${CMAKE_INSTALL_LIBDIR}/udev" - "/${CMAKE_INSTALL_LIBDIR}/udev/rules.d" + set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/lib" + "/lib/modules" + "/lib/modules/${CMAKE_SYSTEM_VERSION}" + "/lib/modules/${CMAKE_SYSTEM_VERSION}/extra" + "/lib/udev" + "/lib/udev/rules.d" "${CPACK_PACKAGING_INSTALL_PREFIX}/share/bash-completion" "${CPACK_PACKAGING_INSTALL_PREFIX}/share/bash-completion/completions" "${CPACK_PACKAGING_INSTALL_PREFIX}/share/man" diff --git a/README.md b/README.md index 47f40f1..d1229c9 100644 --- a/README.md +++ b/README.md @@ -73,14 +73,14 @@ cd build ### Configuration A build of the xloop Linux kernel modules and the xlosetup utility can be configured and customized by the following configuration variables (CMake cache entries): -| Variable | Type | Values | Default value | Description | -|:--------------------------|:-------|:----------------------------------------|:--------------------------------------------------|-----------------------------------------------------| -| `CMAKE_BUILD_TYPE` | STRING | {`Debug`, `Release`} | `Debug` | Build configuration of the xloop project. | -| `KERNEL_BUILD_DIR` | PATH | {`a` .. `z`, `A` .. `Z`, `/`, `_`, `-`} | /${CMAKE_INSTALL_LIBDIR}/modules/`uname -r`/build | Path to Linux kernel modules to compile against. | -| `KERNEL_INSTALL_DIR` | PATH | {`a` .. `z`, `A` .. `Z`, `/`, `_`, `-`} | /${CMAKE_INSTALL_LIBDIR}/modules/`uname -r`/extra | Path to install Linux kernel modules. | -| `XLOOP_MAJOR` | NUMBER | {`0` .. `255`} | `120` | Major number for xloop devices. | -| `XLOOP_CTRL_MINOR` | NUMBER | {`0` .. `255`} | `15` | Minor number for the xloop-control device. | -| `BLK_DEV_XLOOP_MIN_COUNT` | NUMBER | {`0` .. `255`} | `8` | Number of xloop devices to pre-create at init time. | +| Variable | Type | Values | Default value | Description | +|:--------------------------|:-------|:----------------------------------------|:------------------------------|-----------------------------------------------------| +| `CMAKE_BUILD_TYPE` | STRING | {`Debug`, `Release`} | `Debug` | Build configuration of the xloop project. | +| `KERNEL_BUILD_DIR` | PATH | {`a` .. `z`, `A` .. `Z`, `/`, `_`, `-`} | /lib/modules/`uname -r`/build | Path to Linux kernel modules to compile against. | +| `KERNEL_INSTALL_DIR` | PATH | {`a` .. `z`, `A` .. `Z`, `/`, `_`, `-`} | /lib/modules/`uname -r`/extra | Path to install Linux kernel modules. | +| `XLOOP_MAJOR` | NUMBER | {`0` .. `255`} | `120` | Major number for xloop devices. | +| `XLOOP_CTRL_MINOR` | NUMBER | {`0` .. `255`} | `15` | Minor number for the xloop-control device. | +| `BLK_DEV_XLOOP_MIN_COUNT` | NUMBER | {`0` .. `255`} | `8` | Number of xloop devices to pre-create at init time. | A value from the range of appropriate values can be assigend to each configuration variable by executing CMake once with the following command pattern: diff --git a/kernel/CMakeLists.txt b/kernel/CMakeLists.txt index 1f266f6..dd12c80 100644 --- a/kernel/CMakeLists.txt +++ b/kernel/CMakeLists.txt @@ -23,7 +23,7 @@ set(KERNEL_MODULE_XLOOP_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/xloop_file_fmt. ${CMAKE_CURRENT_SOURCE_DIR}/xloop_main.c) set(KERNEL_MODULE_XLOOP_HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/xloop_file_fmt.h ${CMAKE_CURRENT_SOURCE_DIR}/xloop_main.h - ${CMAKE_CURRENT_SOURCE_DIR}/uapi) + ${CMAKE_CURRENT_SOURCE_DIR}/uapi_xloop.h) add_kernel_module(xloop "${KERNEL_BUILD_DIR}" "${KERNEL_INSTALL_DIR}" "CONFIG_BLK_DEV_XLOOP=m" @@ -35,7 +35,7 @@ add_kernel_module(xloop "${KERNEL_BUILD_DIR}" set(KERNEL_MODULE_XLOOP_RAW_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/xloop_file_fmt_raw.c) set(KERNEL_MODULE_XLOOP_RAW_HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/xloop_file_fmt.h ${CMAKE_CURRENT_SOURCE_DIR}/xloop_main.h - ${CMAKE_CURRENT_SOURCE_DIR}/uapi) + ${CMAKE_CURRENT_SOURCE_DIR}/uapi_xloop.h) add_kernel_module(xloop_file_fmt_raw "${KERNEL_BUILD_DIR}" "${KERNEL_INSTALL_DIR}" "CONFIG_BLK_DEV_XLOOP_FILE_FMT_RAW=m" @@ -53,7 +53,7 @@ set(KERNEL_MODULE_XLOOP_QCOW_HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/xloop_file ${CMAKE_CURRENT_SOURCE_DIR}/xloop_file_fmt_qcow_main.h ${CMAKE_CURRENT_SOURCE_DIR}/xloop_file_fmt.h ${CMAKE_CURRENT_SOURCE_DIR}/xloop_main.h - ${CMAKE_CURRENT_SOURCE_DIR}/uapi) + ${CMAKE_CURRENT_SOURCE_DIR}/uapi_xloop.h) add_kernel_module(xloop_file_fmt_qcow "${KERNEL_BUILD_DIR}" "${KERNEL_INSTALL_DIR}" "CONFIG_BLK_DEV_XLOOP_FILE_FMT_QCOW=m" @@ -68,6 +68,6 @@ endif() # install udev rules for xloop devices exposed by the xloop kernel module install(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/udev/50-xloop.rules - DESTINATION /${CMAKE_INSTALL_LIBDIR}/udev/rules.d + DESTINATION /lib/udev/rules.d PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT main) diff --git a/kernel/cmake/kernel.cmake b/kernel/cmake/kernel.cmake index 0d843e6..811ce86 100644 --- a/kernel/cmake/kernel.cmake +++ b/kernel/cmake/kernel.cmake @@ -6,15 +6,31 @@ # macro to define kernel module targets macro(add_kernel_module MODULE_NAME KERNEL_BUILD_DIR KERNEL_INSTALL_DIR MODULE_MACRO MODULE_SOURCE_FILES MODULE_HEADER_FILES BUILD_SOURCE_FILE) + # create directory for kernel module + file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_NAME}) # copy build source file - file(COPY ${BUILD_SOURCE_FILE} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_NAME}) + get_filename_component(BUILD_SOURCE_FILENAME ${BUILD_SOURCE_FILE} NAME) + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_NAME}/${BUILD_SOURCE_FILENAME} + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${BUILD_SOURCE_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_NAME} + DEPENDS ${BUILD_SOURCE_FILE}) + set(BUILD_SOURCE_FILE_PREPARED ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_NAME}/${BUILD_SOURCE_FILENAME}) # copy source files foreach(MODULE_SOURCE_FILE ${MODULE_SOURCE_FILES}) - file(COPY ${MODULE_SOURCE_FILE} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_NAME}) + get_filename_component(MODULE_SOURCE_FILENAME ${MODULE_SOURCE_FILE} NAME) + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_NAME}/${MODULE_SOURCE_FILENAME} + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${MODULE_SOURCE_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_NAME} + DEPENDS ${MODULE_SOURCE_FILE}) + set(MODULE_SOURCE_FILES_PREPARED ${MODULE_SOURCE_FILES_PREPARED} + ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_NAME}/${MODULE_SOURCE_FILENAME}) endforeach() # copy header files foreach(MODULE_HEADER_FILE ${MODULE_HEADER_FILES}) - file(COPY ${MODULE_HEADER_FILE} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_NAME}) + get_filename_component(MODULE_HEADER_FILENAME ${MODULE_HEADER_FILE} NAME) + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_NAME}/${MODULE_HEADER_FILENAME} + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${MODULE_HEADER_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_NAME} + DEPENDS ${MODULE_HEADER_FILE}) + set(MODULE_HEADER_FILES_PREPARED ${MODULE_HEADER_FILES_PREPARED} + ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_NAME}/${MODULE_HEADER_FILENAME}) endforeach() # check if module depends on another module if(NOT ${ARGV7} STREQUAL "") @@ -28,9 +44,10 @@ macro(add_kernel_module MODULE_NAME KERNEL_BUILD_DIR KERNEL_INSTALL_DIR MODULE_M KBUILD_EXTRA_SYMBOLS=${MODULE_EXTRA_SYMBOLS}) add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_NAME}/${MODULE_NAME}.ko COMMAND ${MODULE_BUILD_COMMAND} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_NAME} - DEPENDS ${MODULE_SOURCE_FILES} ${MODULE_HEADER_FILES} ${BUILD_SOURCE_FILE} - VERBATIM) + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_NAME} + COMMENT "Build kernel module ${MODULE_NAME}" + DEPENDS ${BUILD_SOURCE_FILE_PREPARED} ${MODULE_HEADER_FILES_PREPARED} ${MODULE_SOURCE_FILES_PREPARED} + VERBATIM) add_custom_target(${MODULE_NAME} ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_NAME}/${MODULE_NAME}.ko ${ARGV7}) install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_NAME}/${MODULE_NAME}.ko DESTINATION ${KERNEL_INSTALL_DIR} diff --git a/kernel/tests/CMakeLists.txt b/kernel/tests/CMakeLists.txt index f086864..e93ff9d 100644 --- a/kernel/tests/CMakeLists.txt +++ b/kernel/tests/CMakeLists.txt @@ -4,7 +4,7 @@ project(xloop-kernel-test) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include/old) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../uapi) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..) # configure configuration config.h and add it to the include directories configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h) diff --git a/kernel/tests/include/lapi/xloop.h b/kernel/tests/include/lapi/xloop.h index 8e57b31..769d1f0 100644 --- a/kernel/tests/include/lapi/xloop.h +++ b/kernel/tests/include/lapi/xloop.h @@ -8,7 +8,7 @@ #include "config.h" #include -#include +#include #ifndef LO_FLAGS_PARTSCAN # define LO_FLAGS_PARTSCAN 8 diff --git a/kernel/tests/lib/CMakeLists.txt b/kernel/tests/lib/CMakeLists.txt index 9cea565..0ce8982 100644 --- a/kernel/tests/lib/CMakeLists.txt +++ b/kernel/tests/lib/CMakeLists.txt @@ -67,3 +67,4 @@ add_library(libltp STATIC ${CMAKE_CURRENT_SOURCE_DIR}/cloner.c ${CMAKE_CURRENT_SOURCE_DIR}/tst_virt.c ${CMAKE_CURRENT_SOURCE_DIR}/tst_wallclock.c) target_include_directories(libltp PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) +target_compile_options(libltp PUBLIC "-Wno-deprecated-declarations") diff --git a/kernel/tests/lib/tst_device.c b/kernel/tests/lib/tst_device.c index 24f34a3..0df8efe 100644 --- a/kernel/tests/lib/tst_device.c +++ b/kernel/tests/lib/tst_device.c @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/kernel/uapi/linux/xloop.h b/kernel/uapi/linux/xloop.h deleted file mode 100644 index 1bf13c6..0000000 --- a/kernel/uapi/linux/xloop.h +++ /dev/null @@ -1,125 +0,0 @@ -/* SPDX-License-Identifier: GPL-1.0+ WITH Linux-syscall-note */ -/* - * include/linux/xloop.h - * - * Written by Theodore Ts'o, 3/29/93. - * - * Copyright 1993 by Theodore Ts'o. Redistribution of this file is - * permitted under the GNU General Public License. - */ -#ifndef _UAPI_LINUX_XLOOP_H -#define _UAPI_LINUX_XLOOP_H - - -#define XLO_NAME_SIZE 64 -#define XLO_KEY_SIZE 32 - - -/* - * xloop flags - */ -enum { - XLO_FLAGS_READ_ONLY = 1, - XLO_FLAGS_AUTOCLEAR = 4, - XLO_FLAGS_PARTSCAN = 8, - XLO_FLAGS_DIRECT_IO = 16, -}; - -/* XLO_FLAGS that can be set using XLOOP_SET_STATUS(64) */ -#define XLOOP_SET_STATUS_SETTABLE_FLAGS (XLO_FLAGS_AUTOCLEAR | XLO_FLAGS_PARTSCAN) - -/* XLO_FLAGS that can be cleared using XLOOP_SET_STATUS(64) */ -#define XLOOP_SET_STATUS_CLEARABLE_FLAGS (XLO_FLAGS_AUTOCLEAR) - -/* XLO_FLAGS that can be set using XLOOP_CONFIGURE */ -#define XLOOP_CONFIGURE_SETTABLE_FLAGS (XLO_FLAGS_READ_ONLY | XLO_FLAGS_AUTOCLEAR \ - | XLO_FLAGS_PARTSCAN | XLO_FLAGS_DIRECT_IO) - -#include /* for __kernel_old_dev_t */ -#include /* for __u64 */ - -/* Backwards compatibility version */ -struct xloop_info { - int xlo_number; /* ioctl r/o */ - __kernel_old_dev_t xlo_device; /* ioctl r/o */ - unsigned long xlo_inode; /* ioctl r/o */ - __kernel_old_dev_t xlo_rdevice; /* ioctl r/o */ - int xlo_offset; - int xlo_encrypt_type; - int xlo_encrypt_key_size; /* ioctl w/o */ - int xlo_flags; - char xlo_name[XLO_NAME_SIZE]; - unsigned char xlo_encrypt_key[XLO_KEY_SIZE]; /* ioctl w/o */ - unsigned long xlo_init[2]; - char reserved[4]; - int xlo_file_fmt_type; -}; - -struct xloop_info64 { - __u64 xlo_device; /* ioctl r/o */ - __u64 xlo_inode; /* ioctl r/o */ - __u64 xlo_rdevice; /* ioctl r/o */ - __u64 xlo_offset; - __u64 xlo_sizelimit; /* bytes, 0 == max available */ - __u32 xlo_number; /* ioctl r/o */ - __u32 xlo_encrypt_type; - __u32 xlo_encrypt_key_size; /* ioctl w/o */ - __u32 xlo_flags; - __u8 xlo_file_name[XLO_NAME_SIZE]; - __u8 xlo_crypt_name[XLO_NAME_SIZE]; - __u8 xlo_encrypt_key[XLO_KEY_SIZE]; /* ioctl w/o */ - __u64 xlo_init[2]; - __u32 xlo_file_fmt_type; -}; - -/** - * struct xloop_config - Complete configuration for a xloop device. - * @fd: fd of the file to be used as a backing file for the xloop device. - * @block_size: block size to use; ignored if 0. - * @info: struct xloop_info64 to configure the xloop device with. - * - * This structure is used with the XLOOP_CONFIGURE ioctl, and can be used to - * atomically setup and configure all xloop device parameters at once. - */ -struct xloop_config { - __u32 fd; - __u32 block_size; - struct xloop_info64 info; - __u64 __reserved[8]; -}; - -/* - * xloop filter types - */ -#define XLO_CRYPT_NONE 0 -#define XLO_CRYPT_XOR 1 -#define XLO_CRYPT_DES 2 -#define XLO_CRYPT_FISH2 3 /* Twofish encryption */ -#define XLO_CRYPT_BLOW 4 -#define XLO_CRYPT_CAST128 5 -#define XLO_CRYPT_IDEA 6 -#define XLO_CRYPT_DUMMY 9 -#define XLO_CRYPT_SKIPJACK 10 -#define XLO_CRYPT_CRYPTOAPI 18 -#define MAX_XLO_CRYPT 20 - -/* - * IOCTL commands --- we will commandeer 0x4C ('L') - */ -#define XLOOP_SET_FD 0x4C00 -#define XLOOP_CLR_FD 0x4C01 -#define XLOOP_SET_STATUS 0x4C02 -#define XLOOP_GET_STATUS 0x4C03 -#define XLOOP_SET_STATUS64 0x4C04 -#define XLOOP_GET_STATUS64 0x4C05 -#define XLOOP_CHANGE_FD 0x4C06 -#define XLOOP_SET_CAPACITY 0x4C07 -#define XLOOP_SET_DIRECT_IO 0x4C08 -#define XLOOP_SET_BLOCK_SIZE 0x4C09 -#define XLOOP_CONFIGURE 0x4C0A - -/* /dev/xloop-control interface */ -#define XLOOP_CTL_ADD 0x4C80 -#define XLOOP_CTL_REMOVE 0x4C81 -#define XLOOP_CTL_GET_FREE 0x4C82 -#endif /* _UAPI_LINUX_XLOOP_H */ diff --git a/kernel/uapi_xloop.h b/kernel/uapi_xloop.h new file mode 100644 index 0000000..1bf13c6 --- /dev/null +++ b/kernel/uapi_xloop.h @@ -0,0 +1,125 @@ +/* SPDX-License-Identifier: GPL-1.0+ WITH Linux-syscall-note */ +/* + * include/linux/xloop.h + * + * Written by Theodore Ts'o, 3/29/93. + * + * Copyright 1993 by Theodore Ts'o. Redistribution of this file is + * permitted under the GNU General Public License. + */ +#ifndef _UAPI_LINUX_XLOOP_H +#define _UAPI_LINUX_XLOOP_H + + +#define XLO_NAME_SIZE 64 +#define XLO_KEY_SIZE 32 + + +/* + * xloop flags + */ +enum { + XLO_FLAGS_READ_ONLY = 1, + XLO_FLAGS_AUTOCLEAR = 4, + XLO_FLAGS_PARTSCAN = 8, + XLO_FLAGS_DIRECT_IO = 16, +}; + +/* XLO_FLAGS that can be set using XLOOP_SET_STATUS(64) */ +#define XLOOP_SET_STATUS_SETTABLE_FLAGS (XLO_FLAGS_AUTOCLEAR | XLO_FLAGS_PARTSCAN) + +/* XLO_FLAGS that can be cleared using XLOOP_SET_STATUS(64) */ +#define XLOOP_SET_STATUS_CLEARABLE_FLAGS (XLO_FLAGS_AUTOCLEAR) + +/* XLO_FLAGS that can be set using XLOOP_CONFIGURE */ +#define XLOOP_CONFIGURE_SETTABLE_FLAGS (XLO_FLAGS_READ_ONLY | XLO_FLAGS_AUTOCLEAR \ + | XLO_FLAGS_PARTSCAN | XLO_FLAGS_DIRECT_IO) + +#include /* for __kernel_old_dev_t */ +#include /* for __u64 */ + +/* Backwards compatibility version */ +struct xloop_info { + int xlo_number; /* ioctl r/o */ + __kernel_old_dev_t xlo_device; /* ioctl r/o */ + unsigned long xlo_inode; /* ioctl r/o */ + __kernel_old_dev_t xlo_rdevice; /* ioctl r/o */ + int xlo_offset; + int xlo_encrypt_type; + int xlo_encrypt_key_size; /* ioctl w/o */ + int xlo_flags; + char xlo_name[XLO_NAME_SIZE]; + unsigned char xlo_encrypt_key[XLO_KEY_SIZE]; /* ioctl w/o */ + unsigned long xlo_init[2]; + char reserved[4]; + int xlo_file_fmt_type; +}; + +struct xloop_info64 { + __u64 xlo_device; /* ioctl r/o */ + __u64 xlo_inode; /* ioctl r/o */ + __u64 xlo_rdevice; /* ioctl r/o */ + __u64 xlo_offset; + __u64 xlo_sizelimit; /* bytes, 0 == max available */ + __u32 xlo_number; /* ioctl r/o */ + __u32 xlo_encrypt_type; + __u32 xlo_encrypt_key_size; /* ioctl w/o */ + __u32 xlo_flags; + __u8 xlo_file_name[XLO_NAME_SIZE]; + __u8 xlo_crypt_name[XLO_NAME_SIZE]; + __u8 xlo_encrypt_key[XLO_KEY_SIZE]; /* ioctl w/o */ + __u64 xlo_init[2]; + __u32 xlo_file_fmt_type; +}; + +/** + * struct xloop_config - Complete configuration for a xloop device. + * @fd: fd of the file to be used as a backing file for the xloop device. + * @block_size: block size to use; ignored if 0. + * @info: struct xloop_info64 to configure the xloop device with. + * + * This structure is used with the XLOOP_CONFIGURE ioctl, and can be used to + * atomically setup and configure all xloop device parameters at once. + */ +struct xloop_config { + __u32 fd; + __u32 block_size; + struct xloop_info64 info; + __u64 __reserved[8]; +}; + +/* + * xloop filter types + */ +#define XLO_CRYPT_NONE 0 +#define XLO_CRYPT_XOR 1 +#define XLO_CRYPT_DES 2 +#define XLO_CRYPT_FISH2 3 /* Twofish encryption */ +#define XLO_CRYPT_BLOW 4 +#define XLO_CRYPT_CAST128 5 +#define XLO_CRYPT_IDEA 6 +#define XLO_CRYPT_DUMMY 9 +#define XLO_CRYPT_SKIPJACK 10 +#define XLO_CRYPT_CRYPTOAPI 18 +#define MAX_XLO_CRYPT 20 + +/* + * IOCTL commands --- we will commandeer 0x4C ('L') + */ +#define XLOOP_SET_FD 0x4C00 +#define XLOOP_CLR_FD 0x4C01 +#define XLOOP_SET_STATUS 0x4C02 +#define XLOOP_GET_STATUS 0x4C03 +#define XLOOP_SET_STATUS64 0x4C04 +#define XLOOP_GET_STATUS64 0x4C05 +#define XLOOP_CHANGE_FD 0x4C06 +#define XLOOP_SET_CAPACITY 0x4C07 +#define XLOOP_SET_DIRECT_IO 0x4C08 +#define XLOOP_SET_BLOCK_SIZE 0x4C09 +#define XLOOP_CONFIGURE 0x4C0A + +/* /dev/xloop-control interface */ +#define XLOOP_CTL_ADD 0x4C80 +#define XLOOP_CTL_REMOVE 0x4C81 +#define XLOOP_CTL_GET_FREE 0x4C82 +#endif /* _UAPI_LINUX_XLOOP_H */ diff --git a/kernel/xloop_main.h b/kernel/xloop_main.h index e45a891..e1b4cb6 100644 --- a/kernel/xloop_main.h +++ b/kernel/xloop_main.h @@ -15,7 +15,7 @@ #include #include #include -#include "uapi/linux/xloop.h" +#include "uapi_xloop.h" #ifdef CONFIG_DEBUG_FS #include #endif -- cgit v1.2.3-55-g7522