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


 193         bzero((void *)&lmsg, sizeof (lmsg));
 194 
 195         if (!(so->so_mode & SM_BYTESTREAM)) {
 196                 /*
 197                  * If the socket is not byte stream set MSG_EOR
 198                  */
 199                 lmsg.msg_flags = MSG_EOR;
 200         }
 201 
 202         return (socket_sendmsg(so, &lmsg, uiop, cr));
 203 }
 204 
 205 /*ARGSUSED4*/
 206 static int
 207 socket_vop_ioctl(struct vnode *vp, int cmd, intptr_t arg, int mode,
 208     struct cred *cr, int32_t *rvalp, caller_context_t *ct)
 209 {
 210         struct sonode *so = VTOSO(vp);
 211 
 212         ASSERT(vp->v_type == VSOCK);
 213 
 214         switch (cmd) {
 215                 case F_FORKED: {
 216                         if (cr != kcred)
 217                                 return (-1);
 218                         sonode_insert_pid(so, (proc_t *)arg);
 219                         return (0);
 220                 }
 221 
 222                 case F_CLOSED: {
 223                         if (cr != kcred)
 224                                 return (-1);
 225                         sonode_remove_pid(so, (proc_t *)arg);
 226                         return (0);
 227                 }
 228         }
 229 
 230         return (socket_ioctl(so, cmd, arg, mode, cr, rvalp));
 231 }
 232 
 233 /*
 234  * Allow any flags. Record FNDELAY and FNONBLOCK so that they can be inherited
 235  * from listener to acceptor.
 236  */
 237 /* ARGSUSED */
 238 static int
 239 socket_vop_setfl(vnode_t *vp, int oflags, int nflags, cred_t *cr,
 240     caller_context_t *ct)
 241 {
 242         struct sonode *so = VTOSO(vp);
 243         int error = 0;
 244 
 245         ASSERT(vp->v_type == VSOCK);
 246 
 247         mutex_enter(&so->so_lock);
 248         if (nflags & FNDELAY)