简体   繁体   English

将数据从struct net_device_stats复制到用户空间

[英]Copying data from struct net_device_stats to user space

I would like to have a little help with this problem, I need to copy data from the struct net_device_stats of eth0 to userspace to show it to the user.I know I should be doing this with a system call and some people recommended me to make a function that receives a pointer to net_device_stats, and then use the function struct net_device_stats *(*get_stats)(struct net_device *dev). 我想对这个问题有所帮助,我需要将数据从eth0的net_device_stats结构复制到用户空间以显示给用户。我知道我应该通过系统调用来完成此操作,有人建议我这样做一个函数,该函数接收指向net_device_stats的指针,然后使用函数struct net_device_stats *(* get_stats)(struct net_device * dev)。 I don't have much idea of this so I would like to hear tips and recommendations from you about how to approach this problem and what should I have in mind 我对此没有太多想法,所以我想听听您的提示和建议,以了解如何解决此问题以及我应注意的事项

Sorry for my vague English and thank you, if I shouldn't be asking this here please tell me. 对不起,我英语含糊,谢谢。如果我不应该在这里问这个问题,请告诉我。

If I understand you correctly, you should use sysfs for that. 如果我理解正确,则应使用sysfs。 For example, see /sys/class/net/eth0/statistics 例如,请参见/ sys / class / net / eth0 / statistics

There are many examples in Linux under drivers/net directory. 在Linux中,drivers / net目录下有很多示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM