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

Re: /dev/cua* and /dev/ttyS*



Richard Sharman wrote:
> 
> There have been various mailings here along the lines of
> /dev/cua* names are deprepcated in favour of /dev/ttyS*.
> 
> I was just wondering why the change (and when).  I thought it used to
> be that ttyS* was dial-in and cua* was dial-out (or possibly
> vice-versa).
> 
> I looked in /usr/src/linux/Documentation,  and the only reference
> I saw was in devices.txt which stated:
> 
>   4 char        TTY devices
> ...
>                  64 = /dev/ttyS0        First serial port
>                       ...
>                 127 = /dev/ttyS63       64th serial port
> 
>   5 char        Alternate TTY devices
> ...
>                  64 = /dev/cua0         Callout device corresponding to ttyS0
>                       ...
>                 127 = /dev/cua63        Callout device corresponding to ttyS63
> 
> I was just wondering,  what exactly has changed,  and why?

Let me sum it up for you. In the dark days of Unix, /dev/ttyXX
was used for dialin because an open("/dev/ttyXX") would block until
Carrier-Detect went high on the line. /dev/cuaXX was used for 
dialout because open("/dev/cuaXX") would open the device *without*
there being Carrier-Detect. This created a problem however because
locking on serial ports was accomplished by creating a file
in /var/lock of the form /var/lock/LCK..ttyS0. Since the locking
scheme relied (and does rely!) on the name of the device, there are
obvious problems with using two different device files for the same
device. The problem with blocking on open() is solved by passing
O_NONBLOCK as a flag. This is my understanding.

-- 
Jens B. Jorgensen
jjorgens@bdsinc.com


Reply to: