Linux lazyweb, is there a way to detect from software the eject button on an optical drive being pressed while the drive is locked?
Conversation
Notices
-
Embed this notice
Rich Felker (dalias@hachyderm.io)'s status on Saturday, 20-Dec-2025 23:01:24 JST
Rich Felker
-
Embed this notice
Rich Felker (dalias@hachyderm.io)'s status on Saturday, 20-Dec-2025 23:26:50 JST
Rich Felker
@webhat That's basically what I'm asking. I suppose /sys would be the place to look. The intended use is to listen on it and convert presses into an unmount followed by eject command if the unmount succeeds, altho of course you could do anything else with it too.
-
Embed this notice
webhat (webhat@infosec.exchange)'s status on Saturday, 20-Dec-2025 23:26:51 JST
webhat
@dalias does the driver expose this in /sys that you could poll from software or can you query it from a syscall?
-
Embed this notice
Rich Felker (dalias@hachyderm.io)'s status on Saturday, 20-Dec-2025 23:59:42 JST
Rich Felker
@webhat There's an events virtual file that lists "eject_request" and "media_change" and an events_async virtual file that's probably somehow pollable for events...
-
Embed this notice
webhat (webhat@infosec.exchange)'s status on Saturday, 20-Dec-2025 23:59:43 JST
webhat
@dalias I'd probably dig through the driver to see what it exposes
-
Embed this notice
Rich Felker (dalias@hachyderm.io)'s status on Sunday, 21-Dec-2025 00:48:54 JST
Rich Felker
Hmm, maybe this isn't even needed..? The modern Linux iso9660 fs driver seems to ignore whether media is even present and responds to media change events so that a single mount "just works" across multiple media changes.
I'd actually kinda like to disable that though, because it makes it so you have to just keep guessing when the new media is ready rather than knowing it's ready when the mount command returns.
Haelwenn /элвэн/ :triskell: likes this. -
Embed this notice
Rich Felker (dalias@hachyderm.io)'s status on Sunday, 21-Dec-2025 00:57:24 JST
Rich Felker
I think I'd like this feature more if there were separate events for "drawer closed" and "media change completed" and the fs driver could make all accesses stall between these events rather than showing an empty fs during that window.
-
Embed this notice
Rich Felker (dalias@hachyderm.io)'s status on Sunday, 21-Dec-2025 01:32:14 JST
Rich Felker
@erikarn Panicking must have been extremely old behavior, probably from the 1990s. In the early 00s I regularly force-removed media and sometimes even *drives* (unplugging IDE cables) to reset optical drives that were stuck, without crashing.
The change described above in this thread was not about fixing panics.
-
Embed this notice
Adrian Chadd <verified.png> (erikarn@mstdn.social)'s status on Sunday, 21-Dec-2025 01:32:15 JST
Adrian Chadd <verified.png>
@dalias The irony is that the OLD behaviour in freebsd/linux is (a) the eject button was disabled / locked out whilst the media was mounted, and (b) mount did block until it was mounted.
(and of course if the media went away on a mounted filesystem the kernel would typically panic cause noone wrote code that handled that case well, so I do get the UX behind that change, but I would've made the FS more robust..)
-
Embed this notice
Rich Felker (dalias@hachyderm.io)'s status on Sunday, 21-Dec-2025 01:47:03 JST
Rich Felker
@erikarn Do you know if there's any option to force the old behavior?
-
Embed this notice
Adrian Chadd <verified.png> (erikarn@mstdn.social)'s status on Sunday, 21-Dec-2025 01:47:05 JST
Adrian Chadd <verified.png>
@dalias it was still in early 00s in freebsd, they did mostly fix it in linux by then!
i remember when the UX changed to match what windows did and I also disliked it then, heh.
-
Embed this notice
Rich Felker (dalias@hachyderm.io)'s status on Sunday, 21-Dec-2025 02:01:20 JST
Rich Felker
@erikarn I know it can lock the button. What I'm trying to find out is if, when locked, the button event can still be seen by software, so that I can script a custom response to it.
-
Embed this notice
Adrian Chadd <verified.png> (erikarn@mstdn.social)'s status on Sunday, 21-Dec-2025 02:01:21 JST
Adrian Chadd <verified.png>
@dalias A quck bit of googling shows the 'eject' command has some button control
https://www.man7.org/linux/man-pages/man1/eject.1.html
maybe see if that does lock the drive against button press -> eject? And at least then we know all the software bits are there?
-
Embed this notice