diff options
Diffstat (limited to 'utils')
-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 |
6 files changed, 43 insertions, 43 deletions
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; |