[dovecot-cvs] dovecot/src/plugins/quota quota-fs.c,1.16,1.17

cras at dovecot.org cras at dovecot.org
Wed Jun 28 01:00:19 EEST 2006


Update of /var/lib/cvs/dovecot/src/plugins/quota
In directory talvi:/tmp/cvs-serv3452

Modified Files:
	quota-fs.c 
Log Message:
Attempting to fix quota block calculations to be correct.



Index: quota-fs.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/quota/quota-fs.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- quota-fs.c	16 Jun 2006 13:28:17 -0000	1.16
+++ quota-fs.c	27 Jun 2006 22:00:17 -0000	1.17
@@ -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;
 }
 



More information about the dovecot-cvs mailing list