[DRBD-cvs] svn commit by lars - r2257 - branches/drbd-0.7/drbd - thanks for the headsup on drbd-user:

drbd-cvs at lists.linbit.com drbd-cvs at lists.linbit.com
Tue Jul 4 12:31:16 CEST 2006


/ 2006-07-03 19:47
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Author: lars
Date: 2006-07-04 12:31:11 +0200 (Tue, 04 Jul 2006)
New Revision: 2257

Modified:
   branches/drbd-0.7/drbd/drbd_fs.c
Log:

thanks for the headsup on drbd-user:
/ 2006-07-03 19:47:55 +0200
\ Guido Guenther:
> according to block/ioctl.c drbd_ioctl() is supposed to return -ENOCTLCMD
> instead of -EINVAL when it doesn't handle that specific ioctl:
>
> /* Most of the generic ioctls are handled in the normal fallback path.
>    This assumes the blkdev's low level compat_ioctl always returns
>    ENOIOCTLCMD for unknown ioctls. */

well, he is right, even though his proposed patch did not quite work generically.
this patch should do it, for all architechtures and even still be mostly correct
(not worse than before) for 2.4 kernels.


Modified: branches/drbd-0.7/drbd/drbd_fs.c
===================================================================
--- branches/drbd-0.7/drbd/drbd_fs.c	2006-07-04 09:34:04 UTC (rev 2256)
+++ branches/drbd-0.7/drbd/drbd_fs.c	2006-07-04 10:31:11 UTC (rev 2257)
@@ -1069,9 +1069,10 @@
 long drbd_compat_ioctl(struct file *f, unsigned cmd, unsigned long arg)
 {
 	int ret;
-	// lock_kernel(); Not needed, since we have mdev->device_mutex
 	ret = drbd_ioctl(f->f_dentry->d_inode, f, cmd, arg);
-	// unlock_kernel();
+	/* need to map "unknown" to ENOIOCTLCMD
+	 * to get the generic fallback path going */
+	if (ret == -ENOTTY) ret = -ENOIOCTLCMD;
 	return ret;
 }
 #endif
@@ -1123,7 +1124,9 @@
 		switch (cmd) {
 		default:
 			/* oops, unknown IOCTL ?? */
-			err = -EINVAL;
+			/* Sorry, 2.4 kernel will get "no such ioctl" for BLK* ioctls
+			 * on an unconfigured DRBD.  I don't care right now. */
+			err = -ENOTTY;
 			goto out_unlocked;
 
 		case DRBD_IOCTL_GET_CONFIG:
@@ -1176,6 +1179,10 @@
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
 /* see how sys_ioctl and blkdev_ioctl handle it in 2.6 .
  * If I understand correctly, only "private" ioctl end up here.
+ *
+ * unless, of course, we are called by the compat_ioctl, in which case our
+ * drbd_compat_ioctl wrapper will convert ENOTTY into ENOIOCTLCMD, which in
+ * turn will cause the fallback path in the generic compat_sys_ioctl.
  */
 	case BLKGETSIZE:
 		err = put_user(drbd_get_capacity(mdev->this_bdev),(long *)arg);
@@ -1452,7 +1459,7 @@
 		break;
 
 	default:
-		err = -EINVAL;
+		err = -ENOTTY;
 	}
  /* out: */
 	up(&mdev->device_mutex);



More information about the drbd-cvs mailing list