snp.c (148868) | snp.c (150298) |
---|---|
1/*- 2 * Copyright (c) 1995 Ugen J.S.Antsilevich 3 * 4 * Redistribution and use in source forms, with and without modification, 5 * are permitted provided that this entire comment appears intact. 6 * 7 * Redistribution in binary form may occur without any restrictions. 8 * Obviously, it would be nice if you gave credit where credit is due 9 * but requiring it would be too onerous. 10 * 11 * This software is provided ``AS IS'' without any warranties of any kind. 12 * 13 * Snoop stuff. 14 * 15 */ 16 17#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1995 Ugen J.S.Antsilevich 3 * 4 * Redistribution and use in source forms, with and without modification, 5 * are permitted provided that this entire comment appears intact. 6 * 7 * Redistribution in binary form may occur without any restrictions. 8 * Obviously, it would be nice if you gave credit where credit is due 9 * but requiring it would be too onerous. 10 * 11 * This software is provided ``AS IS'' without any warranties of any kind. 12 * 13 * Snoop stuff. 14 * 15 */ 16 17#include <sys/cdefs.h> |
18__FBSDID("$FreeBSD: head/sys/dev/snp/snp.c 148868 2005-08-08 19:55:32Z rwatson $"); | 18__FBSDID("$FreeBSD: head/sys/dev/snp/snp.c 150298 2005-09-18 19:23:35Z cognet $"); |
19 20#include <sys/param.h> 21#include <sys/systm.h> 22#include <sys/fcntl.h> 23#include <sys/filio.h> 24#include <sys/malloc.h> 25#include <sys/tty.h> 26#include <sys/conf.h> 27#include <sys/poll.h> 28#include <sys/kernel.h> 29#include <sys/module.h> 30#include <sys/queue.h> 31#include <sys/snoop.h> 32#include <sys/uio.h> | 19 20#include <sys/param.h> 21#include <sys/systm.h> 22#include <sys/fcntl.h> 23#include <sys/filio.h> 24#include <sys/malloc.h> 25#include <sys/tty.h> 26#include <sys/conf.h> 27#include <sys/poll.h> 28#include <sys/kernel.h> 29#include <sys/module.h> 30#include <sys/queue.h> 31#include <sys/snoop.h> 32#include <sys/uio.h> |
33#include <sys/file.h> 34#include <sys/vnode.h> |
|
33 34static l_close_t snplclose; 35static l_write_t snplwrite; 36static d_open_t snpopen; 37static d_close_t snpclose; 38static d_read_t snpread; 39static d_write_t snpwrite; 40static d_ioctl_t snpioctl; --- 472 unchanged lines hidden (view full) --- 513 u_long cmd; 514 caddr_t data; 515 int flags; 516 struct thread *td; 517{ 518 struct snoop *snp; 519 struct tty *tp, *tpo; 520 struct cdev *tdev; | 35 36static l_close_t snplclose; 37static l_write_t snplwrite; 38static d_open_t snpopen; 39static d_close_t snpclose; 40static d_read_t snpread; 41static d_write_t snpwrite; 42static d_ioctl_t snpioctl; --- 472 unchanged lines hidden (view full) --- 515 u_long cmd; 516 caddr_t data; 517 int flags; 518 struct thread *td; 519{ 520 struct snoop *snp; 521 struct tty *tp, *tpo; 522 struct cdev *tdev; |
523 struct file *fp; |
|
521 int s; 522 523 snp = dev->si_drv1; 524 switch (cmd) { 525 case SNPSTTY: | 524 int s; 525 526 snp = dev->si_drv1; 527 switch (cmd) { 528 case SNPSTTY: |
526#if 0 527 tdev = findcdev(*((dev_t *)data)); 528#else 529 tdev = NULL; 530#endif | 529 s = *(int *)data; 530 if (s < 0 || fget(td, s, &fp) != 0) 531 return (EINVAL); 532 if (fp->f_type != DTYPE_VNODE || 533 fp->f_vnode->v_type != VCHR) { 534 fdrop(fp, td); 535 return (EINVAL); 536 } 537 tdev = fp->f_vnode->v_rdev; 538 fdrop(fp, td); |
531 if (tdev == NULL) 532 return (snp_down(snp)); 533 534 tp = snpdevtotty(tdev); 535 if (!tp) 536 return (EINVAL); 537 if (tp->t_state & TS_SNOOP) 538 return (EBUSY); --- 41 unchanged lines hidden (view full) --- 580 break; 581 582 case FIONREAD: 583 s = spltty(); 584 if (snp->snp_tty != NULL) 585 *(int *)data = snp->snp_len; 586 else 587 if (snp->snp_flags & SNOOP_DOWN) { | 539 if (tdev == NULL) 540 return (snp_down(snp)); 541 542 tp = snpdevtotty(tdev); 543 if (!tp) 544 return (EINVAL); 545 if (tp->t_state & TS_SNOOP) 546 return (EBUSY); --- 41 unchanged lines hidden (view full) --- 588 break; 589 590 case FIONREAD: 591 s = spltty(); 592 if (snp->snp_tty != NULL) 593 *(int *)data = snp->snp_len; 594 else 595 if (snp->snp_flags & SNOOP_DOWN) { |
596 printf("IT IS DOWN\n"); |
|
588 if (snp->snp_flags & SNOOP_OFLOW) 589 *(int *)data = SNP_OFLOW; 590 else 591 *(int *)data = SNP_TTYCLOSE; 592 } else { 593 *(int *)data = SNP_DETACH; 594 } 595 splx(s); --- 92 unchanged lines hidden --- | 597 if (snp->snp_flags & SNOOP_OFLOW) 598 *(int *)data = SNP_OFLOW; 599 else 600 *(int *)data = SNP_TTYCLOSE; 601 } else { 602 *(int *)data = SNP_DETACH; 603 } 604 splx(s); --- 92 unchanged lines hidden --- |