0

I'm writing a utility for which I need to detect whether a floppy disk is present in the floppy disk drive, even when it is broken (cannot be read due to I/O errors).

How can I do this? [ -r /dev/fd0 ] always succeeds, even when no floppy is present; something like dd if=/dev/fd0 will fail when the floppy is broken.

  • https://unix.stackexchange.com/questions/303946/how-do-i-detect-a-floppy-disk-insert-on-rhel-7-and-execute-a-script although it says rhel in the title answer covers debian and ubuntu – Panther Dec 11 '17 at 00:39
  • It asks how to detect when a floppy is inserted. I want to detect whether a floppy is present. Different question. – Reinier Post Dec 11 '17 at 10:42
  • read the answer again, the program contantly polls the drive, not just at insertion. In the question the OP wanted to onlly detect insertion, byt you can adapt to your needs. Since it will poll the floppy on an ongoing basis, so you can use the information any way you wish. I am not sure there is a way to auto detect a failed floppy, either you can read a disk (present) or not (fail, no disk) . Otherwise you can try to find or write your own option, but as floppy is very very old, as mentioned in the link, I think it is unlikely you will find anything else. – Panther Dec 11 '17 at 14:46
  • It happens, no worries. I hope it can meet your needs. – Panther Dec 11 '17 at 15:25
  • Now I wonder whether this should be closed as a duplicate. The question isn't, but the correct answer is. – Reinier Post Dec 11 '17 at 15:57
  • Once you get a working solution, post it as an answer and reference the link. – Panther Dec 11 '17 at 16:01

0 Answers0