diff options
author | Petr Písař <ppisar@redhat.com> | 2013-01-09 18:16:14 +0100 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2013-01-21 23:00:13 +0100 |
commit | 73316c7746e89896c63fc49f24cafe32335df288 (patch) | |
tree | 76d811e3b8a26faac9e91b8d690a81c05efddb33 | |
parent | fdcf21db852bc8d6c1d0b41f2812ba614851e2b4 (diff) | |
download | linuxquota-73316c7746e89896c63fc49f24cafe32335df288.tar.gz |
Recognize units at inode limits by edquota
With this patch, it's possible to specify inode values including
decimal units in the editor run by edquota.
Signed-off-by: Petr Písař <ppisar@redhat.com>
Signed-off-by: Jan Kara <jack@suse.cz>
-rw-r--r-- | edquota.8 | 4 | ||||
-rw-r--r-- | quotaops.c | 26 | ||||
-rw-r--r-- | setquota.c | 2 |
3 files changed, 26 insertions, 6 deletions
@@ -68,6 +68,10 @@ Block usage and limits are reported and interpereted as multiples of kibibyte (1024 bytes) blocks by default. Symbols K, M, G, and T can be appended to numeric value to express kibibytes, mebibytes, gibibytes, and tebibytes. .PP +Inode usage and limits are interpreted literally. Symbols k, m, g, and t can +be appended to numeric value to express multiples of 10^3, 10^6, 10^9, and +10^12 inodes. +.PP Users are permitted to exceed their soft limits for a grace period that may be specified per filesystem. Once the grace period has expired, the soft limit is enforced as a hard limit. @@ -310,11 +310,11 @@ int readprivs(struct dquot *qlist, int infd) { FILE *fd; int cnt; - qsize_t blocks, bsoft, bhard; - long long inodes, isoft, ihard; + qsize_t blocks, bsoft, bhard, inodes, isoft, ihard; struct dquot *q; char fsp[BUFSIZ], line[BUFSIZ]; char blocksstring[BUFSIZ], bsoftstring[BUFSIZ], bhardstring[BUFSIZ]; + char inodesstring[BUFSIZ], isoftstring[BUFSIZ], ihardstring[BUFSIZ]; const char *error; lseek(infd, 0, SEEK_SET); @@ -328,9 +328,9 @@ int readprivs(struct dquot *qlist, int infd) fgets(line, sizeof(line), fd); while (fgets(line, sizeof(line), fd)) { - cnt = sscanf(line, "%s %s %s %s %llu %llu %llu", + cnt = sscanf(line, "%s %s %s %s %s %s %s", fsp, blocksstring, bsoftstring, bhardstring, - &inodes, &isoft, &ihard); + inodesstring, isoftstring, ihardstring); if (cnt != 7) { errstr(_("Bad format:\n%s\n"), line); @@ -354,6 +354,24 @@ int readprivs(struct dquot *qlist, int infd) bhardstring, error); return -1; } + error = str2number(inodesstring, &inodes); + if (error) { + errstr(_("Bad inode usage: %s: %s\n"), + inodesstring, error); + return -1; + } + error = str2number(isoftstring, &isoft); + if (error) { + errstr(_("Bad inode soft limit: %s: %s\n"), + isoftstring, error); + return -1; + } + error = str2number(ihardstring, &ihard); + if (error) { + errstr(_("Bad inode hard limit: %s: %s\n"), + ihardstring, error); + return -1; + } merge_limits_to_list(qlist, fsp, blocks, bsoft, bhard, inodes, isoft, ihard); } @@ -406,8 +406,6 @@ static int read_entry(qid_t *id, qsize_t *isoftlimit, qsize_t *ihardlimit, qsize } break; } - *isoftlimit = is; - *ihardlimit = ih; return 0; } |