Print this page
14249 pseudo-terminal nomenclature should reflect POSIX
Change-Id: Ib4a3cef899ff4c71b09cb0dc6878863c5e8357bc

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/dev/sdev_ptsops.c
          +++ new/usr/src/uts/common/fs/dev/sdev_ptsops.c
↓ open down ↓ 89 lines elided ↑ open up ↑
  90   90  }
  91   91  
  92   92  /*
  93   93   * Check if a pts sdev_node is still valid - i.e. it represents a current pty.
  94   94   * This serves two purposes
  95   95   *      - only valid pts nodes are returned during lookup() and readdir().
  96   96   *      - since pts sdev_nodes are not actively destroyed when a pty goes
  97   97   *        away, we use the validator to do deferred cleanup i.e. when such
  98   98   *        nodes are encountered during subsequent lookup() and readdir().
  99   99   */
 100      -/*ARGSUSED*/
 101  100  int
 102  101  devpts_validate(struct sdev_node *dv)
 103  102  {
 104  103          minor_t min;
 105  104          uid_t uid;
 106  105          gid_t gid;
 107  106          timestruc_t now;
 108  107          char *nm = dv->sdev_name;
 109  108  
 110  109          ASSERT(dv->sdev_state == SDEV_READY);
↓ open down ↓ 6 lines elided ↑ open up ↑
 117  116          }
 118  117  
 119  118          if (devpts_strtol(nm, &min) != 0) {
 120  119                  sdcmn_err7(("devpts_validate: not a valid minor: %s\n", nm));
 121  120                  return (SDEV_VTOR_INVALID);
 122  121          }
 123  122  
 124  123          /*
 125  124           * Check if pts driver is attached
 126  125           */
 127      -        if (ptms_slave_attached() == (major_t)-1) {
 128      -                sdcmn_err7(("devpts_validate: slave not attached\n"));
      126 +        if (ptms_subsidiary_attached() == (major_t)-1) {
      127 +                sdcmn_err7(("devpts_validate: subsidiary not attached\n"));
 129  128                  return (SDEV_VTOR_INVALID);
 130  129          }
 131  130  
 132  131          if (ptms_minor_valid(min, &uid, &gid) == 0) {
 133  132                  if (ptms_minor_exists(min)) {
 134  133                          sdcmn_err7(("devpts_validate: valid in different zone "
 135  134                              "%s\n", nm));
 136  135                          return (SDEV_VTOR_SKIP);
 137  136                  } else {
 138  137                          sdcmn_err7(("devpts_validate: %s not valid pty\n",
↓ open down ↓ 13 lines elided ↑ open up ↑
 152  151                  sdcmn_err7(("devpts_validate: update uid/gid/times%s\n", nm));
 153  152          }
 154  153  
 155  154          return (SDEV_VTOR_VALID);
 156  155  }
 157  156  
 158  157  /*
 159  158   * This callback is invoked from devname_lookup_func() to create
 160  159   * a pts entry when the node is not found in the cache.
 161  160   */
 162      -/*ARGSUSED*/
 163  161  static int
 164  162  devpts_create_rvp(struct sdev_node *ddv, char *nm,
 165  163      void **arg, cred_t *cred, void *whatever, char *whichever)
 166  164  {
 167  165          minor_t min;
 168  166          major_t maj;
 169  167          uid_t uid;
 170  168          gid_t gid;
 171  169          timestruc_t now;
 172  170          struct vattr *vap = (struct vattr *)arg;
 173  171  
 174  172          if (devpts_strtol(nm, &min) != 0) {
 175  173                  sdcmn_err7(("devpts_create_rvp: not a valid minor: %s\n", nm));
 176  174                  return (-1);
 177  175          }
 178  176  
 179  177          /*
 180      -         * Check if pts driver is attached and if it is
 181      -         * get the major number.
      178 +         * Check if pts driver is attached and if it is get the major number.
 182  179           */
 183      -        maj = ptms_slave_attached();
      180 +        maj = ptms_subsidiary_attached();
 184  181          if (maj == (major_t)-1) {
 185      -                sdcmn_err7(("devpts_create_rvp: slave not attached\n"));
      182 +                sdcmn_err7(("devpts_create_rvp: subsidiary not attached\n"));
 186  183                  return (-1);
 187  184          }
 188  185  
 189  186          /*
 190  187           * Only allow creation of ptys allocated to our zone
 191  188           */
 192  189          if (!ptms_minor_valid(min, &uid, &gid)) {
 193  190                  sdcmn_err7(("devpts_create_rvp: %s not valid pty"
 194  191                      "or not valid in this zone\n", nm));
 195  192                  return (-1);
↓ open down ↓ 83 lines elided ↑ open up ↑
 279  276   * sdev_nodes currently don't have a realvp. If a realvp is ever
 280  277   * created for sdev_nodes, then VOP_REALVP() will return the
 281  278   * actual realvp (possibly a ufs vnode). This will defeat the check
 282  279   * in namefs code which checks if VOP_REALVP() returns a devpts
 283  280   * node. We add an ASSERT here in /dev/pts lookup() to check for
 284  281   * this condition. If sdev_nodes ever get a VOP_REALVP() entry point,
 285  282   * change the code in the namefs filesystem code (in nm_mount()) to
 286  283   * access the realvp of the specfs node directly instead of using
 287  284   * VOP_REALVP().
 288  285   */
 289      -/*ARGSUSED3*/
 290  286  static int
 291  287  devpts_lookup(struct vnode *dvp, char *nm, struct vnode **vpp,
 292  288      struct pathname *pnp, int flags, struct vnode *rdir, struct cred *cred,
 293  289      caller_context_t *ct, int *direntflags, pathname_t *realpnp)
 294  290  {
 295  291          struct sdev_node *sdvp = VTOSDEV(dvp);
 296  292          struct sdev_node *dv;
 297  293          struct vnode *rvp = NULL;
 298  294          int error;
 299  295  
↓ open down ↓ 19 lines elided ↑ open up ↑
 319  315  
 320  316          return (error);
 321  317  }
 322  318  
 323  319  /*
 324  320   * We allow create to find existing nodes
 325  321   *      - if the node doesn't exist - EROFS
 326  322   *      - creating an existing dir read-only succeeds, otherwise EISDIR
 327  323   *      - exclusive creates fail - EEXIST
 328  324   */
 329      -/*ARGSUSED2*/
 330  325  static int
 331  326  devpts_create(struct vnode *dvp, char *nm, struct vattr *vap, vcexcl_t excl,
 332  327      int mode, struct vnode **vpp, struct cred *cred, int flag,
 333  328      caller_context_t *ct, vsecattr_t *vsecp)
 334  329  {
 335  330          int error;
 336  331          struct vnode *vp;
 337  332  
 338  333          *vpp = NULL;
 339  334  
↓ open down ↓ 12 lines elided ↑ open up ↑
 352  347                  } else
 353  348                          *vpp = vp;
 354  349          } else if (error == ENOENT) {
 355  350                  error = EROFS;
 356  351          }
 357  352  
 358  353          return (error);
 359  354  }
 360  355  
 361  356  /*
 362      - * Display all instantiated pts (slave) device nodes.
 363      - * A /dev/pts entry will be created only after the first lookup of the slave
 364      - * device succeeds.
      357 + * Display all instantiated pts (subsidiary) device nodes.
      358 + * A /dev/pts entry will be created only after the first lookup of the
      359 + * subsidiary device succeeds.
 365  360   */
 366      -/*ARGSUSED4*/
 367  361  static int
 368  362  devpts_readdir(struct vnode *dvp, struct uio *uiop, struct cred *cred,
 369  363      int *eofp, caller_context_t *ct, int flags)
 370  364  {
 371  365          struct sdev_node *sdvp = VTOSDEV(dvp);
 372  366          if (uiop->uio_offset == 0) {
 373  367                  devpts_prunedir(sdvp);
 374  368          }
 375  369  
 376  370          return (devname_readdir_func(dvp, uiop, cred, eofp, 0));
↓ open down ↓ 3 lines elided ↑ open up ↑
 380  374  static int
 381  375  devpts_set_id(struct sdev_node *dv, struct vattr *vap, int protocol)
 382  376  {
 383  377          ASSERT((protocol & AT_UID) || (protocol & AT_GID));
 384  378          ptms_set_owner(getminor(SDEVTOV(dv)->v_rdev),
 385  379              vap->va_uid, vap->va_gid);
 386  380          return (0);
 387  381  
 388  382  }
 389  383  
 390      -/*ARGSUSED4*/
 391  384  static int
 392  385  devpts_setattr(struct vnode *vp, struct vattr *vap, int flags,
 393  386      struct cred *cred, caller_context_t *ctp)
 394  387  {
 395  388          ASSERT((vp->v_type == VCHR) || (vp->v_type == VDIR));
 396  389          return (devname_setattr_func(vp, vap, flags, cred,
 397  390              devpts_set_id, AT_UID|AT_GID));
 398  391  }
 399  392  
 400  393  
↓ open down ↓ 17 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX