Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix builds on freebsd #3559

Merged
merged 1 commit into from
Dec 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog/unreleased/fix-freebsd.md
Original file line number Diff line number Diff line change
@@ -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
6 changes: 4 additions & 2 deletions pkg/storage/fs/owncloudsql/owncloudsql_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
8 changes: 6 additions & 2 deletions pkg/storage/utils/decomposedfs/node/node_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
}
10 changes: 7 additions & 3 deletions pkg/storage/utils/localfs/localfs_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}