summaryrefslogtreecommitdiff
path: root/quotaops.c
diff options
context:
space:
mode:
authorPetr Písař <ppisar@redhat.com>2013-01-09 18:16:14 +0100
committerJan Kara <jack@suse.cz>2013-01-21 22:52:22 +0100
commitf61d6442cc92a2b2935db6995b8d901235dbd076 (patch)
tree23a50e50a1c355a6c8e897614b4db10ac7301f81 /quotaops.c
parent2d851a9726b799078f8c2279d8dd9ce39b7b4055 (diff)
Recognize units at block limits by edquota
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ř <ppisar@redhat.com> Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'quotaops.c')
-rw-r--r--quotaops.c28
1 files changed, 25 insertions, 3 deletions
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);
}