Print this page
XXXX adding PID information to netstat output

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/syscall/fcntl.c
          +++ new/usr/src/uts/common/syscall/fcntl.c
↓ open down ↓ 170 lines elided ↑ open up ↑
 171  171                           */
 172  172                          mutex_enter(&fp->f_tlock);
 173  173                          fp->f_count--;
 174  174                          mutex_exit(&fp->f_tlock);
 175  175                          error = EMFILE;
 176  176                  } else {
 177  177                          if (cmd == F_DUPFD_CLOEXEC) {
 178  178                                  f_setfd(retval, FD_CLOEXEC);
 179  179                          }
 180  180                  }
      181 +
      182 +                if (error == 0 && fp->f_vnode != NULL) {
      183 +                        (void) VOP_IOCTL(fp->f_vnode, F_ASSOCI_PID,
      184 +                            (intptr_t)p->p_pidp->pid_id, FKIOCTL, kcred,
      185 +                            NULL, NULL);
      186 +                }
      187 +
 181  188                  goto done;
 182  189  
 183  190          case F_DUP2FD_CLOEXEC:
 184  191                  if (fdes == iarg) {
 185  192                          error = EINVAL;
 186  193                          goto done;
 187  194                  }
 188  195  
 189  196                  /*FALLTHROUGH*/
 190  197  
↓ open down ↓ 16 lines elided ↑ open up ↑
 207  214                           * (which we have to do anyway), then releasef(fdes),
 208  215                           * then closeandsetf().  Incrementing f_count ensures
 209  216                           * that fp won't disappear after we call releasef().
 210  217                           * When closeandsetf() fails, we try avoid calling
 211  218                           * closef() because of all the side effects.
 212  219                           */
 213  220                          mutex_enter(&fp->f_tlock);
 214  221                          fp->f_count++;
 215  222                          mutex_exit(&fp->f_tlock);
 216  223                          releasef(fdes);
      224 +
      225 +                        /* assume we have forked successfully */
      226 +                        if (fp->f_vnode != NULL) {
      227 +                                (void) VOP_IOCTL(fp->f_vnode, F_ASSOCI_PID,
      228 +                                    (intptr_t)p->p_pidp->pid_id, FKIOCTL,
      229 +                                    kcred, NULL, NULL);
      230 +                        }
      231 +
 217  232                          if ((error = closeandsetf(iarg, fp)) == 0) {
 218  233                                  if (cmd == F_DUP2FD_CLOEXEC) {
 219  234                                          f_setfd(iarg, FD_CLOEXEC);
 220  235                                  }
 221  236                                  retval = iarg;
 222  237                          } else {
 223  238                                  mutex_enter(&fp->f_tlock);
 224  239                                  if (fp->f_count > 1) {
 225  240                                          fp->f_count--;
 226  241                                          mutex_exit(&fp->f_tlock);
      242 +                                        if (fp->f_vnode != NULL) {
      243 +                                                (void) VOP_IOCTL(fp->f_vnode,
      244 +                                                    F_DASSOC_PID,
      245 +                                                    (intptr_t)p->p_pidp->pid_id,
      246 +                                                    FKIOCTL, kcred, NULL, NULL);
      247 +                                        }
      248 +
 227  249                                  } else {
 228  250                                          mutex_exit(&fp->f_tlock);
 229  251                                          (void) closef(fp);
 230  252                                  }
 231  253                          }
 232  254                          goto out;
 233  255                  }
 234  256                  goto done;
 235  257  
 236  258          case F_SETFL:
↓ open down ↓ 590 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX