From 8c8c6c27552f8554ba014c34d684cb90538ef65b Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 28 Feb 2023 14:05:27 -0700 Subject: Move files around [ci-skip] --- cmd/btrfs-rec/inspect/rebuildtrees/util.go | 31 ++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 cmd/btrfs-rec/inspect/rebuildtrees/util.go (limited to 'cmd/btrfs-rec/inspect/rebuildtrees/util.go') diff --git a/cmd/btrfs-rec/inspect/rebuildtrees/util.go b/cmd/btrfs-rec/inspect/rebuildtrees/util.go new file mode 100644 index 0000000..9d91f23 --- /dev/null +++ b/cmd/btrfs-rec/inspect/rebuildtrees/util.go @@ -0,0 +1,31 @@ +// Copyright (C) 2022 Luke Shumaker +// +// SPDX-License-Identifier: GPL-2.0-or-later + +package rebuildnodes + +import ( + "golang.org/x/exp/constraints" + + "git.lukeshu.com/btrfs-progs-ng/lib/btrfsprogs/btrfsinspect" +) + +func countNodes(nodeScanResults btrfsinspect.ScanDevicesResult) int { + var cnt int + for _, devResults := range nodeScanResults { + cnt += len(devResults.FoundNodes) + } + return cnt +} + +func roundDown[T constraints.Integer](n, d T) T { + return (n / d) * d +} + +func roundUp[T constraints.Integer](n, d T) T { + return ((n + d - 1) / d) * d +} + +func discardOK[T any](val T, _ bool) T { + return val +} -- cgit v1.2.3-54-g00ecf