|
|
dba0f0 |
From 2d851a9726b799078f8c2279d8dd9ce39b7b4055 Mon Sep 17 00:00:00 2001
|
|
|
dba0f0 |
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
|
|
|
dba0f0 |
Date: Wed, 9 Jan 2013 17:27:11 +0100
|
|
|
dba0f0 |
Subject: [PATCH 2/5] Recognize block limit units on setquota standard input
|
|
|
dba0f0 |
MIME-Version: 1.0
|
|
|
dba0f0 |
Content-Type: text/plain; charset=UTF-8
|
|
|
dba0f0 |
Content-Transfer-Encoding: 8bit
|
|
|
dba0f0 |
|
|
|
dba0f0 |
This patch adds support for binary suffixes on `setquota -b' input.
|
|
|
dba0f0 |
|
|
|
dba0f0 |
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
|
|
dba0f0 |
Signed-off-by: Jan Kara <jack@suse.cz>
|
|
|
dba0f0 |
---
|
|
|
dba0f0 |
setquota.c | 26 ++++++++++++++++++++++----
|
|
|
dba0f0 |
1 file changed, 22 insertions(+), 4 deletions(-)
|
|
|
dba0f0 |
|
|
|
dba0f0 |
diff --git a/setquota.c b/setquota.c
|
|
|
dba0f0 |
index ccac7f7..e55b79d 100644
|
|
|
dba0f0 |
--- a/setquota.c
|
|
|
dba0f0 |
+++ b/setquota.c
|
|
|
dba0f0 |
@@ -319,7 +319,9 @@ static int read_entry(qid_t *id, qsize_t *isoftlimit, qsize_t *ihardlimit, qsize
|
|
|
dba0f0 |
static int line = 0;
|
|
|
dba0f0 |
char name[MAXNAMELEN+1];
|
|
|
dba0f0 |
char linebuf[MAXLINELEN], *chptr;
|
|
|
dba0f0 |
- unsigned long is, ih, bs, bh;
|
|
|
dba0f0 |
+ unsigned long is, ih;
|
|
|
dba0f0 |
+ char bs[MAXNAMELEN+1], bh[MAXNAMELEN+1];
|
|
|
dba0f0 |
+ const char *error;
|
|
|
dba0f0 |
int ret;
|
|
|
dba0f0 |
|
|
|
dba0f0 |
while (1) {
|
|
|
dba0f0 |
@@ -337,7 +339,7 @@ static int read_entry(qid_t *id, qsize_t *isoftlimit, qsize_t *ihardlimit, qsize
|
|
|
dba0f0 |
chptr++;
|
|
|
dba0f0 |
if (*chptr == '\n')
|
|
|
dba0f0 |
continue;
|
|
|
dba0f0 |
- ret = sscanf(chptr, "%s %lu %lu %lu %lu", name, &bs, &bh, &is, &ih;;
|
|
|
dba0f0 |
+ ret = sscanf(chptr, "%s %s %s %lu %lu", name, bs, bh, &is, &ih;;
|
|
|
dba0f0 |
if (ret != 5) {
|
|
|
dba0f0 |
errstr(_("Cannot parse input line %d.\n"), line);
|
|
|
dba0f0 |
if (!(flags & FL_CONTINUE_BATCH))
|
|
|
dba0f0 |
@@ -353,12 +355,28 @@ static int read_entry(qid_t *id, qsize_t *isoftlimit, qsize_t *ihardlimit, qsize
|
|
|
dba0f0 |
errstr(_("Skipping line.\n"));
|
|
|
dba0f0 |
continue;
|
|
|
dba0f0 |
}
|
|
|
dba0f0 |
+ error = str2space(bs, bsoftlimit);
|
|
|
dba0f0 |
+ if (error) {
|
|
|
dba0f0 |
+ errstr(_("Unable to parse block soft limit '%s' "
|
|
|
dba0f0 |
+ "on line %d: %s\n"), bs, line, error);
|
|
|
dba0f0 |
+ if (!(flags & FL_CONTINUE_BATCH))
|
|
|
dba0f0 |
+ die(1, _("Exitting.\n"));
|
|
|
dba0f0 |
+ errstr(_("Skipping line.\n"));
|
|
|
dba0f0 |
+ continue;
|
|
|
dba0f0 |
+ }
|
|
|
dba0f0 |
+ error = str2space(bh, bhardlimit);
|
|
|
dba0f0 |
+ if (error) {
|
|
|
dba0f0 |
+ errstr(_("Unable to parse block hard limit '%s' "
|
|
|
dba0f0 |
+ "on line %d: %s\n"), bh, line, error);
|
|
|
dba0f0 |
+ if (!(flags & FL_CONTINUE_BATCH))
|
|
|
dba0f0 |
+ die(1, _("Exitting.\n"));
|
|
|
dba0f0 |
+ errstr(_("Skipping line.\n"));
|
|
|
dba0f0 |
+ continue;
|
|
|
dba0f0 |
+ }
|
|
|
dba0f0 |
break;
|
|
|
dba0f0 |
}
|
|
|
dba0f0 |
*isoftlimit = is;
|
|
|
dba0f0 |
*ihardlimit = ih;
|
|
|
dba0f0 |
- *bsoftlimit = bs;
|
|
|
dba0f0 |
- *bhardlimit = bh;
|
|
|
dba0f0 |
return 0;
|
|
|
dba0f0 |
}
|
|
|
dba0f0 |
|
|
|
dba0f0 |
--
|
|
|
dba0f0 |
1.8.1.4
|
|
|
dba0f0 |
|