[parisc-linux-cvs] fix error returns for ipc syscall wrappers

Richard Hirst rhirst@linuxcare.com
Sun, 25 Mar 2001 22:12:01 +0100


Unfortunately, this doesn't fix fakeroot on 64 bit.  ipcs doesn't
work on 64 bit, btw; the kernel says 

  shmctl(IPC_STAT(cmd=0xd)) does not support libc5 cmds

Richard


===================================================================
RCS file: /home/cvs/parisc/linux/arch/parisc/kernel/sys_parisc32.c,v
retrieving revision 1.1
diff -u -r1.1 sys_parisc32.c
--- sys_parisc32.c      2001/03/02 00:48:47     1.1
+++ sys_parisc32.c      2001/03/25 21:01:34
@@ -2479,15 +2479,16 @@
        int err;
 
        if ((mb = kmalloc(msgsz + sizeof *mb + 4, GFP_KERNEL)) == NULL)
-               return ENOMEM;
+               return -ENOMEM;
 
        err = get_user(mb32.mtype, &umsgp32->mtype);
        mb->mtype = mb32.mtype;
        err |= copy_from_user(mb->mtext, &umsgp32->mtext, msgsz);
 
-       if (err == 0) {
+       if (err)
+               err = -EFAULT;
+       else
                KERNEL_SYSCALL(err, sys_msgsnd, msqid, mb, msgsz, msgflg);
-       }
 
        kfree(mb);
        return err;
@@ -2502,7 +2503,7 @@
        int err;
 
        if ((mb = kmalloc(msgsz + sizeof *mb + 4, GFP_KERNEL)) == NULL)
-               return ENOMEM;
+               return -ENOMEM;
 
        KERNEL_SYSCALL(err, sys_msgrcv, msqid, mb, msgsz, msgtyp, msgflg);
 
@@ -2510,6 +2511,8 @@
                mb32.mtype = mb->mtype;
                err = put_user(mb32.mtype, &umsgp32->mtype);
                err |= copy_to_user(&umsgp32->mtext, mb->mtext, err);
+               if (err)
+                       err = -EFAULT;
        }
 
        kfree(mb);
@@ -2547,7 +2550,7 @@
                /* Don't support the older stuff */
                if (ipc_parse_version(&cmd) != IPC_64) {
                    printk("msgctl() does not support libc5 IPC_STAT\n");
-                   return ENOSYS;
+                   return -ENOSYS;
                }
                err = sys_msgctl(msqid, cmd, buf);
                break;
@@ -2589,7 +2592,7 @@
 
 asmlinkage long sys32_semctl(int semid, int semnum, int cmd, union semun arg)
 {
-       int err = EINVAL;
+       int err = -EINVAL;
        struct shmid64_ds s64;
        union semun u;
        int version = ipc_parse_version(&cmd);
@@ -2599,7 +2602,7 @@
        case IPC_SET:
                if (version != IPC_64) {
                        printk("semctl(IPC_STAT(cmd=0x%x)) does not support libc5-style cmds\n", cmd);
-                       return ENOSYS;
+                       return -ENOSYS;
                }
                /* FALL THROUGH */
        case IPC_INFO:
@@ -2619,7 +2622,7 @@
        case SEM_STAT:
                if (version != IPC_64) {
                        printk("semctl(IPC_STAT(cmd=0x%x)) does not support libc5-style cmds\n", cmd);
-                       return ENOSYS;
+                       return -ENOSYS;
                }
                u.buf = (struct semid_ds *)&s64;
                KERNEL_SYSCALL(err, sys_semctl, semid, semnum, cmd, u);
@@ -2630,7 +2633,7 @@
 
        default:
                printk("semctl(cmd=%d) undefined cmd\n", cmd);
-               err = ENOSYS;
+               err = -ENOSYS;
                break;
        }
 
@@ -2639,7 +2642,7 @@
 
 asmlinkage long sys32_shmctl(int shmid, int cmd, struct shmid_ds *buf)
 {
-       int err = ENOSYS;
+       int err = -ENOSYS;
        struct shmid64_ds s64;
        int version = ipc_parse_version(&cmd);