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

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