Annotation of researchv10no/sys/os/ioctl.c, revision 1.1.1.1

1.1       root        1: #include "sys/param.h"
                      2: #include "sys/user.h"
                      3: #include "sys/inode.h"
                      4: #include "sys/file.h"
                      5: #include "sys/conf.h"
                      6: #include "sys/filio.h"
                      7: 
                      8: /*
                      9:  * ioctl system call
                     10:  * Check legality, execute common code, and switch out to individual
                     11:  * device routine.
                     12:  */
                     13: ioctl()
                     14: {
                     15:        register struct file *fp;
                     16:        register struct inode *ip;
                     17:        register struct a {
                     18:                int     fdes;
                     19:                int     cmd;
                     20:                caddr_t cmarg;
                     21:        } *uap;
                     22: 
                     23:        uap = (struct a *)u.u_ap;
                     24:        if ((fp = getf(uap->fdes)) == NULL
                     25:        ||  (fp->f_flag & (FREAD|FWRITE)) == 0) {
                     26:                u.u_error = EBADF;
                     27:                return;
                     28:        }
                     29:        ip = fp->f_inode;
                     30:        switch (uap->cmd) {
                     31: 
                     32:        case FIOCLEX:                   /* close on exec */
                     33:                u.u_pofile[uap->fdes] |= EXCLOSE;
                     34:                return;
                     35: 
                     36:        case FIONCLEX:                  /* no close on exec */
                     37:                u.u_pofile[uap->fdes] &= ~EXCLOSE;
                     38:                return;
                     39: 
                     40:        }
                     41:        if (ip->i_sptr) {
                     42:                stioctl(ip, uap->cmd, uap->cmarg);
                     43:                return;
                     44:        }
                     45:        (*fstypsw[ip->i_fstyp]->t_ioctl)(ip, uap->cmd, uap->cmarg, fp->f_flag);
                     46: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.