diff options
author | jkar8572 <jkar8572> | 2007-11-08 13:24:17 +0000 |
---|---|---|
committer | jkar8572 <jkar8572> | 2007-11-08 13:24:17 +0000 |
commit | 4a1a91c1431038160deeed2fd12f94bfed67977e (patch) | |
tree | 782421e7d9e9a0695d7a5d9600bdd0ed352caa6a | |
parent | 1501bb88e955d47262d17f14e9fa9df2bdc3f88e (diff) |
Let setquota batch mode accept comments and blank lines (Jacky Bruno, Jan Kara)
-rw-r--r-- | Changelog | 1 | ||||
-rw-r--r-- | setquota.c | 27 |
2 files changed, 21 insertions, 7 deletions
@@ -1,4 +1,5 @@ Changes in quota-tools from 3.15 to 3.16 +* let setquota batch mode accept comments and blank lines (Jacky Bruno, Jan Kara) * print more verbose list of compile options when --version specified (Jan Kara) * quotaon(8) should work only on local filesystems (Ladislav Michnovic) * made possible to use quota rpc in mixed NFSv3 and NFSv4 environments (Jan Kara) @@ -11,6 +11,7 @@ #include <string.h> #include <getopt.h> #include <time.h> +#include <ctype.h> #if defined(RPC) #include "rquota.h" @@ -284,28 +285,40 @@ static int setlimits(struct quota_handle **handles) return ret; } -#define MAXLINELEN (MAXNUMLEN*4+MAXNAMELEN+16) +#define MAXLINELEN 65536 /* Read & parse one batch entry */ static int read_entry(qid_t *id, qsize_t *isoftlimit, qsize_t *ihardlimit, qsize_t *bsoftlimit, qsize_t *bhardlimit) { static int line = 0; char name[MAXNAMELEN+1]; + char linebuf[MAXLINELEN], *chptr; unsigned long is, ih, bs, bh; int ret; - do { + while (1) { line++; - ret = scanf("%s %lu %lu %lu %lu", name, &bs, &bh, &is, &ih); - if (ret == -1) + if (!fgets(linebuf, sizeof(linebuf), stdin)) return -1; + if (linebuf[strlen(linebuf)-1] != '\n') + die(1, _("Line %d too long.\n"), line); + /* Comment? */ + if (linebuf[0] == '#') + continue; + /* Blank line? */ + chptr = linebuf; + while (isblank(*chptr)) + chptr++; + if (*chptr == '\n') + continue; + ret = sscanf(chptr, "%s %lu %lu %lu %lu", name, &bs, &bh, &is, &ih); if (ret != 5) die(1, _("Cannot parse input line %d.\n"), line); - ret = 0; *id = name2id(name, flag2type(flags), !!(flags & FL_NUMNAMES), &ret); if (ret) - errstr(_("Unable to get name '%s'.\n"), name); - } while (ret); + die(1, _("Unable to resolve name '%s' on line %d.\n"), name, line); + break; + } *isoftlimit = is; *ihardlimit = ih; *bsoftlimit = bs; |