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 }