linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Problem with ioctl command TCGETS
@ 2004-11-28  0:22 Ozan Eren Bilgen
  2004-11-28  0:39 ` Al Viro
  0 siblings, 1 reply; 28+ messages in thread
From: Ozan Eren Bilgen @ 2004-11-28  0:22 UTC (permalink / raw)
  To: Linux Kernel Maillist

--- Please CC me your responses ---


Hi,

While tracking KPPP and modem interaction, I experienced a problem with
TCGETS ioctl command, which is defined as constant number 0x5401 in
"include/asm/ioctls.h".  If you decode TCGETS, you will obtain:

	type: 'T'
 	direction: _IOC_NONE
	number: 1
	size: 0

but applications (like KPPP) cause indirectly that the modem descriptor
is ioctl'd by passing a string, as the example in
http://www.ussg.iu.edu/hypermail/linux/kernel/9904.0/0371.html shows: 

	fd = open("/dev/ttyS1", O_RDWR|O_NONBLOCK)
	fcntl(fd, F_GETFD)
	fcntl(fd, F_SETFD, FD_CLOEXEC)
	fcntl(fd, F_GETFL)
	ioctl(fd, TCGETS, {B9600 opost isig icanon echo ...}) = 0
	
CMIIW, TCGETS ioctl command should not interest with its argp, but
drivers/char/tty_ioctl.c does.

	case TCGETS:
		if (kernel_termios_to_user_termios((struct termios __user *)arg,
real_tty->termios))
			return -EFAULT;
		return 0;

I have a few questions:

1. Is it nice to break _IO macros?
2. If it has a historical reason, shall I forget to trust to the
informations that I decoded using _IO* macros?
3. Is there a list of such amazing commands?



Thanks in advance,
Ozan Eren BILGEN



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

* Re: Problem with ioctl command TCGETS
  2004-11-28  0:22 Problem with ioctl command TCGETS Ozan Eren Bilgen
@ 2004-11-28  0:39 ` Al Viro
  2004-11-28  9:59   ` Miklos Szeredi
  0 siblings, 1 reply; 28+ messages in thread
From: Al Viro @ 2004-11-28  0:39 UTC (permalink / raw)
  To: Ozan Eren Bilgen; +Cc: Linux Kernel Maillist

On Sun, Nov 28, 2004 at 02:22:51AM +0200, Ozan Eren Bilgen wrote:
> 1. Is it nice to break _IO macros?

There is nothing nice about ioctls.

> 2. If it has a historical reason, shall I forget to trust to the
> informations that I decoded using _IO* macros?

You should.

> 3. Is there a list of such amazing commands?

There isn't.

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

* Re: Problem with ioctl command TCGETS
  2004-11-28  0:39 ` Al Viro
@ 2004-11-28  9:59   ` Miklos Szeredi
  2004-11-28 10:08     ` Jan Engelhardt
  2004-11-28 10:28     ` Bernd Eckenfels
  0 siblings, 2 replies; 28+ messages in thread
From: Miklos Szeredi @ 2004-11-28  9:59 UTC (permalink / raw)
  To: viro; +Cc: oebilgen, linux-kernel


> > 1. Is it nice to break _IO macros?
> 
> There is nothing nice about ioctls.

On the subject of ioctls:  what about a replacement syscall:

 /** 
  * Getting and setting file parameters safely (ioctl done right)
  * 
  * @fd     file descriptor
  * @param  name of the parameter to get/set
  * @dir    direction flag indicating either get, set, or set-get
  * @value  value to set parameter to (set) or store current value into (get)
  * @size   size of value
  */
 int fparam(int fd, const char *param, int dir, void *value, size_t size);

I know it's been talked about in the past.  Is anyone interested?

Miklos


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

* Re: Problem with ioctl command TCGETS
  2004-11-28  9:59   ` Miklos Szeredi
