[Toybox] [PATCH] getty: ensure utmp is updated.

Ariadne Conill ariadne at dereferenced.org
Sat Aug 15 04:43:58 PDT 2020



On 2020-08-15 05:43, Rob Landley wrote:
> 
> 
> On 8/13/20 10:02 AM, Rob Landley wrote:
>> On 8/11/20 2:25 PM, enh via Toybox wrote:
>>> The key issues here turned out to be that getty is responsible for
>>> creating the file if it doesn't exist, and that the -H flag doesn't
>>> control whether utmp is updated, but whether or not to override the
>>> hostname within the utmp entry.
>>>
>>> While I'm here switch to the more modern utx APIs that all the non-pending
>>> parts of toybox use, and remove the duplication.
>>
>> Applied and pushed, but this reminds me I should really clean this up and
>> promote it.
>>
>> The reason I haven't is I don't really have a test environment for it? (This
>> waits for a modem to dial in to a serial port, adjusts the baud rate, and calls
>> login. I got my first broadband connection in 2001 and haven't owned a modem since.)
> 
> Do you have the FOGGIEST idea why:
> 
>      xopen_stdio(TT.tty_name, O_RDWR|O_NDELAY|O_CLOEXEC);
>      fcntl(0, F_SETFL, fcntl(0, F_GETFL) & ~O_NONBLOCK); // Block read
> 
> O_NDELAY == O_NONBLOCK so it opens the tty nonblock and then immediately
> switches off the nonblock. What (if anything) does that DO? Why is it here? Is
> this something BSD 2.x needed in 1983 because of certain defective ASR-33
> teletype variants when plugged into one of the HP minicomputers with the "zero
> and add packed" instruction?
> 
> The man page is unenlightening, and the kernel source has 373 _files_ with
> O_NONBLOCK in them...

In traditional SysV (with streams), O_NDELAY does not behave the same as 
O_NONBLOCK.

In SysV, O_NDELAY means that a read from a file descriptor that does not 
have any data (or a write which would extend the sendq length above the 
kernel watermark) would immediately return 0 and not set an errno.

BSD also added O_NDELAY, which sets errno to EWOULDBLOCK and returns -1. 
  POSIX standardized the BSD implementation, adding the O_NONBLOCK flag 
for it.

So, in SysV, this would give you a file descriptor that has "blocking" 
reads but where the program itself does the blocking.

Ariadne



More information about the Toybox mailing list