summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Bauer2020-05-29 16:47:54 +0200
committerJonathan Bauer2020-05-29 16:47:54 +0200
commit4c8a6edbb554928b1d4cd1d4e8b54b750b095641 (patch)
tree209b8ac01838658665ea58a53009160491d0960a
parentlib/losetup: merge remote-tracking branch 'util-linux/master' (diff)
downloadkernel-qcow2-util-linux-xloop-hack.tar.gz
kernel-qcow2-util-linux-xloop-hack.tar.xz
kernel-qcow2-util-linux-xloop-hack.zip
initial support for xloopxloop-hack
-rw-r--r--include/loopdev.h2
-rw-r--r--include/pathnames.h4
-rw-r--r--lib/loopdev.c34
3 files changed, 20 insertions, 20 deletions
diff --git a/include/loopdev.h b/include/loopdev.h
index f8559afd6..7fe7cf62c 100644
--- a/include/loopdev.h
+++ b/include/loopdev.h
@@ -76,7 +76,7 @@ struct loop_info64 {
uint32_t lo_file_fmt_type;
} __attribute__((packed));
-#define LOOPDEV_MAJOR 7 /* loop major number */
+#define LOOPDEV_MAJOR 120 /* loop major number */
#define LOOPDEV_DEFAULT_NNODES 8 /* default number of loop devices */
struct loopdev_iter {
diff --git a/include/pathnames.h b/include/pathnames.h
index 2e1f19355..412701505 100644
--- a/include/pathnames.h
+++ b/include/pathnames.h
@@ -138,8 +138,8 @@
#define _PATH_DEV_MEM "/dev/mem"
-#define _PATH_DEV_LOOP "/dev/loop"
-#define _PATH_DEV_LOOPCTL "/dev/loop-control"
+#define _PATH_DEV_LOOP "/dev/xloop"
+#define _PATH_DEV_LOOPCTL "/dev/xloop-control"
/* udev paths */
#define _PATH_DEV_BYLABEL "/dev/disk/by-label"
diff --git a/lib/loopdev.c b/lib/loopdev.c
index ac46f5312..ea3c3d5dd 100644
--- a/lib/loopdev.c
+++ b/lib/loopdev.c
@@ -439,7 +439,7 @@ static int loop_scandir(const char *dirname, int **ary, int hasprefix)
if (hasprefix) {
/* /dev/loop<N> */
- if (sscanf(d->d_name, "loop%u", &n) != 1)
+ if (sscanf(d->d_name, "xloop%u", &n) != 1)
continue;
} else {
/* /dev/loop/<N> */
@@ -535,17 +535,17 @@ static int loopcxt_next_from_sysfs(struct loopdev_cxt *lc)
fd = dirfd(iter->sysblock);
while ((d = readdir(iter->sysblock))) {
- char name[NAME_MAX + 18 + 1];
+ char name[NAME_MAX + 19 + 1];
struct stat st;
DBG(ITER, ul_debugobj(iter, "check %s", d->d_name));
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;
@@ -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;
@@ -697,7 +697,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);
@@ -725,7 +725,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);
@@ -785,7 +785,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);
@@ -864,7 +864,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;
@@ -889,7 +889,7 @@ 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));
return res;
@@ -983,7 +983,7 @@ int loopmod_supports_partscan(void)
if (get_linux_version() >= KERNEL_VERSION(3,2,0))
return 1;
- f = fopen("/sys/module/loop/parameters/max_part", "r" UL_CLOEXECSTR);
+ f = fopen("/sys/module/xloop/parameters/max_part", "r" UL_CLOEXECSTR);
if (!f)
return 0;
rc = fscanf(f, "%d", &ret);
@@ -1004,7 +1004,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;
}
@@ -1023,7 +1023,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;
}
@@ -1069,7 +1069,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)) {
@@ -1616,7 +1616,7 @@ int loopcxt_add_device(struct loopdev_cxt *lc)
}
p = strrchr(dev, '/');
- if (!p || (sscanf(p, "/loop%d", &nr) != 1 && sscanf(p, "/%d", &nr) != 1)
+ if (!p || (sscanf(p, "/xloop%d", &nr) != 1 && sscanf(p, "/%d", &nr) != 1)
|| nr < 0)
goto done;
@@ -1654,7 +1654,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);
}