@ 2004-11-28 10:08     ` Jan Engelhardt
  2004-11-28 10:18       ` Miklos Szeredi
  2004-11-28 10:28     ` Bernd Eckenfels
  1 sibling, 1 reply; 28+ messages in thread
From: Jan Engelhardt @ 2004-11-28 10:08 UTC (permalink / raw)
  To: Miklos Szeredi; +Cc: viro, oebilgen, linux-kernel

>On the subject of ioctls:  what about a replacement syscall:
>
> /**
>  * Getting and setting file parameters safely (ioctl done right)
>  *
>  * @fd     file descriptor
>  * @param  name of the parameter to get/set
>  * @dir    direction flag indicating either get, set, or set-get
>  * @value  value to set parameter to (set) or store current value into (get)
>  * @size   size of value
>  */
> int fparam(int fd, const char *param, int dir, void *value, size_t size);
>
>I know it's been talked about in the past.  Is anyone interested?

The idea is nice, yet the "dir" and "size" parameters in the original _IO*
macros are only there (IMO) to protect against using the wrong value for the
wrong operation on the wrong fd/file/device/socket/etc.

What is the point in making "param" a char*? You would need to parse it down
again.

Oh yeah and call it ioctl2(), sounds more cryptical :)



Jan Engelhardt
-- 
Gesellschaft für Wissenschaftliche Datenverarbeitung
Am Fassberg, 37077 Göttingen, www.gwdg.de

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

* Re: Problem with ioctl command TCGETS
  2004-11-28 10:08     ` Jan Engelhardt
@ 2004-11-28 10:18       ` Miklos Szeredi
  0 siblings, 0 replies; 28+ messages in thread
From: Miklos Szeredi @ 2004-11-28 10:18 UTC (permalink / raw)
  To: jengelh; +Cc: viro, oebilgen, linux-kernel

> The idea is nice, yet the "dir" and "size" parameters in the original _IO*
> macros are only there (IMO) to protect against using the wrong value for the
> wrong operation on the wrong fd/file/device/socket/etc.

Size and dir are there to make the memory passed to the syscall easily
verifiable (like read/write/getsockopt/setsockopt/etc)

> What is the point in making "param" a char*? You would need to parse it down
> again.

'char *' namespace is easier to manage than 'int' namespace.

> Oh yeah and call it ioctl2(), sounds more cryptical :)

Is that an advantage?

Thanks,
Miklos

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

* Re: Problem with ioctl command TCGETS
  2004-11-28  9:59   ` Miklos Szeredi
  2004-11-28 10:08     ` Jan Engelhardt
@ 2004-11-28 10:28     ` Bernd Eckenfels
  2004-11-28 10:56       ` Wichert Akkerman
  2004-11-28 11:22       ` Miklos Szeredi
  1 sibling, 2 replies; 28+ messages in thread
From: Bernd Eckenfels @ 2004-11-28 10:28 UTC (permalink / raw)
  To: linux-kernel

In article <E1CYLpf-0001VQ-00@dorka.pomaz.szeredi.hu> you wrote:
>  * @fd     file descriptor
>  * @param  name of the parameter to get/set
>  * @dir    direction flag indicating either get, set, or set-get
>  * @value  value to set parameter to (set) or store current value into (get)
>  * @size   size of value
>  */
> int fparam(int fd, const char *param, int dir, void *value, size_t size);
> 
> I know it's been talked about in the past.  Is anyone interested?

The set-get is supposed to be used for queries, too? The size of value is
only used for the get case to describe the buffer length in that case?
because otherwise the set-get case may require a short value in and a large
answer structure out.

The syscall should also allow cunking in response, unless we remove all
high-volumne answers from it.

Gruss
Bernd

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

* Re: Problem with ioctl command TCGETS
  2004-11-28 10:28     ` Bernd Eckenfels
@ 2004-11-28 10:56       ` Wichert Akkerman
  2004-11-28 11:52         ` Bernd Eckenfels
  2004-11-28 11:22       ` Miklos Szeredi
  1 sibling, 1 reply; 28+ messages in thread
From: Wichert Akkerman @ 2004-11-28 10:56 UTC (permalink / raw)
  To: linux-kernel

Previously Bernd Eckenfels wrote:
> The syscall should also allow cunking in response, unless we remove all
> high-volumne answers from it.

Are we reinventing netlink?

Wichert.

-- 
Wichert Akkerman <wichert@wiggy.net>    It is simple to make things.
http://www.wiggy.net/                   It is hard to make things simple.

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

* Re: Problem with ioctl command TCGETS
  2004-11-28 10:28     ` Bernd Eckenfels
  2004-11-28 10:56       ` Wichert Akkerman
