]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
losetup: clean up --direct-io
authorKarel Zak <kzak@redhat.com>
Thu, 19 Nov 2015 10:57:05 +0000 (11:57 +0100)
committerKarel Zak <kzak@redhat.com>
Thu, 19 Nov 2015 10:57:05 +0000 (11:57 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/losetup.8
sys-utils/losetup.c

index 41661e553b94f9e39ea8a0f48282b314104e2f36..90fcb9d0621f24e47c79be8213e2c682e337dd4c 100644 (file)
@@ -91,6 +91,10 @@ Detach the file or device associated with the specified loop device(s).
 .BR \-D , " \-\-detach\-all"
 Detach all associated loop devices.
 .TP
+.BR "\-\-direct\-io"[\fI=on|off\fR]
+Enable or disable direct I/O for the backing file. The optional argument can be
+\fIon\fR or \fIoff\fR.  If the optional argument is omitted, it defaults to \fIon\fR.
+.TP
 .BR \-f , " \-\-find"
 Find the first unused loop device.  If a
 .I file
index 918c34da6cb70b4e4a07b60fe99c5f76ec8f3f6c..1d57ab3414f44f79cf65294cca071b859d49cc92 100644 (file)
@@ -399,7 +399,7 @@ static void usage(FILE *out)
        fputs(_("     --sizelimit <num>         device is limited to <num> bytes of the file\n"), out);
        fputs(_(" -P, --partscan                create a partitioned loop device\n"), out);
        fputs(_(" -r, --read-only               set up a read-only loop device\n"), out);
-       fputs(_("     --direct-io               open backing file with O_DIRECT\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(_(" -v, --verbose                 verbose mode\n"), out);
 
@@ -477,7 +477,7 @@ int main(int argc, char **argv)
                { "sizelimit", 1, 0, OPT_SIZELIMIT },
                { "partscan", 0, 0, 'P' },
                { "read-only", 0, 0, 'r' },
-               { "direct-io", 1, 0, OPT_DIO },
+               { "direct-io", 2, 0, OPT_DIO },
                { "raw", 0, 0, OPT_RAW },
                { "show", 0, 0, OPT_SHOW },
                { "verbose", 0, 0, 'v' },
@@ -568,8 +568,9 @@ int main(int argc, char **argv)
                        showdev = 1;
                        break;
                case OPT_DIO:
-                       set_dio = 1;
-                       use_dio = strtoul_or_err(optarg, _("failed to parse dio"));
+                       use_dio = set_dio = 1;
+                       if (optarg)
+                               use_dio = parse_switch(optarg, _("argument error"), "on", "off", NULL);
                        break;
                case 'v':
                        break;