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

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