@ 2004-11-28 11:22       ` Miklos Szeredi
  2004-11-28 12:18         ` Al Viro
  2004-11-28 12:23         ` Bernd Eckenfels
  1 sibling, 2 replies; 28+ messages in thread
From: Miklos Szeredi @ 2004-11-28 11:22 UTC (permalink / raw)
  To: ecki-news2004-05; +Cc: linux-kernel

> The set-get is supposed to be used for queries, too? The size of value is
> only used for the get case to describe the buffer length in that case?
> because otherwise the set-get case may require a short value in and a large
> answer structure out.

You misunderstand the motivation.  This is to get/set small compact
parameters, not huge structures or big data.  Think get/setsockopt().

Miklos

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

* Re: Problem with ioctl command TCGETS
  2004-11-28 10:56       ` Wichert Akkerman
@ 2004-11-28 11:52         ` Bernd Eckenfels
  0 siblings, 0 replies; 28+ messages in thread
From: Bernd Eckenfels @ 2004-11-28 11:52 UTC (permalink / raw)
  To: linux-kernel

In article <20041128105646.GD22793@wiggy.net> you wrote:
> Previously Bernd Eckenfels wrote:
>> The syscall should also allow cunking in response, unless we remove all
>> high-volumne answers from it.
> 
> Are we reinventing netlink?

Yes, meybe high volumne stuff via netlink and parameters via sysctl
interface. Hmm NETLINK on file FDs? :)

Greetings
Bernd

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

* Re: Problem with ioctl command TCGETS
  2004-11-28 11:22       ` Miklos Szeredi
@ 2004-11-28 12:18         ` Al Viro
  2004-11-28 12:32           ` Miklos Szeredi
                             ` (3 more replies)
  2004-11-28 12:23         ` Bernd Eckenfels
  1 sibling, 4 replies; 28+ messages in thread
From: Al Viro @ 2004-11-28 12:18 UTC (permalink / raw)
  To: Miklos Szeredi; +Cc: ecki-news2004-05, linux-kernel

On Sun, Nov 28, 2004 at 12:22:03PM +0100, Miklos Szeredi wrote:
> > The set-get is supposed to be used for queries, too? The size of value is
> > only used for the get case to describe the buffer length in that case?
> > because otherwise the set-get case may require a short value in and a large
> > answer structure out.
> 
> You misunderstand the motivation.  This is to get/set small compact
> parameters, not huge structures or big data.  Think get/setsockopt().

Think read(2)/write(2).  We already have several barfbags too many,
and that includes both ioctl() and setsockopt().  We are stuck with
them for compatibility reasons, but why the hell would we need yet
another one?

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

* Re: Problem with ioctl command TCGETS
  2004-11-28 11:22       ` Miklos Szeredi
  2004-11-28 12:18         ` Al Viro
@ 2004-11-28 12:23         ` Bernd Eckenfels
  1 sibling, 0 replies; 28+ messages in thread
From: Bernd Eckenfels @ 2004-11-28 12:23 UTC (permalink / raw)
  To: linux-kernel

In article <E1CYN7z-0001bZ-00@dorka.pomaz.szeredi.hu> you wrote:
> You misunderstand the motivation.  This is to get/set small compact
> parameters, not huge structures or big data.  Think get/setsockopt().

I understood it quite well. Looks like sys_sysctl to me.

But dont call it a ioctl replacement, since the stuff which causes most
problems will not be handled via that, but more with solutions like netlink.

Greetings
Bernd

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

* Re: Problem with ioctl command TCGETS
  2004-11-28 12:18         ` Al Viro
@ 2004-11-28 12:32           ` Miklos Szeredi
  2004-11-28 12:48             ` Al Viro
  2004-11-28 13:07           ` Tomas Carnecky
                             ` (2 subsequent siblings)
  3 siblings, 1 reply; 28+ messages in thread
From: Miklos Szeredi @ 2004-11-28 12:32 UTC (permalink / raw)
  To: viro; +Cc: ecki-news2004-05, linux-kernel

> Think read(2)/write(2).  We already have several barfbags too many,
> and that includes both ioctl() and setsockopt().  We are stuck with
> them for compatibility reasons, but why the hell would we need yet
> another one?

You can't replace either ioctl() or setsockopt() with read/write can
you?  Both of them set out-of-band information on file descriptors.

Proc maybe ('/proc/PID/fdparam/FD/param')?  I'm sure some people would
have objections to that too. 

Miklos

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

