specified loop device.
.TP
.BR \-P , " \-\-partscan"
-Force the kernel to scan the partition table on a newly created loop device.
+Force the kernel to scan the partition table on a newly created loop device. Note that the
+partition table parsing depends on sector sizes. The default is sector size is 512 bytes,
+otherwise you need to use use the option \fB\-\-sector\-size\fR together with \fB\-\-partscan\fR.
.TP
.BR \-r , " \-\-read\-only"
Set up a read-only loop device.
static int create_loop(struct loopdev_cxt *lc,
int nooverlap, int lo_flags, int flags,
- const char *file, uint64_t offset, uint64_t sizelimit)
+ const char *file, uint64_t offset, uint64_t sizelimit,
+ uint64_t blocksize)
{
int hasdev = loopcxt_has_device(lc);
int rc = 0;
loopcxt_set_sizelimit(lc, sizelimit);
if (lo_flags)
loopcxt_set_flags(lc, lo_flags);
+ if (blocksize > 0)
+ loopcxt_set_blocksize(lc, blocksize);
+
if ((rc = loopcxt_set_backing_file(lc, file))) {
warn(_("%s: failed to use backing file"), file);
break;
switch (act) {
case A_CREATE:
- res = create_loop(&lc, no_overlap, lo_flags, flags, file, offset, sizelimit);
+ res = create_loop(&lc, no_overlap, lo_flags, flags, file,
+ offset, sizelimit, blocksize);
if (res == 0) {
if (showdev)
printf("%s\n", loopcxt_get_device(&lc));
warn_size(file, sizelimit, offset, flags);
- if (set_dio || set_blocksize)
- goto lo_set_post;
+ if (set_dio)
+ goto lo_set_dio;
}
break;
case A_DELETE:
loopcxt_get_device(&lc));
break;
case A_SET_DIRECT_IO:
+lo_set_dio:
+ res = loopcxt_ioctl_dio(&lc, use_dio);
+ if (res)
+ warn(_("%s: set direct io failed"),
+ loopcxt_get_device(&lc));
+ break;
case A_SET_BLOCKSIZE:
- lo_set_post:
- if (set_dio) {
- res = loopcxt_ioctl_dio(&lc, use_dio);
- if (res)
- warn(_("%s: set direct io failed"),
- loopcxt_get_device(&lc));
- }
- if (set_blocksize) {
- res = loopcxt_ioctl_blocksize(&lc, blocksize);
- if (res)
- warn(_("%s: set logical block size failed"),
- loopcxt_get_device(&lc));
- }
+ res = loopcxt_ioctl_blocksize(&lc, blocksize);
+ if (res)
+ warn(_("%s: set logical block size failed"),
+ loopcxt_get_device(&lc));
break;
default:
warnx(_("bad usage"));