XU XUv0.16.0

#core/disk

import: #core/disk

counts: 29 functions, 0 methods, 10 types, 12 constants, 0 method sets

Standard library package `#core/disk`.

const MBR_SIGNATURE

XuAPI
pub const MBR_SIGNATURE = 0xAA55

Purpose

Constant MBR_SIGNATURE, defining protocol or algorithm parameters.

const GPT_SIGNATURE

XuAPI
pub const GPT_SIGNATURE = 0x5452415020494645u64

Purpose

Constant GPT_SIGNATURE, defining protocol or algorithm parameters.

const EXT2_MAGIC

XuAPI
pub const EXT2_MAGIC = 0xEF53

Purpose

Constant EXT2_MAGIC, defining protocol or algorithm parameters.

const EXT2_ROOT_INO

XuAPI
pub const EXT2_ROOT_INO = 2

Purpose

Constant EXT2_ROOT_INO, defining protocol or algorithm parameters.

const EXT2_S_IFMT

XuAPI
pub const EXT2_S_IFMT = 0xF000

Purpose

Constant EXT2_S_IFMT, defining protocol or algorithm parameters.

const EXT2_S_IFREG

XuAPI
pub const EXT2_S_IFREG = 0x8000

Purpose

Constant EXT2_S_IFREG, defining protocol or algorithm parameters.

const EXT2_S_IFDIR

XuAPI
pub const EXT2_S_IFDIR = 0x4000

Purpose

Constant EXT2_S_IFDIR, defining protocol or algorithm parameters.

const EXT2_FT_REG_FILE

XuAPI
pub const EXT2_FT_REG_FILE = 1

Purpose

Constant EXT2_FT_REG_FILE, defining protocol or algorithm parameters.

const EXT2_FT_DIR

XuAPI
pub const EXT2_FT_DIR = 2

Purpose

Constant EXT2_FT_DIR, defining protocol or algorithm parameters.

const TAR_BLOCK_SIZE

XuAPI
pub const TAR_BLOCK_SIZE = 512

Purpose

Constant TAR_BLOCK_SIZE, defining protocol or algorithm parameters.

const TAR_TYPE_FILE

XuAPI
pub const TAR_TYPE_FILE = 48

Purpose

Constant TAR_TYPE_FILE, defining protocol or algorithm parameters.

const TAR_TYPE_DIR

XuAPI
pub const TAR_TYPE_DIR = 53

Purpose

Constant TAR_TYPE_DIR, defining protocol or algorithm parameters.

le16

XuAPI
pub fn le16(p *raw u8) u16

Purpose

Execute le16.

Parameters

p *raw u8
p (*raw u8)

Returns

u16 — a value of this type

le32

XuAPI
pub fn le32(p *raw u8) u32

Purpose

Execute le32.

Parameters

p *raw u8
p (*raw u8)

Returns

u32 — a value of this type

le64

XuAPI
pub fn le64(p *raw u8) u64

Purpose

Execute le64.

Parameters

p *raw u8
p (*raw u8)

Returns

u64 — a value of this type

put_le32

XuAPI
pub fn put_le32(p *raw u8, val u32)

Purpose

Put le32.

Parameters

p *raw u8
p (*raw u8)
val u32
value (u32)

Returns

This call does not return a value.

struct MbrPartition

XuAPI
pub struct MbrPartition {
    pub bootable u8
    pub part_type u8
    pub pad0 u16
    pub lba_start u32
    pub sector_count u32
}

Purpose

Structure encapsulating bootable, part_type, pad0, lba_start, sector_count.

Public fields

bootable u8
field (u8)
part_type u8
field (u8)
pad0 u16
field (u16)
lba_start u32
field (u32)
sector_count u32
field (u32)

mbr_valid

XuAPI
pub fn mbr_valid(sector0 *raw u8) bool

Purpose

Mbr valid.

Parameters

sector0 *raw u8
sector0 (*raw u8)

Returns

bool — true or false

mbr_parse_partition

XuAPI
pub fn mbr_parse_partition(sector0 *raw u8, idx int, out *raw MbrPartition) bool

Purpose

Mbr parse partition.

