osbase/fsquota: replace float calculation
Floats have limited precision and are not needed here.
Change-Id: I51053821af226d312e94d51c4d21224e1ca53908
Reviewed-on: https://review.monogon.dev/c/monogon/+/4009
Tested-by: Jenkins CI
Reviewed-by: Lorenz Brun <lorenz@monogon.tech>
diff --git a/osbase/fsquota/fsquota.go b/osbase/fsquota/fsquota.go
index 4919841..e4f3e92 100644
--- a/osbase/fsquota/fsquota.go
+++ b/osbase/fsquota/fsquota.go
@@ -11,7 +11,6 @@
import (
"errors"
"fmt"
- "math"
"os"
"golang.org/x/sys/unix"
@@ -84,7 +83,10 @@
}
// Always round up to the nearest block size
- bytesLimitBlocks := uint64(math.Ceil(float64(maxBytes) / float64(1024)))
+ bytesLimitBlocks := maxBytes / 1024
+ if bytesLimitBlocks*1024 < maxBytes {
+ bytesLimitBlocks += 1
+ }
return quotactl.SetQuota(dir, quotactl.QuotaTypeProject, lastID, "actl.Quota{
BHardLimit: bytesLimitBlocks,