32bit binaries on amd64 linux26

Pavel Semerad semerad at ss1000.ms.mff.cuni.cz
Fri Apr 29 14:07:58 CEST 2005



Following patch allows to run 32binaries (fs, klog, ...) on 64bit
linux26 kernel. It is adding ioctl conversion on /proc/fs/...
Tested on amd64, arla 0.39, kernel 2.6.11.6 .

Pavel Semerad


--- ./nnpfs/linux/nnpfs_syscalls.c.yy	2005-04-28 16:16:24.000000000 +0200
+++ ./nnpfs/linux/nnpfs_syscalls.c	2005-04-28 17:44:51.000000000 +0200
@@ -51,6 +51,10 @@
 #include <linux/security.h>
 #endif
 
+#ifdef CONFIG_COMPAT
+#include <linux/ioctl32.h>
+#endif
+
 #ifdef RCSID
 RCSID("$Id: 0.39-amd64,v 1.1 2005/04/29 09:59:07 root Exp $");
 #endif
@@ -58,6 +62,7 @@ RCSID("$Id: nnpfs_syscalls.c,v 1.111 200
 static struct proc_dir_entry *nnpfs_procfs_dir;
 
 #define VIOC_SYSCALL _IOW('C',1,void *)
+#define VIOC_SYSCALL32 _IOW('C',1,u32)
 #define NNPFS_PROC_DIR "nnpfs"
 #define NNPFS_PROC_NODE "afs_ioctl"
  
@@ -1097,8 +1102,8 @@ sys_afs_int (int operation,
     return error;
 }
 
-#ifdef SYSCALLHACK
-#ifdef NEED_VICEIOCTL32
+#if defined SYSCALLHACK || defined CONFIG_COMPAT
+#if defined NEED_VICEIOCTL32 || defined CONFIG_COMPAT
 asmlinkage long
 sys32_afs (int operation,
 	   char *a_pathP,
@@ -1162,6 +1167,34 @@ nnpfs_procfs_ioctl(struct inode *inode, 
     return ret;
 }
 
+#ifdef CONFIG_COMPAT
+typedef struct afsprocdata32 {
+    u32 param4;
+    u32 param3;
+    u32 param2;
+    u32 param1;
+    u32 syscall;
+} afsprocdata32;
+
+static int
+nnpfs_procfs_ioctl32(unsigned int fd, unsigned int cmd, unsigned long arg,
+		     struct file *file) {
+    afsprocdata32 args;
+    long ret;
+
+    if (cmd != VIOC_SYSCALL32)
+	return -EINVAL;
+
+    if (copy_from_user(&args, (void *)arg, sizeof(args)))
+	return -EFAULT;
+    
+    ret = sys32_afs((int)args.syscall,
+		    (char *)(long)args.param1, (int)args.param2,
+		    (struct ViceIoctl32 *)(long)args.param3, (int)args.param4);
+    return ret;
+}
+#endif /* CONFIG_COMPAT */
+
 static int nnpfs_init_procfs(void)
 {
     struct proc_dir_entry *entry;
@@ -1181,6 +1214,12 @@ static int nnpfs_init_procfs(void)
     
     entry->owner = THIS_MODULE;
     entry->proc_fops = &nnpfs_procfs_fops;
+
+#ifdef CONFIG_COMPAT
+    if (register_ioctl32_conversion(VIOC_SYSCALL32, nnpfs_procfs_ioctl32)) {
+	printk(KERN_EMERG "nnpfs_init_procfs: unable to register ioctl32\n");
+    }
+#endif /* CONFIG_COMPAT */
     
     NNPFSDEB(XDEBSYS, ("nnpfs_init_procfs: success\n"));
 
@@ -1189,6 +1228,11 @@ static int nnpfs_init_procfs(void)
 
 static void nnpfs_exit_procfs(void)
 {
+#ifdef CONFIG_COMPAT
+    if (unregister_ioctl32_conversion(VIOC_SYSCALL32)) {
+	printk(KERN_EMERG "nnpfs_exit_procfs: error unregistering ioctl32\n");
+    }
+#endif /* CONFIG_COMPAT */
     remove_proc_entry(NNPFS_PROC_NODE, nnpfs_procfs_dir);
     remove_proc_entry(NNPFS_PROC_DIR, proc_root_fs);
 }






More information about the Arla-drinkers mailing list