Print this page
XXXX adding PID information to netstat output

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/os/fio.c
          +++ new/usr/src/uts/common/os/fio.c
↓ open down ↓ 830 lines elided ↑ open up ↑
 831  831          ASSERT(ufp->uf_refcnt > 0);
 832  832          if (--ufp->uf_refcnt == 0)
 833  833                  cv_broadcast(&ufp->uf_closing_cv);
 834  834          UF_EXIT(ufp);
 835  835  }
 836  836  
 837  837  /*
 838  838   * Duplicate all file descriptors across a fork.
 839  839   */
 840  840  void
 841      -flist_fork(uf_info_t *pfip, uf_info_t *cfip)
      841 +flist_fork(proc_t *pp, proc_t *cp)
 842  842  {
 843  843          int fd, nfiles;
 844  844          uf_entry_t *pufp, *cufp;
 845  845  
      846 +        uf_info_t *pfip = P_FINFO(pp);
      847 +        uf_info_t *cfip = P_FINFO(cp);
      848 +
 846  849          mutex_init(&cfip->fi_lock, NULL, MUTEX_DEFAULT, NULL);
 847  850          cfip->fi_rlist = NULL;
 848  851  
 849  852          /*
 850  853           * We don't need to hold fi_lock because all other lwp's in the
 851  854           * parent have been held.
 852  855           */
 853  856          cfip->fi_nfiles = nfiles = flist_minsize(pfip);
 854  857  
 855  858          cfip->fi_list = kmem_zalloc(nfiles * sizeof (uf_entry_t), KM_SLEEP);
 856  859  
 857  860          for (fd = 0, pufp = pfip->fi_list, cufp = cfip->fi_list; fd < nfiles;
 858  861              fd++, pufp++, cufp++) {
 859  862                  cufp->uf_file = pufp->uf_file;
 860  863                  cufp->uf_alloc = pufp->uf_alloc;
 861  864                  cufp->uf_flag = pufp->uf_flag;
 862  865                  cufp->uf_busy = pufp->uf_busy;
      866 +
      867 +                if (cufp->uf_file != NULL && cufp->uf_file->f_vnode != NULL) {
      868 +                        (void) VOP_IOCTL(cufp->uf_file->f_vnode, F_ASSOCI_PID,
      869 +                            (intptr_t)cp->p_pidp->pid_id, FKIOCTL, kcred,
      870 +                            NULL, NULL);
      871 +                }
      872 +
 863  873                  if (pufp->uf_file == NULL) {
 864  874                          ASSERT(pufp->uf_flag == 0);
 865  875                          if (pufp->uf_busy) {
 866  876                                  /*
 867  877                                   * Grab locks to appease ASSERTs in fd_reserve
 868  878                                   */
 869  879                                  mutex_enter(&cfip->fi_lock);
 870  880                                  mutex_enter(&cufp->uf_lock);
 871  881                                  fd_reserve(cfip, fd, -1);
 872  882                                  mutex_exit(&cufp->uf_lock);
↓ open down ↓ 65 lines elided ↑ open up ↑
 938  948  
 939  949          mutex_enter(&fp->f_tlock);
 940  950  
 941  951          ASSERT(fp->f_count > 0);
 942  952  
 943  953          count = fp->f_count--;
 944  954          flag = fp->f_flag;
 945  955          offset = fp->f_offset;
 946  956  
 947  957          vp = fp->f_vnode;
      958 +        if (vp != NULL) {
      959 +                (void) VOP_IOCTL(vp, F_DASSOC_PID,
      960 +                    (intptr_t)(ttoproc(curthread)->p_pidp->pid_id), FKIOCTL,
      961 +                    kcred, NULL, NULL);
      962 +        }
 948  963  
 949  964          error = VOP_CLOSE(vp, flag, count, offset, fp->f_cred, NULL);
 950  965  
 951  966          if (count > 1) {
 952  967                  mutex_exit(&fp->f_tlock);
 953  968                  return (error);
 954  969          }
 955  970          ASSERT(fp->f_count == 0);
 956  971          /* Last reference, remove any OFD style lock for the file_t */
 957  972          ofdcleanlock(fp);
↓ open down ↓ 871 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX