[prev in list] [next in list] [prev in thread] [next in thread]
List: util-linux-ng
Subject: [PATCH] mount: Fix losetup usage()
From: Kamalesh Babulal <kamalesh () linux ! vnet ! ibm ! com>
Date: 2010-07-30 13:18:29
Message-ID: 20100730130629.GB11046 () linux ! vnet ! ibm ! com
[Download RAW message or body]
Hi,
Currently usage() of losetup returns 1 instead of 0, when
invoked with --help and invalid usage. Following patch
alters usage() to return 0, when invoked with --help and
not treat it as an invalid command usage.
Signed-off-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
--
mount/lomount.c | 29 ++++++++++++++++-------------
1 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/mount/lomount.c b/mount/lomount.c
index 6130be1..ffa80c0 100644
--- a/mount/lomount.c
+++ b/mount/lomount.c
@@ -884,7 +884,7 @@ find_unused_loop_device (void) {
#include "strtosize.h"
static void
-usage(void) {
+usage(FILE *fp, int n) {
fprintf(stderr, _("\nUsage:\n"
" %1$s loop_device give info\n"
" %1$s -a | --all list all used\n"
@@ -904,7 +904,7 @@ usage(void) {
" -r | --read-only setup read-only loop device\n"
" --show print device name (with -f <file>)\n"
" -v | --verbose verbose mode\n\n"));
- exit(1);
+ exit(n);
}
int
@@ -966,6 +966,9 @@ main(int argc, char **argv) {
case 'f':
find = 1;
break;
+ case 'h':
+ usage(stdout, 0);
+ break;
case 'j':
assoc = optarg;
break;
@@ -987,42 +990,42 @@ main(int argc, char **argv) {
break;
default:
- usage();
+ usage(stderr, 1);
}
}
if (argc == 1) {
- usage();
+ usage(stderr, 1);
} else if (delete) {
if (argc < optind+1 || encryption || offset || sizelimit ||
capacity || find || all || showdev || assoc || ro)
- usage();
+ usage(stderr, 1);
} else if (find) {
if (capacity || all || assoc || argc < optind || argc > optind+1)
- usage();
+ usage(stderr, 1);
} else if (all) {
if (argc > 2)
- usage();
+ usage(stderr, 1);
} else if (assoc) {
if (capacity || encryption || showdev || passfd || ro)
- usage();
+ usage(stderr, 1);
} else if (capacity) {
if (argc != optind + 1 || encryption || offset || sizelimit ||
showdev || ro)
- usage();
+ usage(stderr, 1);
} else {
if (argc < optind+1 || argc > optind+2)
- usage();
+ usage(stderr, 1);
}
if (offset && strtosize(offset, &off)) {
error(_("%s: invalid offset '%s' specified"), progname, offset);
- usage();
+ usage(stderr, 1);
}
if (sizelimit && strtosize(sizelimit, &slimit)) {
error(_("%s: invalid sizelimit '%s' specified"),
progname, sizelimit);
- usage();
+ usage(stderr, 1);
}
if (all)
@@ -1057,7 +1060,7 @@ main(int argc, char **argv) {
res = show_loop(device);
else {
if (passfd && sscanf(passfd, "%d", &pfd) != 1)
- usage();
+ usage(stderr, 1);
do {
res = set_loop(device, file, off, slimit, encryption, pfd, &ro);
if (res == 2 && find) {
Kamalesh
--
To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic