set_disk_ro(9)
β¨ set_disk_ro β kernel API manual β¨
okay so bestie, welcome to the set_disk_ro(9) page π
this is the one that flips a gendisk between "read-only, don't touch" and "read/write, go off" β iconic behavior tbh π
πΈ NAME πΈ
set_disk_ro β set a gendisk read-only
π¦ SYNOPSIS π¦
void set_disk_ro (struct gendisk *disk , bool read_only );
π ARGUMENTS π
diskβ the gendisk you're operating on π«Ά like, this is the disk we're doing stuff to.read_onlyβtruemeans set the disk read-only,falsemeans set the disk read/write. two settings, one bool, no cap β¨
π§ DESCRIPTION π§
so what does this actually do? set_disk_ro is the function you use to indicate whether a given disk device should have its read-only flag set. that's the whole vibe check right there π«
typically, device drivers use set_disk_ro to indicate whether the underlying physical device is write-protected β like, "hey, this thing won't let you write to it," and now the disk knows that too π₯
π SEE ALSO π
kernel file ./block/genhd.c plus the whole friend group:
bdev_count_inflight(9)__register_blkdev(9)add_disk_fwnode(9)device_add_disk(9)blk_mark_disk_dead(9)del_gendisk(9)invalidate_disk(9)disk_release(9)put_disk(9)
and that's the page, bestie π this one lives in ./block and it's dated October 2026 β so yeah, mark your calendar, the future is calling and it's giving read-only flag energy πβ periodt.
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms