Print this page
XXXX adding PID information to netstat output

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/sockfs/sockcommon_vnops.c
          +++ new/usr/src/uts/common/fs/sockfs/sockcommon_vnops.c
↓ open down ↓ 115 lines elided ↑ open up ↑
 116  116      caller_context_t *ct)
 117  117  {
 118  118          struct vnode *vp = *vpp;
 119  119          struct sonode *so = VTOSO(vp);
 120  120  
 121  121          flag &= ~FCREAT;                /* paranoia */
 122  122          mutex_enter(&so->so_lock);
 123  123          so->so_count++;
 124  124          mutex_exit(&so->so_lock);
 125  125  
      126 +        if (!(curproc->p_flag & SSYS))
      127 +                sonode_insert_pid(so, curproc->p_pidp->pid_id);
      128 +
 126  129          ASSERT(so->so_count != 0);      /* wraparound */
 127  130          ASSERT(vp->v_type == VSOCK);
 128  131  
 129  132          return (0);
 130  133  }
 131  134  
 132  135  /*ARGSUSED*/
 133  136  static int
 134  137  socket_vop_close(struct vnode *vp, int flag, int count, offset_t offset,
 135  138      struct cred *cr, caller_context_t *ct)
↓ open down ↓ 65 lines elided ↑ open up ↑
 201  204  }
 202  205  
 203  206  /*ARGSUSED4*/
 204  207  static int
 205  208  socket_vop_ioctl(struct vnode *vp, int cmd, intptr_t arg, int mode,
 206  209      struct cred *cr, int32_t *rvalp, caller_context_t *ct)
 207  210  {
 208  211          struct sonode *so = VTOSO(vp);
 209  212  
 210  213          ASSERT(vp->v_type == VSOCK);
      214 +
      215 +        switch (cmd) {
      216 +        case F_ASSOCI_PID:
      217 +                if (cr != kcred)
      218 +                        return (EPERM);
      219 +                if (!(curproc->p_flag & SSYS))
      220 +                        sonode_insert_pid(so, (pid_t)arg);
      221 +                return (0);
      222 +
      223 +        case F_DASSOC_PID:
      224 +                if (cr != kcred)
      225 +                        return (EPERM);
      226 +                if (!(curproc->p_flag & SSYS))
      227 +                        sonode_remove_pid(so, (pid_t)arg);
      228 +                return (0);
      229 +        }
 211  230  
 212  231          return (socket_ioctl(so, cmd, arg, mode, cr, rvalp));
 213  232  }
 214  233  
 215  234  /*
 216  235   * Allow any flags. Record FNDELAY and FNONBLOCK so that they can be inherited
 217  236   * from listener to acceptor.
 218  237   */
 219  238  /* ARGSUSED */
 220  239  static int
↓ open down ↓ 262 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX