tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: pty(4) doco fix



        Hello David.  If your supposition is correct, it looks to me like
things should behave the way you expect under NetBSD-4 and NetBSD-5.  The
The line:
pti->pt_send = 0;
is not there under NetBSD-5 or NetBSD-4.
Have you tried your test there?
-Brian

On Sep 2, 12:06pm, David Young wrote:
} Subject: Re: pty(4) doco fix
} On Thu, Sep 02, 2010 at 11:40:18AM -0500, David Young wrote:
} > I'm trying to use TIOCPKT_IOCTL, which is described in pty(4).  I had
} > to use an undocumented ioctl, TIOCEXT, to get it to work, and it worked
} > differently than the manual page said it would.  I've attached a patch
} > for the manual page, and the new manual page, for review.
} > 
} > All uses of TIOCPKT_IOCTL in the kernel should be reviewed.  ISTR that
} > the way it's used in sysinst doesn't accord with the documentation, old
} > or new.
} 
} I still think that the TIOCEXT doco fix is correct, but the reason
} that TIOCPKT_IOCTL works differently than I expected *seems* to be a
} regression in ptcread().  In NetBSD, we have this:
} 
}                 if (ISSET(tp->t_state, TS_ISOPEN)) {
}                         if (pti->pt_flags & PF_PKT && (c = pti->pt_send)) {
}                                 pti->pt_send = 0;
}                                 mutex_spin_exit(&tty_lock);
}                                 error = ureadc(c, uio);
}                                 if (error)
}                                         return (error);
}                                 /*
}                                  * Since we don't have the tty locked, there's
}                                  * a risk of messing up `t_termios'. This is
}                                  * relevant only if the tty got closed and 
then
}                                  * opened again while we were out uiomoving.
}                                  */
}                                 if (pti->pt_send & TIOCPKT_IOCTL) {
}                                         cc = min(uio->uio_resid,
}                                                 sizeof(tp->t_termios));
}                                         uiomove((void *) &tp->t_termios,
}                                                 cc, uio);
}                                 }
}                                 return (0);
}                         }
} 
} pti->pt_send is set to 0 before the test for TIOCPKT_IOCTL, so ptcread()
} never writes a termios structure.  I guess that we could test 'c' for
} TIOCPKT_IOCTL, instead.
} 
} I compared with the code in FreeBSD.  Their manual page doesn't describe
} TIOCPKT_IOCTL, but it looks their pty(4) behaves the way our manual says
} ours should:
} 
}                 if (tp->t_state&TS_ISOPEN) {
}                         if (pt->pt_flags&PF_PKT && pt->pt_send) {
}                                 error = ureadc((int)pt->pt_send, uio);
}                                 if (error)
}                                         return (error);
}                                 if (pt->pt_send & TIOCPKT_IOCTL) {
}                                         cc = min(uio->uio_resid,
}                                                 sizeof(tp->t_termios));
}                                         uiomove(&tp->t_termios, cc, uio);
}                                 }
}                                 pt->pt_send = 0;
}                                 return (0);
}                         }
} 
} Dave
} 
} -- 
} David Young             OJC Technologies
} dyoung%ojctech.com@localhost      Urbana, IL * (217) 278-3933
>-- End of excerpt from David Young




Home | Main Index | Thread Index | Old Index