In case reading of block 0 during open() fails, it is not the right thing to let open() succeed. Fix this by introducing FD_OPEN_SHOULD_FAIL_BIT flag, and setting it in case the bio callback encounters an error while trying to read block 0. As a bonus, this works around certain broken userspace (blkid), which is not able to properly handle read()s returning IO errors. Hence be nice to those, and bail out during open() already; if block 0 is not readable, read()s are not going to provide any meaningful data anyway.
Showing the changes to include/uapi/linux (1 of 2 files). Show all
Unified · Split
| @@ -185,7 +185,8 @@ enum { · 184 unmodified lines | ||
| 185 | 185 | * to clear media change status */ |
| 186 | 186 | FD_UNUSED_BIT, |
| 187 | 187 | FD_DISK_CHANGED_BIT, /* disk has been changed since last i/o */ |
| 188 | − FD_DISK_WRITABLE_BIT /* disk is writable */ | |
| 188 | + FD_DISK_WRITABLE_BIT, /* disk is writable */ | |
| 189 | + FD_OPEN_SHOULD_FAIL_BIT | |
| 189 | 190 | }; |
| 190 | 191 | |
| 191 | 192 | #define FDSETDRVPRM _IOW(2, 0x90, struct floppy_drive_params) |