Change to includes. no more ../h
[unix-history] / usr / src / sys / kern / kern_descrip.c
index e6ba686..39b991f 100644 (file)
@@ -1,20 +1,20 @@
-/*     kern_descrip.c  6.1     83/07/29        */
-
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/dir.h"
-#include "../h/user.h"
-#include "../h/kernel.h"
-#include "../h/inode.h"
-#include "../h/proc.h"
-#include "../h/conf.h"
-#include "../h/file.h"
-#include "../h/socket.h"
-#include "../h/socketvar.h"
-#include "../h/mount.h"
-#include "../h/stat.h"
-
-#include "../h/ioctl.h"
+/*     kern_descrip.c  6.5     84/08/29        */
+
+#include "param.h"
+#include "systm.h"
+#include "dir.h"
+#include "user.h"
+#include "kernel.h"
+#include "inode.h"
+#include "proc.h"
+#include "conf.h"
+#include "file.h"
+#include "socket.h"
+#include "socketvar.h"
+#include "mount.h"
+#include "stat.h"
+
+#include "ioctl.h"
 
 /*
  * Descriptor management.
 
 /*
  * Descriptor management.
@@ -55,9 +55,7 @@ dup()
 
        if (uap->i &~ 077) { uap->i &= 077; dup2(); return; }   /* XXX */
 
 
        if (uap->i &~ 077) { uap->i &= 077; dup2(); return; }   /* XXX */
 
-       fp = getf(uap->i);
-       if (fp == 0)
-               return;
+       GETF(fp, uap->i);
        j = ufalloc(0);
        if (j < 0)
                return;
        j = ufalloc(0);
        if (j < 0)
                return;
@@ -71,9 +69,7 @@ dup2()
        } *uap = (struct a *) u.u_ap;
        register struct file *fp;
 
        } *uap = (struct a *) u.u_ap;
        register struct file *fp;
 
-       fp = getf(uap->i);
-       if (fp == 0)
-               return;
+       GETF(fp, uap->i);
        if (uap->j < 0 || uap->j >= NOFILE) {
                u.u_error = EBADF;
                return;
        if (uap->j < 0 || uap->j >= NOFILE) {
                u.u_error = EBADF;
                return;
@@ -117,12 +113,10 @@ fcntl()
        register char *pop;
 
        uap = (struct a *)u.u_ap;
        register char *pop;
 
        uap = (struct a *)u.u_ap;
-       fp = getf(uap->fdes);
-       if (fp == NULL)
-               return;
+       GETF(fp, uap->fdes);
        pop = &u.u_pofile[uap->fdes];
        switch(uap->cmd) {
        pop = &u.u_pofile[uap->fdes];
        switch(uap->cmd) {
-       case 0:
+       case F_DUPFD:
                i = uap->arg;
                if (i < 0 || i > NOFILE) {
                        u.u_error = EINVAL;
                i = uap->arg;
                if (i < 0 || i > NOFILE) {
                        u.u_error = EINVAL;
@@ -133,19 +127,19 @@ fcntl()
                dupit(i, fp, *pop);
                break;
 
                dupit(i, fp, *pop);
                break;
 
-       case 1:
+       case F_GETFD:
                u.u_r.r_val1 = *pop & 1;
                break;
 
                u.u_r.r_val1 = *pop & 1;
                break;
 
-       case 2:
+       case F_SETFD:
                *pop = (*pop &~ 1) | (uap->arg & 1);
                break;
 
                *pop = (*pop &~ 1) | (uap->arg & 1);
                break;
 
-       case 3:
+       case F_GETFL:
                u.u_r.r_val1 = fp->f_flag+FOPEN;
                break;
 
                u.u_r.r_val1 = fp->f_flag+FOPEN;
                break;
 
-       case 4:
+       case F_SETFL:
                fp->f_flag &= FCNTLCANT;
                fp->f_flag |= (uap->arg-FOPEN) &~ FCNTLCANT;
                u.u_error = fset(fp, FNDELAY, fp->f_flag & FNDELAY);
                fp->f_flag &= FCNTLCANT;
                fp->f_flag |= (uap->arg-FOPEN) &~ FCNTLCANT;
                u.u_error = fset(fp, FNDELAY, fp->f_flag & FNDELAY);
@@ -156,12 +150,12 @@ fcntl()
                        (void) fset(fp, FNDELAY, 0);
                break;
 
                        (void) fset(fp, FNDELAY, 0);
                break;
 
-       case 5:
-               u.u_error = fsetown(fp, uap->arg);
+       case F_GETOWN:
+               u.u_error = fgetown(fp, &u.u_r.r_val1);
                break;
 
                break;
 
-       case 6:
-               u.u_error = fgetown(fp, &u.u_r.r_val1);
+       case F_SETOWN:
+               u.u_error = fsetown(fp, uap->arg);
                break;
 
        default:
                break;
 
        default:
@@ -237,16 +231,14 @@ close()
        register struct file *fp;
        register u_char *pf;
 
        register struct file *fp;
        register u_char *pf;
 
-       fp = getf(uap->i);
-       if (fp == 0)
-               return;
+       GETF(fp, uap->i);
        pf = (u_char *)&u.u_pofile[uap->i];
        if (*pf & UF_MAPPED)
                munmapfd(uap->i);
        pf = (u_char *)&u.u_pofile[uap->i];
        if (*pf & UF_MAPPED)
                munmapfd(uap->i);
-       closef(fp);
-       /* WHAT IF u.u_error ? */
        u.u_ofile[uap->i] = NULL;
        *pf = 0;
        u.u_ofile[uap->i] = NULL;
        *pf = 0;
+       closef(fp);
+       /* WHAT IF u.u_error ? */
 }
 
 fstat()
 }
 
 fstat()
@@ -259,9 +251,7 @@ fstat()
        struct stat ub;
 
        uap = (struct a *)u.u_ap;
        struct stat ub;
 
        uap = (struct a *)u.u_ap;
-       fp = getf(uap->fdes);
-       if (fp == 0)
-               return;
+       GETF(fp, uap->fdes);
        switch (fp->f_type) {
 
        case DTYPE_INODE:
        switch (fp->f_type) {
 
        case DTYPE_INODE:
@@ -398,9 +388,7 @@ flock()
        } *uap = (struct a *)u.u_ap;
        register struct file *fp;
 
        } *uap = (struct a *)u.u_ap;
        register struct file *fp;
 
-       fp = getf(uap->fd);
-       if (fp == NULL)
-               return;
+       GETF(fp, uap->fd);
        if (fp->f_type != DTYPE_INODE) {
                u.u_error = EOPNOTSUPP;
                return;
        if (fp->f_type != DTYPE_INODE) {
                u.u_error = EOPNOTSUPP;
                return;