From 2deca52179626fd54c3637c3a1fd9dc06b1238f4 Mon Sep 17 00:00:00 2001 From: Michael Barz Date: Thu, 15 Dec 2022 14:34:08 +0100 Subject: [PATCH] fix builds on freebsd --- changelog/unreleased/fix-freebsd.md | 5 +++++ pkg/storage/fs/owncloudsql/owncloudsql_unix.go | 6 ++++-- pkg/storage/utils/decomposedfs/node/node_unix.go | 8 ++++++-- pkg/storage/utils/localfs/localfs_unix.go | 10 +++++++--- 4 files changed, 22 insertions(+), 7 deletions(-) create mode 100644 changelog/unreleased/fix-freebsd.md diff --git a/changelog/unreleased/fix-freebsd.md b/changelog/unreleased/fix-freebsd.md new file mode 100644 index 0000000000..476d3e1803 --- /dev/null +++ b/changelog/unreleased/fix-freebsd.md @@ -0,0 +1,5 @@ +Bugfix: Fix build on freebsd + +Building reva on freebsd was broken due to some deviations in return value types from the filesystem. + +https://github.com/cs3org/reva/pull/3559 diff --git a/pkg/storage/fs/owncloudsql/owncloudsql_unix.go b/pkg/storage/fs/owncloudsql/owncloudsql_unix.go index 48ac614252..4d7500bfc6 100755 --- a/pkg/storage/fs/owncloudsql/owncloudsql_unix.go +++ b/pkg/storage/fs/owncloudsql/owncloudsql_unix.go @@ -78,8 +78,10 @@ func (fs *owncloudsqlfs) GetQuota(ctx context.Context, ref *provider.Reference) if err != nil { return 0, 0, 0, err } - total := stat.Blocks * uint64(stat.Bsize) // Total data blocks in filesystem - used := (stat.Blocks - stat.Bavail) * uint64(stat.Bsize) // Free blocks available to unprivileged user + // Total data blocks in filesystem + total := stat.Blocks * uint64(stat.Bsize) + // Free blocks available to unprivileged user + used := (stat.Blocks - uint64(stat.Bavail)) * uint64(stat.Bsize) //nolint:unconvert remaining := total - used return total, used, remaining, nil } diff --git a/pkg/storage/utils/decomposedfs/node/node_unix.go b/pkg/storage/utils/decomposedfs/node/node_unix.go index 05edf02158..0051557a7e 100644 --- a/pkg/storage/utils/decomposedfs/node/node_unix.go +++ b/pkg/storage/utils/decomposedfs/node/node_unix.go @@ -21,7 +21,9 @@ package node -import "syscall" +import ( + "syscall" +) // GetAvailableSize stats the filesystem and return the available bytes func GetAvailableSize(path string) (uint64, error) { @@ -30,5 +32,7 @@ func GetAvailableSize(path string) (uint64, error) { if err != nil { return 0, err } - return stat.Bavail * uint64(stat.Bsize), nil + + // convert stat.Bavail to uint64 because it returns an int64 on freebsd + return uint64(stat.Bavail) * uint64(stat.Bsize), nil //nolint:unconvert } diff --git a/pkg/storage/utils/localfs/localfs_unix.go b/pkg/storage/utils/localfs/localfs_unix.go index 8faebe5f14..8d8f43c6b6 100644 --- a/pkg/storage/utils/localfs/localfs_unix.go +++ b/pkg/storage/utils/localfs/localfs_unix.go @@ -76,8 +76,12 @@ func (fs *localfs) GetQuota(ctx context.Context, ref *provider.Reference) (uint6 if err != nil { return 0, 0, 0, err } - total := stat.Blocks * uint64(stat.Bsize) // Total data blocks in filesystem - used := (stat.Blocks - stat.Bavail) * uint64(stat.Bsize) // Free blocks available to unprivileged user - remaining := stat.Bavail * uint64(stat.Bsize) + // Total data blocks in filesystem + total := stat.Blocks * uint64(stat.Bsize) + // Free blocks available to unprivileged user + // convert stat.Bavail to uint64 because it returns an int64 on freebsd + used := (stat.Blocks - uint64(stat.Bavail)) * uint64(stat.Bsize) //nolint:unconvert + // convert stat.Bavail to uint64 because it returns an int64 on freebsd + remaining := uint64(stat.Bavail) * uint64(stat.Bsize) //nolint:unconvert return total, used, remaining, nil }