|
|
7c06a3 |
From 0d5a11f41afe14f779908fbc366c492b818a0864 Mon Sep 17 00:00:00 2001
|
|
|
7c06a3 |
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
|
|
|
7c06a3 |
Date: Wed, 6 Mar 2013 11:32:32 +0100
|
|
|
7c06a3 |
Subject: [PATCH 3/4] Correct quotasync exit code
|
|
|
7c06a3 |
MIME-Version: 1.0
|
|
|
7c06a3 |
Content-Type: text/plain; charset=UTF-8
|
|
|
7c06a3 |
Content-Transfer-Encoding: 8bit
|
|
|
7c06a3 |
|
|
|
7c06a3 |
This fixes `quotasync -h' exit code as well as it uses more portable
|
|
|
7c06a3 |
EXIT_SUCCESS/EXIT_FAILURE values.
|
|
|
7c06a3 |
|
|
|
7c06a3 |
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
|
|
7c06a3 |
Signed-off-by: Jan Kara <jack@suse.cz>
|
|
|
7c06a3 |
---
|
|
|
7c06a3 |
quotasync.c | 23 +++++++++++++----------
|
|
|
7c06a3 |
1 file changed, 13 insertions(+), 10 deletions(-)
|
|
|
7c06a3 |
|
|
|
7c06a3 |
diff --git a/quotasync.c b/quotasync.c
|
|
|
7c06a3 |
index cab9015..cfc3f2d 100644
|
|
|
7c06a3 |
--- a/quotasync.c
|
|
|
7c06a3 |
+++ b/quotasync.c
|
|
|
7c06a3 |
@@ -20,7 +20,7 @@ static char **mnt;
|
|
|
7c06a3 |
static int mntcnt;
|
|
|
7c06a3 |
char *progname;
|
|
|
7c06a3 |
|
|
|
7c06a3 |
-static void usage(void)
|
|
|
7c06a3 |
+static void usage(int status)
|
|
|
7c06a3 |
{
|
|
|
7c06a3 |
printf(_(
|
|
|
7c06a3 |
"%1$s: Utility for syncing quotas.\n"
|
|
|
7c06a3 |
@@ -39,7 +39,7 @@ static void usage(void)
|
|
|
7c06a3 |
"\n"
|
|
|
7c06a3 |
));
|
|
|
7c06a3 |
printf(_("Report bugs to <%s>.\n"), MY_EMAIL);
|
|
|
7c06a3 |
- exit(1);
|
|
|
7c06a3 |
+ exit(status);
|
|
|
7c06a3 |
}
|
|
|
7c06a3 |
|
|
|
7c06a3 |
static void parse_options(int argcnt, char **argstr)
|
|
|
7c06a3 |
@@ -57,11 +57,12 @@ static void parse_options(int argcnt, char **argstr)
|
|
|
7c06a3 |
while ((ret = getopt_long(argcnt, argstr, "ahugV", long_opts, NULL)) != -1) {
|
|
|
7c06a3 |
switch (ret) {
|
|
|
7c06a3 |
case '?':
|
|
|
7c06a3 |
+ usage(EXIT_FAILURE);
|
|
|
7c06a3 |
case 'h':
|
|
|
7c06a3 |
- usage();
|
|
|
7c06a3 |
+ usage(EXIT_SUCCESS);
|
|
|
7c06a3 |
case 'V':
|
|
|
7c06a3 |
version();
|
|
|
7c06a3 |
- exit(0);
|
|
|
7c06a3 |
+ exit(EXIT_SUCCESS);
|
|
|
7c06a3 |
case 'u':
|
|
|
7c06a3 |
flags |= FL_USER;
|
|
|
7c06a3 |
break;
|
|
|
7c06a3 |
@@ -77,7 +78,7 @@ static void parse_options(int argcnt, char **argstr)
|
|
|
7c06a3 |
if ((flags & FL_ALL && optind != argcnt) ||
|
|
|
7c06a3 |
(!(flags & FL_ALL) && optind == argcnt)) {
|
|
|
7c06a3 |
fputs(_("Bad number of arguments.\n"), stderr);
|
|
|
7c06a3 |
- usage();
|
|
|
7c06a3 |
+ usage(EXIT_FAILURE);
|
|
|
7c06a3 |
}
|
|
|
7c06a3 |
if (!(flags & FL_ALL)) {
|
|
|
7c06a3 |
mnt = argstr + optind;
|
|
|
7c06a3 |
@@ -100,10 +101,12 @@ static int syncquotas(int type)
|
|
|
7c06a3 |
int i, ret = 0;
|
|
|
7c06a3 |
|
|
|
7c06a3 |
if (flags & FL_ALL) {
|
|
|
7c06a3 |
- if (sync_one(type, NULL) < 0)
|
|
|
7c06a3 |
+ if (sync_one(type, NULL) < 0) {
|
|
|
7c06a3 |
errstr(_("%s quota sync failed: %s\n"), _(type2name(type)),
|
|
|
7c06a3 |
strerror(errno));
|
|
|
7c06a3 |
- return -1;
|
|
|
7c06a3 |
+ ret = -1;
|
|
|
7c06a3 |
+ }
|
|
|
7c06a3 |
+ return ret;
|
|
|
7c06a3 |
}
|
|
|
7c06a3 |
|
|
|
7c06a3 |
handles = create_handle_list(mntcnt, mnt, type, fmt,
|
|
|
7c06a3 |
@@ -124,7 +127,7 @@ static int syncquotas(int type)
|
|
|
7c06a3 |
|
|
|
7c06a3 |
int main(int argc, char **argv)
|
|
|
7c06a3 |
{
|
|
|
7c06a3 |
- int ret = 0;
|
|
|
7c06a3 |
+ int ret = EXIT_SUCCESS;
|
|
|
7c06a3 |
|
|
|
7c06a3 |
gettexton();
|
|
|
7c06a3 |
progname = basename(argv[0]);
|
|
|
7c06a3 |
@@ -134,9 +137,9 @@ int main(int argc, char **argv)
|
|
|
7c06a3 |
|
|
|
7c06a3 |
if (flags & FL_USER)
|
|
|
7c06a3 |
if (syncquotas(USRQUOTA))
|
|
|
7c06a3 |
- ret = 1;
|
|
|
7c06a3 |
+ ret = EXIT_FAILURE;
|
|
|
7c06a3 |
if (flags & FL_GROUP)
|
|
|
7c06a3 |
if (syncquotas(GRPQUOTA))
|
|
|
7c06a3 |
- ret = 1;
|
|
|
7c06a3 |
+ ret = EXIT_FAILURE;
|
|
|
7c06a3 |
return ret;
|
|
|
7c06a3 |
}
|
|
|
7c06a3 |
--
|
|
|
7c06a3 |
1.8.1.4
|
|
|
7c06a3 |
|