changeset 4448:cf334cc732e7 HEAD

Attempting to fix quota block calculations to be correct.
author Timo Sirainen <tss@iki.fi>
date Wed, 28 Jun 2006 01:00:17 +0300
parents 0a615e0aa04d
children a2d8624f8f2e
files src/plugins/quota/quota-fs.c
diffstat 1 files changed, 17 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/plugins/quota/quota-fs.c	Wed Jun 28 00:13:45 2006 +0300
+++ b/src/plugins/quota/quota-fs.c	Wed Jun 28 01:00:17 2006 +0300
@@ -24,13 +24,15 @@
 #  define dqb_curblocks dqb_curspace
 #endif
 
+#ifndef DEV_BSIZE
+#  define DEV_BSIZE 512
+#endif
+
 struct fs_quota_mountpoint {
 	char *mount_path;
 	char *device_path;
 	char *type;
 
-	unsigned int blk_size;
-
 #ifdef HAVE_Q_QUOTACTL
 	int fd;
 	char *path;
@@ -102,7 +104,6 @@
 		return NULL;
 
 	mount = i_new(struct fs_quota_mountpoint, 1);
-	mount->blk_size = point.block_size;
 	mount->device_path = point.device_path;
 	mount->mount_path = point.mount_path;
 	mount->type = point.type;
@@ -196,28 +197,33 @@
 
 		if (quotactl(QCMD(Q_XGETQUOTA, USRQUOTA),
 			     root->mount->device_path,
-			     root->uid, (void *)&xdqblk) < 0) {
+			     root->uid, (caddr_t)&xdqblk) < 0) {
 			i_error("quotactl(Q_XGETQUOTA, %s) failed: %m",
 				root->mount->device_path);
 			quota_set_error(_root->setup->quota,
 					"Internal quota error");
 			return -1;
 		}
-		dqblk.dqb_curblocks = xdqblk.d_bcount << 9;
-		dqblk.dqb_bsoftlimit = xdqblk.d_blk_softlimit >> 1;
+
+		/* values always returned in 512 byte blocks */
+		*value_r = xdqblk.d_bcount >> 1;
+		*limit_r = xdqblk.d_blk_softlimit >> 1;
 	} else
 #endif
 	{
 		/* ext2, ext3 */
 		if (quotactl(QCMD(Q_GETQUOTA, USRQUOTA),
 			     root->mount->device_path,
-			     root->uid, (void *)&dqblk) < 0) {
+			     root->uid, (caddr_t)&dqblk) < 0) {
 			i_error("quotactl(Q_GETQUOTA, %s) failed: %m",
 				root->mount->device_path);
 			quota_set_error(_root->setup->quota,
 					"Internal quota error");
 			return -1;
 		}
+
+		*value_r = dqblk.dqb_curblocks / 1024;
+		*limit_r = dqblk.dqb_bsoftlimit;
 	}
 #elif defined(HAVE_QUOTACTL)
 	/* BSD, AIX */
@@ -228,6 +234,8 @@
 		quota_set_error(_root->setup->quota, "Internal quota error");
 		return -1;
 	}
+	*value_r = (uint64_t)dqblk.dqb_curblocks * 1024 / DEV_BSIZE;
+	*limit_r = (uint64_t)dqblk.dqb_bsoftlimit * 1024 / DEV_BSIZE;
 #else
 	/* Solaris */
 	if (root->mount->fd == -1)
@@ -241,11 +249,9 @@
 		quota_set_error(_root->setup->quota, "Internal quota error");
 		return -1;
 	}
+	*value_r = (uint64_t)dqblk.dqb_curblocks * 1024 / DEV_BSIZE;
+	*limit_r = (uint64_t)dqblk.dqb_bsoftlimit * 1024 / DEV_BSIZE;
 #endif
-	*value_r = (uint64_t)dqblk.dqb_curblocks *
-		(uint64_t)root->mount->blk_size / 1024;
-	*limit_r = (uint64_t)dqblk.dqb_bsoftlimit *
-		(uint64_t)root->mount->blk_size / 1024;
 	return 1;
 }