Print this page
XXXX adding PID information to netstat output


  60 #include <sys/debug.h>
  61 #include <sys/strredir.h>
  62 #include <sys/fs/fifonode.h>
  63 #include <sys/fs/snode.h>
  64 #include <sys/strlog.h>
  65 #include <sys/strsun.h>
  66 #include <sys/project.h>
  67 #include <sys/kbio.h>
  68 #include <sys/msio.h>
  69 #include <sys/tty.h>
  70 #include <sys/ptyvar.h>
  71 #include <sys/vuid_event.h>
  72 #include <sys/modctl.h>
  73 #include <sys/sunddi.h>
  74 #include <sys/sunldi_impl.h>
  75 #include <sys/autoconf.h>
  76 #include <sys/policy.h>
  77 #include <sys/dld.h>
  78 #include <sys/zone.h>
  79 #include <c2/audit.h>

  80 
  81 /*
  82  * This define helps improve the readability of streams code while
  83  * still maintaining a very old streams performance enhancement.  The
  84  * performance enhancement basically involved having all callers
  85  * of straccess() perform the first check that straccess() will do
  86  * locally before actually calling straccess().  (There by reducing
  87  * the number of unnecessary calls to straccess().)
  88  */
  89 #define i_straccess(x, y)       ((stp->sd_sidp == NULL) ? 0 : \
  90                                     (stp->sd_vnode->v_type == VFIFO) ? 0 : \
  91                                     straccess((x), (y)))
  92 
  93 /*
  94  * what is mblk_pull_len?
  95  *
  96  * If a streams message consists of many short messages,
  97  * a performance degradation occurs from copyout overhead.
  98  * To decrease the per mblk overhead, messages that are
  99  * likely to consist of many small mblks are pulled up into


5665                 return (strcopyout(&pgrp, (void *)arg, sizeof (pid_t),
5666                     copyflag));
5667         }
5668 
5669         case TIOCSCTTY:
5670         {
5671                 return (strctty(stp));
5672         }
5673 
5674         case TIOCNOTTY:
5675         {
5676                 /* freectty() always assumes curproc. */
5677                 if (freectty(B_FALSE) != 0)
5678                         return (0);
5679                 return (ENOTTY);
5680         }
5681 
5682         case FIONBIO:
5683         case FIOASYNC:
5684                 return (0);     /* handled by the upper layer */












5685         }
5686 }
5687 
5688 /*
5689  * Custom free routine used for M_PASSFP messages.
5690  */
5691 static void
5692 free_passfp(struct k_strrecvfd *srf)
5693 {
5694         (void) closef(srf->fp);
5695         kmem_free(srf, sizeof (struct k_strrecvfd) + sizeof (frtn_t));
5696 }
5697 
5698 /* ARGSUSED */
5699 int
5700 do_sendfp(struct stdata *stp, struct file *fp, struct cred *cr)
5701 {
5702         queue_t *qp, *nextqp;
5703         struct k_strrecvfd *srf;
5704         mblk_t *mp;




  60 #include <sys/debug.h>
  61 #include <sys/strredir.h>
  62 #include <sys/fs/fifonode.h>
  63 #include <sys/fs/snode.h>
  64 #include <sys/strlog.h>
  65 #include <sys/strsun.h>
  66 #include <sys/project.h>
  67 #include <sys/kbio.h>
  68 #include <sys/msio.h>
  69 #include <sys/tty.h>
  70 #include <sys/ptyvar.h>
  71 #include <sys/vuid_event.h>
  72 #include <sys/modctl.h>
  73 #include <sys/sunddi.h>
  74 #include <sys/sunldi_impl.h>
  75 #include <sys/autoconf.h>
  76 #include <sys/policy.h>
  77 #include <sys/dld.h>
  78 #include <sys/zone.h>
  79 #include <c2/audit.h>
  80 #include <sys/fcntl.h>
  81 
  82 /*
  83  * This define helps improve the readability of streams code while
  84  * still maintaining a very old streams performance enhancement.  The
  85  * performance enhancement basically involved having all callers
  86  * of straccess() perform the first check that straccess() will do
  87  * locally before actually calling straccess().  (There by reducing
  88  * the number of unnecessary calls to straccess().)
  89  */
  90 #define i_straccess(x, y)       ((stp->sd_sidp == NULL) ? 0 : \
  91                                     (stp->sd_vnode->v_type == VFIFO) ? 0 : \
  92                                     straccess((x), (y)))
  93 
  94 /*
  95  * what is mblk_pull_len?
  96  *
  97  * If a streams message consists of many short messages,
  98  * a performance degradation occurs from copyout overhead.
  99  * To decrease the per mblk overhead, messages that are
 100  * likely to consist of many small mblks are pulled up into


5666                 return (strcopyout(&pgrp, (void *)arg, sizeof (pid_t),
5667                     copyflag));
5668         }
5669 
5670         case TIOCSCTTY:
5671         {
5672                 return (strctty(stp));
5673         }
5674 
5675         case TIOCNOTTY:
5676         {
5677                 /* freectty() always assumes curproc. */
5678                 if (freectty(B_FALSE) != 0)
5679                         return (0);
5680                 return (ENOTTY);
5681         }
5682 
5683         case FIONBIO:
5684         case FIOASYNC:
5685                 return (0);     /* handled by the upper layer */
5686         case F_FORKED: {
5687                 if (crp != kcred)
5688                         return (-1);
5689                 sh_insert_pid(stp, (proc_t *)arg);
5690                 return (0);
5691         }
5692         case F_CLOSED: {
5693                 if (crp != kcred)
5694                         return (-1);
5695                 sh_remove_pid(stp, (proc_t *)arg);
5696                 return (0);
5697         }
5698         }
5699 }
5700 
5701 /*
5702  * Custom free routine used for M_PASSFP messages.
5703  */
5704 static void
5705 free_passfp(struct k_strrecvfd *srf)
5706 {
5707         (void) closef(srf->fp);
5708         kmem_free(srf, sizeof (struct k_strrecvfd) + sizeof (frtn_t));
5709 }
5710 
5711 /* ARGSUSED */
5712 int
5713 do_sendfp(struct stdata *stp, struct file *fp, struct cred *cr)
5714 {
5715         queue_t *qp, *nextqp;
5716         struct k_strrecvfd *srf;
5717         mblk_t *mp;