Blame SOURCES/quota-4.01-Recognize-units-at-block-limits-by-edquota.patch

370c56
From f61d6442cc92a2b2935db6995b8d901235dbd076 Mon Sep 17 00:00:00 2001
370c56
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
370c56
Date: Wed, 9 Jan 2013 18:16:14 +0100
370c56
Subject: [PATCH 3/5] Recognize units at block limits by edquota
370c56
MIME-Version: 1.0
370c56
Content-Type: text/plain; charset=UTF-8
370c56
Content-Transfer-Encoding: 8bit
370c56
370c56
With this patch, it's possible to specify block values including
370c56
binary units in the editor run by edquota.
370c56
370c56
Signed-off-by: Petr Písař <ppisar@redhat.com>
370c56
Signed-off-by: Jan Kara <jack@suse.cz>
370c56
---
370c56
 edquota.8  |  4 ++++
370c56
 quotaops.c | 28 +++++++++++++++++++++++++---
370c56
 2 files changed, 29 insertions(+), 3 deletions(-)
370c56
370c56
diff --git a/edquota.8 b/edquota.8
370c56
index 4b1406b..2617068 100644
370c56
--- a/edquota.8
370c56
+++ b/edquota.8
370c56
@@ -64,6 +64,10 @@ is then invoked on the file.  The quotas may then be modified, new
370c56
 quotas added, etc.
370c56
 Setting a quota to zero indicates that no quota should be imposed.
370c56
 .PP
370c56
+Block usage and limits are reported and interpereted as multiples of kibibyte
370c56
+(1024 bytes) blocks by default. Symbols K, M, G, and T can be appended to
370c56
+numeric value to express kibibytes, mebibytes, gibibytes, and tebibytes.
370c56
+.PP
370c56
 Users are permitted to exceed their soft limits for a grace period that
370c56
 may be specified per filesystem.  Once the grace period has expired, the
370c56
 soft limit is enforced as a hard limit.
370c56
diff --git a/quotaops.c b/quotaops.c
370c56
index 1416015..32e21da 100644
370c56
--- a/quotaops.c
370c56
+++ b/quotaops.c
370c56
@@ -310,9 +310,12 @@ int readprivs(struct dquot *qlist, int infd)
370c56
 {
370c56
 	FILE *fd;
370c56
 	int cnt;
370c56
-	long long blocks, bsoft, bhard, inodes, isoft, ihard;
370c56
+	qsize_t blocks, bsoft, bhard;
370c56
+	long long inodes, isoft, ihard;
370c56
 	struct dquot *q;
370c56
 	char fsp[BUFSIZ], line[BUFSIZ];
370c56
+	char blocksstring[BUFSIZ], bsoftstring[BUFSIZ], bhardstring[BUFSIZ];
370c56
+	const char *error;
370c56
 
370c56
 	lseek(infd, 0, SEEK_SET);
370c56
 	if (!(fd = fdopen(dup(infd), "r")))
370c56
@@ -325,13 +328,32 @@ int readprivs(struct dquot *qlist, int infd)
370c56
 	fgets(line, sizeof(line), fd);
370c56
 
370c56
 	while (fgets(line, sizeof(line), fd)) {
370c56
-		cnt = sscanf(line, "%s %llu %llu %llu %llu %llu %llu",
370c56
-			     fsp, &blocks, &bsoft, &bhard, &inodes, &isoft, &ihard);
370c56
+		cnt = sscanf(line, "%s %s %s %s %llu %llu %llu",
370c56
+			     fsp, blocksstring, bsoftstring, bhardstring,
370c56
+			     &inodes, &isoft, &ihard);
370c56
 
370c56
 		if (cnt != 7) {
370c56
 			errstr(_("Bad format:\n%s\n"), line);
370c56
 			return -1;
370c56
 		}
370c56
+		error = str2space(blocksstring, &blocks;;
370c56
+		if (error) {
370c56
+			errstr(_("Bad block usage: %s: %s\n"),
370c56
+				blocksstring, error);
370c56
+			return -1;
370c56
+		}
370c56
+		error = str2space(bsoftstring, &bsoft);
370c56
+		if (error) {
370c56
+			errstr(_("Bad block soft limit: %s: %s\n"),
370c56
+				bsoftstring, error);
370c56
+			return -1;
370c56
+		}
370c56
+		error = str2space(bhardstring, &bhard);
370c56
+		if (error) {
370c56
+			errstr(_("Bad block hard limit: %s: %s\n"),
370c56
+				bhardstring, error);
370c56
+			return -1;
370c56
+		}
370c56
 
370c56
 		merge_limits_to_list(qlist, fsp, blocks, bsoft, bhard, inodes, isoft, ihard);
370c56
 	}
370c56
-- 
370c56
1.8.1.4
370c56