public inbox for util-linux@vger.kernel.org
 help / color / mirror / Atom feed
From: Robert Milasan <rmilasan@suse.com>
To: <util-linux@vger.kernel.org>
Subject: swapon: fix -d short option
Date: Tue, 21 Oct 2014 10:02:46 +0200	[thread overview]
Message-ID: <20141021100246.3e956b6d@viper.suse.cz> (raw)

[-- 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);

             reply	other threads:[~2014-10-21  8:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-21  8:02 Robert Milasan [this message]
2014-10-21  9:55 ` swapon: fix -d short option Karel Zak
2014-10-21 10:07   ` Robert Milasan
2014-10-21 10:38     ` Karel Zak
2014-10-21 19:41       ` Benno Schulenberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20141021100246.3e956b6d@viper.suse.cz \
    --to=rmilasan@suse.com \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox