losetup checks for empty lo_flags when A_CREATE (action) is not
requested, otherwise it prints
"the options %s are allowed during loop device setup only"
error message. We need to cleanup lo_flags when alone --direct-io
requested.
Fix also typo in man page, "losetup --direct-io" is the same as
"losetup --direct-io=on".
Signed-off-by: Karel Zak <kzak@redhat.com>
Set up a read-only loop device.
*--direct-io*[**=on**|*off*]::
-Enable or disable direct I/O for the backing file. The optional argument can be either *on* or *off*. If the argument is omitted, it defaults to *off*.
+Enable or disable direct I/O for the backing file. The optional argument can be either *on* or *off*. If the optional argument is omitted, it defaults to *on*.
*-v*, *--verbose*::
Verbose mode.
* OR
* losetup {--direct-io[=off]|--logical-blocksize=size}... <device>
*/
- if (!(set_dio || set_blocksize))
- act = A_SHOW_ONE;
- if (set_dio)
+ if (set_dio) {
act = A_SET_DIRECT_IO;
- if (set_blocksize)
+ lo_flags &= ~LO_FLAGS_DIRECT_IO;
+ } else if (set_blocksize)
act = A_SET_BLOCKSIZE;
+ else
+ act = A_SHOW_ONE;
+
if (!is_loopdev(argv[optind]) ||
loopcxt_set_device(&lc, argv[optind]))
err(EXIT_FAILURE, _("%s: failed to use device"),