From f61d6442cc92a2b2935db6995b8d901235dbd076 Mon Sep 17 00:00:00 2001 From: Petr Písař Date: Wed, 9 Jan 2013 18:16:14 +0100 Subject: Recognize units at block limits by edquota MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With this patch, it's possible to specify block values including binary units in the editor run by edquota. Signed-off-by: Petr Písař Signed-off-by: Jan Kara --- quotaops.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'quotaops.c') diff --git a/quotaops.c b/quotaops.c index 1416015..32e21da 100644 --- a/quotaops.c +++ b/quotaops.c @@ -310,9 +310,12 @@ int readprivs(struct dquot *qlist, int infd) { FILE *fd; int cnt; - long long blocks, bsoft, bhard, inodes, isoft, ihard; + qsize_t blocks, bsoft, bhard; + long long inodes, isoft, ihard; struct dquot *q; char fsp[BUFSIZ], line[BUFSIZ]; + char blocksstring[BUFSIZ], bsoftstring[BUFSIZ], bhardstring[BUFSIZ]; + const char *error; lseek(infd, 0, SEEK_SET); if (!(fd = fdopen(dup(infd), "r"))) @@ -325,13 +328,32 @@ int readprivs(struct dquot *qlist, int infd) fgets(line, sizeof(line), fd); while (fgets(line, sizeof(line), fd)) { - cnt = sscanf(line, "%s %llu %llu %llu %llu %llu %llu", - fsp, &blocks, &bsoft, &bhard, &inodes, &isoft, &ihard); + cnt = sscanf(line, "%s %s %s %s %llu %llu %llu", + fsp, blocksstring, bsoftstring, bhardstring, + &inodes, &isoft, &ihard); if (cnt != 7) { errstr(_("Bad format:\n%s\n"), line); return -1; } + error = str2space(blocksstring, &blocks); + if (error) { + errstr(_("Bad block usage: %s: %s\n"), + blocksstring, error); + return -1; + } + error = str2space(bsoftstring, &bsoft); + if (error) { + errstr(_("Bad block soft limit: %s: %s\n"), + bsoftstring, error); + return -1; + } + error = str2space(bhardstring, &bhard); + if (error) { + errstr(_("Bad block hard limit: %s: %s\n"), + bhardstring, error); + return -1; + } merge_limits_to_list(qlist, fsp, blocks, bsoft, bhard, inodes, isoft, ihard); } -- cgit v1.2.3