f989b93
From 73316c7746e89896c63fc49f24cafe32335df288 Mon Sep 17 00:00:00 2001
f989b93
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
f989b93
Date: Wed, 9 Jan 2013 18:16:14 +0100
f989b93
Subject: [PATCH 5/5] Recognize units at inode limits by edquota
f989b93
MIME-Version: 1.0
f989b93
Content-Type: text/plain; charset=UTF-8
f989b93
Content-Transfer-Encoding: 8bit
f989b93
f989b93
With this patch, it's possible to specify inode values including
f989b93
decimal units in the editor run by edquota.
f989b93
f989b93
Signed-off-by: Petr Písař <ppisar@redhat.com>
f989b93
Signed-off-by: Jan Kara <jack@suse.cz>
f989b93
---
f989b93
 edquota.8  |  4 ++++
f989b93
 quotaops.c | 26 ++++++++++++++++++++++----
f989b93
 setquota.c |  2 --
f989b93
 3 files changed, 26 insertions(+), 6 deletions(-)
f989b93
f989b93
diff --git a/edquota.8 b/edquota.8
f989b93
index 2617068..fefb5d4 100644
f989b93
--- a/edquota.8
f989b93
+++ b/edquota.8
f989b93
@@ -68,6 +68,10 @@ Block usage and limits are reported and interpereted as multiples of kibibyte
f989b93
 (1024 bytes) blocks by default. Symbols K, M, G, and T can be appended to
f989b93
 numeric value to express kibibytes, mebibytes, gibibytes, and tebibytes.
f989b93
 .PP
f989b93
+Inode usage and limits are interpreted literally. Symbols k, m, g, and t can
f989b93
+be appended to numeric value to express multiples of 10^3, 10^6, 10^9, and
f989b93
+10^12 inodes.
f989b93
+.PP
f989b93
 Users are permitted to exceed their soft limits for a grace period that
f989b93
 may be specified per filesystem.  Once the grace period has expired, the
f989b93
 soft limit is enforced as a hard limit.
f989b93
diff --git a/quotaops.c b/quotaops.c
f989b93
index 32e21da..175a945 100644
f989b93
--- a/quotaops.c
f989b93
+++ b/quotaops.c
f989b93
@@ -310,11 +310,11 @@ int readprivs(struct dquot *qlist, int infd)
f989b93
 {
f989b93
 	FILE *fd;
f989b93
 	int cnt;
f989b93
-	qsize_t blocks, bsoft, bhard;
f989b93
-	long long inodes, isoft, ihard;
f989b93
+	qsize_t blocks, bsoft, bhard, inodes, isoft, ihard;
f989b93
 	struct dquot *q;
f989b93
 	char fsp[BUFSIZ], line[BUFSIZ];
f989b93
 	char blocksstring[BUFSIZ], bsoftstring[BUFSIZ], bhardstring[BUFSIZ];
f989b93
+	char inodesstring[BUFSIZ], isoftstring[BUFSIZ], ihardstring[BUFSIZ];
f989b93
 	const char *error;
f989b93
 
f989b93
 	lseek(infd, 0, SEEK_SET);
f989b93
@@ -328,9 +328,9 @@ int readprivs(struct dquot *qlist, int infd)
f989b93
 	fgets(line, sizeof(line), fd);
f989b93
 
f989b93
 	while (fgets(line, sizeof(line), fd)) {
f989b93
-		cnt = sscanf(line, "%s %s %s %s %llu %llu %llu",
f989b93
+		cnt = sscanf(line, "%s %s %s %s %s %s %s",
f989b93
 			     fsp, blocksstring, bsoftstring, bhardstring,
f989b93
-			     &inodes, &isoft, &ihard);
f989b93
+			     inodesstring, isoftstring, ihardstring);
f989b93
 
f989b93
 		if (cnt != 7) {
f989b93
 			errstr(_("Bad format:\n%s\n"), line);
f989b93
@@ -354,6 +354,24 @@ int readprivs(struct dquot *qlist, int infd)
f989b93
 				bhardstring, error);
f989b93
 			return -1;
f989b93
 		}
f989b93
+		error = str2number(inodesstring, &inodes);
f989b93
+		if (error) {
f989b93
+			errstr(_("Bad inode usage: %s: %s\n"),
f989b93
+				inodesstring, error);
f989b93
+			return -1;
f989b93
+		}
f989b93
+		error = str2number(isoftstring, &isoft);
f989b93
+		if (error) {
f989b93
+			errstr(_("Bad inode soft limit: %s: %s\n"),
f989b93
+				isoftstring, error);
f989b93
+			return -1;
f989b93
+		}
f989b93
+		error = str2number(ihardstring, &ihard);
f989b93
+		if (error) {
f989b93
+			errstr(_("Bad inode hard limit: %s: %s\n"),
f989b93
+				ihardstring, error);
f989b93
+			return -1;
f989b93
+		}
f989b93
 
f989b93
 		merge_limits_to_list(qlist, fsp, blocks, bsoft, bhard, inodes, isoft, ihard);
f989b93
 	}
f989b93
diff --git a/setquota.c b/setquota.c
f989b93
index 19449ad..cc5fee8 100644
f989b93
--- a/setquota.c
f989b93
+++ b/setquota.c
f989b93
@@ -406,8 +406,6 @@ static int read_entry(qid_t *id, qsize_t *isoftlimit, qsize_t *ihardlimit, qsize
f989b93
 		}
f989b93
 		break;
f989b93
 	}
f989b93
-	*isoftlimit = is;
f989b93
-	*ihardlimit = ih;
f989b93
 	return 0;
f989b93
 }
f989b93
 
f989b93
-- 
f989b93
1.8.1.4
f989b93