Re: [PATCH] remove TCGETS

David Woodhouse <[email protected]> Wed, 29 Oct 2003 00:46:42 +0000
Newsgroups gmane.comp.file-systems.intermezzo.devel,gmane.linux.file-systems
Message-ID <[email protected]>
On Tue, 2003-10-28 at 13:07 -0800, Linus Torvalds wrote:
> I don't know you you _require_ an executive decision, but the simple fact 
> is that the regular Linux ioctl() handler always returns ENOTTY if it 
> doesn't match a ioctl number. See fs/ioctl.c.

I don't require an executive decision to fix my own code -- the patch
went into my CVS tree this morning and is attached. But if I'm going to
hunt down bogus -EINVAL returns and convert them to -ENOTTY, an
executive decision makes my life easier because it stops people bitching
at me for it :)

> In short, the way I think this should be handled is:
>  - if you don't recognize the ioctl, you should return ENOTTY
>  - if you recognize the ioctl, but some parameter to the ioctl is wrong, 
>    you should return EINVAL.

Absolutely.

> This is consistent with file_ioctl(), and also consistent with traditional
> uses of ENOTTY. It also just happens to make LTP pass, but I will leave to
> you to make up your own mind on whether that is because LTP is a good
> test, or whether it's just a small unimportant detail.

Life is full of small unimportant details. Being consistent about them
is a quality of implementation issue. 

Index: fs/jffs2/ioctl.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/ioctl.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -p -r1.7 -r1.8
--- fs/jffs2/ioctl.c	4 Oct 2003 08:33:06 -0000	1.7
+++ fs/jffs2/ioctl.c	28 Oct 2003 16:16:28 -0000	1.8
@@ -1,13 +1,13 @@
 /*
  * JFFS2 -- Journalling Flash File System, Version 2.
  *
- * Copyright (C) 2001 Red Hat, Inc.
+ * Copyright (C) 2001-2003 Red Hat, Inc.
  *
  * Created by David Woodhouse <[email protected]>
  *
  * For licensing information, see the file 'LICENCE' in this directory.
  *
- * $Id: ioctl.c,v 1.7 2003/10/04 08:33:06 dwmw2 Exp $
+ * $Id: ioctl.c,v 1.8 2003/10/28 16:16:28 dwmw2 Exp $
  *
  */
 
@@ -18,6 +18,6 @@ int jffs2_ioctl(struct inode *inode, str
 {
 	/* Later, this will provide for lsattr.jffs2 and chattr.jffs2, which
 	   will include compression support etc. */
-	return -EINVAL;
+	return -ENOTTY;
 }
 	


-- 
dwmw2




-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?   SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/