linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [WTF?] extremely old dead code
@ 2018-09-10 23:55 Al Viro
  2018-09-12  2:32 ` Linus Torvalds
  0 siblings, 1 reply; 2+ messages in thread
From: Al Viro @ 2018-09-10 23:55 UTC (permalink / raw)
  To: linux-kernel; +Cc: Linus Torvalds

	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;
                        else
wasn'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"...

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [WTF?] extremely old dead code
  2018-09-10 23:55 [WTF?] extremely old dead code Al Viro
@ 2018-09-12  2:32 ` Linus Torvalds
  0 siblings, 0 replies; 2+ messages in thread
From: Linus Torvalds @ 2018-09-12  2:32 UTC (permalink / raw)
  To: Al Viro; +Cc: Linux Kernel Mailing List

On Mon, Sep 10, 2018 at 1:55 PM Al Viro <viro@zeniv.linux.org.uk> wrote:
>
> 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-09-12  2:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-10 23:55 [WTF?] extremely old dead code Al Viro
2018-09-12  2:32 ` Linus Torvalds

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).