raw-posix: Detect IDE floppy via ioctl
PATCH 1/1 raw-posix: Detect IDE floppy via ioctl
Current IDE floppy detection is hardcoded based on source file name. Make this smarter by attempting a floppy specific ioctl.
--- block/raw-posix.c | 19 ++++++++++++++++++- 1 files changed, 18 insertions(+), 1 deletions(-)
block/raw-posix.c +18 -1
@@ -1055,9 +1055,26 @@ static int floppy_open(BlockDriverState *bs, const char *filename, int flags)static int floppy_probe_device (const char *filename) { +int fd, ret; +struct floppy_struct fdparam; +if (strstart (filename,"/dev/fd" ,NULL ))return 100 ; -return 0 ; + + fd =open (filename,O_RDONLY |O_NONBLOCK ); +if (fd <0 ) { +return 0 ; + } + +/* Attempt to detect via a floppy specific ioctl */ +if (ioctl (fd,FDGETPRM , &fdparam) <0 && errno ==EINVAL ) { + ret =0 ; + }else { + ret =100 ; + } + +close (fd); +return ret; }
Signature · 1 line
1.6.6
Quoted 2 lines · Cole Robinson
Current IDE floppy detection is hardcoded based on source file name. Make this smarter by attempting a floppy specific ioctl.
IDE floppys show up as /dev/hd?, these are old legacy floppies.
Otherwise looks good except that I think the ioctl should have a higher match priority than the name match. Same applies to the CDROM version of the patch.
Quoted 6 lines · Christoph Hellwig
Quoted 2 lines · Cole Robinson
Current IDE floppy detection is hardcoded based on source file name. Make this smarter by attempting a floppy specific ioctl.
IDE floppys show up as
/dev/hd?, these are old legacy floppies.
Ah, didn't realize there was a difference.
Quoted 3 lines
Otherwise looks good except that I think the ioctl should have a higher match priority than the name match. Same applies to the CDROM version of the patch.
Will do.
Thanks,
Cole