Parameters

sector0 *raw u8
sector0 (*raw u8)
idx int
idx (int)
out *raw MbrPartition
out (*raw MbrPartition)

Returns

bool — true or false

struct GptHeader

XuAPI
pub struct GptHeader {
    pub signature u64
    pub revision u32
    pub header_size u32
    pub header_crc32 u32
    pub reserved u32
    pub current_lba u64
    pub backup_lba u64
    pub first_usable_lba u64
    pub last_usable_lba u64
    pub entries_lba u64
    pub num_entries u32
    pub entry_size u32
    pub entries_crc32 u32
}

Purpose

Disk Metadata header descriptor structure.

Public fields

signature u64
field (u64)
revision u32
field (u32)
header_size u32
field (u32)
header_crc32 u32
field (u32)
reserved u32
field (u32)
current_lba u64
field (u64)
backup_lba u64
field (u64)
first_usable_lba u64
field (u64)
last_usable_lba u64
field (u64)
entries_lba u64
field (u64)
num_entries u32
field (u32)
entry_size u32
field (u32)
entries_crc32 u32
field (u32)

struct GptEntry

XuAPI
pub struct GptEntry {
    pub type_guid_lo u64
    pub type_guid_hi u64
    pub unique_guid_lo u64
    pub unique_guid_hi u64
    pub first_lba u64
    pub last_lba u64
    pub attrs u64
    pub name_ascii_len u32
    pub pad u32
}

Purpose

Structure encapsulating type_guid_lo, type_guid_hi, unique_guid_lo, unique_guid_hi, first_lba.

Public fields

type_guid_lo u64
field (u64)
type_guid_hi u64
field (u64)
unique_guid_lo u64
field (u64)
unique_guid_hi u64
field (u64)
first_lba u64
field (u64)
last_lba u64
field (u64)
attrs u64
field (u64)
name_ascii_len u32
field (u32)
pad u32
field (u32)

gpt_parse_header

XuAPI
pub fn gpt_parse_header(lba1 *raw u8, out *raw GptHeader) bool

Purpose

Gpt parse header.

Parameters

lba1 *raw u8
lba1 (*raw u8)
out *raw GptHeader
out (*raw GptHeader)

Returns

bool — true or false

gpt_parse_entry

XuAPI
pub fn gpt_parse_entry(entry_buf *raw u8, entry_size usize, out *raw GptEntry) bool

Purpose

Gpt parse entry.

Parameters

entry_buf *raw u8
entry_buf (*raw u8)
entry_size usize
entry_size (usize)
out *raw GptEntry
out (*raw GptEntry)

Returns

bool — true or false

gpt_verify_entries_crc

XuAPI
pub fn gpt_verify_entries_crc(hdr &GptHeader, entries_buf *raw u8, buf_len usize) bool

Purpose

Gpt verify entries crc.

Parameters

hdr &GptHeader
hdr (read-only borrow; caller keeps the original; type &GptHeader)
entries_buf *raw u8
entries_buf (*raw u8)
buf_len usize
buf_len (usize)

Returns

bool — true or false

struct Fat32Bpb

XuAPI
pub struct Fat32Bpb {
    pub bytes_per_sector u16
    pub sectors_per_cluster u8
    pub num_fats u8
    pub reserved_sectors u16
    pub pad0 u16
    pub fat_size_sectors u32
    pub root_cluster u32
    pub part_lba u64
    pub first_fat_lba u64
    pub first_data_lba u64
}

Purpose

Structure encapsulating bytes_per_sector, sectors_per_cluster, num_fats, reserved_sectors, pad0.

Public fields

bytes_per_sector u16
field (u16)
sectors_per_cluster u8
field (u8)
num_fats u8
field (u8)
reserved_sectors u16
field (u16)
pad0 u16
field (u16)
fat_size_sectors u32
field (u32)
root_cluster u32
field (u32)
part_lba u64
field (u64)
first_fat_lba u64
field (u64)
first_data_lba u64
field (u64)

struct Fat32DirEntry

XuAPI
pub struct Fat32DirEntry {
    pub name [11]u8
    pub attr u8
    pub first_cluster u32
    pub file_size u32
}