* Re: Problem with ioctl command TCGETS
  2004-11-28 12:32           ` Miklos Szeredi
@ 2004-11-28 12:48             ` Al Viro
  2004-11-28 12:52               ` Miklos Szeredi
  0 siblings, 1 reply; 28+ messages in thread
From: Al Viro @ 2004-11-28 12:48 UTC (permalink / raw)
  To: Miklos Szeredi; +Cc: ecki-news2004-05, linux-kernel

On Sun, Nov 28, 2004 at 01:32:17PM +0100, Miklos Szeredi wrote:
> > Think read(2)/write(2).  We already have several barfbags too many,
> > and that includes both ioctl() and setsockopt().  We are stuck with
> > them for compatibility reasons, but why the hell would we need yet
> > another one?
> 
> You can't replace either ioctl() or setsockopt() with read/write can
> you?  Both of them set out-of-band information on file descriptors.

Out-of-band == should be on a separate channel...

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

* Re: Problem with ioctl command TCGETS
  2004-11-28 12:48             ` Al Viro
@ 2004-11-28 12:52               ` Miklos Szeredi
  2004-11-28 13:03                 ` Al Viro
  2004-11-28 13:20                 ` Tomas Carnecky
  0 siblings, 2 replies; 28+ messages in thread
From: Miklos Szeredi @ 2004-11-28 12:52 UTC (permalink / raw)
  To: viro; +Cc: ecki-news2004-05, linux-kernel


> > > Think read(2)/write(2).  We already have several barfbags too many,
> > > and that includes both ioctl() and setsockopt().  We are stuck with
> > > them for compatibility reasons, but why the hell would we need yet
> > > another one?
> > 
> > You can't replace either ioctl() or setsockopt() with read/write can
> > you?  Both of them set out-of-band information on file descriptors.
> 
> Out-of-band == should be on a separate channel...

Tell me how?  E.g. how would you set/get sound stream parameters if
not with ioctl()?

Miklos

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

* Re: Problem with ioctl command TCGETS
  2004-11-28 12:52               ` Miklos Szeredi
@ 2004-11-28 13:03                 ` Al Viro
  2004-11-28 14:30                   ` Tomas Carnecky
  2004-12-10  4:01                   ` Ingo Oeser
  2004-11-28 13:20                 ` Tomas Carnecky
  1 sibling, 2 replies; 28+ messages in thread
From: Al Viro @ 2004-11-28 13:03 UTC (permalink / raw)
  To: Miklos Szeredi; +Cc: ecki-news2004-05, linux-kernel

On Sun, Nov 28, 2004 at 01:52:41PM +0100, Miklos Szeredi wrote:
> 
> > > > Think read(2)/write(2).  We already have several barfbags too many,
> > > > and that includes both ioctl() and setsockopt().  We are stuck with
> > > > them for compatibility reasons, but why the hell would we need yet
> > > > another one?
> > > 
> > > You can't replace either ioctl() or setsockopt() with read/write can
> > > you?  Both of them set out-of-band information on file descriptors.
> > 
> > Out-of-band == should be on a separate channel...
> 
> Tell me how?  E.g. how would you set/get sound stream parameters if
> not with ioctl()?

Have several related files.

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

* Re: Problem with ioctl command TCGETS
  2004-11-28 12:18         ` Al Viro
  2004-11-28 12:32           ` Miklos Szeredi
@ 2004-11-28 13:07           ` Tomas Carnecky
  2004-11-28 13:11             ` Al Viro
  2004-11-28 17:42           ` Alan Cox
  2004-11-30 13:26           ` Pavel Machek
  3 siblings, 1 reply; 28+ messages in thread
From: Tomas Carnecky @ 2004-11-28 13:07 UTC (permalink / raw)
  To: Al Viro; +Cc: Miklos Szeredi, ecki-news2004-05, linux-kernel

Al Viro wrote:
> On Sun, Nov 28, 2004 at 12:22:03PM +0100, Miklos Szeredi wrote:
> 
>>>The set-get is supposed to be used for queries, too? The size of value is
>>>only used for the get case to describe the buffer length in that case?
>>>because otherwise the set-get case may require a short value in and a large
>>>answer structure out.
>>
>>You misunderstand the motivation.  This is to get/set small compact
>>parameters, not huge structures or big data.  Think get/setsockopt().
> 
> 
> Think read(2)/write(2).  We already have several barfbags too many,
> and that includes both ioctl() and setsockopt().  We are stuck with
> them for compatibility reasons, but why the hell would we need yet
> another one?

And what's the option? So without ioctl, how would you reaplace this:
ioctl(cdrom_fd, CDROMEJECT, 0)?

tom

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

