Skip to content

BlockDevice

Defined in: src/fs/block_dev.ts:184

A whole disk or one of its partitions, i.e. struct block_device.

Every one of these has a device number of its own, so it gets a node under /dev and shows up in /sys/class/block.

new BlockDevice(disk, part_no, start, nr_sectors): BlockDevice

Defined in: src/fs/block_dev.ts:188

GenDisk

number

number

Where this starts on the disk, in sectors

number

How long this is, in sectors

BlockDevice

optional device?: Device<unknown>

Defined in: src/fs/block_dev.ts:186

Only set while the block device is added


readonly disk: GenDisk

Defined in: src/fs/block_dev.ts:189


nr_sectors: number

Defined in: src/fs/block_dev.ts:194

How long this is, in sectors


readonly ops: FileOperations

Defined in: src/fs/block_dev.ts:228

Everything the block layer does before handing an operation to the driver: offsets are made relative to the whole disk and clamped to this device’s range, which is what keeps a write to a partition inside it. Linux does this in blk_partition_remap.


readonly part_no: number

Defined in: src/fs/block_dev.ts:190


start: number

Defined in: src/fs/block_dev.ts:192

Where this starts on the disk, in sectors

get dev_t(): DevT

Defined in: src/fs/block_dev.ts:197

DevT


get name(): string

Defined in: src/fs/block_dev.ts:206

What this is called, like Linux’s disk_name. A p is inserted before the partition number when the disk’s name already ends in a digit, so a partition of nvme0n1 is nvme0n1p1 rather than nvme0n11.

string


get read_only(): boolean

Defined in: src/fs/block_dev.ts:215

Whether this can be written to. A partition of a read-only disk is read only whatever it was told.

boolean

set read_only(value): void

Defined in: src/fs/block_dev.ts:219

boolean

void

protected attrs(): Record<string, DeviceAttribute>

Defined in: src/fs/block_dev.ts:278

The attributes this gets in sysfs. Sizes are all in sectors.

Record<string, DeviceAttribute>


register(): void

Defined in: src/fs/block_dev.ts:306

Internal

Add this to sysfs and /dev.

void

EBUSY if something already has this device number


unregister(): void

Defined in: src/fs/block_dev.ts:336

Internal

void