Bug 83265 - TIOCMIWAIT semantics changed in 2.4.18-19.7
TIOCMIWAIT semantics changed in 2.4.18-19.7
Product: Red Hat Linux
Classification: Retired
Component: kernel (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Arjan van de Ven
Brian Brock
Depends On:
  Show dependency treegraph
Reported: 2003-01-31 23:21 EST by David J. Schwartz
Modified: 2007-04-18 12:50 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2003-02-01 17:03:49 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description David J. Schwartz 2003-01-31 23:21:49 EST
Description of problem:

The semantics of the TIOCMIWAIT IOCTL seem to differ between 2.4.18-19.7 and
previous kernel versions. An incompatible API change is inappropriate between
minor kernel version changes.

The previous semantics of TIOCMIWAIT were:
int ret;
int events;
int fd;
ret=ioctl(fd, TIOCMIWAIT, &events);

The new semantics are:
ret=tioctl(fd, TIOCMIWAIT, events);

While the new semantics are, arguably, more logical, all code that uses
TIOCMIWAIT is broken by this change. There doesn't seem to be any reasonable way
to probe for this change, so code that uses TIOCMIWAIT has to be built for one
kernel version or the other.

This change is of too great a scope to make between minor kernel revisions and
was probably made by accident.

Version-Release number of selected component (if applicable):


How reproducible:

100% reproducible.

Steps to Reproduce:
1. Compile any program that uses TIOCMIWAIT
2. Try it on both old and new kernels
3. Compare results
Actual results:

TIOCMIWAIT works if you pass an address as the last parameter in new kernels and
if you pass the value as the last parameter in older kernels.

Expected results:

They should be the same, this is too great a change to make between minor kernel

Additional info:

I'm curious if this change was an error and the old semantics are supposed to be
there, or if it's a semantics change that was made deliberately and included in
the minor update by mistake, or if it was a change deliberately made between
minor kernel releases.
Comment 1 Alan Cox 2003-02-01 06:50:11 EST
TIOCMWAIT has always taken "event" not &event. Is it possible that your code
worked before
because event sat at an address that had the right bits set to make it
apparently work ?
Comment 2 David J. Schwartz 2003-02-01 14:57:26 EST
I suppose that's possible, but there's two reasons I don't think it's likely. 
First, several programs of mine that worked on the old kernel now don't work 
and do work with this change. It's hard to imagine how a kernel version change 
would affect the memory layout of the processes that way.

Second, I've found web references both ways.

I'm going to look at the source code for earlier kernels and look at the 
TIOCMIWAIT implementation. I'm fairly certain I'll find it takes a pointer to 
the flags in the earlier implementations.
Comment 3 David J. Schwartz 2003-02-01 15:00:16 EST
Sorry, that reference should be:
Comment 4 David J. Schwartz 2003-02-01 17:03:49 EST
I checked the kernel source and it seems that you're right. I guess some other 
change made the code that previously happened to work (because the address 
happened to have the 0x40 bit set in it) no longer work.

There doesn't appear to be any authoritative or even quasi-authoritative 
documentation for this ioctl and the examples I've found are split between the 
correct and incorrect form about 3 to 2 in favor of the correct format. I'll go 
with the majority, especially where the source agrees.

Thanks for the prompt response and sorry for the false alarm. I'm going to send 
off emails to others having reliability problems with TIOCMIWAIT that are 
probably due to their addresses not happening to have the right bits set.

Note You need to log in before you can comment on or make changes to this bug.