All of lore.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: linux-kernel@vger.kernel.org
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Subject: [WTF?] extremely old dead code
Date: Tue, 11 Sep 2018 00:55:50 +0100	[thread overview]
Message-ID: <20180910235550.GN19965@ZenIV.linux.org.uk> (raw)

	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"...

             reply	other threads:[~2018-09-10 23:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-10 23:55 Al Viro [this message]
2018-09-12  2:32 ` [WTF?] extremely old dead code Linus Torvalds

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180910235550.GN19965@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.