summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManuel Bentele2020-09-14 14:19:32 +0200
committerManuel Bentele2020-09-16 07:37:56 +0200
commit233910a1ed5d11ffe673f1fbcecd68f577fb686c (patch)
tree25aba58bba30c49ee6c6cb2ed0d4f900e512bcb9
parentChanged printing in kernel modules to support dynamic debug (diff)
downloadxloop-233910a1ed5d11ffe673f1fbcecd68f577fb686c.tar.gz
xloop-233910a1ed5d11ffe673f1fbcecd68f577fb686c.tar.xz
xloop-233910a1ed5d11ffe673f1fbcecd68f577fb686c.zip
Fixed CMake build error on Linux v5.8 or later
-rw-r--r--README.md1
-rw-r--r--kernel/CMakeLists.txt18
-rw-r--r--kernel/cmake/kernel.cmake39
-rw-r--r--kernel/tests/testcases/kernel/syscalls/ioctl/CMakeLists.txt1
4 files changed, 28 insertions, 31 deletions
diff --git a/README.md b/README.md
index f9074a0..8a7eb52 100644
--- a/README.md
+++ b/README.md
@@ -51,6 +51,7 @@ Optionally, the output files can be installed with superuser permissions on the
```shell
sudo make install
+sudo depmod -a
```
diff --git a/kernel/CMakeLists.txt b/kernel/CMakeLists.txt
index 752a645..e45ffc2 100644
--- a/kernel/CMakeLists.txt
+++ b/kernel/CMakeLists.txt
@@ -30,9 +30,6 @@ if(CMAKE_BUILD_TYPE MATCHES Debug)
set(KERNEL_C_FLAGS "${KERNEL_C_FLAGS} ${KERNEL_C_FLAGS_DEBUG}")
endif(CMAKE_BUILD_TYPE MATCHES Debug)
-# preparation of the Kbuild file
-add_kernel_build(prepare ${CMAKE_CURRENT_SOURCE_DIR}/Kbuild)
-
# xloop main Linux kernel module
set(KERNEL_MODULE_XLOOP_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/xloop_file_fmt.c
${CMAKE_CURRENT_SOURCE_DIR}/xloop_main.c)
@@ -43,16 +40,18 @@ add_kernel_module(xloop "${KERNEL_DIR}"
"CONFIG_BLK_DEV_XLOOP=m"
"${KERNEL_MODULE_XLOOP_SOURCE_FILES}"
"${KERNEL_MODULE_XLOOP_HEADER_FILES}"
- ${CMAKE_CURRENT_BINARY_DIR}/Kbuild)
+ ${CMAKE_CURRENT_SOURCE_DIR}/Kbuild)
# xloop_file_fmt_raw Linux kernel module
set(KERNEL_MODULE_XLOOP_RAW_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/xloop_file_fmt_raw.c)
-set(KERNEL_MODULE_XLOOP_RAW_HEADER_FILES )
+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)
add_kernel_module(xloop_file_fmt_raw "${KERNEL_DIR}"
"CONFIG_BLK_DEV_XLOOP_FILE_FMT_RAW=m"
"${KERNEL_MODULE_XLOOP_RAW_SOURCE_FILES}"
"${KERNEL_MODULE_XLOOP_RAW_HEADER_FILES}"
- ${CMAKE_CURRENT_BINARY_DIR}/Kbuild
+ ${CMAKE_CURRENT_SOURCE_DIR}/Kbuild
xloop)
# xloop_file_fmt_qcow Linux kernel module
@@ -61,12 +60,15 @@ set(KERNEL_MODULE_XLOOP_QCOW_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/xloop_file
${CMAKE_CURRENT_SOURCE_DIR}/xloop_file_fmt_qcow_main.c)
set(KERNEL_MODULE_XLOOP_QCOW_HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/xloop_file_fmt_qcow_cache.h
${CMAKE_CURRENT_SOURCE_DIR}/xloop_file_fmt_qcow_cluster.h
- ${CMAKE_CURRENT_SOURCE_DIR}/xloop_file_fmt_qcow_main.h)
+ ${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)
add_kernel_module(xloop_file_fmt_qcow "${KERNEL_DIR}"
"CONFIG_BLK_DEV_XLOOP_FILE_FMT_QCOW=m"
"${KERNEL_MODULE_XLOOP_QCOW_SOURCE_FILES}"
"${KERNEL_MODULE_XLOOP_QCOW_HEADER_FILES}"
- ${CMAKE_CURRENT_BINARY_DIR}/Kbuild
+ ${CMAKE_CURRENT_SOURCE_DIR}/Kbuild
xloop)
if(${CMAKE_BUILD_TYPE} MATCHES Debug)
diff --git a/kernel/cmake/kernel.cmake b/kernel/cmake/kernel.cmake
index dd45b12..8fa8c2d 100644
--- a/kernel/cmake/kernel.cmake
+++ b/kernel/cmake/kernel.cmake
@@ -4,40 +4,35 @@
# Copyright (C) 2020 Manuel Bentele <development@manuel-bentele.de>
#
-# macro to define target for preparing the Kbuild file
-macro(add_kernel_build BUILD_SOURCE_TARGET BUILD_SOURCE_FILE)
- get_filename_component(BUILD_SOURCE_FILE_NAME ${BUILD_SOURCE_FILE} NAME)
- add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${BUILD_SOURCE_FILE_NAME}
- COMMAND ${CMAKE_COMMAND}
- ARGS -E copy ${BUILD_SOURCE_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${BUILD_SOURCE_FILE_NAME}
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
- DEPENDS ${BUILD_SOURCE_FILE}
- VERBATIM)
- add_custom_target(${BUILD_SOURCE_TARGET} DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${BUILD_SOURCE_FILE_NAME})
-endmacro(add_kernel_build)
-
# macro to define kernel module targets
-macro(add_kernel_module MODULE_NAME KERNEL_DIR MODULE_MACRO MODULE_SOURCE_FILES MODULE_HEADER_FILES BUILD_SOURCE_TARGET)
+macro(add_kernel_module MODULE_NAME KERNEL_DIR MODULE_MACRO MODULE_SOURCE_FILES MODULE_HEADER_FILES BUILD_SOURCE_FILE)
+ # copy build source file
+ file(COPY ${BUILD_SOURCE_FILE} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_NAME})
# copy source files
foreach(MODULE_SOURCE_FILE ${MODULE_SOURCE_FILES})
- file(COPY ${MODULE_SOURCE_FILE} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
+ file(COPY ${MODULE_SOURCE_FILE} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_NAME})
endforeach()
# copy header files
foreach(MODULE_HEADER_FILE ${MODULE_HEADER_FILES})
- file(COPY ${MODULE_HEADER_FILE} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
+ file(COPY ${MODULE_HEADER_FILE} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_NAME})
endforeach()
+ # check if module depends on another module
+ if(NOT ${ARGV6} STREQUAL "")
+ set(MODULE_EXTRA_SYMBOLS ${CMAKE_CURRENT_BINARY_DIR}/${ARGV6}/Module.symvers)
+ endif()
# define build command
set(MODULE_BUILD_COMMAND ${CMAKE_MAKE_PROGRAM} ${MODULE_MACRO}
-C ${KERNEL_DIR}/build
- M=${CMAKE_CURRENT_BINARY_DIR} modules
- EXTRA_CFLAGS=${KERNEL_C_FLAGS})
- add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_NAME}.ko
+ M=${CMAKE_CURRENT_BINARY_DIR}/${MODULE_NAME} modules
+ EXTRA_CFLAGS=${KERNEL_C_FLAGS}
+ 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}
- DEPENDS ${MODULE_SOURCE_FILES} ${MODULE_HEADER_FILES} ${BUILD_SOURCE_TARGET}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_NAME}
+ DEPENDS ${MODULE_SOURCE_FILES} ${MODULE_HEADER_FILES} ${BUILD_SOURCE_FILE}
VERBATIM)
- add_custom_target(${MODULE_NAME} ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_NAME}.ko ${ARGV6})
- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_NAME}.ko
+ add_custom_target(${MODULE_NAME} ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_NAME}/${MODULE_NAME}.ko ${ARGV6})
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_NAME}/${MODULE_NAME}.ko
DESTINATION ${KERNEL_DIR}/extra
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
endmacro(add_kernel_module) \ No newline at end of file
diff --git a/kernel/tests/testcases/kernel/syscalls/ioctl/CMakeLists.txt b/kernel/tests/testcases/kernel/syscalls/ioctl/CMakeLists.txt
index 674b787..2ae10f6 100644
--- a/kernel/tests/testcases/kernel/syscalls/ioctl/CMakeLists.txt
+++ b/kernel/tests/testcases/kernel/syscalls/ioctl/CMakeLists.txt
@@ -5,7 +5,6 @@ project(xloop-kernel-test-ioctl_xloop)
# test ioctl_xloop01
add_executable(tst_ioctl_xloop01 ${CMAKE_CURRENT_SOURCE_DIR}/ioctl_xloop01.c)
target_link_libraries(tst_ioctl_xloop01 LINK_PUBLIC libltp)
-install(TARGETS tst_ioctl_xloop01 DESTINATION bin)
# test ioctl_xloop02
add_executable(tst_ioctl_xloop02 ${CMAKE_CURRENT_SOURCE_DIR}/ioctl_xloop02.c)