diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2023-03-15 21:38:56 -0600 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2023-03-15 21:42:46 -0600 |
commit | 17833fa13d5a7dcd79ad507fe4abf96b4a4a898b (patch) | |
tree | c8361c8278b07839be9af2ccee3507d324a7a216 /lib/btrfs/btrfsprim/key.go | |
parent | 0cc16b8d1da61c0bfb8743c8b68888b0ba73d4bb (diff) |
btrfsprim: Fix Key.Mm(), and add Key.Pp()
Diffstat (limited to 'lib/btrfs/btrfsprim/key.go')
-rw-r--r-- | lib/btrfs/btrfsprim/key.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/btrfs/btrfsprim/key.go b/lib/btrfs/btrfsprim/key.go index 7a3cc5c..b07cc8c 100644 --- a/lib/btrfs/btrfsprim/key.go +++ b/lib/btrfs/btrfsprim/key.go @@ -64,8 +64,26 @@ func (key Key) Mm() Key { key.Offset-- case key.ItemType > 0: key.ItemType-- + key.Offset = MaxOffset case key.ObjectID > 0: key.ObjectID-- + key.ItemType = MAX_KEY + key.Offset = MaxOffset + } + return key +} + +func (key Key) Pp() Key { + switch { + case key.Offset < MaxOffset: + key.Offset++ + case key.ItemType < MAX_KEY: + key.ItemType++ + key.Offset = 0 + case key.ObjectID < MAX_OBJECTID: + key.ObjectID++ + key.ItemType = 0 + key.Offset = 0 } return key } |