summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bash-completion/losetup8
-rw-r--r--include/loopdev.h17
-rw-r--r--lib/loopdev.c97
-rw-r--r--sys-utils/losetup.85
-rw-r--r--sys-utils/losetup.c68
-rw-r--r--tests/expected/losetup/losetup-blkdev-offset1
-rw-r--r--tests/expected/losetup/losetup-blkdev-section1
-rw-r--r--tests/expected/losetup/losetup-blkdev-show1
-rw-r--r--tests/expected/losetup/losetup-blkdev-sizelimit1
-rw-r--r--tests/expected/losetup/losetup-file-offset1
-rw-r--r--tests/expected/losetup/losetup-file-section1
-rw-r--r--tests/expected/losetup/losetup-file-secton3
-rw-r--r--tests/expected/losetup/losetup-file-show1
-rw-r--r--tests/expected/losetup/losetup-file-sizelimit1
-rw-r--r--tests/expected/losetup/losetup-file-type4
-rwxr-xr-xtests/ts/losetup/losetup8
-rw-r--r--tests/ts/losetup/losetup_functions.sh1
17 files changed, 197 insertions, 22 deletions
diff --git a/bash-completion/losetup b/bash-completion/losetup
index d20726533..e085abe28 100644
--- a/bash-completion/losetup
+++ b/bash-completion/losetup
@@ -24,12 +24,17 @@ _losetup_module()
COMPREPLY=( $(compgen -W "number" -- $cur) )
return 0
;;
+ '-t'|'--type')
+ ARG="RAW QCOW VDI VMDK"
+ COMPREPLY=( $(compgen -W "$ARG" -- $cur) )
+ return 0
+ ;;
'-O'|'--output')
local prefix realcur OUTPUT_ALL OUTPUT
realcur="${cur##*,}"
prefix="${cur%$realcur}"
OUTPUT_ALL="NAME AUTOCLEAR BACK-FILE BACK-INO
- BACK-MAJ:MIN MAJ:MIN OFFSET PARTSCAN RO
+ BACK-MAJ:MIN FILE-FORMAT MAJ:MIN OFFSET PARTSCAN RO
SIZELIMIT DIO"
for WORD in $OUTPUT_ALL; do
if ! [[ $prefix == *"$WORD"* ]]; then
@@ -58,6 +63,7 @@ _losetup_module()
--partscan
--read-only
--show
+ --type
--verbose
--json
--list
diff --git a/include/loopdev.h b/include/loopdev.h
index 0e3a7517a..f8559afd6 100644
--- a/include/loopdev.h
+++ b/include/loopdev.h
@@ -11,6 +11,14 @@
#define LO_CRYPT_DES 2
#define LO_CRYPT_CRYPTOAPI 18
+/*
+ * loop_info.lo_file_fmt_type
+ */
+#define LO_FILE_FMT_RAW 0
+#define LO_FILE_FMT_QCOW 1
+#define LO_FILE_FMT_VDI 2
+#define LO_FILE_FMT_VMDK 3
+
#define LOOP_SET_FD 0x4C00
#define LOOP_CLR_FD 0x4C01
/*
@@ -42,6 +50,7 @@ enum {
LO_FLAGS_AUTOCLEAR = 4, /* kernel >= 2.6.25 */
LO_FLAGS_PARTSCAN = 8, /* kernel >= 3.2 */
LO_FLAGS_DIRECT_IO = 16, /* kernel >= 4.2 */
+ LO_FLAGS_FILE_FMT = 32
};
#define LO_NAME_SIZE 64
@@ -64,7 +73,8 @@ struct loop_info64 {
uint8_t lo_crypt_name[LO_NAME_SIZE];
uint8_t lo_encrypt_key[LO_KEY_SIZE];
uint64_t lo_init[2];
-};
+ uint32_t lo_file_fmt_type;
+} __attribute__((packed));
#define LOOPDEV_MAJOR 7 /* loop major number */
#define LOOPDEV_DEFAULT_NNODES 8 /* default number of loop devices */
@@ -175,6 +185,7 @@ extern int loopcxt_ioctl_blocksize(struct loopdev_cxt *lc, uint64_t blocksize);
int loopcxt_set_offset(struct loopdev_cxt *lc, uint64_t offset);
int loopcxt_set_sizelimit(struct loopdev_cxt *lc, uint64_t sizelimit);
int loopcxt_set_blocksize(struct loopdev_cxt *lc, uint64_t blocksize);
+int loopcxt_set_file_fmt_type(struct loopdev_cxt *lc, uint32_t file_fmt_type);
int loopcxt_set_flags(struct loopdev_cxt *lc, uint32_t flags);
int loopcxt_set_backing_file(struct loopdev_cxt *lc, const char *filename);
@@ -185,6 +196,8 @@ extern int loopcxt_get_offset(struct loopdev_cxt *lc, uint64_t *offset);
extern int loopcxt_get_blocksize(struct loopdev_cxt *lc, uint64_t *blocksize);
extern int loopcxt_get_sizelimit(struct loopdev_cxt *lc, uint64_t *size);
extern int loopcxt_get_encrypt_type(struct loopdev_cxt *lc, uint32_t *type);
+extern int loopcxt_get_file_fmt_type(struct loopdev_cxt *lc, uint32_t* file_fmt_type);
+extern char *loopcxt_get_file_fmt_type_string(struct loopdev_cxt *lc);
extern const char *loopcxt_get_crypt_name(struct loopdev_cxt *lc);
extern int loopcxt_is_autoclear(struct loopdev_cxt *lc);
extern int loopcxt_is_readonly(struct loopdev_cxt *lc);
@@ -205,4 +218,6 @@ extern int loopcxt_is_used(struct loopdev_cxt *lc,
uint64_t sizelimit,
int flags);
+extern int parse_file_fmt_type(const char *file_fmt_type_str, uint32_t *file_fmt_type);
+
#endif /* UTIL_LINUX_LOOPDEV_H */
diff --git a/lib/loopdev.c b/lib/loopdev.c
index 99a093926..ac46f5312 100644
--- a/lib/loopdev.c
+++ b/lib/loopdev.c
@@ -665,6 +665,9 @@ struct loop_info64 *loopcxt_get_info(struct loopdev_cxt *lc)
if (fd < 0)
return NULL;
+ /* indicate that file format support is implemented in sys-utils */
+ lc->info.lo_flags |= LO_FLAGS_FILE_FMT;
+
if (ioctl(fd, LOOP_GET_STATUS64, &lc->info) == 0) {
lc->has_info = 1;
lc->info_failed = 0;
@@ -824,6 +827,75 @@ int loopcxt_get_encrypt_type(struct loopdev_cxt *lc, uint32_t *type)
}
/*
+ * @file_fmt_type_str: file format type string.
+ * @file_fmt_type: returns file format type from the given file format string.
+ *
+ * Returns: <0 on error, 0 on success
+ */
+int parse_file_fmt_type(const char *file_fmt_type_str, uint32_t *file_fmt_type)
+{
+ int rc = 0;
+
+ if (!strcmp(file_fmt_type_str, "RAW"))
+ *file_fmt_type = LO_FILE_FMT_RAW;
+ else if (!strcmp(file_fmt_type_str, "QCOW"))
+ *file_fmt_type = LO_FILE_FMT_QCOW;
+ else if (!strcmp(file_fmt_type_str, "VDI"))
+ *file_fmt_type = LO_FILE_FMT_VDI;
+ else if (!strcmp(file_fmt_type_str, "VMDK"))
+ *file_fmt_type = LO_FILE_FMT_VMDK;
+ else
+ rc = -EINVAL;
+
+ return rc;
+}
+
+/*
+ * @lc: context
+ * @file_fmt_type: returns file format type of the given device
+ *
+ * Returns: <0 on error, 0 on success
+ */
+int loopcxt_get_file_fmt_type(struct loopdev_cxt *lc, uint32_t* file_fmt_type)
+{
+ struct path_cxt *sysfs = loopcxt_get_sysfs(lc);
+ int rc = 0;
+
+ 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)
+ rc = parse_file_fmt_type(file_fmt_str, file_fmt_type);
+ } else
+ rc = -errno;
+
+ if (rc != 0 && loopcxt_ioctl_enabled(lc)) {
+ struct loop_info64 *lo = loopcxt_get_info(lc);
+ if (lo)
+ *file_fmt_type = lo->lo_file_fmt_type;
+ }
+
+ return 0;
+}
+
+/*
+ * @lc: context
+ *
+ * Returns (allocated) string with file format type of the current loop device.
+ */
+char *loopcxt_get_file_fmt_type_string(struct loopdev_cxt *lc)
+{
+ struct path_cxt *sysfs = loopcxt_get_sysfs(lc);
+ char *res = NULL;
+
+ if (sysfs)
+ ul_path_read_string(sysfs, &res, "loop/file_fmt_type");
+
+ DBG(CXT, ul_debugobj(lc, "loopcxt_get_file_fmt_type_string [%s]", res));
+ return res;
+}
+
+/*
* @lc: context
* @devno: returns crypt name
*
@@ -1124,6 +1196,23 @@ int loopcxt_set_blocksize(struct loopdev_cxt *lc, uint64_t blocksize)
/*
* @lc: context
+ * @file_fmt_type: kernel LO_FILE_FMT_{RAW,QCOW,VDI,VMDK} flags
+ *
+ * The setting is removed by loopcxt_set_device() loopcxt_next()!
+ *
+ * Returns: 0 on success, <0 on error.
+ */
+int loopcxt_set_file_fmt_type(struct loopdev_cxt *lc, uint32_t file_fmt_type) {
+ if (!lc)
+ return -EINVAL;
+ lc->info.lo_file_fmt_type = file_fmt_type;
+
+ DBG(CXT, ul_debugobj(lc, "set file_fmt_type=%u", (unsigned) file_fmt_type));
+ return 0;
+}
+
+/*
+ * @lc: context
* @flags: kernel LO_FLAGS_{READ_ONLY,USE_AOPS,AUTOCLEAR} flags
*
* The setting is removed by loopcxt_set_device() loopcxt_next()!
@@ -1353,6 +1442,10 @@ int loopcxt_setup_device(struct loopdev_cxt *lc)
}
do {
+ /* indicate that file format support is implemented in
+ * sys-utils */
+ lc->info.lo_flags |= LO_FLAGS_FILE_FMT;
+
err = ioctl(dev_fd, LOOP_SET_STATUS64, &lc->info);
again = err && errno == EAGAIN;
if (again)
@@ -1415,6 +1508,10 @@ int loopcxt_ioctl_status(struct loopdev_cxt *lc)
DBG(SETUP, ul_debugobj(lc, "device open: OK"));
do {
+ /* indicate that file format support is implemented in
+ * sys-utils */
+ lc->info.lo_flags |= LO_FLAGS_FILE_FMT;
+
err = ioctl(dev_fd, LOOP_SET_STATUS64, &lc->info);
again = err && errno == EAGAIN;
if (again)
diff --git a/sys-utils/losetup.8 b/sys-utils/losetup.8
index a14e7cb33..5af155284 100644
--- a/sys-utils/losetup.8
+++ b/sys-utils/losetup.8
@@ -136,6 +136,11 @@ Enable or disable direct I/O for the backing file. The optional argument
can be either \fBon\fR or \fBoff\fR. If the argument is omitted, it defaults
to \fBon\fR.
.TP
+.BR \-t , " \-\-type \fIformat\fR"
+Set the file format type of the loop device. If no file format type is specified,
+the RAW file format is used by default. Valid file formats are: \fBRAW\fR,
+\fBQCOW\fR, \fBVDI\fR, \fBVMDK\fR.
+.TP
.BR \-v , " \-\-verbose"
Verbose mode.
.TP
diff --git a/sys-utils/losetup.c b/sys-utils/losetup.c
index 379b95f17..5e5ce9e28 100644
--- a/sys-utils/losetup.c
+++ b/sys-utils/losetup.c
@@ -43,6 +43,7 @@ enum {
COL_NAME = 0,
COL_AUTOCLR,
COL_BACK_FILE,
+ COL_FILE_FMT_TYPE,
COL_BACK_INO,
COL_BACK_MAJMIN,
COL_MAJMIN,
@@ -69,18 +70,19 @@ struct colinfo {
};
static struct colinfo infos[] = {
- [COL_AUTOCLR] = { "AUTOCLEAR", 1, SCOLS_FL_RIGHT, N_("autoclear flag set"), SCOLS_JSON_BOOLEAN},
- [COL_BACK_FILE] = { "BACK-FILE", 0.3, 0, N_("device backing file")},
- [COL_BACK_INO] = { "BACK-INO", 4, SCOLS_FL_RIGHT, N_("backing file inode number"), SCOLS_JSON_NUMBER},
- [COL_BACK_MAJMIN] = { "BACK-MAJ:MIN", 6, 0, N_("backing file major:minor device number")},
- [COL_NAME] = { "NAME", 0.25, 0, N_("loop device name")},
- [COL_OFFSET] = { "OFFSET", 5, SCOLS_FL_RIGHT, N_("offset from the beginning"), SCOLS_JSON_NUMBER},
- [COL_PARTSCAN] = { "PARTSCAN", 1, SCOLS_FL_RIGHT, N_("partscan flag set"), SCOLS_JSON_BOOLEAN},
- [COL_RO] = { "RO", 1, SCOLS_FL_RIGHT, N_("read-only device"), SCOLS_JSON_BOOLEAN},
- [COL_SIZELIMIT] = { "SIZELIMIT", 5, SCOLS_FL_RIGHT, N_("size limit of the file in bytes"), SCOLS_JSON_NUMBER},
- [COL_MAJMIN] = { "MAJ:MIN", 3, 0, N_("loop device major:minor number")},
- [COL_DIO] = { "DIO", 1, SCOLS_FL_RIGHT, N_("access backing file with direct-io"), SCOLS_JSON_BOOLEAN},
- [COL_LOGSEC] = { "LOG-SEC", 4, SCOLS_FL_RIGHT, N_("logical sector size in bytes"), SCOLS_JSON_NUMBER},
+ [COL_AUTOCLR] = { "AUTOCLEAR", 1, SCOLS_FL_RIGHT, N_("autoclear flag set"), SCOLS_JSON_BOOLEAN},
+ [COL_BACK_FILE] = { "BACK-FILE", 0.3, 0, N_("device backing file")},
+ [COL_FILE_FMT_TYPE] = { "FILE-FORMAT", 1, 0, N_("backing file format")},
+ [COL_BACK_INO] = { "BACK-INO", 4, SCOLS_FL_RIGHT, N_("backing file inode number"), SCOLS_JSON_NUMBER},
+ [COL_BACK_MAJMIN] = { "BACK-MAJ:MIN", 6, 0, N_("backing file major:minor device number")},
+ [COL_NAME] = { "NAME", 0.25, 0, N_("loop device name")},
+ [COL_OFFSET] = { "OFFSET", 5, SCOLS_FL_RIGHT, N_("offset from the beginning"), SCOLS_JSON_NUMBER},
+ [COL_PARTSCAN] = { "PARTSCAN", 1, SCOLS_FL_RIGHT, N_("partscan flag set"), SCOLS_JSON_BOOLEAN},
+ [COL_RO] = { "RO", 1, SCOLS_FL_RIGHT, N_("read-only device"), SCOLS_JSON_BOOLEAN},
+ [COL_SIZELIMIT] = { "SIZELIMIT", 5, SCOLS_FL_RIGHT, N_("size limit of the file in bytes"), SCOLS_JSON_NUMBER},
+ [COL_MAJMIN] = { "MAJ:MIN", 3, 0, N_("loop device major:minor number")},
+ [COL_DIO] = { "DIO", 1, SCOLS_FL_RIGHT, N_("access backing file with direct-io"), SCOLS_JSON_BOOLEAN},
+ [COL_LOGSEC] = { "LOG-SEC", 4, SCOLS_FL_RIGHT, N_("logical sector size in bytes"), SCOLS_JSON_NUMBER},
};
static int columns[ARRAY_SIZE(infos) * 2] = {-1};
@@ -120,11 +122,16 @@ static int printf_loopdev(struct loopdev_cxt *lc)
ino_t ino = 0;
char *fname;
uint32_t type;
+ char *file_fmt_str;
fname = loopcxt_get_backing_file(lc);
if (!fname)
return -EINVAL;
+ file_fmt_str = loopcxt_get_file_fmt_type_string(lc);
+ if (!file_fmt_str)
+ return -EINVAL;
+
if (loopcxt_get_backing_devno(lc, &dev) == 0)
loopcxt_get_backing_inode(lc, &ino);
@@ -141,6 +148,9 @@ static int printf_loopdev(struct loopdev_cxt *lc)
if (loopcxt_get_sizelimit(lc, &x) == 0 && x)
printf(_(", sizelimit %ju"), x);
+
+ printf(_(", file-format %s"), file_fmt_str);
+
goto done;
}
@@ -162,6 +172,8 @@ static int printf_loopdev(struct loopdev_cxt *lc)
printf(_(", encryption %s (type %u)"), e, type);
}
+ printf(_(", file-format %s"), file_fmt_str);
+
done:
free(fname);
printf("\n");
@@ -241,6 +253,9 @@ static int set_scols_data(struct loopdev_cxt *lc, struct libscols_line *ln)
case COL_BACK_FILE:
p = loopcxt_get_backing_file(lc);
break;
+ case COL_FILE_FMT_TYPE:
+ p = loopcxt_get_file_fmt_type_string(lc);
+ break;
case COL_OFFSET:
if (loopcxt_get_offset(lc, &x) == 0)
xasprintf(&np, "%jd", x);
@@ -424,6 +439,7 @@ static void __attribute__((__noreturn__)) usage(void)
fputs(_(" -r, --read-only set up a read-only loop device\n"), out);
fputs(_(" --direct-io[=<on|off>] open backing file with O_DIRECT\n"), out);
fputs(_(" --show print device name after setup (with -f)\n"), out);
+ fputs(_(" -t, --type set file format type of the loop device\n"), out);
fputs(_(" -v, --verbose verbose mode\n"), out);
/* output options */
@@ -473,7 +489,7 @@ static void warn_size(const char *filename, uint64_t size, uint64_t offset, int
static int create_loop(struct loopdev_cxt *lc,
int nooverlap, int lo_flags, int flags,
const char *file, uint64_t offset, uint64_t sizelimit,
- uint64_t blocksize)
+ uint64_t blocksize, uint32_t file_fmt_type)
{
int hasdev = loopcxt_has_device(lc);
int rc = 0;
@@ -568,6 +584,12 @@ static int create_loop(struct loopdev_cxt *lc,
warn(_("%s: failed to use backing file"), file);
break;
}
+
+ if ((rc = loopcxt_set_file_fmt_type(lc, file_fmt_type))) {
+ warn(_("failed to use backing file format type"));
+ break;
+ }
+
errno = 0;
rc = loopcxt_setup_device(lc);
if (rc == 0)
@@ -595,6 +617,8 @@ int main(int argc, char **argv)
char *outarg = NULL;
int list = 0;
unsigned long use_dio = 0, set_dio = 0, set_blocksize = 0;
+ int use_file_fmt_type = 0;
+ uint32_t file_fmt_type = 0;
enum {
OPT_SIZELIMIT = CHAR_MAX + 1,
@@ -625,6 +649,7 @@ int main(int argc, char **argv)
{ "direct-io", optional_argument, NULL, OPT_DIO },
{ "raw", no_argument, NULL, OPT_RAW },
{ "show", no_argument, NULL, OPT_SHOW },
+ { "type", required_argument, NULL, 't' },
{ "verbose", no_argument, NULL, 'v' },
{ "version", no_argument, NULL, 'V' },
{ NULL, 0, NULL, 0 }
@@ -647,7 +672,7 @@ int main(int argc, char **argv)
if (loopcxt_init(&lc, 0))
err(EXIT_FAILURE, _("failed to initialize loopcxt"));
- while ((c = getopt_long(argc, argv, "ab:c:d:Dfhj:JlLno:O:PrvV",
+ while ((c = getopt_long(argc, argv, "ab:c:d:Dfhj:JlLno:O:Prt:vV",
longopts, NULL)) != -1) {
err_exclusive_options(c, longopts, excl, excl_st);
@@ -725,6 +750,14 @@ int main(int argc, char **argv)
if (optarg)
use_dio = parse_switch(optarg, _("argument error"), "on", "off", NULL);
break;
+ case 't':
+ if (optarg) {
+ if (parse_file_fmt_type(optarg, &file_fmt_type) == 0)
+ use_file_fmt_type = 1;
+ else
+ errx(EXIT_FAILURE, _("failed to parse file format type"));
+ }
+ break;
case 'v':
break;
case OPT_SIZELIMIT: /* --sizelimit */
@@ -763,6 +796,7 @@ int main(int argc, char **argv)
columns[ncolumns++] = COL_AUTOCLR;
columns[ncolumns++] = COL_RO;
columns[ncolumns++] = COL_BACK_FILE;
+ columns[ncolumns++] = COL_FILE_FMT_TYPE;
columns[ncolumns++] = COL_DIO;
columns[ncolumns++] = COL_LOGSEC;
}
@@ -822,10 +856,10 @@ int main(int argc, char **argv)
}
if (act != A_CREATE &&
- (sizelimit || lo_flags || showdev))
+ (sizelimit || lo_flags || showdev || use_file_fmt_type))
errx(EXIT_FAILURE,
_("the options %s are allowed during loop device setup only"),
- "--{sizelimit,partscan,read-only,show}");
+ "--{sizelimit,partscan,read-only,show,type}");
if ((flags & LOOPDEV_FL_OFFSET) &&
act != A_CREATE && (act != A_SHOW || !file))
@@ -838,7 +872,7 @@ int main(int argc, char **argv)
switch (act) {
case A_CREATE:
res = create_loop(&lc, no_overlap, lo_flags, flags, file,
- offset, sizelimit, blocksize);
+ offset, sizelimit, blocksize, file_fmt_type);
if (res == 0) {
if (showdev)
printf("%s\n", loopcxt_get_device(&lc));
diff --git a/tests/expected/losetup/losetup-blkdev-offset b/tests/expected/losetup/losetup-blkdev-offset
index 7b37b6fb0..496392386 100644
--- a/tests/expected/losetup/losetup-blkdev-offset
+++ b/tests/expected/losetup/losetup-blkdev-offset
@@ -1,3 +1,4 @@
offset: 1048576
sizelimit: 0
size: 10485760
+type: RAW
diff --git a/tests/expected/losetup/losetup-blkdev-section b/tests/expected/losetup/losetup-blkdev-section
index b480d6654..379bef3af 100644
--- a/tests/expected/losetup/losetup-blkdev-section
+++ b/tests/expected/losetup/losetup-blkdev-section
@@ -1,3 +1,4 @@
offset: 1048576
sizelimit: 3145728
size: 3145728
+type: RAW
diff --git a/tests/expected/losetup/losetup-blkdev-show b/tests/expected/losetup/losetup-blkdev-show
index 2afc15105..245e096be 100644
--- a/tests/expected/losetup/losetup-blkdev-show
+++ b/tests/expected/losetup/losetup-blkdev-show
@@ -1,3 +1,4 @@
offset: 0
sizelimit: 0
size: 11534336
+type: RAW
diff --git a/tests/expected/losetup/losetup-blkdev-sizelimit b/tests/expected/losetup/losetup-blkdev-sizelimit
index d220d48da..7e2ed601d 100644
--- a/tests/expected/losetup/losetup-blkdev-sizelimit
+++ b/tests/expected/losetup/losetup-blkdev-sizelimit
@@ -1,3 +1,4 @@
offset: 0
sizelimit: 3145728
size: 3145728
+type: RAW
diff --git a/tests/expected/losetup/losetup-file-offset b/tests/expected/losetup/losetup-file-offset
index b416f8e01..4a1ab54e7 100644
--- a/tests/expected/losetup/losetup-file-offset
+++ b/tests/expected/losetup/losetup-file-offset
@@ -1,3 +1,4 @@
offset: 1048576
sizelimit: 0
size: 9437184
+type: RAW
diff --git a/tests/expected/losetup/losetup-file-section b/tests/expected/losetup/losetup-file-section
index b480d6654..379bef3af 100644
--- a/tests/expected/losetup/losetup-file-section
+++ b/tests/expected/losetup/losetup-file-section
@@ -1,3 +1,4 @@
offset: 1048576
sizelimit: 3145728
size: 3145728
+type: RAW
diff --git a/tests/expected/losetup/losetup-file-secton b/tests/expected/losetup/losetup-file-secton
deleted file mode 100644
index b480d6654..000000000
--- a/tests/expected/losetup/losetup-file-secton
+++ /dev/null
@@ -1,3 +0,0 @@
-offset: 1048576
-sizelimit: 3145728
-size: 3145728
diff --git a/tests/expected/losetup/losetup-file-show b/tests/expected/losetup/losetup-file-show
index 09d11473f..063a12646 100644
--- a/tests/expected/losetup/losetup-file-show
+++ b/tests/expected/losetup/losetup-file-show
@@ -1,3 +1,4 @@
offset: 0
sizelimit: 0
size: 10485760
+type: RAW
diff --git a/tests/expected/losetup/losetup-file-sizelimit b/tests/expected/losetup/losetup-file-sizelimit
index d220d48da..7e2ed601d 100644
--- a/tests/expected/losetup/losetup-file-sizelimit
+++ b/tests/expected/losetup/losetup-file-sizelimit
@@ -1,3 +1,4 @@
offset: 0
sizelimit: 3145728
size: 3145728
+type: RAW
diff --git a/tests/expected/losetup/losetup-file-type b/tests/expected/losetup/losetup-file-type
new file mode 100644
index 000000000..063a12646
--- /dev/null
+++ b/tests/expected/losetup/losetup-file-type
@@ -0,0 +1,4 @@
+offset: 0
+sizelimit: 0
+size: 10485760
+type: RAW
diff --git a/tests/ts/losetup/losetup b/tests/ts/losetup/losetup
index 1fec0dd06..42eb1d78c 100755
--- a/tests/ts/losetup/losetup
+++ b/tests/ts/losetup/losetup
@@ -69,6 +69,14 @@ lo_print $LODEV >> $TS_OUTPUT
$TS_CMD_LOSETUP -d $LODEV
ts_finalize_subtest
+ts_init_subtest "file-type"
+LODEV=$( $TS_CMD_LOSETUP --type RAW --find --show $BACKFILE )
+if [ -z "$LODEV" ]; then
+ ts_log "Failed to create loop device"
+fi
+lo_print $LODEV >> $TS_OUTPUT
+$TS_CMD_LOSETUP -d $LODEV
+ts_finalize_subtest
ts_init_subtest "file-section"
LODEV=$( $TS_CMD_LOSETUP --offset 1MiB --sizelimit 3MiB --find --show $BACKFILE )
diff --git a/tests/ts/losetup/losetup_functions.sh b/tests/ts/losetup/losetup_functions.sh
index d17c82a30..875b53e94 100644
--- a/tests/ts/losetup/losetup_functions.sh
+++ b/tests/ts/losetup/losetup_functions.sh
@@ -4,4 +4,5 @@ function lo_print {
echo "offset: $( $TS_CMD_LOSETUP --list --raw -n -O OFFSET $lo )"
echo "sizelimit: $( $TS_CMD_LOSETUP --list --raw -n -O SIZELIMIT $lo )"
echo "size: $( $TS_CMD_LSBLK -o SIZE -b -n -r $lo )"
+ echo "type: $( $TS_CMD_LOSETUP --list --raw -n -O FILE-FORMAT $lo )"
}