public inbox for util-linux@vger.kernel.org
 help / color / mirror / Atom feed
* swapon: fix -d short option
@ 2014-10-21  8:02 Robert Milasan
  2014-10-21  9:55 ` Karel Zak
  0 siblings, 1 reply; 5+ messages in thread
From: Robert Milasan @ 2014-10-21  8:02 UTC (permalink / raw)
  To: util-linux

[-- Attachment #1: Type: text/plain, Size: 663 bytes --]

When -d option is used with swapon, is expected that there is an equal
'=' which at least according to the man page it doesn't make sense or
it's not properly explained.

If we use -d as we should, then swapon takes 'once' or 'pages' as an
actual device:

dhcp33:~ # swapon -p -2 -d once /dev/sdb1
swapon: stat failed once: No such file or directory

The short option -d, should be something like "swapon -d once ...." not
"swapon -d=once ...."

I've attached the patch to fix this small issue.


-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmilasan@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A

[-- Attachment #2: swapon_fix-d-short-option.patch --]
[-- Type: text/x-patch, Size: 631 bytes --]

diff --git a/sys-utils/swapon.c b/sys-utils/swapon.c
index 8609ea2..20baea3 100644
--- a/sys-utils/swapon.c
+++ b/sys-utils/swapon.c
@@ -846,12 +846,9 @@ int main(int argc, char *argv[])
 		case 'd':
 			discard |= SWAP_FLAG_DISCARD;
 			if (optarg) {
-				if (*optarg == '=')
-					optarg++;
-
-				if (strcmp(optarg, "once") == 0)
+				if (strncmp(optarg, "once", 4) == 0)
 					discard |= SWAP_FLAG_DISCARD_ONCE;
-				else if (strcmp(optarg, "pages") == 0)
+				else if (strncmp(optarg, "pages", 5) == 0)
 					discard |= SWAP_FLAG_DISCARD_PAGES;
 				else
 					errx(EXIT_FAILURE, _("unsupported discard policy: %s"), optarg);

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-10-21 19:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-21  8:02 swapon: fix -d short option Robert Milasan
2014-10-21  9:55 ` Karel Zak
2014-10-21 10:07   ` Robert Milasan
2014-10-21 10:38     ` Karel Zak
2014-10-21 19:41       ` Benno Schulenberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox