Skip to contentSkip to conversation

PATCH: fix block layer ioctl bug

PATCH Alan Cox 1 participant 1 message May 12, 2004 Block layer

lore
Share & tools
lore

Alan Cox

author
#0 lore raw

The block layer checks for -EINVAL from block layer driver ioctls. This is wrong - ENOTTY is unknown and some drivers correctly use this. I suspect for an internal ioctl 2.7 should change to -ENOIOCTLCMD and bitch about old style returns

This is conservative fix for the 2.6 case, it keeps the bogus -EINVAL to avoid breaking stuff

drivers/block/ioctl.c +2 -1
diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.6/drivers/block/ioctl.c linux-2.6.6/drivers/block/ioctl.c
@@ -203,7 +203,8 @@
 	case BLKROSET:
 		if (disk->fops->ioctl) {
 			ret = disk->fops->ioctl(inode, file, cmd, arg);
-			if (ret != -EINVAL)
+			/* -EINVAL to handle old uncorrected drivers */
+			if (ret != -EINVAL && ret != -ENOTTY)
 				return ret;
 		}
 		if (!capable(CAP_SYS_ADMIN))