Kernel compatibility : ioctl(2)
RFC 4/11 Kernel compatibility : ioctl(2)
Continuing with syscalls, I would like to indicate you a modification I've done with regards to ioctl's. The thing is, I have had the need for ioctl's that return *file descriptors*, instead of standard return codes.
To distinguish them from the others, I have given them identifiers that are superior or equal to 0x80000000 (when unsigned, negative when signed). Of course, Linux will reject them, but that's fine, these are low-level OS-dependant ioctl's that aren't supposed to be compatible.
Do you have any objection or remark regarding this?
Thanks!
Emmanuel
Quoted 3 lines · On Tue, 15 Apr 2014 15:42:54 +0200 Emmanuel Colbus <[email protected]> wrote:
Continuing with syscalls, I would like to indicate you a modification I've done with regards to ioctl's. The thing is, I have had the need for ioctl's that return *file descriptors*, instead of standard return codes.
You probably only think you have ;-)
The return from an ioctl on 32bit is going to be an unsigned 32bit value, as is a Linux file handle. So if you do
fd = ioctl(foo);
then not only have you got an interface that isn't compliant with POSIX/SuS you also have no error reporting capability.
The expectation of ioctl is
err = ioctl(fd, FDIOWIBBLE, &result);
now if result is a pointer to where to store one or more file handles you are sorted.
If you are going to use SuS/POSIX naming I'd really suggest sticking to the expected behaviour in the standards.
Alan
Quoted 9 lines · One Thousand Gnomes
Quoted 3 lines · On Tue, 15 Apr 2014 15:42:54 +0200 Emmanuel Colbus <[email protected]> wrote:
Continuing with syscalls, I would like to indicate you a modification I've done with regards to ioctl's. The thing is, I have had the need for ioctl's that return *file descriptors*, instead of standard return codes.
You probably only think you have ;-)
Quoted 7 lines
The return from an ioctl on 32bit is going to be an unsigned 32bit value, as is a Linux file handle. So if you do
fd = ioctl(foo);then not only have you got an interface that isn't compliant with POSIX/SuS you also have no error reporting capability.
Wait, on 32 bits, no process can have 2^32 file handles, or even 2^31. Thus, since the error code is a negative value, userspace will simply do :
fd = _sys_ioctl(foo);
if (fd < 0)
errno = -fd;
Which the libc is going to do for them anyways if they call ioctl() directly.
Quoted 7 lines
The expectation of ioctl is
err = ioctl(fd, FDIOWIBBLE, &result);now if result is a pointer to where to store one or more file handles you are sorted.
Also feasible.
Quoted 3 lines
If you are going to use SuS/POSIX naming I'd really suggest sticking to the expected behaviour in the standards.
I think this is an unproblematic extension, especially since these ioctls are only supposed to be called by low-level software shipped with the OS.
Quoted 3 lines
Alan
Emmanuel
Quoted 3 lines
I think this is an unproblematic extension, especially since these ioctls are only supposed to be called by low-level software shipped with the OS.
Thats the excuse everyone gives for messing up standards stuff. It usually comes back to bite you later.
If it's not ioctl don't call it ioctl, have a fdoctl() or something
Alan
Quoted 11 lines · One Thousand Gnomes
Quoted 3 lines
I think this is an unproblematic extension, especially since these ioctls are only supposed to be called by low-level software shipped with the OS.
Thats the excuse everyone gives for messing up standards stuff. It usually comes back to bite you later.
If it's not ioctl don't call it ioctl, have a
fdoctl()or somethingAlan
I see your point... Well, this looks like the most staightforward approach then. I'll go with fdoctl().
Emmanuel