u.u_pofile flags are now UF_*
[unix-history] / usr / src / sys / kern / sys_generic.c
index 53208ee..65173f2 100644 (file)
@@ -1,9 +1,10 @@
-/*     sys_generic.c   5.15    82/10/10        */
+/*     sys_generic.c   5.25    82/12/09        */
 
 #include "../h/param.h"
 #include "../h/systm.h"
 #include "../h/dir.h"
 #include "../h/user.h"
 
 #include "../h/param.h"
 #include "../h/systm.h"
 #include "../h/dir.h"
 #include "../h/user.h"
+#include "../h/ioctl.h"
 #include "../h/tty.h"
 #include "../h/file.h"
 #include "../h/inode.h"
 #include "../h/tty.h"
 #include "../h/file.h"
 #include "../h/inode.h"
@@ -21,6 +22,7 @@
 #endif
 #include "../h/descrip.h"
 #include "../h/uio.h"
 #endif
 #include "../h/descrip.h"
 #include "../h/uio.h"
+#include "../h/cmap.h"
 
 /*
  * Read system call.
 
 /*
  * Read system call.
@@ -200,8 +202,7 @@ rwip(ip, uio, rw)
        struct buf *bp;
        struct fs *fs;
        daddr_t lbn, bn;
        struct buf *bp;
        struct fs *fs;
        daddr_t lbn, bn;
-       register int on, type;
-       register unsigned n;
+       register int n, on, type;
        int size;
        long bsize;
        extern int mem_no;
        int size;
        long bsize;
        extern int mem_no;
@@ -209,9 +210,12 @@ rwip(ip, uio, rw)
 
        if (rw != UIO_READ && rw != UIO_WRITE)
                panic("rwip");
 
        if (rw != UIO_READ && rw != UIO_WRITE)
                panic("rwip");
+       if (rw == UIO_READ && uio->uio_resid == 0)
+               return (0);
        if (uio->uio_offset < 0 &&
            ((ip->i_mode&IFMT) != IFCHR || mem_no != major(dev)))
        if (uio->uio_offset < 0 &&
            ((ip->i_mode&IFMT) != IFCHR || mem_no != major(dev)))
-               return (EINVAL); if (rw == UIO_READ)
+               return (EINVAL);
+       if (rw == UIO_READ)
                ip->i_flag |= IACC;
        type = ip->i_mode&IFMT;
        if (type == IFCHR) {
                ip->i_flag |= IACC;
        type = ip->i_mode&IFMT;
        if (type == IFCHR) {
@@ -219,14 +223,16 @@ rwip(ip, uio, rw)
                register c = uio->uio_resid;
 #endif
                if (rw == UIO_READ)
                register c = uio->uio_resid;
 #endif
                if (rw == UIO_READ)
-                       (*cdevsw[major(dev)].d_read)(dev, uio);
+                       u.u_error = (*cdevsw[major(dev)].d_read)(dev, uio);
                else {
                        ip->i_flag |= IUPD|ICHG;
                else {
                        ip->i_flag |= IUPD|ICHG;
-                       (*cdevsw[major(dev)].d_write)(dev, uio);
+                       u.u_error = (*cdevsw[major(dev)].d_write)(dev, uio);
                }
                CHARGE(sc_tio * (c - uio->uio_resid));
                return (u.u_error);
        }
                }
                CHARGE(sc_tio * (c - uio->uio_resid));
                return (u.u_error);
        }
+       if (uio->uio_resid == 0)
+               return (0);
        if (rw == UIO_WRITE && type == IFREG &&
            uio->uio_offset + uio->uio_resid >
              u.u_rlimit[RLIMIT_FSIZE].rlim_cur) {
        if (rw == UIO_WRITE && type == IFREG &&
            uio->uio_offset + uio->uio_resid >
              u.u_rlimit[RLIMIT_FSIZE].rlim_cur) {
@@ -275,6 +281,7 @@ rwip(ip, uio, rw)
                        ip->i_lastr = lbn;
                } else {
                        int i, count;
                        ip->i_lastr = lbn;
                } else {
                        int i, count;
+                       extern struct cmap *mfind();
 
                        count = howmany(size, DEV_BSIZE);
                        for (i = 0; i < count; i += CLSIZE)
 
                        count = howmany(size, DEV_BSIZE);
                        for (i = 0; i < count; i += CLSIZE)
@@ -292,7 +299,7 @@ rwip(ip, uio, rw)
                        goto bad;
                }
                u.u_error =
                        goto bad;
                }
                u.u_error =
-                   uiomove(bp->b_un.b_addr+on, (u_int)n, rw, uio);
+                   uiomove(bp->b_un.b_addr+on, n, rw, uio);
                if (rw == UIO_READ) {
                        if (n + on == bsize || uio->uio_offset == ip->i_size)
                                bp->b_flags |= B_AGE;
                if (rw == UIO_READ) {
                        if (n + on == bsize || uio->uio_offset == ip->i_size)
                                bp->b_flags |= B_AGE;
@@ -404,6 +411,7 @@ again:
        return (0);
 }
 
        return (0);
 }
 
+#ifdef notdef
 /*
  * Get next character written in by user from uio.
  */
 /*
  * Get next character written in by user from uio.
  */
@@ -444,6 +452,7 @@ again:
        uio->uio_offset++;
        return (c & 0377);
 }
        uio->uio_offset++;
        return (c & 0377);
 }
+#endif
 
 /*
  * Ioctl system call
 
 /*
  * Ioctl system call
@@ -485,11 +494,11 @@ ioctl()
        }
 #endif
        if (com == FIOCLEX) {
        }
 #endif
        if (com == FIOCLEX) {
-               u.u_pofile[uap->fdes] |= EXCLOSE;
+               u.u_pofile[uap->fdes] |= UF_EXCLOSE;
                return;
        }
        if (com == FIONCLEX) {
                return;
        }
        if (com == FIONCLEX) {
-               u.u_pofile[uap->fdes] &= ~EXCLOSE;
+               u.u_pofile[uap->fdes] &= ~UF_EXCLOSE;
                return;
        }
 
                return;
        }
 
@@ -518,7 +527,7 @@ ioctl()
                bzero((caddr_t)data, size);
 
        if (fp->f_type == DTYPE_SOCKET)
                bzero((caddr_t)data, size);
 
        if (fp->f_type == DTYPE_SOCKET)
-               soioctl(fp->f_socket, com, data);
+               u.u_error = soioctl(fp->f_socket, com, data);
        else {
                register struct inode *ip = fp->f_inode;
                int fmt = ip->i_mode & IFMT;
        else {
                register struct inode *ip = fp->f_inode;
                int fmt = ip->i_mode & IFMT;
@@ -539,7 +548,7 @@ ioctl()
                        u.u_eosys = RESTARTSYS;
                        return;
                }
                        u.u_eosys = RESTARTSYS;
                        return;
                }
-               (*cdevsw[major(dev)].d_ioctl)(dev, com, data, 0);
+               u.u_error = (*cdevsw[major(dev)].d_ioctl)(dev, com, data, 0);
        }
 
 returndata:
        }
 
 returndata:
@@ -566,7 +575,7 @@ nullioctl(tp, cmd, data, flags)
 #ifdef lint
        tp = tp; data = data; flags = flags;
 #endif
 #ifdef lint
        tp = tp; data = data; flags = flags;
 #endif
-       return (cmd);
+       return (-1);
 }
 
 ostty()
 }
 
 ostty()