LOCKDEV(8)
π LOCKDEV(8) β the manual, but make it make sense π
okay bestie, sit down, we're learning lockdev and it's actually gonna be fun.
So lockdev is a setgid binary β yes, setgid, we love a permission moment β and what it gives you is a reliable way to put an exclusive lock in /var/lock on your devices (think ttyS0 and its little friends) using both the FSSTND and the SVr4 methods. And because of that, regular users don't need write access in /var/lock. no cap, that's the whole point. π
And how does it pull this off? Through calls to the liblockdev(3) API. she's built different, fr fr.
β¨ SYNOPSIS β¨
/usr/sbin/lockdev [<operation>] <device>
πΈ DESCRIPTION πΈ
So the lockdev command can do one of the following operations (and all of them are calls to the liblockdev(3) API, iykyk):
-lβ lock the device, using thedev_lock()function π-uβ unlock the device, using thedev_unlock()function π- no operation β just test the lock, using the
dev_testlock()function π
π RETURN VALUES π
exit codes!! and bestie they MATTER, so here's the full vibe check:
0βdev_lock: OK β¨ βdev_unlock: OK β¨ βdev_testlock: not locked1βdev_lock: locked other βdev_unlock: locked other βdev_testlock: locked2βEACCES3βEROFS4βEFAULT5βEINVAL6βENAMETOOLONG7βENOENT8βENOTDIR9βENOMEM10βELOOP11βEIO12βEPERM255βdev_lock: error βdev_unlock: error βdev_testlock: error π
not me reading 255 three times like it's gonna change. it doesn't. error is error, bestie. π
π¦ SEE ALSO π¦
okay that's the page!! this one is dated SEPTEMBER 2009 and it lives in the LOCKDEV(8) manual β iconic of her honestly. go forth and lock your devices responsibly. mwah π π«Ά
π¦ where this page comes from
- alpine 3.24: lockdev-doc 0_git20130107-r4 Β· LGPL-2.1-or-later
- centos-stream 10: lockdev 1.0.4-0.46.20111007git.el10 Β· LGPL-2.1-or-later
- centos-stream 9: lockdev 1.0.4-0.38.20111007git.el9 Β· LGPLv2
- centos-stream 9: lockdev 1.0.4-0.38.20111007git.el9 Β· LGPLv2
- fedora 43: lockdev 1.0.4-0.53.20111007git.fc43 Β· LGPL-2.1-or-later
- fedora 43: lockdev 1.0.4-0.53.20111007git.fc43 Β· LGPL-2.1-or-later
- fedora 44: lockdev 1.0.4-0.54.20111007git.fc44 Β· LGPL-2.1-or-later
- fedora 44: lockdev 1.0.4-0.54.20111007git.fc44 Β· LGPL-2.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms