summaryrefslogtreecommitdiffstats
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
parent2d851a9726b799078f8c2279d8dd9ce39b7b4055 (diff)
downloadquota-tools-f61d6442cc92a2b2935db6995b8d901235dbd076.tar.gz
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>
-rw-r--r--edquota.84
-rw-r--r--quotaops.c28
2 files changed, 29 insertions, 3 deletions
diff --git a/edquota.8 b/edquota.8
index 4b1406b..2617068 100644
--- a/edquota.8
+++ b/edquota.8
@@ -64,6 +64,10 @@ is then invoked on the file. The quotas may then be modified, new
quotas added, etc.
Setting a quota to zero indicates that no quota should be imposed.
.PP
+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
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.
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);
}