public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC][4/11][MANUX] Kernel compatibility : ioctl(2)
@ 2014-04-15 13:42 Emmanuel Colbus
  2014-04-15 15:00 ` One Thousand Gnomes
  0 siblings, 1 reply; 5+ messages in thread
From: Emmanuel Colbus @ 2014-04-15 13:42 UTC (permalink / raw)
  To: linux-kernel

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

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

* Re: [RFC][4/11][MANUX] Kernel compatibility : ioctl(2)
  2014-04-15 13:42 [RFC][4/11][MANUX] Kernel compatibility : ioctl(2) Emmanuel Colbus
@ 2014-04-15 15:00 ` One Thousand Gnomes
  2014-04-15 16:00   ` Emmanuel Colbus
  0 siblings, 1 reply; 5+ messages in thread
From: One Thousand Gnomes @ 2014-04-15 15:00 UTC (permalink / raw)
  To: Emmanuel Colbus; +Cc: linux-kernel

On Tue, 15 Apr 2014 15:42:54 +0200
Emmanuel Colbus <ecolbus@manux.info> 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

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

* Re: [RFC][4/11][MANUX] Kernel compatibility : ioctl(2)
  2014-04-15 15:00 ` One Thousand Gnomes
@ 2014-04-15 16:00   ` Emmanuel Colbus
  2014-04-15 16:05     ` One Thousand Gnomes
  0 siblings, 1 reply; 5+ messages in thread
From: Emmanuel Colbus @ 2014-04-15 16:00 UTC (permalink / raw)
  To: One Thousand Gnomes; +Cc: linux-kernel

Le 15/04/2014 17:00, One Thousand Gnomes a écrit :
> On Tue, 15 Apr 2014 15:42:54 +0200
> Emmanuel Colbus <ecolbus@manux.info> 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.

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.

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

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

> 
> Alan
> 

Emmanuel

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

* Re: [RFC][4/11][MANUX] Kernel compatibility : ioctl(2)
  2014-04-15 16:00   ` Emmanuel Colbus
@ 2014-04-15 16:05     ` One Thousand Gnomes
  2014-04-15 16:32       ` Emmanuel Colbus
  0 siblings, 1 reply; 5+ messages in thread
From: One Thousand Gnomes @ 2014-04-15 16:05 UTC (permalink / raw)
  To: Emmanuel Colbus; +Cc: linux-kernel

> 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

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

* Re: [RFC][4/11][MANUX] Kernel compatibility : ioctl(2)
  2014-04-15 16:05     ` One Thousand Gnomes
@ 2014-04-15 16:32       ` Emmanuel Colbus
  0 siblings, 0 replies; 5+ messages in thread
From: Emmanuel Colbus @ 2014-04-15 16:32 UTC (permalink / raw)
  To: One Thousand Gnomes; +Cc: linux-kernel

Le 15/04/2014 18:05, One Thousand Gnomes a écrit :
>> 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
> 

I see your point... Well, this looks like the most staightforward
approach then. I'll go with fdoctl().

Emmanuel

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

end of thread, other threads:[~2014-04-15 16:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-15 13:42 [RFC][4/11][MANUX] Kernel compatibility : ioctl(2) Emmanuel Colbus
2014-04-15 15:00 ` One Thousand Gnomes
2014-04-15 16:00   ` Emmanuel Colbus
2014-04-15 16:05     ` One Thousand Gnomes
2014-04-15 16:32       ` Emmanuel Colbus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox