dcavalca / rpms / util-linux

Forked from rpms/util-linux 2 years ago
Clone
05ad79
From 14a4f41a94cc4bd227940c4bd976e39d9f13e8c5 Mon Sep 17 00:00:00 2001
05ad79
From: Karel Zak <kzak@redhat.com>
05ad79
Date: Thu, 7 Jun 2018 12:05:08 +0200
05ad79
Subject: [PATCH 168/173] losetup: keep -f and <devname> mutually exclusive
05ad79
05ad79
losetup tries to blindly use specified device as well as search for
05ad79
the first free device, the result is:
05ad79
05ad79
 # losetup /dev/loop1 -f /tmp/tfile_loop1
05ad79
 losetup: /dev/loop1: failed to set up loop device: Invalid argument
05ad79
05ad79
fixed version:
05ad79
05ad79
 # losetup /dev/loop10 -f img
05ad79
 losetup: unexpected arguments
05ad79
05ad79
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1566432
05ad79
Upstream: http://github.com/karelzak/util-linux/commit/c3f5a0f1d47dbc47f6d21da232d4eb1cfb7905db
05ad79
Signed-off-by: Karel Zak <kzak@redhat.com>
05ad79
---
05ad79
 sys-utils/losetup.c | 3 +++
05ad79
 1 file changed, 3 insertions(+)
05ad79
05ad79
diff --git a/sys-utils/losetup.c b/sys-utils/losetup.c
05ad79
index d9b0c9b61..8df831b8f 100644
05ad79
--- a/sys-utils/losetup.c
05ad79
+++ b/sys-utils/losetup.c
05ad79
@@ -545,6 +545,9 @@ int main(int argc, char **argv)
05ad79
 		 */
05ad79
 		act = A_CREATE;
05ad79
 		file = argv[optind++];
05ad79
+
05ad79
+		if (optind < argc)
05ad79
+			errx(EXIT_FAILURE, _("unexpected arguments"));
05ad79
 	}
05ad79
 
05ad79
 	if (list && !act && optind == argc)
05ad79
-- 
05ad79
2.14.4
05ad79