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

370c56
From 73316c7746e89896c63fc49f24cafe32335df288 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 5/5] Recognize units at inode 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 inode values including
370c56
decimal 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 | 26 ++++++++++++++++++++++----
370c56
 setquota.c |  2 --
370c56
 3 files changed, 26 insertions(+), 6 deletions(-)
370c56
370c56
diff --git a/edquota.8 b/edquota.8
370c56
index 2617068..fefb5d4 100644
370c56
--- a/edquota.8
370c56
+++ b/edquota.8
370c56
@@ -68,6 +68,10 @@ 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
+Inode usage and limits are interpreted literally. Symbols k, m, g, and t can
370c56
+be appended to numeric value to express multiples of 10^3, 10^6, 10^9, and
370c56
+10^12 inodes.
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 32e21da..175a945 100644
370c56
--- a/quotaops.c
370c56
+++ b/quotaops.c
370c56
@@ -310,11 +310,11 @@ int readprivs(struct dquot *qlist, int infd)
370c56
 {
370c56
 	FILE *fd;
370c56
 	int cnt;
370c56
-	qsize_t blocks, bsoft, bhard;
370c56
-	long long inodes, isoft, ihard;
370c56
+	qsize_t blocks, bsoft, bhard, inodes, isoft, ihard;
370c56
 	struct dquot *q;
370c56
 	char fsp[BUFSIZ], line[BUFSIZ];
370c56
 	char blocksstring[BUFSIZ], bsoftstring[BUFSIZ], bhardstring[BUFSIZ];
370c56
+	char inodesstring[BUFSIZ], isoftstring[BUFSIZ], ihardstring[BUFSIZ];
370c56
 	const char *error;
370c56
 
370c56
 	lseek(infd, 0, SEEK_SET);
370c56
@@ -328,9 +328,9 @@ 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 %s %s %s %llu %llu %llu",
370c56
+		cnt = sscanf(line, "%s %s %s %s %s %s %s",
370c56
 			     fsp, blocksstring, bsoftstring, bhardstring,
370c56
-			     &inodes, &isoft, &ihard);
370c56
+			     inodesstring, isoftstring, ihardstring);
370c56
 
370c56
 		if (cnt != 7) {
370c56
 			errstr(_("Bad format:\n%s\n"), line);
370c56
@@ -354,6 +354,24 @@ int readprivs(struct dquot *qlist, int infd)
370c56
 				bhardstring, error);
370c56
 			return -1;
370c56
 		}
370c56
+		error = str2number(inodesstring, &inodes);
370c56
+		if (error) {
370c56
+			errstr(_("Bad inode usage: %s: %s\n"),
370c56
+				inodesstring, error);
370c56
+			return -1;
370c56
+		}
370c56
+		error = str2number(isoftstring, &isoft);
370c56
+		if (error) {
370c56
+			errstr(_("Bad inode soft limit: %s: %s\n"),
370c56
+				isoftstring, error);
370c56
+			return -1;
370c56
+		}
370c56
+		error = str2number(ihardstring, &ihard);
370c56
+		if (error) {
370c56
+			errstr(_("Bad inode hard limit: %s: %s\n"),
370c56
+				ihardstring, error);
370c56
+			return -1;
370c56
+		}
370c56
 
370c56
 		merge_limits_to_list(qlist, fsp, blocks, bsoft, bhard, inodes, isoft, ihard);
370c56
 	}
370c56
diff --git a/setquota.c b/setquota.c
370c56
index 19449ad..cc5fee8 100644
370c56
--- a/setquota.c
370c56
+++ b/setquota.c
370c56
@@ -406,8 +406,6 @@ static int read_entry(qid_t *id, qsize_t *isoftlimit, qsize_t *ihardlimit, qsize
370c56
 		}
370c56
 		break;
370c56
 	}
370c56
-	*isoftlimit = is;
370c56
-	*ihardlimit = ih;
370c56
 	return 0;
370c56
 }
370c56
 
370c56
-- 
370c56
1.8.1.4
370c56