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.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new BlockDevice(
disk,part_no,start,nr_sectors):BlockDevice
Defined in: src/fs/block_dev.ts:188
Parameters
Section titled “Parameters”part_no
Section titled “part_no”number
number
Where this starts on the disk, in sectors
nr_sectors
Section titled “nr_sectors”number
How long this is, in sectors
Returns
Section titled “Returns”BlockDevice
Properties
Section titled “Properties”device?
Section titled “device?”
optionaldevice?:Device<unknown>
Defined in: src/fs/block_dev.ts:186
Only set while the block device is added
readonlydisk:GenDisk
Defined in: src/fs/block_dev.ts:189
nr_sectors
Section titled “nr_sectors”nr_sectors:
number
Defined in: src/fs/block_dev.ts:194
How long this is, in sectors
readonlyops: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.
part_no
Section titled “part_no”
readonlypart_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
Accessors
Section titled “Accessors”Get Signature
Section titled “Get Signature”get dev_t():
DevT
Defined in: src/fs/block_dev.ts:197
Returns
Section titled “Returns”Get Signature
Section titled “Get Signature”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.
Returns
Section titled “Returns”string
read_only
Section titled “read_only”Get Signature
Section titled “Get Signature”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.
Returns
Section titled “Returns”boolean
Set Signature
Section titled “Set Signature”set read_only(
value):void
Defined in: src/fs/block_dev.ts:219
Parameters
Section titled “Parameters”boolean
Returns
Section titled “Returns”void
Methods
Section titled “Methods”attrs()
Section titled “attrs()”
protectedattrs():Record<string,DeviceAttribute>
Defined in: src/fs/block_dev.ts:278
The attributes this gets in sysfs. Sizes are all in sectors.
Returns
Section titled “Returns”Record<string, DeviceAttribute>
register()
Section titled “register()”register():
void
Defined in: src/fs/block_dev.ts:306
Internal
Add this to sysfs and /dev.
Returns
Section titled “Returns”void
Throws
Section titled “Throws”EBUSY if something already has this device number
unregister()
Section titled “unregister()”unregister():
void
Defined in: src/fs/block_dev.ts:336
Internal
Returns
Section titled “Returns”void