* Re: Problem with ioctl command TCGETS
  2004-11-28 13:07           ` Tomas Carnecky
@ 2004-11-28 13:11             ` Al Viro
  2004-11-28 13:19               ` Tomas Carnecky
  0 siblings, 1 reply; 28+ messages in thread
From: Al Viro @ 2004-11-28 13:11 UTC (permalink / raw)
  To: Tomas Carnecky; +Cc: Miklos Szeredi, ecki-news2004-05, linux-kernel

On Sun, Nov 28, 2004 at 02:07:04PM +0100, Tomas Carnecky wrote:
> >Think read(2)/write(2).  We already have several barfbags too many,
> >and that includes both ioctl() and setsockopt().  We are stuck with
> >them for compatibility reasons, but why the hell would we need yet
> >another one?
> 
> And what's the option? So without ioctl, how would you reaplace this:
> ioctl(cdrom_fd, CDROMEJECT, 0)?

Which part of "we are stuck with them" is not clear enough?  If you insist
on using the same descriptor for data and for out-of-band mess - no, you
can't get anything saner.  If you do not, you can; it's that simple...

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

* Re: Problem with ioctl command TCGETS
  2004-11-28 13:11             ` Al Viro
@ 2004-11-28 13:19               ` Tomas Carnecky
  0 siblings, 0 replies; 28+ messages in thread
From: Tomas Carnecky @ 2004-11-28 13:19 UTC (permalink / raw)
  To: Al Viro; +Cc: Miklos Szeredi, ecki-news2004-05, linux-kernel

Al Viro wrote:
> On Sun, Nov 28, 2004 at 02:07:04PM +0100, Tomas Carnecky wrote:
> 
>>>Think read(2)/write(2).  We already have several barfbags too many,
>>>and that includes both ioctl() and setsockopt().  We are stuck with
>>>them for compatibility reasons, but why the hell would we need yet
>>>another one?
>>
>>And what's the option? So without ioctl, how would you reaplace this:
>>ioctl(cdrom_fd, CDROMEJECT, 0)?
> 
> Which part of "we are stuck with them" is not clear enough?  If you insist
> on using the same descriptor for data and for out-of-band mess - no, you
> can't get anything saner.  If you do not, you can; it's that simple...

Ok, I know ioctl is bad, but please tell me how to replace them, that's
all I want to know. Did you propose any other mechanism which could
replace ioctl? Or do you think such things (eject the cdrom) are not
meant to be done from applications?
I certainly don't insist on using them, but I don't see (yet) any way
how to replace them. Please enlighten me.

tom

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

* Re: Problem with ioctl command TCGETS
  2004-11-28 12:52               ` Miklos Szeredi
  2004-11-28 13:03                 ` Al Viro
@ 2004-11-28 13:20                 ` Tomas Carnecky
  2004-11-28 14:05                   ` Al Viro
  1 sibling, 1 reply; 28+ messages in thread
From: Tomas Carnecky @ 2004-11-28 13:20 UTC (permalink / raw)
  To: Miklos Szeredi; +Cc: viro, ecki-news2004-05, linux-kernel

Miklos Szeredi wrote:
>>>>Think read(2)/write(2).  We already have several barfbags too many,
>>>>and that includes both ioctl() and setsockopt().  We are stuck with
>>>>them for compatibility reasons, but why the hell would we need yet
>>>>another one?
>>>
>>>You can't replace either ioctl() or setsockopt() with read/write can
>>>you?  Both of them set out-of-band information on file descriptors.
>>
>>Out-of-band == should be on a separate channel...
> 
> 
> Tell me how?  E.g. how would you set/get sound stream parameters if
> not with ioctl()?
> 

Maybe using sysfs? /sys/device/cdrom/param ?
But then you'd have to open another file :(

And what about somethink like:
cdrom_fd = open("/dev/cdrom", O_RDWR)
cdrom_param_fd = get_param_fd(cdrom_fd) /* a new syscall */
Now read/write to this param fd.
And two new entries in the struct file_operations:
write_param([same args as write])
read_param([same args as read])

tom

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

* Re: Problem with ioctl command TCGETS
  2004-11-28 13:20                 ` Tomas Carnecky
