Print this page
XXXX adding PID information to netstat output


 106 };
 107 
 108 
 109 /*
 110  * generic vnode ops
 111  */
 112 
 113 /*ARGSUSED*/
 114 static int
 115 socket_vop_open(struct vnode **vpp, int flag, struct cred *cr,
 116     caller_context_t *ct)
 117 {
 118         struct vnode *vp = *vpp;
 119         struct sonode *so = VTOSO(vp);
 120 
 121         flag &= ~FCREAT;            /* paranoia */
 122         mutex_enter(&so->so_lock);
 123         so->so_count++;
 124         mutex_exit(&so->so_lock);
 125 



 126         ASSERT(so->so_count != 0);   /* wraparound */
 127         ASSERT(vp->v_type == VSOCK);
 128 
 129         return (0);
 130 }
 131 
 132 /*ARGSUSED*/
 133 static int
 134 socket_vop_close(struct vnode *vp, int flag, int count, offset_t offset,
 135     struct cred *cr, caller_context_t *ct)
 136 {
 137         struct sonode *so;
 138         int error = 0;
 139 
 140         so = VTOSO(vp);
 141         ASSERT(vp->v_type == VSOCK);
 142 
 143         cleanlocks(vp, ttoproc(curthread)->p_pid, 0);
 144         cleanshares(vp, ttoproc(curthread)->p_pid);
 145 


 191         bzero((void *)&lmsg, sizeof (lmsg));
 192 
 193         if (!(so->so_mode & SM_BYTESTREAM)) {
 194                 /*
 195                  * If the socket is not byte stream set MSG_EOR
 196                  */
 197                 lmsg.msg_flags = MSG_EOR;
 198         }
 199 
 200         return (socket_sendmsg(so, &lmsg, uiop, cr));
 201 }
 202 
 203 /*ARGSUSED4*/
 204 static int
 205 socket_vop_ioctl(struct vnode *vp, int cmd, intptr_t arg, int mode,
 206     struct cred *cr, int32_t *rvalp, caller_context_t *ct)
 207 {
 208         struct sonode *so = VTOSO(vp);
 209 
 210         ASSERT(vp->v_type == VSOCK);
















 211 
 212         return (socket_ioctl(so, cmd, arg, mode, cr, rvalp));
 213 }
 214 
 215 /*
 216  * Allow any flags. Record FNDELAY and FNONBLOCK so that they can be inherited
 217  * from listener to acceptor.
 218  */
 219 /* ARGSUSED */
 220 static int
 221 socket_vop_setfl(vnode_t *vp, int oflags, int nflags, cred_t *cr,
 222     caller_context_t *ct)
 223 {
 224         struct sonode *so = VTOSO(vp);
 225         int error = 0;
 226 
 227         ASSERT(vp->v_type == VSOCK);
 228 
 229         mutex_enter(&so->so_lock);
 230         if (nflags & FNDELAY)




 106 };
 107 
 108 
 109 /*
 110  * generic vnode ops
 111  */
 112 
 113 /*ARGSUSED*/
 114 static int
 115 socket_vop_open(struct vnode **vpp, int flag, struct cred *cr,
 116     caller_context_t *ct)
 117 {
 118         struct vnode *vp = *vpp;
 119         struct sonode *so = VTOSO(vp);
 120 
 121         flag &= ~FCREAT;            /* paranoia */
 122         mutex_enter(&so->so_lock);
 123         so->so_count++;
 124         mutex_exit(&so->so_lock);
 125 
 126         if (!(curproc->p_flag & SSYS))
 127                 sonode_insert_pid(so, curproc->p_pidp->pid_id);
 128 
 129         ASSERT(so->so_count != 0);   /* wraparound */
 130         ASSERT(vp->v_type == VSOCK);
 131 
 132         return (0);
 133 }
 134 
 135 /*ARGSUSED*/
 136 static int
 137 socket_vop_close(struct vnode *vp, int flag, int count, offset_t offset,
 138     struct cred *cr, caller_context_t *ct)
 139 {
 140         struct sonode *so;
 141         int error = 0;
 142 
 143         so = VTOSO(vp);
 144         ASSERT(vp->v_type == VSOCK);
 145 
 146         cleanlocks(vp, ttoproc(curthread)->p_pid, 0);
 147         cleanshares(vp, ttoproc(curthread)->p_pid);
 148 


 194         bzero((void *)&lmsg, sizeof (lmsg));
 195 
 196         if (!(so->so_mode & SM_BYTESTREAM)) {
 197                 /*
 198                  * If the socket is not byte stream set MSG_EOR
 199                  */
 200                 lmsg.msg_flags = MSG_EOR;
 201         }
 202 
 203         return (socket_sendmsg(so, &lmsg, uiop, cr));
 204 }
 205 
 206 /*ARGSUSED4*/
 207 static int
 208 socket_vop_ioctl(struct vnode *vp, int cmd, intptr_t arg, int mode,
 209     struct cred *cr, int32_t *rvalp, caller_context_t *ct)
 210 {
 211         struct sonode *so = VTOSO(vp);
 212 
 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         }
 230 
 231         return (socket_ioctl(so, cmd, arg, mode, cr, rvalp));
 232 }
 233 
 234 /*
 235  * Allow any flags. Record FNDELAY and FNONBLOCK so that they can be inherited
 236  * from listener to acceptor.
 237  */
 238 /* ARGSUSED */
 239 static int
 240 socket_vop_setfl(vnode_t *vp, int oflags, int nflags, cred_t *cr,
 241     caller_context_t *ct)
 242 {
 243         struct sonode *so = VTOSO(vp);
 244         int error = 0;
 245 
 246         ASSERT(vp->v_type == VSOCK);
 247 
 248         mutex_enter(&so->so_lock);
 249         if (nflags & FNDELAY)