patch for driver/block/floppy.c (versioncode)

Uwe Ohse (uwe@tirka.gun.de)
Thu, 29 Feb 1996 11:47:17 +0100


>I don't likely need to say this, but there are parts of the kernel
>(floppy driver comes to mind) that assume the next major release is
>going to be 1.4. Might not be a bad idea to do a sweep or two before

--- floppy.c.old Thu Feb 29 10:41:03 1996
+++ drivers/block/floppy.c Thu Feb 29 11:34:24 1996
@@ -108,6 +108,7 @@
/* do print messages for unexpected interrupts */
static int print_unex=1;
#include <linux/utsname.h>
+#include <linux/version.h>
#include <linux/module.h>

/* the following is the mask of allowed drives. By default units 2 and
@@ -3137,27 +3138,32 @@

static inline int xlate_0x00xx_ioctl(int *cmd, int *size)
{
- int i;
/* old ioctls' for kernels <= 1.3.33 */
/* When the next even release will come around, we'll start
- * warning against these.
- * When the next odd release will come around, we'll fail with
- * -EINVAL */
- if(strcmp(system_utsname.version, "1.4.0") >= 0)
- printk("obsolete floppy ioctl %x\n", *cmd);
- if((system_utsname.version[0] == '1' &&
- strcmp(system_utsname.version, "1.5.0") >= 0) ||
- (system_utsname.version[0] >= '2' &&
- strcmp(system_utsname.version, "2.1.0") >= 0))
- return -EINVAL;
- for (i=0; i < ARRAY_SIZE(translation_table); i++) {
- if (*cmd == translation_table[i].oldcmd) {
- *size = translation_table[i].oldsize;
- *cmd = translation_table[i].newcmd;
- return 0;
+ * warning against these. */
+#if LINUX_VERSION_CODE >= 0x010400
+ printk("obsolete floppy ioctl %x, update the `%s' binary\n",
+ *cmd,current->comm);
+#endif
+
+ /* When the next odd release will come around, we'll fail with
+ * -EINVAL. This catches 1.5 and 2.1. */
+#if (LINUX_VERSION_CODE < 0x020000 && LINUX_VERSION_CODE >=0x010500) \
+ || (LINUX_VERSION_CODE > 0x020100)
+ return -EINVAL;
+#else
+ {
+ int i;
+ for (i=0; i < ARRAY_SIZE(translation_table); i++) {
+ if (*cmd == translation_table[i].oldcmd) {
+ *size = translation_table[i].oldsize;
+ *cmd = translation_table[i].newcmd;
+ return 0;
+ }
}
}
return -EINVAL;
+#endif
}

static int fd_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,