开发者

How to programmatically detect sata drive unplug in SuSE Linux?

Does anyone know of a method I can use to programmatically detect if a SATA hard drive has been unplugged? Our file system is mounted in READ-ONLY mode when we need to detect the removal of the drive. We noticed the other day that we were able to unplug 开发者_如何学JAVAa hard drive and everything continued to run without a hitch until the next time we attempted to read from a file on disk.


Parsing the output of dmesg is a bad idea for several reasons, not the least of which it being inefficient and dependent on the format that the printk in the kernel happens to use.

On modern Linux systems, hardware changes are usually handled through udev which, in turn, will propagate change events up through D-BUS.

You may want to search how the insert and removal of memory sticks is handled; the methods should be fairly similar.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