[lxc-devel] [lxd/master] lxd/storage/quota: Fix bad typing

stgraber on Github lxc-bot at linuxcontainers.org
Wed Oct 23 18:12:34 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 370 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20191023/f0a62581/attachment.bin>
-------------- next part --------------
From cc2aa806307cb700606d0786208d60ccea7cfd3f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Wed, 23 Oct 2019 14:11:27 -0400
Subject: [PATCH] lxd/storage/quota: Fix bad typing
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Closes #6345

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd/storage/quota/projectquota.go | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/lxd/storage/quota/projectquota.go b/lxd/storage/quota/projectquota.go
index f96032009d..c1b6b1ad1b 100644
--- a/lxd/storage/quota/projectquota.go
+++ b/lxd/storage/quota/projectquota.go
@@ -74,7 +74,7 @@ int quota_supported(char *dev_path) {
 	return quotactl(QCMD(Q_GETINFO, PRJQUOTA), dev_path, 0, (caddr_t)&dqinfo);
 }
 
-int quota_get_usage(char *dev_path, uint32_t id) {
+int64_t quota_get_usage(char *dev_path, uint32_t id) {
 	struct if_dqblk quota;
 
 	if (quotactl(QCMD(Q_GETQUOTA, PRJQUOTA), dev_path, id, (caddr_t)&quota) < 0) {
@@ -85,7 +85,7 @@ int quota_get_usage(char *dev_path, uint32_t id) {
 }
 
 
-int quota_set(char *dev_path, uint32_t id, int hard_bytes) {
+int quota_set(char *dev_path, uint32_t id, uint64_t hard_bytes) {
 	struct if_dqblk quota;
 	fs_disk_quota_t xfsquota;
 
@@ -266,7 +266,7 @@ func GetProjectUsage(path string, id uint32) (int64, error) {
 
 	size := C.quota_get_usage(cDevPath, C.uint32_t(id))
 	if size < 0 {
-		return -1, fmt.Errorf("Failed to get project consumption for id '%d' on '%s'", id, path)
+		return -1, fmt.Errorf("Failed to get project consumption for id '%d' on '%s'", id, devPath)
 	}
 
 	return int64(size), nil
@@ -284,8 +284,8 @@ func SetProjectQuota(path string, id uint32, bytes int64) error {
 	cDevPath := C.CString(devPath)
 	defer C.free(unsafe.Pointer(cDevPath))
 
-	if C.quota_set(cDevPath, C.uint32_t(id), C.int(bytes/1024)) != 0 {
-		return fmt.Errorf("Failed to set project quota for id '%d' on '%s'", id, path)
+	if C.quota_set(cDevPath, C.uint32_t(id), C.uint64_t(bytes/1024)) != 0 {
+		return fmt.Errorf("Failed to set project quota for id '%d' on '%s'", id, devPath)
 	}
 
 	return nil


More information about the lxc-devel mailing list