@ 2004-11-28 14:05                   ` Al Viro
  0 siblings, 0 replies; 28+ messages in thread
From: Al Viro @ 2004-11-28 14:05 UTC (permalink / raw)
  To: Tomas Carnecky; +Cc: Miklos Szeredi, ecki-news2004-05, linux-kernel

On Sun, Nov 28, 2004 at 02:20:19PM +0100, Tomas Carnecky wrote:
> But then you'd have to open another file :(

Correct, but not necessary on sysfs.

> And what about somethink like:
> cdrom_fd = open("/dev/cdrom", O_RDWR)
> cdrom_param_fd = get_param_fd(cdrom_fd) /* a new syscall */
> Now read/write to this param fd.
> And two new entries in the struct file_operations:
> write_param([same args as write])
> read_param([same args as read])

That assumes that there is any sort of uniform semantics for these
operations.  There isn't.  Moreover, you are insisting on pushing
all of them into the same channel; not a good idea since the set
of things done with ioctls tends to consist of several unrelated
classes, often coming from a bunch of unrelated subsystems.

There is no mechanical replacement for ioctl(); the nature of its
problems is that we have a random mix of unrelated operations bumped
into one pile.

Take a look at e.g. networking ioctls.  Most of them openly ignores the
descriptor used to issue an ioctl - more often then not the first thing
they do is to peek into the passed data structure and go looking for
the real object we are going to operate upon; e.g. find an interface by
name.  Of course it's bogus; any sane modification of that API would
have the object selected by the opened file we are passing to it.

And no, we have no chance in hell to rewrite all userland code that
uses these suckers, so we are stuck with them for all forseeable future.
UCB folks had no taste, film at 11...

For more or less common (read: implemented by more than a couple of drivers)
ioctls we have to keep them anyway; for the stuff where we really stand
a chance of doing some kind of changes (including the new operations) we
can bloody well do splitup by files that would match the nature of operations.
Which leaves the "get me secondary channel by fd" kind of operations
without any uses.

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

* Re: Problem with ioctl command TCGETS
  2004-11-28 13:03                 ` Al Viro
@ 2004-11-28 14:30                   ` Tomas Carnecky
  2004-11-28 15:27                     ` Al Viro
  2004-12-10  4:01                   ` Ingo Oeser
  1 sibling, 1 reply; 28+ messages in thread
From: Tomas Carnecky @ 2004-11-28 14:30 UTC (permalink / raw)
  To: Al Viro; +Cc: Miklos Szeredi, ecki-news2004-05, linux-kernel

Al Viro wrote:
> On Sun, Nov 28, 2004 at 01:52:41PM +0100, Miklos Szeredi wrote:
> 
>>>>>Think read(2)/write(2).  We already have several barfbags too many,
>>>>>and that includes both ioctl() and setsockopt().  We are stuck with
>>>>>them for compatibility reasons, but why the hell would we need yet
>>>>>another one?
>>>>
>>>>You can't replace either ioctl() or setsockopt() with read/write can
>>>>you?  Both of them set out-of-band information on file descriptors.
>>>
>>>Out-of-band == should be on a separate channel...
>>
>>Tell me how?  E.g. how would you set/get sound stream parameters if
>>not with ioctl()?
> 
> 
> Have several related files.

You mean.. like nvidia?
/dev/nvidiactl
/dev/nvidia0
/dev/nvidia1
/dev/nvidia2
and do read/write on /dev/nvidiactl (instead on ioctl)?

tom

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

* Re: Problem with ioctl command TCGETS
  2004-11-28 14:30                   ` Tomas Carnecky
@ 2004-11-28 15:27                     ` Al Viro
  2004-11-28 18:23                       ` Tomas Carnecky
  0 siblings, 1 reply; 28+ messages in thread
From: Al Viro @ 2004-11-28 15:27 UTC (permalink / raw)
  To: Tomas Carnecky; +Cc: Miklos Szeredi, ecki-news2004-05, linux-kernel

On Sun, Nov 28, 2004 at 03:30:19PM +0100, Tomas Carnecky wrote:
> You mean.. like nvidia?
> /dev/nvidiactl
> /dev/nvidia0
> /dev/nvidia1
> /dev/nvidia2
> and do read/write on /dev/nvidiactl (instead on ioctl)?

Really depends on situation - in some cases that's the obvious clean
variant, in some you might want something more specific.  Usually
it helps to ask "what object am I working with?" and see if it gives
a reasonable picture.  Note, BTW, that your example (eject) actually
demonstrates what kind of ugliness can be created by piling everything
together - the logics around "it's currently used, do not eject and
return -EBUSY" is broken and unfixable in all cdrom drivers.  Broken
exactly because we need to open device itself to issue eject request.
Think what happens if we get
	fd = open("/dev/cdrom", 0);
	if (fork()) {
		read a lot from that sucker
	} else {
		sleep for a while
		ioctl(fd, CDROMEJECT, 0);
	}
