patch-2.3.99-pre3 linux/arch/sparc64/kernel/ioctl32.c

Next file: linux/arch/sparc64/kernel/sys_sparc32.c
Previous file: linux/arch/sparc64/kernel/binfmt_aout32.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.99-pre2/linux/arch/sparc64/kernel/ioctl32.c linux/arch/sparc64/kernel/ioctl32.c
@@ -1,4 +1,4 @@
-/* $Id: ioctl32.c,v 1.83 2000/03/14 07:31:25 jj Exp $
+/* $Id: ioctl32.c,v 1.85 2000/03/23 05:25:41 davem Exp $
  * ioctl32.c: Conversion between 32bit and 64bit native ioctls.
  *
  * Copyright (C) 1997-2000  Jakub Jelinek  (jakub@redhat.com)
@@ -1594,7 +1594,7 @@
 {
 	mm_segment_t old_fs = get_fs();
 	struct loop_info l;
-	int err = 0;
+	int err = -EINVAL;
 
 	switch(cmd) {
 	case LOOP_SET_STATUS:
@@ -1604,11 +1604,13 @@
 		err |= __get_user(l.lo_rdevice, &((struct loop_info32 *)arg)->lo_rdevice);
 		err |= __copy_from_user((char *)&l.lo_offset, (char *)&((struct loop_info32 *)arg)->lo_offset,
 					   8 + (unsigned long)l.lo_init - (unsigned long)&l.lo_offset);
-		if (err)
-			return -EFAULT;
-		set_fs (KERNEL_DS);
-		err = sys_ioctl (fd, cmd, (unsigned long)&l);
-		set_fs (old_fs);
+		if (err) {
+			err = -EFAULT;
+		} else {
+			set_fs (KERNEL_DS);
+			err = sys_ioctl (fd, cmd, (unsigned long)&l);
+			set_fs (old_fs);
+		}
 		break;
 	case LOOP_GET_STATUS:
 		set_fs (KERNEL_DS);
@@ -1621,10 +1623,19 @@
 			err |= __put_user(l.lo_rdevice, &((struct loop_info32 *)arg)->lo_rdevice);
 			err |= __copy_to_user((char *)&((struct loop_info32 *)arg)->lo_offset,
 					   (char *)&l.lo_offset, (unsigned long)l.lo_init - (unsigned long)&l.lo_offset);
+			if (err)
+				err = -EFAULT;
 		}
 		break;
+	default: {
+		static int count = 0;
+		if (++count <= 20)
+			printk("%s: Unknown loop ioctl cmd, fd(%d) "
+			       "cmd(%08x) arg(%08lx)\n",
+			       __FUNCTION__, fd, cmd, arg);
 	}
-	return err ? -EFAULT : 0;
+	}
+	return err;
 }
 
 extern int tty_ioctl(struct inode * inode, struct file * file, unsigned int cmd, unsigned long arg);
@@ -1803,6 +1814,8 @@
 #define ATM_SETESIF32     _IOW('a', ATMIOC_ITF+13, struct atmif_sioc32)
 #define ATM_GETSTAT32     _IOW('a', ATMIOC_SARCOM+0, struct atmif_sioc32)
 #define ATM_GETSTATZ32    _IOW('a', ATMIOC_SARCOM+1, struct atmif_sioc32)
+#define ATM_GETLOOP32	  _IOW('a', ATMIOC_SARCOM+2, struct atmif_sioc32)
+#define ATM_SETLOOP32	  _IOW('a', ATMIOC_SARCOM+3, struct atmif_sioc32)
 
 static struct {
         unsigned int cmd32;
@@ -1821,7 +1834,9 @@
 	{ ATM_SETESI32,      ATM_SETESI },
 	{ ATM_SETESIF32,     ATM_SETESIF },
 	{ ATM_GETSTAT32,     ATM_GETSTAT },
-	{ ATM_GETSTATZ32,    ATM_GETSTATZ }
+	{ ATM_GETSTATZ32,    ATM_GETSTATZ },
+	{ ATM_GETLOOP32,     ATM_GETLOOP },
+	{ ATM_SETLOOP32,     ATM_SETLOOP }
 };
 
 #define NR_ATM_IOCTL (sizeof(atm_ioctl_map)/sizeof(atm_ioctl_map[0]))
@@ -1941,8 +1956,6 @@
         unsigned int cmd = 0;
         
 	switch (cmd32) {
-	case SUNI_GETLOOP:
-	case SUNI_SETLOOP:
 	case SONET_GETSTAT:
 	case SONET_GETSTATZ:
 	case SONET_GETDIAG:
@@ -1954,7 +1967,6 @@
 		return do_atmif_sioc(fd, cmd32, arg);
 	}
 
-	if (cmd == 0) {
 		for (i = 0; i < NR_ATM_IOCTL; i++) {
 			if (cmd32 == atm_ioctl_map[i].cmd32) {
 				cmd = atm_ioctl_map[i].cmd;
@@ -1964,7 +1976,6 @@
 	        if (i == NR_ATM_IOCTL) {
 	        return -EINVAL;
 	        }
-	}
         
         switch (cmd) {
 	case ATM_GETNAMES:
@@ -1983,6 +1994,8 @@
 	case ATM_SETESIF:
 	case ATM_GETSTAT:
 	case ATM_GETSTATZ:
+	case ATM_GETLOOP:
+	case ATM_SETLOOP:
                 return do_atmif_sioc(fd, cmd, arg);
         }
 
@@ -3076,8 +3089,8 @@
 HANDLE_IOCTL(ATM_SETESIF32, do_atm_ioctl)
 HANDLE_IOCTL(ATM_GETSTAT32, do_atm_ioctl)
 HANDLE_IOCTL(ATM_GETSTATZ32, do_atm_ioctl)
-HANDLE_IOCTL(SUNI_GETLOOP, do_atm_ioctl)
-HANDLE_IOCTL(SUNI_SETLOOP, do_atm_ioctl)
+HANDLE_IOCTL(ATM_GETLOOP32, do_atm_ioctl)
+HANDLE_IOCTL(ATM_SETLOOP32, do_atm_ioctl)
 HANDLE_IOCTL(SONET_GETSTAT, do_atm_ioctl)
 HANDLE_IOCTL(SONET_GETSTATZ, do_atm_ioctl)
 HANDLE_IOCTL(SONET_GETDIAG, do_atm_ioctl)

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)