extremely old dead code
Folks, please tell me that I'm misreading the history
here...
0.97:
kernel/chr_dev/tty_ioctl.c:tty_ioctl():
+ case FIONBIO:
+ if (arg)
+ file->f_flags |= O_NONBLOCK;
+ else
+ file->f_flags &= ~O_NONBLOCK;
+ return 0;
0.98.2:
fs/ioctl.c:sys_ioctl():
+ case FIONBIO:
+ on = get_fs_long((unsigned long *) arg);
+ if (on)
+ filp->f_flags |= O_NONBLOCK;
+ else
+ filp->f_flags &= ~O_NONBLOCK;
+ return 0;
Note that the call of ->f_op->ioctl() is in default: in the same switch, i.e. unreachable with cmd == FIONBIO.
0.98.3:
kernel/chr_dev/tty_ioctl.c:tty_ioctl():
case FIONBIO:
+ arg = get_fs_long((unsigned long *) arg);
if (arg)
file->f_flags |= O_NONBLOCK;
elsewasn't that dead code by that point?
0.99.13k: kernel/chr_dev/tty_ioctl.c moves to drivers/char/tty_ioctl.c, tty_ioctl() essentially unchanged.
1.1.13: tty_ioctl() moves from drivers/char/tty_ioctl.c to drivers/char/tty_io.c, leaving some bits behind (as n_tty_ioctl()). FIONBIO handling is among the moved parts.
1.3.4: in tty_ioctl()
case FIONBIO:
- retval = verify_area(VERIFY_READ, (void *) arg, sizeof(long));
+ retval = verify_area(VERIFY_READ, (void *) arg, sizeof(int));
1.3.28: same change happens in sys_ioctl().
2.1.4: handling moved to helper (fionbio())
In 2006: Alan writes a nice description of fionbio() +/**
+ * fionbio - non blocking ioctl + * @file: file to set blocking value + * @p: user parameter + * + * Historical tty interfaces had a blocking control ioctl before + * the generic functionality existed. This piece of history is preserved + * in the expected tty API of posix OS's.
+ *
+ * Locking: none, the open fle handle ensures it won't go away.
+ */
"generic functionality" bit refers to fcntl(2) (F_SETFL)
In 2010: the whole thing is moved to drivers/tty/tty_io.c
Hadn't that sucker been dead code since 0.98.2? What am I missing here? Note that this thing had quite a few functionality changes over those years; had they even been tested?
Confused and hoping to be told "Al, you're an idiot, here's an obvious way for that thing to be reached"...
Quoted 4 lines · Al Viro
Hadn't that sucker been dead code since 0.98.2? What am I missing here? Note that this thing had quite a few functionality changes over those years; had they even been tested?
Looks about right to me. The only point that actually acts on FIONBIO is the fs/ioctl.c code.
Impressively, the dead tty code looks perfectly correct to me too, despite not ever being triggered.
Linus