Patchwork UBI: block: Use ENOSYS as return value when CONFIG_UBIBLOCK=n

login
register
mail settings
Submitter Ezequiel Garcia
Date March 4, 2014, 10:57 a.m.
Message ID <1393930663-8737-1-git-send-email-ezequiel.garcia@free-electrons.com>
Download mbox | patch
Permalink /patch/326214/
State Superseded
Headers show

Comments

Ezequiel Garcia - March 4, 2014, 10:57 a.m.
In order to have a way of distinguishing an invalid ioctl from a
not supported (but otherwise valid) ioctl, this commit changes the
return value of the ioctl stubs from ENOTTY to ENOSYS.

This will be useful to report more accurate error messages from
userspace tools.

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
 drivers/mtd/ubi/ubi.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Artem Bityutskiy - March 4, 2014, 11:49 a.m.
On Tue, 2014-03-04 at 07:57 -0300, Ezequiel Garcia wrote:
> In order to have a way of distinguishing an invalid ioctl from a
> not supported (but otherwise valid) ioctl, this commit changes the
> return value of the ioctl stubs from ENOTTY to ENOSYS.

Sounds logical, no objections, except it is curious if this is something
you invented or this is a general rule in the Linux kernel? If it is,
may be you can point to some discussions, or give some example or other
source of this knowledge? I just want to be educated a bit. Thanks!
Ezequiel Garcia - March 4, 2014, 12:14 p.m.
On Tue, Mar 04, 2014 at 01:49:51PM +0200, Artem Bityutskiy wrote:
> On Tue, 2014-03-04 at 07:57 -0300, Ezequiel Garcia wrote:
> > In order to have a way of distinguishing an invalid ioctl from a
> > not supported (but otherwise valid) ioctl, this commit changes the
> > return value of the ioctl stubs from ENOTTY to ENOSYS.
> 
> Sounds logical, no objections, except it is curious if this is something
> you invented or this is a general rule in the Linux kernel? If it is,
> may be you can point to some discussions, or give some example or other
> source of this knowledge? I just want to be educated a bit. Thanks!
> 

Yes, I think it's a pretty extended kernel practice to return -ENOSYS when
a function is not built or either not implemented.

A good number of headers in include/linux/ use -ENOSYS as the return value
for the !CONFIG_FEATURE stubs.

$ git grep ENOSYS include/linux/  | wc -l
172

And of course, the syscall ABI returns -ENOSYS for unimplemented system calls.
Artem Bityutskiy - March 4, 2014, 1 p.m.
On Tue, 2014-03-04 at 09:14 -0300, Ezequiel Garcia wrote:
> On Tue, Mar 04, 2014 at 01:49:51PM +0200, Artem Bityutskiy wrote:
> > On Tue, 2014-03-04 at 07:57 -0300, Ezequiel Garcia wrote:
> > > In order to have a way of distinguishing an invalid ioctl from a
> > > not supported (but otherwise valid) ioctl, this commit changes the
> > > return value of the ioctl stubs from ENOTTY to ENOSYS.
> > 
> > Sounds logical, no objections, except it is curious if this is something
> > you invented or this is a general rule in the Linux kernel? If it is,
> > may be you can point to some discussions, or give some example or other
> > source of this knowledge? I just want to be educated a bit. Thanks!
> > 
> 
> Yes, I think it's a pretty extended kernel practice to return -ENOSYS when
> a function is not built or either not implemented.

Pushed this one and the previous 3 ones. I think what is left is ioctl
names and the user-space tool.

Thanks!
Ezequiel Garcia - March 5, 2014, 1:30 p.m.
On Mar 04, Artem Bityutskiy wrote:
> On Tue, 2014-03-04 at 09:14 -0300, Ezequiel Garcia wrote:
> > On Tue, Mar 04, 2014 at 01:49:51PM +0200, Artem Bityutskiy wrote:
> > > On Tue, 2014-03-04 at 07:57 -0300, Ezequiel Garcia wrote:
> > > > In order to have a way of distinguishing an invalid ioctl from a
> > > > not supported (but otherwise valid) ioctl, this commit changes the
> > > > return value of the ioctl stubs from ENOTTY to ENOSYS.
> > > 
> > > Sounds logical, no objections, except it is curious if this is something
> > > you invented or this is a general rule in the Linux kernel? If it is,
> > > may be you can point to some discussions, or give some example or other
> > > source of this knowledge? I just want to be educated a bit. Thanks!
> > > 
> > 
> > Yes, I think it's a pretty extended kernel practice to return -ENOSYS when
> > a function is not built or either not implemented.
> 
> Pushed this one and the previous 3 ones. I think what is left is ioctl
> names and the user-space tool.
> 

I'm seeing all the other patches pushed, but not this one. Do you want me to
send a rebased patch?

Patch

diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h
index e76ff98..a8118f2 100644
--- a/drivers/mtd/ubi/ubi.h
+++ b/drivers/mtd/ubi/ubi.h
@@ -873,8 +873,8 @@  int ubiblock_del(struct ubi_volume_info *vi);
 #else
 static inline int ubiblock_init(void) { return 0; }
 static inline void ubiblock_exit(void) {}
-static inline int ubiblock_add(struct ubi_volume_info *vi) { return -ENOTTY; }
-static inline int ubiblock_del(struct ubi_volume_info *vi) { return -ENOTTY; }
+static inline int ubiblock_add(struct ubi_volume_info *vi) { return -ENOSYS; }
+static inline int ubiblock_del(struct ubi_volume_info *vi) { return -ENOSYS; }
 #endif