gpt4 book ai didi

linux - 以编程方式读取 "/proc/bus/input/devices"

转载 作者:太空狗 更新时间:2023-10-29 12:41:12 24 4
gpt4 key购买 nike

有没有办法使用一些 sysfs 结构以编程方式读取内容 /proc/bus/input/devices

我知道我可以解析文件并获取值。但我正在寻找是否有更好的方法。

最佳答案

有。您可以使用 libsysfs。这是 IBM 关于它的 API 等的论文 - Libsysfs - a programming interface to gather device information in Linux

话虽如此,Linux 内核开发人员并不鼓励这样做 - 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.

关于linux - 以编程方式读取 "/proc/bus/input/devices",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43336396/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com