diff options
author | Manuel Bentele | 2020-09-09 17:32:57 +0200 |
---|---|---|
committer | Manuel Bentele | 2020-09-16 07:37:56 +0200 |
commit | 55d94d412d4269d93e9c71a2ce59d1b9631b8957 (patch) | |
tree | 27ef4827a02635d2c9dd84b2949079b424a3a90d | |
parent | Added CMake files to build xloop kernel modules and xlosetup utility (diff) | |
download | xloop-55d94d412d4269d93e9c71a2ce59d1b9631b8957.tar.gz xloop-55d94d412d4269d93e9c71a2ce59d1b9631b8957.tar.xz xloop-55d94d412d4269d93e9c71a2ce59d1b9631b8957.zip |
Renamed files from loop to xloop and generate package only in Release mode
-rw-r--r-- | CMakeLists.txt | 42 | ||||
-rw-r--r-- | kernel/CMakeLists.txt | 31 | ||||
-rw-r--r-- | kernel/Kbuild | 8 | ||||
-rw-r--r-- | kernel/Makefile | 12 | ||||
-rw-r--r-- | kernel/uapi/linux/xloop.h (renamed from kernel/uapi/linux/loop.h) | 2 | ||||
-rw-r--r-- | kernel/xloop_file_fmt.c (renamed from kernel/loop_file_fmt.c) | 4 | ||||
-rw-r--r-- | kernel/xloop_file_fmt.h (renamed from kernel/loop_file_fmt.h) | 4 | ||||
-rw-r--r-- | kernel/xloop_file_fmt_qcow_cache.c (renamed from kernel/loop_file_fmt_qcow_cache.c) | 6 | ||||
-rw-r--r-- | kernel/xloop_file_fmt_qcow_cache.h (renamed from kernel/loop_file_fmt_qcow_cache.h) | 2 | ||||
-rw-r--r-- | kernel/xloop_file_fmt_qcow_cluster.c (renamed from kernel/loop_file_fmt_qcow_cluster.c) | 8 | ||||
-rw-r--r-- | kernel/xloop_file_fmt_qcow_cluster.h (renamed from kernel/loop_file_fmt_qcow_cluster.h) | 2 | ||||
-rw-r--r-- | kernel/xloop_file_fmt_qcow_main.c (renamed from kernel/loop_file_fmt_qcow_main.c) | 8 | ||||
-rw-r--r-- | kernel/xloop_file_fmt_qcow_main.h (renamed from kernel/loop_file_fmt_qcow_main.h) | 2 | ||||
-rw-r--r-- | kernel/xloop_file_fmt_raw.c (renamed from kernel/loop_file_fmt_raw.c) | 2 | ||||
-rw-r--r-- | kernel/xloop_main.c (renamed from kernel/loop_main.c) | 10 | ||||
-rw-r--r-- | kernel/xloop_main.h (renamed from kernel/loop_main.h) | 4 | ||||
-rw-r--r-- | utils/CMakeLists.txt | 2 | ||||
-rw-r--r-- | utils/bash-completion/xlosetup (renamed from utils/bash-completion/losetup) | 6 | ||||
-rw-r--r-- | utils/lib/loopdev.c | 56 | ||||
-rw-r--r-- | utils/sys-utils/CMakeLists.txt | 4 | ||||
-rw-r--r-- | utils/sys-utils/xlosetup.8 (renamed from utils/sys-utils/losetup.8) | 0 | ||||
-rw-r--r-- | utils/sys-utils/xlosetup.c (renamed from utils/sys-utils/losetup.c) | 18 |
22 files changed, 113 insertions, 120 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 3a9f07a..ba17bf4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,26 +8,28 @@ if(NOT CMAKE_BUILD_TYPE) endif() # define packaging -set(CPACK_GENERATOR "DEB") -set(CPACK_SOURCE_GENERATOR "TGZ") -set(CPACK_IGNORE_FILES "*.gitignore") -set(CPACK_PACKAGE_NAME "xloop") -set(CPACK_PACKAGE_DESCRIPTION "xloop Kernel modules and utility") -set(CPACK_PACKAGE_VERSION_MAJOR 0) -set(CPACK_PACKAGE_VERSION_MINOR 1) -set(CPACK_PACKAGE_SECTION admin) -set(CPACK_PACKAGE_VENDOR "University of Freiburg") -set(CPACK_PACKAGE_CONTACT "Christian Rößler <christian.roessler@rz.uni-freiburg.de>") -set(CPACK_PACKAGE_HOMEPAGE_URL "https://git.openslx.org/openslx-ng/xloop.git/") -set(CPACK_PACKAGE_CHECKSUM SHA256) -set(CPACK_STRIP_FILES TRUE) -set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT) -set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6") -file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/package/deb/postinst "depmod -a\n") -file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/package/deb/postrm "depmod -a\n") -set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA ${CMAKE_CURRENT_BINARY_DIR}/package/deb/postinst - ${CMAKE_CURRENT_BINARY_DIR}/package/deb/postrm) -include(CPack) +if(NOT CMAKE_BUILD_TYPE MATCHES Debug) + set(CPACK_GENERATOR "DEB") + set(CPACK_SOURCE_GENERATOR "TGZ") + set(CPACK_IGNORE_FILES "*.gitignore") + set(CPACK_PACKAGE_NAME "xloop") + set(CPACK_PACKAGE_DESCRIPTION "xloop Kernel modules and utility") + set(CPACK_PACKAGE_VERSION_MAJOR 0) + set(CPACK_PACKAGE_VERSION_MINOR 1) + set(CPACK_PACKAGE_SECTION admin) + set(CPACK_PACKAGE_VENDOR "University of Freiburg") + set(CPACK_PACKAGE_CONTACT "Christian Rößler <christian.roessler@rz.uni-freiburg.de>") + set(CPACK_PACKAGE_HOMEPAGE_URL "https://git.openslx.org/openslx-ng/xloop.git/") + set(CPACK_PACKAGE_CHECKSUM SHA256) + set(CPACK_STRIP_FILES TRUE) + set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT) + set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6") + file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/package/deb/postinst "depmod -a\n") + file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/package/deb/postrm "depmod -a\n") + set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA ${CMAKE_CURRENT_BINARY_DIR}/package/deb/postinst + ${CMAKE_CURRENT_BINARY_DIR}/package/deb/postrm) + include(CPack) +endif() # add subprojects add_subdirectory(kernel) diff --git a/kernel/CMakeLists.txt b/kernel/CMakeLists.txt index c850f0a..7cc79dd 100644 --- a/kernel/CMakeLists.txt +++ b/kernel/CMakeLists.txt @@ -15,14 +15,17 @@ set(BLK_DEV_XLOOP_MIN_COUNT 8 CACHE STRING "Number of xloop devices to pre-create at init time") set(XLOOP_MAJOR 120 CACHE STRING "Major number for xloop devices") +set(XLOOP_CTRL_MINOR 15 + CACHE STRING "Minor number for xloop-control device") # print configured settings message(STATUS "Kernel module path is " ${KERNEL_DIR}) message(STATUS "Number of xloop devices to pre-create at init time is " ${BLK_DEV_XLOOP_MIN_COUNT}) message(STATUS "Major number for xloop devices is " ${XLOOP_MAJOR}) +message(STATUS "Minor number for xloop-control device is " ${XLOOP_CTRL_MINOR}) # set C flags for a Linux kernel module -set(KERNEL_C_FLAGS "-DCONFIG_BLK_DEV_XLOOP_MIN_COUNT=${BLK_DEV_XLOOP_MIN_COUNT} -DXLOOP_MAJOR=${XLOOP_MAJOR}" +set(KERNEL_C_FLAGS "-DCONFIG_BLK_DEV_XLOOP_MIN_COUNT=${BLK_DEV_XLOOP_MIN_COUNT} -DXLOOP_MAJOR=${XLOOP_MAJOR} -DXLOOP_CTRL_MINOR=${XLOOP_CTRL_MINOR}" CACHE STRING "C flags to be used for building the kernel module") # set C flags for the debug mode of a Linux kernel module set(KERNEL_C_FLAGS_DEBUG "-g -DDEBUG" @@ -37,10 +40,10 @@ endif(CMAKE_BUILD_TYPE MATCHES Debug) add_kernel_build(prepare ${CMAKE_CURRENT_SOURCE_DIR}/Kbuild) # xloop main Linux kernel module -set(KERNEL_MODULE_XLOOP_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/loop_file_fmt.c - ${CMAKE_CURRENT_SOURCE_DIR}/loop_main.c) -set(KERNEL_MODULE_XLOOP_HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/loop_file_fmt.h - ${CMAKE_CURRENT_SOURCE_DIR}/loop_main.h +set(KERNEL_MODULE_XLOOP_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/xloop_file_fmt.c + ${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) add_kernel_module(xloop "${KERNEL_DIR}" "CONFIG_BLK_DEV_XLOOP=m" @@ -49,9 +52,9 @@ add_kernel_module(xloop "${KERNEL_DIR}" ${CMAKE_CURRENT_BINARY_DIR}/Kbuild) # xloop_file_fmt_raw Linux kernel module -set(KERNEL_MODULE_XLOOP_RAW_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/loop_file_fmt_raw.c) +set(KERNEL_MODULE_XLOOP_RAW_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/xloop_file_fmt_raw.c) set(KERNEL_MODULE_XLOOP_RAW_HEADER_FILES ) -add_kernel_module(loop_file_fmt_raw "${KERNEL_DIR}" +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}" @@ -59,13 +62,13 @@ add_kernel_module(loop_file_fmt_raw "${KERNEL_DIR}" xloop) # xloop_file_fmt_qcow Linux kernel module -set(KERNEL_MODULE_XLOOP_QCOW_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/loop_file_fmt_qcow_cache.c - ${CMAKE_CURRENT_SOURCE_DIR}/loop_file_fmt_qcow_cluster.c - ${CMAKE_CURRENT_SOURCE_DIR}/loop_file_fmt_qcow_main.c) -set(KERNEL_MODULE_XLOOP_QCOW_HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/loop_file_fmt_qcow_cache.h - ${CMAKE_CURRENT_SOURCE_DIR}/loop_file_fmt_qcow_cluster.h - ${CMAKE_CURRENT_SOURCE_DIR}/loop_file_fmt_qcow_main.h) -add_kernel_module(loop_file_fmt_qcow "${KERNEL_DIR}" +set(KERNEL_MODULE_XLOOP_QCOW_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/xloop_file_fmt_qcow_cache.c + ${CMAKE_CURRENT_SOURCE_DIR}/xloop_file_fmt_qcow_cluster.c + ${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) +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}" diff --git a/kernel/Kbuild b/kernel/Kbuild index a216066..e3b34ac 100644 --- a/kernel/Kbuild +++ b/kernel/Kbuild @@ -2,11 +2,11 @@ # Linux kernel module xloop obj-$(CONFIG_BLK_DEV_XLOOP) += xloop.o -xloop-objs += loop_main.o loop_file_fmt.o +xloop-objs += xloop_main.o xloop_file_fmt.o # Linux kernel module loop_file_fmt_raw -obj-$(CONFIG_BLK_DEV_XLOOP_FILE_FMT_RAW) += loop_file_fmt_raw.o +obj-$(CONFIG_BLK_DEV_XLOOP_FILE_FMT_RAW) += xloop_file_fmt_raw.o # Linux kernel module loop_file_fmt_qcow -obj-$(CONFIG_BLK_DEV_XLOOP_FILE_FMT_QCOW) += loop_file_fmt_qcow.o -loop_file_fmt_qcow-objs += loop_file_fmt_qcow_main.o loop_file_fmt_qcow_cluster.o loop_file_fmt_qcow_cache.o
\ No newline at end of file +obj-$(CONFIG_BLK_DEV_XLOOP_FILE_FMT_QCOW) += xloop_file_fmt_qcow.o +xloop_file_fmt_qcow-objs += xloop_file_fmt_qcow_main.o xloop_file_fmt_qcow_cluster.o xloop_file_fmt_qcow_cache.o
\ No newline at end of file diff --git a/kernel/Makefile b/kernel/Makefile deleted file mode 100644 index ca9019a..0000000 --- a/kernel/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -include $(PWD)/Kbuild - -ifndef KDIR - KDIR = /lib/modules/$(shell uname -r)/build -endif - -all: - make -C "$(KDIR)" "M=$(PWD)" modules - -clean: - make -C "$(KDIR)" "M=$(PWD)" clean diff --git a/kernel/uapi/linux/loop.h b/kernel/uapi/linux/xloop.h index f93f6ad..1bf13c6 100644 --- a/kernel/uapi/linux/loop.h +++ b/kernel/uapi/linux/xloop.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-1.0+ WITH Linux-syscall-note */ /* - * include/linux/loop.h + * include/linux/xloop.h * * Written by Theodore Ts'o, 3/29/93. * diff --git a/kernel/loop_file_fmt.c b/kernel/xloop_file_fmt.c index 062ea0d..18672f7 100644 --- a/kernel/loop_file_fmt.c +++ b/kernel/xloop_file_fmt.c @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0 */ /* - * loop_file_fmt.c + * xloop_file_fmt.c * * File format subsystem for the xloop device module. * @@ -10,7 +10,7 @@ #include <linux/kernel.h> #include <linux/module.h> -#include "loop_file_fmt.h" +#include "xloop_file_fmt.h" /* storage for all registered file format drivers */ static struct xloop_file_fmt_driver *xloop_file_fmt_drivers[MAX_XLO_FILE_FMT] = { diff --git a/kernel/loop_file_fmt.h b/kernel/xloop_file_fmt.h index 38d6a3b..a419f33 100644 --- a/kernel/loop_file_fmt.h +++ b/kernel/xloop_file_fmt.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0 */ /* - * loop_file_fmt.h + * xloop_file_fmt.h * * File format subsystem for the xloop device module. * @@ -10,7 +10,7 @@ #ifndef _LINUX_XLOOP_FILE_FMT_H #define _LINUX_XLOOP_FILE_FMT_H -#include "loop_main.h" +#include "xloop_main.h" struct xloop_file_fmt; diff --git a/kernel/loop_file_fmt_qcow_cache.c b/kernel/xloop_file_fmt_qcow_cache.c index 4ef772a..c0e19fb 100644 --- a/kernel/loop_file_fmt_qcow_cache.c +++ b/kernel/xloop_file_fmt_qcow_cache.c @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0 */ /* - * loop_file_fmt_qcow_cache.c + * xloop_file_fmt_qcow_cache.c * * QCOW file format driver for the xloop device module. * @@ -20,8 +20,8 @@ #include <linux/fs.h> #include <linux/vmalloc.h> -#include "loop_file_fmt_qcow_main.h" -#include "loop_file_fmt_qcow_cache.h" +#include "xloop_file_fmt_qcow_main.h" +#include "xloop_file_fmt_qcow_cache.h" static inline void *__xloop_file_fmt_qcow_cache_get_table_addr( struct xloop_file_fmt_qcow_cache *c, int table) diff --git a/kernel/loop_file_fmt_qcow_cache.h b/kernel/xloop_file_fmt_qcow_cache.h index d2f1010..527d4ae 100644 --- a/kernel/loop_file_fmt_qcow_cache.h +++ b/kernel/xloop_file_fmt_qcow_cache.h @@ -14,7 +14,7 @@ #ifndef _LINUX_XLOOP_FILE_FMT_QCOW_CACHE_H #define _LINUX_XLOOP_FILE_FMT_QCOW_CACHE_H -#include "loop_file_fmt.h" +#include "xloop_file_fmt.h" struct xloop_file_fmt_qcow_cache_table { s64 offset; diff --git a/kernel/loop_file_fmt_qcow_cluster.c b/kernel/xloop_file_fmt_qcow_cluster.c index 593a173..82fbc4f 100644 --- a/kernel/loop_file_fmt_qcow_cluster.c +++ b/kernel/xloop_file_fmt_qcow_cluster.c @@ -13,10 +13,10 @@ #include <linux/kernel.h> #include <linux/string.h> -#include "loop_file_fmt.h" -#include "loop_file_fmt_qcow_main.h" -#include "loop_file_fmt_qcow_cache.h" -#include "loop_file_fmt_qcow_cluster.h" +#include "xloop_file_fmt.h" +#include "xloop_file_fmt_qcow_main.h" +#include "xloop_file_fmt_qcow_cache.h" +#include "xloop_file_fmt_qcow_cluster.h" /* * Loads a L2 slice into memory (L2 slices are the parts of L2 tables diff --git a/kernel/loop_file_fmt_qcow_cluster.h b/kernel/xloop_file_fmt_qcow_cluster.h index 5078f29..ff3e0a1 100644 --- a/kernel/loop_file_fmt_qcow_cluster.h +++ b/kernel/xloop_file_fmt_qcow_cluster.h @@ -13,7 +13,7 @@ #ifndef _LINUX_XLOOP_FILE_FMT_QCOW_CLUSTER_H #define _LINUX_XLOOP_FILE_FMT_QCOW_CLUSTER_H -#include "loop_file_fmt.h" +#include "xloop_file_fmt.h" extern int xloop_file_fmt_qcow_cluster_get_offset(struct xloop_file_fmt *xlo_fmt, u64 offset, diff --git a/kernel/loop_file_fmt_qcow_main.c b/kernel/xloop_file_fmt_qcow_main.c index 7c3e360..c1fe34c 100644 --- a/kernel/loop_file_fmt_qcow_main.c +++ b/kernel/xloop_file_fmt_qcow_main.c @@ -22,10 +22,10 @@ #include <linux/vmalloc.h> #include <linux/zlib.h> -#include "loop_file_fmt.h" -#include "loop_file_fmt_qcow_main.h" -#include "loop_file_fmt_qcow_cache.h" -#include "loop_file_fmt_qcow_cluster.h" +#include "xloop_file_fmt.h" +#include "xloop_file_fmt_qcow_main.h" +#include "xloop_file_fmt_qcow_cache.h" +#include "xloop_file_fmt_qcow_cluster.h" static int __qcow_file_fmt_header_read(struct file *file, struct xloop_file_fmt_qcow_header *header) diff --git a/kernel/loop_file_fmt_qcow_main.h b/kernel/xloop_file_fmt_qcow_main.h index 54b94c3..e6031be 100644 --- a/kernel/loop_file_fmt_qcow_main.h +++ b/kernel/xloop_file_fmt_qcow_main.h @@ -24,7 +24,7 @@ #include <linux/debugfs.h> #endif -#include "loop_file_fmt.h" +#include "xloop_file_fmt.h" #ifdef CONFIG_DEBUG_DRIVER #define ASSERT(x) \ diff --git a/kernel/loop_file_fmt_raw.c b/kernel/xloop_file_fmt_raw.c index 11cc8cd..6c205ee 100644 --- a/kernel/loop_file_fmt_raw.c +++ b/kernel/xloop_file_fmt_raw.c @@ -21,7 +21,7 @@ #include <linux/uio.h> #include <linux/version.h> -#include "loop_file_fmt.h" +#include "xloop_file_fmt.h" static inline loff_t __raw_file_fmt_rq_get_pos(struct xloop_file_fmt *xlo_fmt, struct request *rq) diff --git a/kernel/loop_main.c b/kernel/xloop_main.c index 221b59f..a29b644 100644 --- a/kernel/loop_main.c +++ b/kernel/xloop_main.c @@ -1,5 +1,5 @@ /* - * loop_main.c + * xloop_main.c * * Written by Theodore Ts'o, 3/29/93 * @@ -86,8 +86,8 @@ #include <linux/debugfs.h> #endif -#include "loop_file_fmt.h" -#include "loop_main.h" +#include "xloop_file_fmt.h" +#include "xloop_main.h" #include <linux/uaccess.h> @@ -2087,12 +2087,12 @@ static const struct file_operations xloop_ctl_fops = { }; static struct miscdevice xloop_misc = { - .minor = LOOP_CTRL_MINOR, + .minor = XLOOP_CTRL_MINOR, .name = "xloop-control", .fops = &xloop_ctl_fops, }; -MODULE_ALIAS_MISCDEV(LOOP_CTRL_MINOR); +MODULE_ALIAS_MISCDEV(XLOOP_CTRL_MINOR); MODULE_ALIAS("devname:xloop-control"); static int __init xloop_init(void) diff --git a/kernel/loop_main.h b/kernel/xloop_main.h index 1b5851a..b9d0405 100644 --- a/kernel/loop_main.h +++ b/kernel/xloop_main.h @@ -15,12 +15,12 @@ #include <linux/spinlock.h> #include <linux/mutex.h> #include <linux/kthread.h> -#include "uapi/linux/loop.h" +#include "uapi/linux/xloop.h" #ifdef CONFIG_DEBUG_FS #include <linux/debugfs.h> #endif -#include "loop_file_fmt.h" +#include "xloop_file_fmt.h" /* Possible states of device */ enum { diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt index 93fc41c..7669fd9 100644 --- a/utils/CMakeLists.txt +++ b/utils/CMakeLists.txt @@ -14,6 +14,6 @@ add_subdirectory(lib) add_subdirectory(libsmartcols) add_subdirectory(sys-utils) -install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/bash-completion/losetup +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/bash-completion/xlosetup DESTINATION /usr/share/bash-completion/completions PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
\ No newline at end of file diff --git a/utils/bash-completion/losetup b/utils/bash-completion/xlosetup index e085abe..cdf75f1 100644 --- a/utils/bash-completion/losetup +++ b/utils/bash-completion/xlosetup @@ -1,4 +1,4 @@ -_losetup_module() +_xlosetup_module() { local cur prev OPTS ARG COMPREPLY=() @@ -16,7 +16,7 @@ _losetup_module() return 0 ;; '-c'|'--set-capacity') - ARG="$(for I in /dev/loop[0-9]*; do if [ -e $I ]; then echo $I; fi; done)" + ARG="$(for I in /dev/xloop[0-9]*; do if [ -e $I ]; then echo $I; fi; done)" COMPREPLY=( $(compgen -W "$ARG" -- $cur) ) return 0 ;; @@ -82,4 +82,4 @@ _losetup_module() COMPREPLY=( $(compgen -f -- $cur) ) return 0 } -complete -F _losetup_module losetup +complete -F _xlosetup_module xlosetup diff --git a/utils/lib/loopdev.c b/utils/lib/loopdev.c index 686be53..57129bd 100644 --- a/utils/lib/loopdev.c +++ b/utils/lib/loopdev.c @@ -13,7 +13,7 @@ * - reads info from /sys/block/loop<N>/loop/<attr> (new kernels) * - reads info by ioctl * - supports *unlimited* number of loop devices - * - supports /dev/loop<N> as well as /dev/loop/<N> + * - supports /dev/xloop<N> as well as /dev/xloop/<N> * - minimize overhead (fd, loopinfo, ... are shared for all operations) * - setup (associate device and backing file) * - delete (dis-associate file) @@ -77,9 +77,9 @@ static void loopdev_init_debug(void) * @lc: context * @device: device name, absolute device path or NULL to reset the current setting * - * Sets device, absolute paths (e.g. "/dev/loop<N>") are unchanged, device - * names ("loop<N>") are converted to the path (/dev/loop<N> or to - * /dev/loop/<N>) + * Sets device, absolute paths (e.g. "/dev/xloop<N>") are unchanged, device + * names ("xloop<N>") are converted to the path (/dev/xloop<N> or to + * /dev/xloop/<N>) * * This sets the device name, but does not check if the device exists! * @@ -107,9 +107,9 @@ int loopcxt_set_device(struct loopdev_cxt *lc, const char *device) if (*device != '/') { const char *dir = _PATH_DEV; - /* compose device name for /dev/loop<n> or /dev/loop/<n> */ + /* compose device name for /dev/xloop<n> or /dev/xloop/<n> */ if (lc->flags & LOOPDEV_FL_DEVSUBDIR) { - if (strlen(device) < 5) + if (strlen(device) < 6) return -1; device += 4; dir = _PATH_DEV_LOOP "/"; /* _PATH_DEV uses tailing slash */ @@ -324,7 +324,7 @@ int loopcxt_init_iterator(struct loopdev_cxt *lc, int flags) if (!lc->extra_check) { /* - * Check for /dev/loop/<N> subdirectory + * Check for /dev/xloop/<N> subdirectory */ if (!(lc->flags & LOOPDEV_FL_DEVSUBDIR) && stat(_PATH_DEV_LOOP, &st) == 0 && S_ISDIR(st.st_mode)) @@ -438,11 +438,11 @@ static int loop_scandir(const char *dirname, int **ary, int hasprefix) continue; if (hasprefix) { - /* /dev/loop<N> */ - if (sscanf(d->d_name, "loop%u", &n) != 1) + /* /dev/xloop<N> */ + if (sscanf(d->d_name, "xloop%u", &n) != 1) continue; } else { - /* /dev/loop/<N> */ + /* /dev/xloop/<N> */ char *end = NULL; errno = 0; @@ -451,7 +451,7 @@ static int loop_scandir(const char *dirname, int **ary, int hasprefix) continue; } if (n < LOOPDEV_DEFAULT_NNODES) - continue; /* ignore loop<0..7> */ + continue; /* ignore xloop<0..7> */ if (count + 1 > arylen) { int *tmp; @@ -542,10 +542,10 @@ static int loopcxt_next_from_sysfs(struct loopdev_cxt *lc) if (strcmp(d->d_name, ".") == 0 || strcmp(d->d_name, "..") == 0 - || strncmp(d->d_name, "loop", 4) != 0) + || strncmp(d->d_name, "xloop", 4) != 0) continue; - snprintf(name, sizeof(name), "%s/loop/backing_file", d->d_name); + snprintf(name, sizeof(name), "%s/xloop/backing_file", d->d_name); if (fstatat(fd, name, &st, 0) != 0) continue; @@ -599,7 +599,7 @@ int loopcxt_next(struct loopdev_cxt *lc) for (++iter->ncur; iter->ncur < LOOPDEV_DEFAULT_NNODES; iter->ncur++) { char name[16]; - snprintf(name, sizeof(name), "loop%d", iter->ncur); + snprintf(name, sizeof(name), "xloop%d", iter->ncur); if (loopiter_set_device(lc, name) == 0) return 0; @@ -607,7 +607,7 @@ int loopcxt_next(struct loopdev_cxt *lc) iter->default_check = 0; } - /* C) the worst possibility, scan whole /dev or /dev/loop/<N> + /* C) the worst possibility, scan whole /dev or /dev/xloop/<N> */ if (!iter->minors) { DBG(ITER, ul_debugobj(iter, "next: scanning /dev")); @@ -618,7 +618,7 @@ int loopcxt_next(struct loopdev_cxt *lc) } for (++iter->ncur; iter->ncur < iter->nminors; iter->ncur++) { char name[16]; - snprintf(name, sizeof(name), "loop%d", iter->minors[iter->ncur]); + snprintf(name, sizeof(name), "xloop%d", iter->minors[iter->ncur]); if (loopiter_set_device(lc, name) == 0) return 0; @@ -694,7 +694,7 @@ char *loopcxt_get_backing_file(struct loopdev_cxt *lc) * This is always preferred, the loop_info64 * has too small buffer for the filename. */ - ul_path_read_string(sysfs, &res, "loop/backing_file"); + ul_path_read_string(sysfs, &res, "xloop/backing_file"); if (!res && loopcxt_ioctl_enabled(lc)) { struct loop_info64 *lo = loopcxt_get_info(lc); @@ -722,7 +722,7 @@ int loopcxt_get_offset(struct loopdev_cxt *lc, uint64_t *offset) int rc = -EINVAL; if (sysfs) - rc = ul_path_read_u64(sysfs, offset, "loop/offset"); + rc = ul_path_read_u64(sysfs, offset, "xloop/offset"); if (rc && loopcxt_ioctl_enabled(lc)) { struct loop_info64 *lo = loopcxt_get_info(lc); @@ -782,7 +782,7 @@ int loopcxt_get_sizelimit(struct loopdev_cxt *lc, uint64_t *size) int rc = -EINVAL; if (sysfs) - rc = ul_path_read_u64(sysfs, size, "loop/sizelimit"); + rc = ul_path_read_u64(sysfs, size, "xloop/sizelimit"); if (rc && loopcxt_ioctl_enabled(lc)) { struct loop_info64 *lo = loopcxt_get_info(lc); @@ -861,7 +861,7 @@ int loopcxt_get_file_fmt_type(struct loopdev_cxt *lc, uint32_t* file_fmt_type) if (sysfs) { /* check if file_fmt_type is accessible and supported by the kernel module */ char* file_fmt_str = NULL; - if (ul_path_read_string(sysfs, &file_fmt_str, "loop/file_fmt_type") == 0) + if (ul_path_read_string(sysfs, &file_fmt_str, "xloop/file_fmt_type") == 0) rc = parse_file_fmt_type(file_fmt_str, file_fmt_type); } else rc = -errno; @@ -886,9 +886,9 @@ char *loopcxt_get_file_fmt_type_string(struct loopdev_cxt *lc) char *res = NULL; if (sysfs) - ul_path_read_string(sysfs, &res, "loop/file_fmt_type"); + ul_path_read_string(sysfs, &res, "xloop/file_fmt_type"); - DBG(CXT, ul_debugobj(lc, "loopcxt_get_file_fmt_type_string [%s]", res)); + DBG(CXT, ul_debugobj(lc, "xloopcxt_get_file_fmt_type_string [%s]", res)); return res; } @@ -1001,7 +1001,7 @@ int loopcxt_is_partscan(struct loopdev_cxt *lc) if (sysfs) { /* kernel >= 3.2 */ int fl; - if (ul_path_read_s32(sysfs, &fl, "loop/partscan") == 0) + if (ul_path_read_s32(sysfs, &fl, "xloop/partscan") == 0) return fl; } @@ -1020,7 +1020,7 @@ int loopcxt_is_autoclear(struct loopdev_cxt *lc) if (sysfs) { int fl; - if (ul_path_read_s32(sysfs, &fl, "loop/autoclear") == 0) + if (ul_path_read_s32(sysfs, &fl, "xloop/autoclear") == 0) return fl; } @@ -1066,7 +1066,7 @@ int loopcxt_is_dio(struct loopdev_cxt *lc) if (sysfs) { int fl; - if (ul_path_read_s32(sysfs, &fl, "loop/dio") == 0) + if (ul_path_read_s32(sysfs, &fl, "xloop/dio") == 0) return fl; } if (loopcxt_ioctl_enabled(lc)) { @@ -1407,8 +1407,8 @@ int loopcxt_setup_device(struct loopdev_cxt *lc) break; if (errno != EACCES && errno != ENOENT) break; - /* We have permissions to open /dev/loop-control, but open - * /dev/loopN failed with EACCES, it's probably because udevd + /* We have permissions to open /dev/xloop-control, but open + * /dev/xloopN failed with EACCES, it's probably because udevd * does not applied chown yet. Let's wait a moment. */ xusleep(25000); } while (cnt++ < 16); @@ -1643,7 +1643,7 @@ int loopcxt_find_unused(struct loopdev_cxt *lc) rc = ioctl(ctl, LOOP_CTL_GET_FREE); if (rc >= 0) { char name[16]; - snprintf(name, sizeof(name), "loop%d", rc); + snprintf(name, sizeof(name), "xloop%d", rc); rc = loopiter_set_device(lc, name); } diff --git a/utils/sys-utils/CMakeLists.txt b/utils/sys-utils/CMakeLists.txt index a36e88c..8f3ee47 100644 --- a/utils/sys-utils/CMakeLists.txt +++ b/utils/sys-utils/CMakeLists.txt @@ -4,11 +4,11 @@ cmake_minimum_required(VERSION 3.10) project(xloop-utils-sys-utils) # add xlosetup executable -add_executable(xlosetup ${CMAKE_CURRENT_SOURCE_DIR}/losetup.c) +add_executable(xlosetup ${CMAKE_CURRENT_SOURCE_DIR}/xlosetup.c) target_link_libraries(xlosetup LINK_PUBLIC libcommon libsmartcols) target_include_directories(xlosetup PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../lib ${CMAKE_CURRENT_SOURCE_DIR}/../libsmartcols) install(TARGETS xlosetup DESTINATION bin) -install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/losetup.8 +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/xlosetup.8 DESTINATION /usr/share/man/man8 PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
\ No newline at end of file diff --git a/utils/sys-utils/losetup.8 b/utils/sys-utils/xlosetup.8 index 92aff3e..92aff3e 100644 --- a/utils/sys-utils/losetup.8 +++ b/utils/sys-utils/xlosetup.8 diff --git a/utils/sys-utils/losetup.c b/utils/sys-utils/xlosetup.c index 5e5ce9e..cab1037 100644 --- a/utils/sys-utils/losetup.c +++ b/utils/sys-utils/xlosetup.c @@ -2,7 +2,7 @@ * Copyright (C) 2011 Karel Zak <kzak@redhat.com> * Originally from Ted's losetup.c * - * losetup.c - setup and control loop devices + * xlosetup.c - setup and control loop devices */ #include <assert.h> #include <stdio.h> @@ -458,7 +458,7 @@ static void __attribute__((__noreturn__)) usage(void) for (i = 0; i < ARRAY_SIZE(infos); i++) fprintf(out, " %12s %s\n", infos[i].name, _(infos[i].help)); - printf(USAGE_MAN_TAIL("losetup(8)")); + printf(USAGE_MAN_TAIL("xlosetup(8)")); exit(EXIT_SUCCESS); } @@ -494,7 +494,7 @@ static int create_loop(struct loopdev_cxt *lc, int hasdev = loopcxt_has_device(lc); int rc = 0; - /* losetup --find --noverlap file.img */ + /* xlosetup --find --noverlap file.img */ if (!hasdev && nooverlap) { rc = loopcxt_find_overlap(lc, file, offset, sizelimit); switch (rc) { @@ -541,7 +541,7 @@ static int create_loop(struct loopdev_cxt *lc, if (hasdev && !is_loopdev(loopcxt_get_device(lc))) loopcxt_add_device(lc); - /* losetup --noverlap /dev/loopN file.img */ + /* xlosetup --noverlap /dev/loopN file.img */ if (hasdev && nooverlap) { struct loopdev_cxt lc2; @@ -803,7 +803,7 @@ int main(int argc, char **argv) if (act == A_FIND_FREE && optind < argc) { /* - * losetup -f <backing_file> + * xlosetup -f <backing_file> */ act = A_CREATE; file = argv[optind++]; @@ -814,15 +814,15 @@ int main(int argc, char **argv) if (list && !act && optind == argc) /* - * losetup --list defaults to --all + * xlosetup --list defaults to --all */ act = A_SHOW; if (!act && optind + 1 == argc) { /* - * losetup [--list] <device> + * xlosetup [--list] <device> * OR - * losetup {--direct-io[=off]|--logical-blocksize=size}... <device> + * xlosetup {--direct-io[=off]|--logical-blocksize=size}... <device> */ if (!(set_dio || set_blocksize)) act = A_SHOW_ONE; @@ -838,7 +838,7 @@ int main(int argc, char **argv) } if (!act) { /* - * losetup <loopdev> <backing_file> + * xlosetup <loopdev> <backing_file> */ act = A_CREATE; |