Device inspection
Functions to check device properties and status.device::is_device
device::is_device
Check if path is a character device.
device.sh:10
device::is_block
device::is_block
Check if path is a block device.
device.sh:15
device::is_writeable
device::is_writeable
Check if device is writable.
device.sh:20
device::is_readable
device::is_readable
Check if device is readable.
device.sh:25
device::exists
device::exists
Check if device exists (block or character).
device.sh:30
device::has_processes
device::has_processes
Check if device has open file handles via lsof.
device.sh:35
device::is_occupied
device::is_occupied
Check if device is occupied via /proc (no lsof needed).
device.sh:41
device::is_mounted
device::is_mounted
Check if a block device is mounted.Usage:
device.sh:46
device::is_loop
device::is_loop
Check if device is a loop device.
device.sh:52
device::is_ram
device::is_ram
Check if device is a RAM disk.
device.sh:57
device::is_virtual
device::is_virtual
Check if device is a virtual/pseudo device.Detects:
device.sh:62
/dev/null,/dev/zero,/dev/full/dev/random,/dev/urandom/dev/stdin,/dev/stdout,/dev/stderr/dev/fd/*,/dev/ptmx,/dev/tty*
Device classification
Functions to identify device types and properties.device::type
device::type
Returns the type of a device as a string.Possible returns:
device.sh:80
virtual- Virtual/pseudo deviceloop- Loop deviceram- RAM disktty- Terminal devicepty- Pseudo-terminalpartition- Disk partitionnvme- NVMe devicedisk- Physical diskoptical- CD/DVD driveusb- USB deviceblock- Generic block devicechar- Generic character deviceunknown- Unknown type
device::number
device::number
Returns the major:minor device number.Usage:
device.sh:124
device::filesystem
device::filesystem
Returns the filesystem on a block device (if mounted or detectable).Usage:
device.sh:146
device::size_bytes
device::size_bytes
Returns the size of a block device in bytes.
device.sh:167
device::size_mb
device::size_mb
Returns the size of a block device in MB.
device.sh:192
device::mount_point
device::mount_point
Returns the mount point of a block device (empty if not mounted).Usage:
device.sh:200
Device listing
Functions to enumerate devices on the system.device::list::block
device::list::block
List all block devices.
device.sh:221
device::list::char
device::list::char
List all character devices.
device.sh:236
device::list::tty
device::list::tty
List all TTY devices.
device.sh:241
device::list::loop
device::list::loop
List all loop devices.
device.sh:246
device::list::mounted
device::list::mounted
List mounted devices with their mount points.Usage:
device.sh:251
Special devices
Functions for working with special system devices.device::zero
device::zero
Write n bytes of zeros to a device or file (wraps /dev/zero).Warning: This is destructive — use with care.Usage:
device.sh:272
device::random
device::random
Read n random bytes from /dev/urandom.Usage:
device.sh:283
device::null_ok
device::null_ok
Check if /dev/null is functional (sanity check).
device.sh:290