>From the driver point of view, we have only one opener.  There's no way
to tell how many processes might have file descriptors that point to
what we'd opened back then.  So we either need to keep track of all
changes in descriptor tables and provide exclusion between that and
ioctls (have fun) or admit that driver might be hit with eject in the
middle of IO, all logics along the lines of "it's opened by somebody,
no eject for us" nonwithstanding.

And then there are horrors like cciss special-casing the open of 1st disk
on a controller (even if there's none) so that we could talk to controller
itself (in particular, tell it to go look for disks that might be attached
to it now).  It gets very ugly; same for RAID array creation, same for
loop device setup and races around it, etc.

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

* Re: Problem with ioctl command TCGETS
  2004-11-28 12:18         ` Al Viro
  2004-11-28 12:32           ` Miklos Szeredi
  2004-11-28 13:07           ` Tomas Carnecky
@ 2004-11-28 17:42           ` Alan Cox
  2004-11-30 13:26           ` Pavel Machek
  3 siblings, 0 replies; 28+ messages in thread
From: Alan Cox @ 2004-11-28 17:42 UTC (permalink / raw)
  To: Al Viro; +Cc: Miklos Szeredi, ecki-news2004-05, Linux Kernel Mailing List

On Sul, 2004-11-28 at 12:18, Al Viro wrote:
> Think read(2)/write(2).  We already have several barfbags too many,
> and that includes both ioctl() and setsockopt().  We are stuck with
> them for compatibility reasons, but why the hell would we need yet
> another one?

Synchronization.


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

* Re: Problem with ioctl command TCGETS
  2004-11-28 15:27                     ` Al Viro
@ 2004-11-28 18:23                       ` Tomas Carnecky
  2004-11-28 18:51                         ` Miklos Szeredi
  0 siblings, 1 reply; 28+ messages in thread
From: Tomas Carnecky @ 2004-11-28 18:23 UTC (permalink / raw)
  To: Al Viro; +Cc: Miklos Szeredi, ecki-news2004-05, linux-kernel

Al Viro wrote:
> On Sun, Nov 28, 2004 at 03:30:19PM +0100, Tomas Carnecky wrote:
> 
>>You mean.. like nvidia?
>>/dev/nvidiactl
>>/dev/nvidia0
>>/dev/nvidia1
>>/dev/nvidia2
>>and do read/write on /dev/nvidiactl (instead on ioctl)?
> 
> 
> Really depends on situation - in some cases that's the obvious clean
> variant, in some you might want something more specific.

The 'good' thing on ioctl is that _every_ device supports that. It
doesn't matter which device you open, each one supports ioctl.
Now if each driver cooks up it's own replacement.. and everyone
knows that developers don't really like to document their code.. :/

Was there ever a thread on lkml about a ioctl replacement? I'd
really like to read about proposals, so far everyone talks only about
replacing it... but no one wants to say how _exactly_.

tom


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

* Re: Problem with ioctl command TCGETS
  2004-11-28 18:23                       ` Tomas Carnecky
@ 2004-11-28 18:51                         ` Miklos Szeredi
  0 siblings, 0 replies; 28+ messages in thread
From: Miklos Szeredi @ 2004-11-28 18:51 UTC (permalink / raw)
  To: tom; +Cc: viro, ecki-news2004-05, linux-kernel

> Was there ever a thread on lkml about a ioctl replacement? I'd
> really like to read about proposals, so far everyone talks only about
> replacing it... but no one wants to say how _exactly_.

I remember from one in May 2001 with a subject "RFD w/info-PATCH]
device arguments from lookup)" and it's offshoots.  It's not all about
ioctls, but there are proposals for improvements to the ioctl
interface and other interesting stuff.  Link to start of thread in
MARC:

  http://marc.theaimsgroup.com/?l=linux-kernel&m=99025355313916&w=2

Miklos

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

