Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 04 Feb 2008 15:51:30 +0300
From:      Andrew Kolchoogin <andrew@rinet.ru>
To:        stable@freebsd.org
Subject:   Re: /dev/cuad0: Device busy
Message-ID:  <1202129490.2261.15.camel@akela>
In-Reply-To: <200802041204.m14C4lTO074894@drugs.dv.isc.org>
References:  <200802041204.m14C4lTO074894@drugs.dv.isc.org>

next in thread | previous in thread | raw e-mail | index | archive | help
> > > Personally, I never understood the concept of "dial-in" and "call-out"
> > > devices on FreeBSD.  I ran BBS software for years on both Apple II
> > > hardware and PC hardware; there was no distinction between such devices.
> > > A serial port is a serial port.  Chances are I'm not understanding why
> > > there's a distinction, but there doesn't appear to be any explanation of
> > > why there's a distinction within manpages or the handbook...
> > The distinction exists to allow an application to wait on the "dial-in"
> > port for incoming calls and another application to make outgoing call
> > mean time using the same port as "call-out" while the port is idle.
> And once there is a incoming call block out going calls until
> the incoming call completes.
    And for now one must forget existance of such devices and
use /dev/ttyd* for both incoming and outgoing calls.

    Long history is the following: terminal devices under UNIX have
changed its semantics quite a long time ago. Historically, there are a
pair of devices, one was for dial-in, and another -- for dial-out. This
absurd was created because of absence of non-blocking open()'s --
O_NONBLOCK simply doesn't work for open()'s of devices. As such,
historical getty implementation opens port in blocking mode and blocks
until carrier is detected on terminal line. Kernel doesn't allow
multiple simultaneous opens of /dev/tty* in blocking mode to prevent
multiple applications from accessing serial port simultaneously -- as
such, if we want to make outgoing call, we ought to have 'some another'
device physically attached to the same serial port, so, /dev/cua* exist.

    For now, there are virtually no software that relates on this
behaviour -- POSIX tty locking semantics mandate us to check lock files
in well-known system-wide directory -- /var/spool/lock in FreeBSD.
Kernel allows opens of /dev/tty* in non-blocking mode many times, as
such, no special 'dial-out' device needs to make outgoing call.

    It is clear that _all_ applications communicating with serial port
use one semantics -- historical UNIX or POSIX. One can not use
system /usr/libexec/getty with POSIX-compatible software because it
opens /dev/tty* in blocking mode. Use comms/mgetty+sendfax mgetty
instead -- to be precise, mgetty also can be used with UNIX tty
semantics (see description of configuration keyword "blocking"), but
just don't do it. ;)
-- 
    Andrew Kolchoogin.





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1202129490.2261.15.camel>