mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* How should an application ask for uinput module load?
@ 2006-03-28 19:42 Samuel Thibault
  2006-03-29 22:01 ` Samuel Thibault
  2006-04-25 17:54 ` Dmitry Torokhov
  0 siblings, 2 replies; 3+ messages in thread
From: Samuel Thibault @ 2006-03-28 19:42 UTC (permalink / raw)
  To: linux-kernel; +Cc: dave

Hi,

Given a freshly booted linux box, hence uinput is not loaded (why would
it be, it doesn't drive any real hardware) ; what is the right way(tm)
for an application to have the uinput module loaded, so that it can open
/dev/input/uinput for emulating keypresses?

- With good-old static /dev, we could just open /dev/input/uinput
  (installed by the distribution), and thanks to a
  alias char-major-10-223 uinput
  line somewhere in /etc/modprobe.d, uinput finally gets auto-loaded.

- With devfs, it doesn't look like it works (/dev/misc/uinput is not
  present and opening it just like if it existed doesn't work). But I
  read in archives that it could be feasible.

- With udev, this just cannot work. As explained in an earlier thread,
  even using a special filesystem that would report the opening attempt
  to udevd wouldn't work fine since udevd takes time for creating the
  device, and hence the original program needs to be notified ; this
  becomes racy.

So what is the correct way to do it? I can see two approaches:

Using modprobe:
- try to use /dev/input/uinput ; if it succeeds, fine.
- else, if errno != ENOENT, fail
- else, (ENOENT)
  - try to call `cat /proc/sys/kernel/modprobe` uinput
  - try to use /dev/input/uinput again ; if it succeeds, fine
    - else, assume that it really wasn't compiled, and hence fail.

Triggering auto-load by creating one's own node.
- try to use /dev/input/uinput ; if it suceeds, fine.
- else, if errno != ENOENT, fail
- else, (ENOENT)
  - mknod /somewhere/safe/uinput c 10 223
  - use /somewhere/safe/uinput ; if it succeeds, fine
    - else, assume that it really wasn't compiled, and hence fail.

I guess the same problem arises for loop devices and all such virtual
devices...

Regards,
Samuel

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

* Re: How should an application ask for uinput module load?
  2006-03-28 19:42 How should an application ask for uinput module load? Samuel Thibault
@ 2006-03-29 22:01 ` Samuel Thibault
  2006-04-25 17:54 ` Dmitry Torokhov
  1 sibling, 0 replies; 3+ messages in thread
From: Samuel Thibault @ 2006-03-29 22:01 UTC (permalink / raw)
  To: linux-kernel, dave

Hi,

Samuel Thibault, le Tue 28 Mar 2006 21:42:10 +0200, a écrit :
> what is the right way(tm) for an application to have the uinput
> module loaded, so that it can open /dev/input/uinput for emulating
> keypresses?
>
>...
> 
> I can see two approaches:
> 
> Using modprobe:
> - try to use /dev/input/uinput ; if it succeeds, fine.
> - else, if errno != ENOENT, fail
> - else, (ENOENT)
>   - try to call `cat /proc/sys/kernel/modprobe` uinput
>   - try to use /dev/input/uinput again ; if it succeeds, fine
>     - else, assume that it really wasn't compiled, and hence fail.
> 
> Triggering auto-load by creating one's own node.
> - try to use /dev/input/uinput ; if it suceeds, fine.
> - else, if errno != ENOENT, fail
> - else, (ENOENT)
>   - mknod /somewhere/safe/uinput c 10 223
>   - use /somewhere/safe/uinput ; if it succeeds, fine
>     - else, assume that it really wasn't compiled, and hence fail.
> 
> I guess the same problem arises for loop devices and all such virtual
> devices...

So? Nobody knows, or nobody cares?

Samuel

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

* Re: How should an application ask for uinput module load?
  2006-03-28 19:42 How should an application ask for uinput module load? Samuel Thibault
  2006-03-29 22:01 ` Samuel Thibault
@ 2006-04-25 17:54 ` Dmitry Torokhov
  1 sibling, 0 replies; 3+ messages in thread
From: Dmitry Torokhov @ 2006-04-25 17:54 UTC (permalink / raw)
  To: Samuel Thibault, linux-kernel, dave

On 3/28/06, Samuel Thibault <samuel.thibault@ens-lyon.org> wrote:
> Hi,
>
> Given a freshly booted linux box, hence uinput is not loaded (why would
> it be, it doesn't drive any real hardware) ; what is the right way(tm)
> for an application to have the uinput module loaded, so that it can open
> /dev/input/uinput for emulating keypresses?
>
> - With good-old static /dev, we could just open /dev/input/uinput
>  (installed by the distribution), and thanks to a
>  alias char-major-10-223 uinput
>  line somewhere in /etc/modprobe.d, uinput finally gets auto-loaded.
>
> - With devfs, it doesn't look like it works (/dev/misc/uinput is not
>  present and opening it just like if it existed doesn't work). But I
>  read in archives that it could be feasible.
>
> - With udev, this just cannot work. As explained in an earlier thread,
>  even using a special filesystem that would report the opening attempt
>  to udevd wouldn't work fine since udevd takes time for creating the
>  device, and hence the original program needs to be notified ; this
>  becomes racy.
>
> So what is the correct way to do it? I can see two approaches:
>
> Using modprobe:
> - try to use /dev/input/uinput ; if it succeeds, fine.
> - else, if errno != ENOENT, fail
> - else, (ENOENT)
>  - try to call `cat /proc/sys/kernel/modprobe` uinput
>  - try to use /dev/input/uinput again ; if it succeeds, fine
>    - else, assume that it really wasn't compiled, and hence fail.
>
> Triggering auto-load by creating one's own node.
> - try to use /dev/input/uinput ; if it suceeds, fine.
> - else, if errno != ENOENT, fail
> - else, (ENOENT)
>  - mknod /somewhere/safe/uinput c 10 223
>  - use /somewhere/safe/uinput ; if it succeeds, fine
>    - else, assume that it really wasn't compiled, and hence fail.
>
> I guess the same problem arises for loop devices and all such virtual
> devices...
>

Hi Samuel,

I am not sure about loop devices but for uinput there is most likely a
daemon that needs to be started so I would just load the module
(modprobe uinput) right from the same script that starts the daemon.
You do not need to check if module has already been loaded, just try
loading it unconditionally and use /dev/input/uinput.

--
Dmitry

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

end of thread, other threads:[~2006-04-25 17:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-28 19:42 How should an application ask for uinput module load? Samuel Thibault
2006-03-29 22:01 ` Samuel Thibault
2006-04-25 17:54 ` Dmitry Torokhov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®