简体   繁体   中英

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). 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. For example, see /sys/class/net/eth0/statistics

There are many examples in Linux under drivers/net directory.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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