3

Is there a way to read contents /proc/bus/input/devices programmatically using some sysfs structures ?

I know I can parse the file and get values. But I am looking if there is a better method.

Monku
  • 2,440
  • 4
  • 33
  • 57

1 Answers1

0

There is. You can use libsysfs. Here is paper from IBM about it's API etc. - Libsysfs - a programming interface to gather device information in Linux

That being said, it is discouraged by Linux kernel developers - Rules on how to access information in the Linux kernel sysfs

Do not use libsysfs It makes assumptions about sysfs which are not true. Its API does not offer any abstraction, it exposes all the kernel driver-core implementation details in its own API. Therefore it is not better than reading directories and opening the files yourself. Also, it is not actively maintained, in the sense of reflecting the current kernel development. The goal of providing a stable interface to sysfs has failed; it causes more problems than it solves. It violates many of the rules in this document.

Krystian Sakowski
  • 1,613
  • 14
  • 20
  • If it's not recommended probably wouldn't use it then. But do thanks for sharing the link. It's indeed informative – Monku Apr 16 '17 at 01:38