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

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