summaryrefslogtreecommitdiff
path: root/quotasys.c
diff options
context:
space:
mode:
authorjkar8572 <jkar8572>2001-09-10 10:34:16 +0000
committerjkar8572 <jkar8572>2001-09-10 10:34:16 +0000
commitb38bda88e0b6050d745889f478f6f8b78a7e776f (patch)
tree7767f7b3a10a9d0857a8e43745fe9c2749c8ceae /quotasys.c
parentc0144017620cbee64a818ede2ea7d23d04aaff56 (diff)
Implemented reading of statistics through /proc/fs/quota (Nathan Scott) + minor changes by Jan Kara
Diffstat (limited to 'quotasys.c')
-rw-r--r--quotasys.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/quotasys.c b/quotasys.c
index f25a80a..85af84e 100644
--- a/quotasys.c
+++ b/quotasys.c
@@ -454,17 +454,23 @@ int devcmp_handles(struct quota_handle *a, struct quota_handle *b)
* Check kernel quota version
*/
-#define KERN_KNOWN_QUOTA_VERSION (6*10000 + 5*100 + 0)
-
int kern_quota_format(void)
{
struct dqstats stats;
+ FILE *f;
int ret = 0;
struct stat st;
if (!stat("/proc/fs/xfs/stat", &st))
ret |= (1 << QF_XFS);
- if (quotactl(QCMD(Q_GETSTATS, 0), NULL, 0, (void *)&stats) < 0) {
+ if ((f = fopen(QSTAT_FILE, "r"))) {
+ if (fscanf(f, "Version %u", &stats.version) != 1) {
+ fclose(f);
+ return QF_TOONEW;
+ }
+ fclose(f);
+ }
+ else if (quotactl(QCMD(Q_GETSTATS, 0), NULL, 0, (void *)&stats) < 0) {
if (errno == ENOSYS || errno == ENOTSUP) /* Quota not compiled? */
return QF_ERROR;
if (errno == EINVAL || errno == EFAULT || errno == EPERM) /* Old quota compiled? */
@@ -474,7 +480,11 @@ int kern_quota_format(void)
/* We might do some more generic checks in future but this should be enough for now */
if (stats.version > KERN_KNOWN_QUOTA_VERSION) /* Newer kernel than we know? */
return QF_TOONEW;
- return ret | (1 << QF_VFSV0); /* New format supported */
+ if (stats.version <= 6*10000+4*100+0) /* Old quota format? */
+ ret |= (1 << QF_VFSOLD);
+ else
+ ret |= (1 << QF_VFSV0);
+ return ret; /* New format supported */
}
/*