Purpose

Structure encapsulating name, attr, first_cluster, file_size.

Public fields

name [11]u8
name
attr u8
field (u8)
first_cluster u32
field (u32)
file_size u32
field (u32)

fat32_parse_bpb

XuAPI
pub fn fat32_parse_bpb(boot_sec *raw u8, part_lba u64, out *raw Fat32Bpb) bool

Purpose

Fat32 parse bpb.

Parameters

boot_sec *raw u8
boot_sec (*raw u8)
part_lba u64
part_lba (u64)
out *raw Fat32Bpb
out (*raw Fat32Bpb)

Returns

bool — true or false

fat32_cluster_to_lba

XuAPI
pub fn fat32_cluster_to_lba(bpb &Fat32Bpb, cluster u32) u64

Purpose

Fat32 cluster to lba.

Parameters

bpb &Fat32Bpb
bpb (read-only borrow; caller keeps the original; type &Fat32Bpb)
cluster u32
cluster (u32)

Returns

u64 — a value of this type

fat32_find_entry_in_sector

XuAPI
pub fn fat32_find_entry_in_sector(sec_buf *raw u8, name83 *raw u8, out *raw Fat32DirEntry) bool

Purpose

Fat32 find entry in sector.

Parameters

sec_buf *raw u8
sec_buf (*raw u8)
name83 *raw u8
name83 (*raw u8)
out *raw Fat32DirEntry
out (*raw Fat32DirEntry)

Returns

bool — true or false

fat32_format_83_name

XuAPI
pub fn fat32_format_83_name(filename &string, out11 *raw u8) bool

Purpose

Fat32 format 83 name.

Parameters

filename &string
filename (read-only borrow; caller keeps the original; type &string)
out11 *raw u8
out11 (*raw u8)

Returns

bool — true or false

fat32_fat_sector_and_offset

XuAPI
pub fn fat32_fat_sector_and_offset(bpb &Fat32Bpb, cluster u32, out_lba *raw u64, out_off *raw usize) bool

Purpose

Fat32 fat sector and offset.

Parameters

bpb &Fat32Bpb
bpb (read-only borrow; caller keeps the original; type &Fat32Bpb)
cluster u32
cluster (u32)
out_lba *raw u64
out_lba (*raw u64)
out_off *raw usize
out_off (*raw usize)

Returns

bool — true or false

fat32_next_cluster_from_sector

XuAPI
pub fn fat32_next_cluster_from_sector(fat_sec *raw u8, off usize) u32

Purpose

Fat32 next cluster from sector.

Parameters

fat_sec *raw u8
fat_sec (*raw u8)
off usize
offset (usize)

Returns

u32 — a value of this type

fat32_is_eoc

XuAPI
pub fn fat32_is_eoc(cluster u32) bool

Purpose

Whether fat32 is eoc.

Parameters

cluster u32
cluster (u32)

Returns

bool — true or false

struct Ext2Superblock

XuAPI
pub struct Ext2Superblock {
    pub inodes_count u32
    pub blocks_count u32
    pub first_data_block u32
    pub block_size u32
    pub blocks_per_group u32
    pub inodes_per_group u32
    pub inode_size u16
    pub magic u16
    pub magic_pad u32
}

Purpose

Structure encapsulating inodes_count, blocks_count, first_data_block, block_size, blocks_per_group.

Public fields

inodes_count u32
field (u32)
blocks_count u32
field (u32)
first_data_block u32
field (u32)
block_size u32
field (u32)
blocks_per_group u32
field (u32)
inodes_per_group u32
field (u32)
inode_size u16
field (u16)
magic u16
field (u16)
magic_pad u32
field (u32)

struct Ext2GroupDesc

XuAPI
pub struct Ext2GroupDesc {
    pub block_bitmap u32
    pub inode_bitmap u32
    pub inode_table u32
    pub free_blocks_count u16
    pub free_inodes_count u16
    pub used_dirs_count u16
    pub pad0 u16
}

Purpose

Structure encapsulating block_bitmap, inode_bitmap, inode_table, free_blocks_count, free_inodes_count.

Public fields

