~/bend-docscommunity

src/disk/ext4free.bend checks

raw source on the hub · import 0x5fb57f1b8ad4cb61031f616c44af7445/src/disk/ext4free.bend as Ext4free

3 imports
import Base
import ../lib/u64.bend as U
import ../lib/bytes.bend as B

Types

type Fs source · line 31 · raw

Data

type Run source · line 115 · raw

Data

A run of free blocks: the first block and how many.

type GptTab source · line 217 · raw

Data

A GPT header's entries: their offset, count (at most 128) and entry size.

Definitions

def Ext.magic source · line 34 · raw

U32

def Ext.le16 source · line 38 · raw

@+bs:List<&2, U32> -> @+at:Nat -> U32

def Ext.le32 source · line 41 · raw

@+bs:List<&2, U32> -> @+at:Nat -> U32

def Ext.is_ext source · line 45 · raw

@+sb:List<&2, U32> -> Bool

Whether 1024 superblock bytes are ext4's.

def Ext.fs source · line 51 · raw

@+base:0x5fb57f1b8ad4cb61031f616c44af7445/src/lib/u64.U64 -> @+sb:List<&2, U32> -> Fs

The file system whose superblock (its 1024 bytes) lies at base + 1024. Blocks are counted in 32 bits (16 TiB with 4 KiB blocks): a larger one is left alone.

def Fs.ok source · line 67 · raw

@f:Fs -> Bool

def Fs.groups source · line 72 · raw

@f:Fs -> U32

def Fs.bsize source · line 77 · raw

@f:Fs -> U32

def Fs.dsize source · line 82 · raw

@f:Fs -> U32

def Fs.block_at source · line 88 · raw

@f:Fs -> @+n:U32 -> 0x5fb57f1b8ad4cb61031f616c44af7445/src/lib/u64.U64

The byte offset of block n.

def Fs.descs_at source · line 94 · raw

@+f:Fs -> 0x5fb57f1b8ad4cb61031f616c44af7445/src/lib/u64.U64

Where the group descriptors start, and their bytes for every group.

def Fs.descs_len source · line 99 · raw

@+f:Fs -> U32

def Fs.bitmap source · line 104 · raw

@+f:Fs -> @+ds:List<&2, U32> -> @+g:U32 -> Maybe<&2, U32>

Group g's block bitmap block, or none (BLOCK_UNINIT, or a bitmap block past the end), from the descriptors' bytes.

def Ext.runs.close source · line 118 · raw

@+first:U32 -> @+i:U32 -> @cur:Maybe<&2, U32> -> @+acc:List<&2, Run> -> List<&2, Run>

def Ext.walk source · line 130 · raw

@fuel:Nat -> @done:Bool -> @refill:Bool -> @used:Bool -> @bs:List<&2, U32> -> @+b:U32 -> @+k:U32 -> @+i:U32 -> @+n:U32 -> @+first:U32 -> @+cur:Maybe<&2, U32> -> @+acc:List<&2, Run> -> List<&2, Run>

The runs of clear bits among the first n of a bitmap, newest first; block numbers from first. One pass over the bytes, a bit at a time (fuel: bits and bytes); each call is handed what the next step needs to know (a byte to take, the end reached, bit i set), as a def may only match its parameters, in order.

def Ext.runs source · line 161 · raw

@+bs:List<&2, U32> -> @+n:U32 -> @+first:U32 -> List<&2, Run>

def Fs.free_runs source · line 165 · raw

@+f:Fs -> @+g:U32 -> @+bs:List<&2, U32> -> List<&2, Run>

The free runs of group g, its bitmap's bytes read.

def Fs.log source · line 173 · raw

@f:Fs -> U32

def Fs.range source · line 181 · raw

@+f:Fs -> @r:Run -> Pair(0x5fb57f1b8ad4cb61031f616c44af7445/src/lib/u64.U64, 0x5fb57f1b8ad4cb61031f616c44af7445/src/lib/u64.U64)

A run as a byte range of the image: the whole 4 KiB blocks inside it (a host punches holes in those; with 1 KiB file system blocks a run's ends may cut one), as offset and length (0: none).

def Part.mbr.go source · line 195 · raw

@fuel:Nat -> @+bs:List<&2, U32> -> @+i:U32 -> List<&2, 0x5fb57f1b8ad4cb61031f616c44af7445/src/lib/u64.U64>

The byte offsets of the partitions an MBR lists (type 0: none), from the first sector's bytes.

def Part.signed source · line 206 · raw

@+bs:List<&2, U32> -> Bool

def Part.gpt source · line 210 · raw

@+bs:List<&2, U32> -> Bool

Whether the first sector is a GPT's protective MBR (type 0xEE).

def Part.mbr source · line 213 · raw

@+bs:List<&2, U32> -> List<&2, 0x5fb57f1b8ad4cb61031f616c44af7445/src/lib/u64.U64>

def Part.gpt_table source · line 220 · raw

@+hdr:List<&2, U32> -> GptTab

def Part.gpt_entries.go source · line 224 · raw

@fuel:Nat -> @+es:List<&2, U32> -> @+i:U32 -> @+n:U32 -> @+size:U32 -> List<&2, 0x5fb57f1b8ad4cb61031f616c44af7445/src/lib/u64.U64>

The byte offsets of the partitions in a GPT's entries (zero type: unused).

def Part.gpt_entries source · line 235 · raw

@+es:List<&2, U32> -> @+n:U32 -> @+size:U32 -> List<&2, 0x5fb57f1b8ad4cb61031f616c44af7445/src/lib/u64.U64>