Skip to content

GenDisk

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

A disk, i.e. struct gendisk.

Adding one publishes it as /dev/<name> and /sys/block/<name>. Partitions of it get device numbers counting up from the disk’s own.

new GenDisk(init): GenDisk

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

GenDiskInit

GenDisk

attrs: Record<string, DeviceAttribute> = {}

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

Attributes the driver adds to the disk in sysfs, on top of the ones every disk gets


readonly diskseq: number

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

A number that is never reused, so a disk can be told apart from one that replaced it


readonly first_minor: number = 0

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

The disk’s own minor, which its partitions count up from


optional hidden?: boolean

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

Hidden disks exist but are not meant to be used directly, so udev ignores them


readonly major: number

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


readonly minors: number = 0

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

How many minors are reserved for the disk and its partitions. 0 means partitions are numbered elsewhere.


readonly name: string

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


optional no_part?: boolean

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

Whether the disk can be partitioned at all


readonly ops: BlockDeviceOperations

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


optional owner?: Module

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


optional parent?: Device<unknown>

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

The device this disk hangs off, e.g. its controller. Disks without one are virtual.


readonly part0: BlockDevice

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

The whole disk, i.e. part0


readonly parts: Map<number, BlockDevice>

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

Partitions, by partition number


optional read_only?: boolean

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


optional removable?: boolean

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

get added(): boolean

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

Whether the disk is currently in sysfs

boolean


get capacity(): number

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

How big the disk is, in sectors

number

set capacity(sectors): void

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

number

void

[dispose](): void

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

void


add(): void

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

Publish the disk, i.e. add_disk.

void

EBUSY if the disk is already added, or something has its device number


add_partition(part_no, start, count): BlockDevice

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

Add a partition of the disk.

number

number

where the partition starts, in sectors

number

how long the partition is, in sectors

BlockDevice

EINVAL if the disk can’t be partitioned, or the partition doesn’t fit on it

EBUSY if there is already a partition with this number


del(): void

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

Remove the disk and every partition of it, i.e. del_gendisk.

void


del_partition(part_no): void

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

Remove a partition. Does nothing if there isn’t one with this number.

number

void