- type = ip->i_mode & IFMT;
- if (type == IFCHR) {
- ip->i_flag |= IUPD|ICHG;
- CHARGE(sc_tio * u.u_count);
- (*cdevsw[major(dev)].d_write)(dev);
+ switch (uio->uio_segflg) {
+
+ case 0:
+ if (subyte(iov->iov_base, c) < 0)
+ return (EFAULT);
+ break;
+
+ case 1:
+ *iov->iov_base = c;
+ break;
+
+ case 2:
+ if (suibyte(iov->iov_base, c) < 0)
+ return (EFAULT);
+ break;
+ }
+ iov->iov_base++;
+ iov->iov_len--;
+ uio->uio_resid--;
+ uio->uio_offset++;
+ return (0);
+}
+
+/*
+ * Get next character written in by user from uio.
+ */
+uwritec(uio)
+ struct uio *uio;
+{
+ register struct iovec *iov;
+ register int c;
+
+again:
+ if (uio->uio_iovcnt <= 0 || uio->uio_resid <= 0)
+ panic("uwritec");
+ iov = uio->uio_iov;
+ if (iov->iov_len == 0) {
+ uio->uio_iovcnt--;
+ uio->uio_iov++;
+ goto again;
+ }
+ switch (uio->uio_segflg) {
+
+ case 0:
+ c = fubyte(iov->iov_base);
+ break;
+
+ case 1:
+ c = *iov->iov_base & 0377;
+ break;
+
+ case 2:
+ c = fuibyte(iov->iov_base);
+ break;
+ }
+ if (c < 0)
+ return (-1);
+ iov->iov_base++;
+ iov->iov_len--;
+ uio->uio_resid--;
+ uio->uio_offset++;
+ return (c & 0377);
+}
+
+/*
+ * Ioctl system call
+ * Check legality, execute common code,
+ * and switch out to individual device routine.
+ */
+ioctl()
+{
+ register struct file *fp;
+ struct a {
+ int fdes;
+ int cmd;
+ caddr_t cmarg;
+ } *uap;
+ register int com;
+ register u_int size;
+ char data[IOCPARM_MASK+1];
+
+ uap = (struct a *)u.u_ap;
+ if ((fp = getf(uap->fdes)) == NULL)
+ return;
+ if ((fp->f_flag & (FREAD|FWRITE)) == 0) {
+ u.u_error = EBADF;