* Re: Problem with ioctl command TCGETS
  2004-11-28 12:18         ` Al Viro
                             ` (2 preceding siblings ...)
  2004-11-28 17:42           ` Alan Cox
@ 2004-11-30 13:26           ` Pavel Machek
  2004-11-30 15:46             ` Al Viro
  3 siblings, 1 reply; 28+ messages in thread
From: Pavel Machek @ 2004-11-30 13:26 UTC (permalink / raw)
  To: Al Viro; +Cc: Miklos Szeredi, ecki-news2004-05, linux-kernel

Hi!

> > > The set-get is supposed to be used for queries, too? The size of value is
> > > only used for the get case to describe the buffer length in that case?
> > > because otherwise the set-get case may require a short value in and a large
> > > answer structure out.
> > 
> > You misunderstand the motivation.  This is to get/set small compact
> > parameters, not huge structures or big data.  Think get/setsockopt().
> 
> Think read(2)/write(2).  We already have several barfbags too many,
> and that includes both ioctl() and setsockopt().  We are stuck with
> them for compatibility reasons, but why the hell would we need yet
> another one?

Passing structure using read/write is evil, because there's nowhere to hook 
32/64 bit translation.
-- 
64 bytes from 195.113.31.123: icmp_seq=28 ttl=51 time=448769.1 ms         


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

* Re: Problem with ioctl command TCGETS
  2004-11-30 13:26           ` Pavel Machek
@ 2004-11-30 15:46             ` Al Viro
  0 siblings, 0 replies; 28+ messages in thread
From: Al Viro @ 2004-11-30 15:46 UTC (permalink / raw)
  To: Pavel Machek; +Cc: Miklos Szeredi, ecki-news2004-05, linux-kernel

On Tue, Nov 30, 2004 at 02:26:19PM +0100, Pavel Machek wrote:
> > Think read(2)/write(2).  We already have several barfbags too many,
> > and that includes both ioctl() and setsockopt().  We are stuck with
> > them for compatibility reasons, but why the hell would we need yet
> > another one?
> 
> Passing structure using read/write is evil, because there's nowhere to hook 
> 32/64 bit translation.

No, really?  And we must use different layouts for 32 and 64 bit platforms
for which religious reasons, exactly?

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

* Re: Problem with ioctl command TCGETS
  2004-11-28 13:03                 ` Al Viro
  2004-11-28 14:30                   ` Tomas Carnecky
@ 2004-12-10  4:01                   ` Ingo Oeser
  1 sibling, 0 replies; 28+ messages in thread
From: Ingo Oeser @ 2004-12-10  4:01 UTC (permalink / raw)
  To: Al Viro; +Cc: linux-kernel

You wrote:
[read/write vs ioctl]
> > Tell me how?  E.g. how would you set/get sound stream parameters if
> > not with ioctl()?
>
> Have several related files.

Look at your monitor. Technically this is an output device.
But there are little controls, where you can make adjustments.

ioctl is nothing else: A controller for an io-stream.

It also makes quite clear, that we are packetizing read/writes now.
And it cannot be fdopen()ed ;-)

Maybe we COULD split strictly for reads and writes, but
we still need a side channel for that to be opened by
passing a file descriptor.

How else would you control a tty/pty which you got as stdin/stdout?

Maybe one could hack this into xattr-support? ;-)

Regards

Ingo Oeser


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

end of thread, other threads:[~2004-12-10  4:01 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-28  0:22 Problem with ioctl command TCGETS Ozan Eren Bilgen
2004-11-28  0:39 ` Al Viro
2004-11-28  9:59   ` Miklos Szeredi
2004-11-28 10:08     ` Jan Engelhardt
2004-11-28 10:18       ` Miklos Szeredi
2004-11-28 10:28     ` Bernd Eckenfels
2004-11-28 10:56       ` Wichert Akkerman
2004-11-28 11:52         ` Bernd Eckenfels
2004-11-28 11:22       ` Miklos Szeredi
2004-11-28 12:18         ` Al Viro
2004-11-28 12:32           ` Miklos Szeredi
2004-11-28 12:48             ` Al Viro
2004-11-28 12:52               ` Miklos Szeredi
2004-11-28 13:03                 ` Al Viro
2004-11-28 14:30                   ` Tomas Carnecky
2004-11-28 15:27                     ` Al Viro
2004-11-28 18:23                       ` Tomas Carnecky
2004-11-28 18:51                         ` Miklos Szeredi
2004-12-10  4:01                   ` Ingo Oeser
2004-11-28 13:20                 ` Tomas Carnecky
2004-11-28 14:05                   ` Al Viro
2004-11-28 13:07           ` Tomas Carnecky
2004-11-28 13:11             ` Al Viro
2004-11-28 13:19               ` Tomas Carnecky
2004-11-28 17:42           ` Alan Cox
2004-11-30 13:26           ` Pavel Machek
2004-11-30 15:46             ` Al Viro
2004-11-28 12:23         ` Bernd Eckenfels

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