1: /*
   2:  * Ioctl.
   3:  */
   4: 
   5: /*
   6:  *	SCCS id	@(#)ioctl.c	2.1 (Berkeley)	8/5/83
   7:  */
   8: #include "param.h"
   9: #include <sys/systm.h>
  10: #include <sys/dir.h>
  11: #include <sys/user.h>
  12: #include <sys/tty.h>
  13: #include <sys/proc.h>
  14: #ifdef  MPX_FILS
  15: #include <sys/mx.h>
  16: #endif
  17: #include <sys/inode.h>
  18: #include <sys/file.h>
  19: #include <sys/reg.h>
  20: #include <sys/conf.h>
  21: 
  22: /*
  23:  * stty/gtty writearound
  24:  */
  25: stty()
  26: {
  27:     u.u_arg[2] = u.u_arg[1];
  28:     u.u_arg[1] = TIOCSETP;
  29:     ioctl();
  30: }
  31: 
  32: gtty()
  33: {
  34:     u.u_arg[2] = u.u_arg[1];
  35:     u.u_arg[1] = TIOCGETP;
  36:     ioctl();
  37: }
  38: 
  39: /*
  40:  * ioctl system call
  41:  * Check legality, execute common code, and switch out to individual
  42:  * device routine.
  43:  */
  44: ioctl()
  45: {
  46:     register struct file *fp;
  47:     register struct inode *ip;
  48:     register struct a {
  49:         int fdes;
  50:         int cmd;
  51:         caddr_t cmarg;
  52:     } *uap;
  53:     dev_t dev;
  54:     int fmt;
  55: 
  56:     uap = (struct a *)u.u_ap;
  57:     if ((fp = getf(uap->fdes)) == NULL)
  58:         return;
  59:     if ((fp->f_flag & (FREAD|FWRITE)) == 0) {
  60:         u.u_error = EBADF;
  61:         return;
  62:     }
  63:     if (uap->cmd==FIOCLEX) {
  64:         u.u_pofile[uap->fdes] |= EXCLOSE;
  65:         return;
  66:     }
  67:     if (uap->cmd==FIONCLEX) {
  68:         u.u_pofile[uap->fdes] &= ~EXCLOSE;
  69:         return;
  70:     }
  71: #ifdef  UCB_NET
  72:     if (fp->f_flag & FSOCKET) {
  73:         soioctl(fp->f_socket, uap->cmd, uap->cmarg);
  74:         return;
  75:     }
  76: #endif
  77:     ip = fp->f_inode;
  78:     fmt = ip->i_mode & IFMT;
  79: #ifdef  MPX_FILS
  80:     if (fmt != IFCHR && fmt != IFMPC)
  81: #else
  82:     if (fmt != IFCHR)
  83: #endif
  84:         {
  85: #ifdef  UCB_NTTY
  86:         if (uap->cmd==FIONREAD && (fmt == IFREG || fmt == IFDIR)) {
  87:             off_t nread = ip->i_size - fp->f_un.f_offset;
  88: 
  89:             if (copyout((caddr_t)&nread, uap->cmarg, sizeof(off_t)))
  90:                 u.u_error = EFAULT;
  91:         } else
  92: #endif
  93: #ifdef  UCB_NET
  94:                if (uap->cmd == FIONBIO || uap->cmd == FIOASYNC)
  95:             return;
  96:         else
  97: #endif
  98:             u.u_error = ENOTTY;
  99:         return;
 100:     }
 101:     dev = ip->i_un.i_rdev;
 102:     u.u_r.r_val1 = 0;
 103: #ifdef  MENLO_JCL
 104:     if ((u.u_procp->p_flag&SNUSIG) && save(u.u_qsav)) {
 105:         u.u_eosys = RESTARTSYS;
 106:         return;
 107:     }
 108: #endif
 109:     (*cdevsw[major(dev)].d_ioctl)(dev, uap->cmd, uap->cmarg, fp->f_flag);
 110: }
 111: 
 112: /*
 113:  * Do nothing specific version of line
 114:  * discipline specific ioctl command.
 115:  */
 116: /*ARGSUSED*/
 117: nullioctl(tp, cmd, addr, flag)
 118: struct tty *tp;
 119: caddr_t addr;
 120: {
 121:     return (cmd);
 122: }

Defined functions

gtty defined in line 32; used 2 times
ioctl defined in line 44; used 4 times
nullioctl defined in line 117; used 6 times
stty defined in line 25; used 2 times

Defined struct's

a defined in line 48; used 2 times
  • in line 56(2)
Last modified: 1983-08-06
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 975
Valid CSS Valid XHTML 1.0 Strict