Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about register_keyboard_notifier #10

Closed
GuyOded opened this issue Feb 25, 2018 · 4 comments
Closed

Question about register_keyboard_notifier #10

GuyOded opened this issue Feb 25, 2018 · 4 comments

Comments

@GuyOded
Copy link

GuyOded commented Feb 25, 2018

Can you please share documentation about this function? Found none on the Internet...

@jarun jarun closed this as completed in 0b57776 Feb 25, 2018
@jarun
Copy link
Owner

jarun commented Feb 25, 2018

I have added a comment on what we are doing. You can find the function here:

https://elixir.bootlin.com/linux/v3.6/source/drivers/tty/vt/keyboard.c#L149

in brief, it adds a new notifier block (which has a callback function to be called when a console keyboard event happens) to a list of such blocks.

@jarun
Copy link
Owner

jarun commented Feb 25, 2018

And the notifier_block structure is here:

https://elixir.bootlin.com/linux/v3.6/source/include/linux/notifier.h#L50

@jarun
Copy link
Owner

jarun commented Feb 25, 2018

After reading your mail I realized you are trying to figure out keyboard_notifier_list.

See https://elixir.bootlin.com/linux/v3.6/source/drivers/tty/vt/keyboard.c#L143. Now ATOMIC_NOTIFIER_HEAD is a macro which is defined in

https://elixir.bootlin.com/linux/v3.6/source/include/linux/notifier.h#L103

It's a structure that initializes with an unlocked spinlock and a NULL head pointer. Once setup, when you call register_keyboard_notifier, the notifier_block struct you pass is set as the head of the list.

@jarun
Copy link
Owner

jarun commented Feb 25, 2018

When it's the kernel, in many cases you may really have to look into the code to figure out what's going on. On practice (and not necessarily on Linux kernel code only), it becomes simpler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants