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