u.u_pofile flags are now UF_*
[unix-history] / usr / src / sys / kern / sys_generic.c
index a2467b6..65173f2 100644 (file)
@@ -1,15 +1,15 @@
-/*     sys_generic.c   5.14    82/09/08        */
+/*     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/buf.h"
 #include "../h/proc.h"
 #include "../h/tty.h"
 #include "../h/file.h"
 #include "../h/inode.h"
 #include "../h/buf.h"
 #include "../h/proc.h"
-#include "../h/inline.h"
 #include "../h/conf.h"
 #include "../h/socket.h"
 #include "../h/socketvar.h"
 #include "../h/conf.h"
 #include "../h/socket.h"
 #include "../h/socketvar.h"
@@ -22,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.
@@ -150,14 +151,14 @@ rwuio(uio, rw)
                int sosend(), soreceive();
                u.u_error = 
                    (*(rw==UIO_READ?soreceive:sosend))
                int sosend(), soreceive();
                u.u_error = 
                    (*(rw==UIO_READ?soreceive:sosend))
-                     (fp->f_socket, (struct sockaddr *)0, uio);
+                     (fp->f_socket, (struct sockaddr *)0, uio, 0);
        } else {
                ip = fp->f_inode;
                uio->uio_offset = fp->f_offset;
                if ((ip->i_mode&IFMT) == IFREG) {
        } else {
                ip = fp->f_inode;
                uio->uio_offset = fp->f_offset;
                if ((ip->i_mode&IFMT) == IFREG) {
-                       ilock(ip);
+                       ILOCK(ip);
                        u.u_error = rwip(ip, uio, rw);
                        u.u_error = rwip(ip, uio, rw);
-                       iunlock(ip);
+                       IUNLOCK(ip);
                } else
                        u.u_error = rwip(ip, uio, rw);
                fp->f_offset += count - uio->uio_resid;
                } else
                        u.u_error = rwip(ip, uio, rw);
                fp->f_offset += count - uio->uio_resid;
@@ -201,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;
@@ -210,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) {
@@ -220,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) {
@@ -276,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)
@@ -293,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;
@@ -405,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.
  */
@@ -445,6 +452,7 @@ again:
        uio->uio_offset++;
        return (c & 0377);
 }
        uio->uio_offset++;
        return (c & 0377);
 }
+#endif
 
 /*
  * Ioctl system call
 
 /*
  * Ioctl system call
@@ -486,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;
        }
 
@@ -519,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;
@@ -540,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:
@@ -567,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()