All of lore.kernel.org
 help / color / mirror / Atom feed
* procedure for creating new ioctl?
@ 2002-06-10 18:09 Joseph Cheek
  2002-06-10 18:17 ` Richard B. Johnson
  0 siblings, 1 reply; 3+ messages in thread
From: Joseph Cheek @ 2002-06-10 18:09 UTC (permalink / raw)
  To: linux-kernel

hi all,

i'd like to create a new ioctl for use in my kernels [actually i already 
have 8-)] but want to make sure that i follow any established procedure 
for creating it before requesting it be included in the kernel. 
 specifically, is there a way to ensure the ioctl number i use isn't in 
use by anyone else?  is there a central registry?

so far i've just picked an arbitrary number:

sanfrancisco:/usr/src/linux-2.4.17/include/linux# diff -Naur kd.h{.orig,}
--- kd.h.orig   Mon Jun 10 11:08:22 2002
+++ kd.h        Thu Jun  6 16:00:33 2002
@@ -177,4 +177,6 @@
    don't reuse for the time being */
 /* note: 0x4B60-0x4B6D, 0x4B70-0x4B72 used above */

+#define KDGETKEYDOWNSTATE      0x4B80  /* read kernel keydown bit */
+
 #endif /* _LINUX_KD_H */

any tips, pointers appreciated.

joe

-- 
Joseph Cheek, CTO and Founder, Lycoris
joseph@lycoris.com, www.lycoris.com
Lycoris Desktop/LX: Familiar.  Powerful.  Open.
+1 425 413-9521 voice, +1 425 671-0504 fax



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

* Re: procedure for creating new ioctl?
  2002-06-10 18:09 procedure for creating new ioctl? Joseph Cheek
@ 2002-06-10 18:17 ` Richard B. Johnson
  2002-06-10 19:56   ` Andreas Dilger
  0 siblings, 1 reply; 3+ messages in thread
From: Richard B. Johnson @ 2002-06-10 18:17 UTC (permalink / raw)
  To: Joseph Cheek; +Cc: linux-kernel

On Mon, 10 Jun 2002, Joseph Cheek wrote:

> hi all,
> 
> i'd like to create a new ioctl for use in my kernels [actually i already 
> have 8-)] but want to make sure that i follow any established procedure 
> for creating it before requesting it be included in the kernel. 
>  specifically, is there a way to ensure the ioctl number i use isn't in 
> use by anyone else?  is there a central registry?
> 
> so far i've just picked an arbitrary number:
> 
> sanfrancisco:/usr/src/linux-2.4.17/include/linux# diff -Naur kd.h{.orig,}
> --- kd.h.orig   Mon Jun 10 11:08:22 2002
> +++ kd.h        Thu Jun  6 16:00:33 2002
> @@ -177,4 +177,6 @@
>     don't reuse for the time being */
>  /* note: 0x4B60-0x4B6D, 0x4B70-0x4B72 used above */
> 
> +#define KDGETKEYDOWNSTATE      0x4B80  /* read kernel keydown bit */
> +
>  #endif /* _LINUX_KD_H */
> 
> any tips, pointers appreciated.
> 
> joe
> 

I use SIOCDEVPRIVATE as the starting value for new ioctls:

/*
 *   Interface to the private device functions. User API sees this only.
 */
#define CHEK_SEEPROM   SIOCDEVPRIVATE + 0x07
#define READ_SEEPROM   SIOCDEVPRIVATE + 0x08
#define WRITE_SEEPROM  SIOCDEVPRIVATE + 0x09


I've seen this in several drivers. I think this is the way to do it
so there is no interference with other ioctls.

Cheers,
Dick Johnson

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

                 Windows-2000/Professional isn't.


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

* Re: procedure for creating new ioctl?
  2002-06-10 18:17 ` Richard B. Johnson
@ 2002-06-10 19:56   ` Andreas Dilger
  0 siblings, 0 replies; 3+ messages in thread
From: Andreas Dilger @ 2002-06-10 19:56 UTC (permalink / raw)
  To: Richard B. Johnson; +Cc: Joseph Cheek, linux-kernel

On Jun 10, 2002  14:17 -0400, Richard B. Johnson wrote:
> I use SIOCDEVPRIVATE as the starting value for new ioctls:
> 
> /*
>  *   Interface to the private device functions. User API sees this only.
>  */
> #define CHEK_SEEPROM   SIOCDEVPRIVATE + 0x07
> #define READ_SEEPROM   SIOCDEVPRIVATE + 0x08
> #define WRITE_SEEPROM  SIOCDEVPRIVATE + 0x09
> 
> 
> I've seen this in several drivers. I think this is the way to do it
> so there is no interference with other ioctls.

Of course there is.  That means that a program accidentally running on
the wrong device will get completely unexpected results because the
ioctl numbers will all be some value above SIOCDEVPRIVATE.

Since each of the drivers have (mostly) their own private ioctl handling,
there is less of an issue of actual ioctl number conflicts as there
is an issue that ioctl numbers should be globally unique to avoid
accidental side effects when running on an incorrect device.

Besides which, SIOCDEVPRIVATE is supposed to be for socket (networking)
ioctls and not just random ioctl values.  The comment above it also
indicates this value is deprecated...

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


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

end of thread, other threads:[~2002-06-10 19:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-06-10 18:09 procedure for creating new ioctl? Joseph Cheek
2002-06-10 18:17 ` Richard B. Johnson
2002-06-10 19:56   ` Andreas Dilger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.