block_bitmap u32
field (u32)
inode_bitmap u32
field (u32)
inode_table u32
field (u32)
free_blocks_count u16
field (u16)
free_inodes_count u16
field (u16)
used_dirs_count u16
field (u16)
pad0 u16
field (u16)

struct Ext2Inode

XuAPI
pub struct Ext2Inode {
    pub mode u16
    pub uid u16
    pub size u32
    pub links_count u16
    pub pad0 u16
    pub blocks u32
    pub block [15]u32
}

Purpose

Structure encapsulating mode, uid, size, links_count, pad0.

Public fields

mode u16
mode
uid u16
field (u16)
size u32
field (u32)
links_count u16
field (u16)
pad0 u16
field (u16)
blocks u32
field (u32)
block [15]u32
field ([15]u32)

struct Ext2DirEntry

XuAPI
pub struct Ext2DirEntry {
    pub inode u32
    pub rec_len u16
    pub name_len u8
    pub file_type u8
    pub name [255]u8
    pub pad0 u8
}

Purpose

Structure encapsulating inode, rec_len, name_len, file_type, name.

Public fields

inode u32
field (u32)
rec_len u16
field (u16)
name_len u8
field (u8)
file_type u8
field (u8)
name [255]u8
name
pad0 u8
field (u8)

ext2_parse_superblock

XuAPI
pub fn ext2_parse_superblock(sb_buf *raw u8, out *raw Ext2Superblock) bool

Purpose

Ext2 parse superblock.

Parameters

sb_buf *raw u8
sb_buf (*raw u8)
out *raw Ext2Superblock
out (*raw Ext2Superblock)

Returns

bool — true or false

ext2_parse_group_desc

XuAPI
pub fn ext2_parse_group_desc(bgdt_buf *raw u8, group_idx u32, out *raw Ext2GroupDesc) bool

Purpose

Ext2 parse group desc.

Parameters

bgdt_buf *raw u8
bgdt_buf (*raw u8)
group_idx u32
group_idx (u32)
out *raw Ext2GroupDesc
out (*raw Ext2GroupDesc)

Returns

bool — true or false

ext2_parse_inode

XuAPI
pub fn ext2_parse_inode(inode_buf *raw u8, out *raw Ext2Inode) bool

Purpose

Ext2 parse inode.

Parameters

inode_buf *raw u8
inode_buf (*raw u8)
out *raw Ext2Inode
out (*raw Ext2Inode)

Returns

bool — true or false

ext2_find_dir_entry

XuAPI
pub fn ext2_find_dir_entry(dir_buf *raw u8, dir_len usize, name &string, out *raw Ext2DirEntry) bool

Purpose

Ext2 find directory entry.

Parameters

dir_buf *raw u8
dir_buf (*raw u8)
dir_len usize
dir_len (usize)
name &string
name (read-only borrow; caller keeps the original; type &string)
out *raw Ext2DirEntry
out (*raw Ext2DirEntry)

Returns

bool — true or false

ext2_indirect_block_ptr

XuAPI
pub fn ext2_indirect_block_ptr(ind_block_buf *raw u8, block_size u32, idx u32) u32

Purpose

Ext2 indirect block ptr.

Parameters

ind_block_buf *raw u8
ind_block_buf (*raw u8)
block_size u32
block_size (u32)
idx u32
idx (u32)

Returns

u32 — a value of this type

ext2_file_block_lba

XuAPI
pub fn ext2_file_block_lba(inode &Ext2Inode, sb &Ext2Superblock, ind_block_buf *raw u8, file_blk_idx u32) u64

Purpose

Ext2 file block lba.

Parameters

inode &Ext2Inode
inode (read-only borrow; caller keeps the original; type &Ext2Inode)
sb &Ext2Superblock
sb (read-only borrow; caller keeps the original; type &Ext2Superblock)
ind_block_buf *raw u8
ind_block_buf (*raw u8)
file_blk_idx u32
file_blk_idx (u32)

Returns

u64 — a value of this type

ext2_dind_indices

XuAPI
pub fn ext2_dind_indices(sb &Ext2Superblock, file_blk_idx u32, out_l1 *raw u32, out_l2 *raw u32) bool

