summaryrefslogtreecommitdiff
path: root/lib/btrfs/btrfsitem/item_freespaceinfo.go
blob: 069936743afc6c202e3a428c7be62b3189a3ce2f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright (C) 2022-2023  Luke Shumaker <lukeshu@lukeshu.com>
//
// SPDX-License-Identifier: GPL-2.0-or-later

package btrfsitem

import (
	"git.lukeshu.com/btrfs-progs-ng/lib/binstruct"
	"git.lukeshu.com/btrfs-progs-ng/lib/fmtutil"
)

// key.objectid = object ID of the BlockGroup (logical_addr)
// key.offset = offset of the BlockGroup (size)
type FreeSpaceInfo struct { // trivial FREE_SPACE_INFO=198
	ExtentCount   int32          `bin:"off=0, siz=4"`
	Flags         FreeSpaceFlags `bin:"off=4, siz=4"`
	binstruct.End `bin:"off=8"`
}

type FreeSpaceFlags uint32

const (
	FREE_SPACE_USING_BITMAPS = FreeSpaceFlags(1 << iota)
)

var freeSpaceFlagNames = []string{
	"USING_BITMAPS",
}

func (f FreeSpaceFlags) Has(req FreeSpaceFlags) bool { return f&req == req }
func (f FreeSpaceFlags) String() string {
	return fmtutil.BitfieldString(f, freeSpaceFlagNames, fmtutil.HexNone)
}