Skip to content

Commit

Permalink
fix builds on freebsd
Browse files Browse the repository at this point in the history
  • Loading branch information
micbar committed Dec 15, 2022
1 parent 61a5414 commit 2deca52
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
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
}

0 comments on commit 2deca52

Please sign in to comment.