Purpose

Compute L1 and L2 indices within the double-indirect tree (inode.block[13]) for file_blk_idx.

Parameters

sb &Ext2Superblock
sb (read-only borrow; caller keeps the original; type &Ext2Superblock)
file_blk_idx u32
file_blk_idx (u32)
out_l1 *raw u32
out_l1 (*raw u32)
out_l2 *raw u32
out_l2 (*raw u32)

Returns

bool — true or false

ext2_file_block_lba_dind

XuAPI
pub fn ext2_file_block_lba_dind( inode &Ext2Inode, sb &Ext2Superblock, ind1_buf *raw u8, dind_l1_buf *raw u8, dind_l2_buf *raw u8, file_blk_idx u32 ) u64

Purpose

Resolve file_blk_idx to a 512-byte sector LBA supporting direct, single-indirect, and double-indirect (inode.block[13]) blocks. Callers must pass dind_l1_buf read from inode.block[13] and dind_l2_buf read from ext2_indirect_block_ptr(dind_l1_buf, sb.block_size, l1).

Parameters

inode &Ext2Inode
inode (read-only borrow; caller keeps the original; type &Ext2Inode)
sb &Ext2Superblock
sb (read-only borrow; caller keeps the original; type &Ext2Superblock)
ind1_buf *raw u8
ind1_buf (*raw u8)
dind_l1_buf *raw u8
dind_l1_buf (*raw u8)
dind_l2_buf *raw u8
dind_l2_buf (*raw u8)
file_blk_idx u32
file_blk_idx (u32)

Returns

u64 — a value of this type

struct TarEntry

XuAPI
pub struct TarEntry {
    pub name_off usize
    pub name_len usize
    pub data_off usize
    pub size usize
    pub typeflag u8
    pub pad0 u8
    pub pad1 u16
    pub pad2 u32
}

Purpose

Structure encapsulating name_off, name_len, data_off, size, typeflag.

Public fields

name_off usize
field (usize)
name_len usize
field (usize)
data_off usize
field (usize)
size usize
field (usize)
typeflag u8
field (u8)
pad0 u8
field (u8)
pad1 u16
field (u16)
pad2 u32
field (u32)

tar_parse_octal

XuAPI
pub fn tar_parse_octal(p *raw u8, max_len usize) usize

Purpose

Tar parse octal.

Parameters

p *raw u8
p (*raw u8)
max_len usize
max_len (usize)

Returns

usize — a value of this type

tar_header_checksum_ok

XuAPI
pub fn tar_header_checksum_ok(hdr *raw u8) bool

Purpose

Tar header checksum ok.

Parameters

hdr *raw u8
hdr (*raw u8)

Returns

bool — true or false

tar_entry_has_prefix

XuAPI
pub fn tar_entry_has_prefix(archive *raw u8, entry &TarEntry) bool

Purpose

Return true if the USTAR header for entry has a non-empty prefix field (bytes 345..500).

Parameters

archive *raw u8
archive (*raw u8)
entry &TarEntry
entry (read-only borrow; caller keeps the original; type &TarEntry)

Returns

bool — true or false

tar_format_path

XuAPI
pub fn tar_format_path(archive *raw u8, entry &TarEntry, out_buf *raw u8, cap usize) usize

Purpose

Format NUL-terminated full <prefix>/<name> or <name> for entry into out_buf, returning the number of bytes written excluding the NUL terminator.

Parameters

archive *raw u8
archive (*raw u8)
entry &TarEntry
entry (read-only borrow; caller keeps the original; type &TarEntry)
out_buf *raw u8
out_buf (*raw u8)
cap usize
cap (usize)

Returns

usize — a value of this type

tar_find_file

XuAPI
pub fn tar_find_file(archive *raw u8, archive_len usize, target_name &string, out *raw TarEntry) bool

Purpose

Tar find file.

Parameters

archive *raw u8
archive (*raw u8)
archive_len usize
archive_len (usize)
target_name &string
target_name (read-only borrow; caller keeps the original; type &string)
out *raw TarEntry
out (*raw TarEntry)

Returns

bool — true or false