2002-02-19 20:21:33

by Pavel Machek

[permalink] [raw]
Subject: ENOTTY from ext3 code?

Hi!

ext3/ioctl.c:

...
return -ENOTTY;

Does it really make sense to return "not a typewriter" from ext3
ioctl?
Pavel
--
(about SSSCA) "I don't say this lightly. However, I really think that the U.S.
no longer is classifiable as a democracy, but rather as a plutocracy." --hpa


2002-02-19 20:32:27

by Alexander Viro

[permalink] [raw]
Subject: Re: ENOTTY from ext3 code?



On Tue, 19 Feb 2002, Pavel Machek wrote:

> Hi!
>
> ext3/ioctl.c:
>
> ...
> return -ENOTTY;
>
> Does it really make sense to return "not a typewriter" from ext3
> ioctl?

s/typewriter/teletype/ and ext3 indeed is not one (and thus shouldn't _have_
ioctl() in the first place). Seriously, -ENOTTY is normal error for "I don't
know anything about that ioctl".

2002-02-19 20:36:55

by Richard B. Johnson

[permalink] [raw]
Subject: Re: ENOTTY from ext3 code?

On Tue, 19 Feb 2002, Pavel Machek wrote:

> Hi!
>
> ext3/ioctl.c:
>
> ...
> return -ENOTTY;
>
> Does it really make sense to return "not a typewriter" from ext3
> ioctl?

But yes! The de-facto return code for a file-system ioctl() that
is undefined, i.e., wrong parameter, is ENOTTY. This is because
it really means "Not a terminal". Terminals have the most ioctls.

Cheers,
Dick Johnson

Penguin : Linux version 2.4.1 on an i686 machine (797.90 BogoMips).

111,111,111 * 111,111,111 = 12,345,678,987,654,321

2002-02-19 20:58:00

by Andrew Morton

[permalink] [raw]
Subject: Re: ENOTTY from ext3 code?

Pavel Machek wrote:
>
> Hi!
>
> ext3/ioctl.c:
>
> ...
> return -ENOTTY;
>
> Does it really make sense to return "not a typewriter" from ext3
> ioctl?

ERRORS
...

ENOTTY d is not associated with a character special
device.

ENOTTY The specified request does not apply to the kind of
object that the descriptor d references.


Lots and lots of ioctls return ENOTTY when passed a request
which they don't understand. There's probably a great reason
for this, but I can't immediately think what it might be.

-

2002-02-19 21:21:15

by Andreas Dilger

[permalink] [raw]
Subject: Re: ENOTTY from ext3 code?

On Feb 19, 2002 12:56 -0800, Andrew Morton wrote:
> Pavel Machek wrote:
> > ext3/ioctl.c:
> >
> > ...
> > return -ENOTTY;
> >
> > Does it really make sense to return "not a typewriter" from ext3
> > ioctl?
>
> ERRORS
> ...
>
> ENOTTY The specified request does not apply to the kind of
> object that the descriptor d references.
>
> Lots and lots of ioctls return ENOTTY when passed a request
> which they don't understand. There's probably a great reason
> for this, but I can't immediately think what it might be.

Well, returning ENOTTY for unknown ioctls instead of EINVAL allows you
to distinguish between 'I have no idea what you are asking of me' and
'you passed me the incorrect parameter to this request' in the caller.

Cheers, Andreas
--
Andreas Dilger
http://sourceforge.net/projects/ext2resize/
http://www-mddsp.enel.ucalgary.ca/People/adilger/

2002-02-19 21:27:15

by Guest section DW

[permalink] [raw]
Subject: Re: ENOTTY from ext3 code?

On Tue, Feb 19, 2002 at 08:09:32PM +0100, Pavel Machek wrote:

> ext3/ioctl.c:
>
> ...
> return -ENOTTY;
>
> Does it really make sense to return "not a typewriter" from ext3
> ioctl?

I suppose you know the definition of ENOTTY?

Quoting POSIX:
[ENOTTY] Inappropriate I/O control operation.

2002-02-19 21:53:52

by Pete Zaitcev

[permalink] [raw]
Subject: Re: ENOTTY from ext3 code?

> ext3/ioctl.c:
> ...
> return -ENOTTY;
>
> Does it really make sense to return "not a typewriter" from ext3
> ioctl?

Absolutely. In fact, it's a pet pieve of mine. Lots and lots
of clueless driver writes return -EINVAL in such cases,
and I keep cleaning it up. The problem with EINVAL is that
it makes it harder to diagnose any problems that can come up.

Also, recent strerror() returns "Inappropriate ioctl for a device",
if that is your concern. Personally, I think "Not a typewriter"
was a warmer and fuzzier reference to the roots, but oh well...
Dennis giveth, TOG taketh away...

-- Pete

2002-02-20 01:09:13

by Alan

[permalink] [raw]
Subject: Re: ENOTTY from ext3 code?

> if that is your concern. Personally, I think "Not a typewriter"
> was a warmer and fuzzier reference to the roots, but oh well...
> Dennis giveth, TOG taketh away...

TOG says you are right. -ENOTTY is the right thing in most cases