accessing data structure of eth0 from user space????
Linux - KernelThis forum is for all discussion relating to the Linux kernel.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
accessing data structure of eth0 from user space????
hi all,
i want to access the data structure corresponding to eth0 from user space,is it possible to do it thru a user space program??
i know i can do it thru struct net_device,in <linux/netdevice.h>,but this is possible only in kernel space.
can i do the same thing thru a user space program???
but i want to access the data structure(to be specific,the pointer to structure that contains details about eth0)
i dont want to write to the datastructure,i just want to display it.
but ONLY thru data structures.
thanx for reply
A text file, that contains the information you want, is a data structure (though a simple one). On Linux, the /proc and /sys filesystems are the userland interface to system data.
u mst be knowing that header file
#include <linux/netdevice.h> contains structure definition
struct net_device {
...
...
};
the pointer to structure eth0 is of type ' struct net_device'
i want to access this data structure from a user space program.
i DONT want to use data in /proc or /sys.
i just wanna know whether this is possible from a user space program??
i dont want to write a module(a kernel space module) to do taht work.
i m using a filesystem created by buildroot,which does nt have sysfs and /sys directory,so i wanna do it thru a user space program,i.e display the details of eth0.
i dont wanna use /proc details.
i hope u can get wot i wanna do
Not only is that area of memory off-limits to you, but there are timing-related issues as well. Your program executes in a virtual storage environment; hardware does not.
So you have to make a system-call that will copy what you want to know into a buffer in userland. By far the easiest way to do that is "/proc."
Ah now I get what you mean by structure (also have reread your posts).
You want access to the complete kernel object?
Well, its going be hard work eh!
The kernel space is separated from user space. Currently the kernel space provides "statistical output" to user space through proc filesystem. It also provides input from api like the one I mentionned.
But you can't easily access directly a kernel object from userspace (hence the procfs and sysfs philosophy for non-kernel developpers)
Either you modify your kernel by recoding the outputed information in procfs or you develop a kernel module (its harder that what you think because of what sundialsvcs said, concurrency, timing, sleeping ..) that will put a lock on the netdevice (or device list), read its fields and export them to userspace memory.
In general the ioctl gateway have sufficient information.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.