get device from file struct
quick question for the gurus.. is it possible to determine the hardware device from a file struct during read/write system call. For example in fs/read_write.c when doing a vfs_read.
thanks
Quoted 4 lines · Silviu Craciunas
quick question for the gurus.. is it possible to determine the hardware device from a file struct during read/write system call. For example in
fs/read_write.cwhen doing avfs_read.
file->f_dentry->d_inode gives you the inode. If the inode is on top of a block device, inode->i_bdev gives you a struct block_device that might help you.
Brice
Quoted 11 lines · Brice Goglin
Quoted 4 lines · Silviu Craciunas
quick question for the gurus.. is it possible to determine the hardware device from a file struct during read/write system call. For example in
fs/read_write.cwhen doing avfs_read.
file->f_dentry->d_inodegives you the inode. If the inode is on top of a block device,inode->i_bdevgives you a structblock_devicethat might help you.Brice
thanks for the reply, the block device can be determined with the major and minor numbers , what I would be more interested in is if one can get the net_device struct from the file struct
silviu
Quoted 4 lines
thanks for the reply, the block device can be determined with the major and minor numbers , what I would be more interested in is if one can get the
net_devicestruct from the file struct
Just how are you supposed to match files and network devices?
-`J'
Quoted 8 lines · Jan Engelhardt
Quoted 3 lines
thanks for the reply, the block device can be determined with the major and minor numbers , what I would be more interested in is if one can get the
net_devicestruct from the file structJust how are you supposed to match files and network devices?
-`J'
from the struct file you can get the struct socket and from there to the struct sock . What I would like to find out is where the data is coming from (read) and where it is going to(write) or if it is even possible to find the net device out using the struct file.
Silviu
Quoted 10 lines
Quoted 7 lines
Quoted 4 lines
thanks for the reply, the block device can be determined with the major and minor numbers , what I would be more interested in is if one can get the
net_devicestruct from the file structJust how are you supposed to match files and network devices?
from the struct file you can get the struct socket and from there to the struct sock .
That only applies when using PF_LOCAL sockets.
Quoted 3 lines
What I would like to find out is where the data is coming from (read) and where it is going to(write) or if it is even possible to find the net device out using the struct file.
I really don't get what you want.
Suppose a daemon reads from a socket (PF_INET), then there is a file descriptor to sockfs (look into /proc/$$/fd/). Well, then you may be able to get the struct file for that socket, but it does not connect to a regular file (S_IFREG) at all.
-`J'
Quoted 18 lines · Jan Engelhardt
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
thanks for the reply, the block device can be determined with the major and minor numbers , what I would be more interested in is if one can get the
net_devicestruct from the file structJust how are you supposed to match files and network devices?
from the struct file you can get the struct socket and from there to the struct sock .
That only applies when using
PF_LOCALsockets.Quoted 3 lines
What I would like to find out is where the data is coming from (read) and where it is going to(write) or if it is even possible to find the net device out using the struct file.
I really don't get what you want.
Quoted 7 lines
Suppose a daemon reads from a socket (
PF_INET), then there is a file descriptor to sockfs (look into/proc/$$/fd/). Well, then you may be able to get the struct file for that socket, but it does not connect to a regular file (S_IFREG) at all.-`J'
in fs/read_write.c, the vfs_read function does:
file->f_op->read(file, buf, count, pos);
after this call is it possible to determine where the data is coming from? e.g., the first hard disk, a pipe or from a socket. If it is a socket we are interested from which device (eth0, eth1, lo, ...) the data was received.
silviu
Quoted 8 lines
in
fs/read_write.c, thevfs_readfunction does:
file->f_op->read(file, buf, count, pos);after this call is it possible to determine where the data is coming from?
e.g., the first hard disk, a pipe or from a socket.
For hard disks:
file->f_dentry->d_inode->d_sb->s_bdev gives you the block device in case it is a non-virtual filesystem.
For pipes/sockets I do not know of a may to go from a filp to a struct sock or struct socket.
Quoted 2 lines
If it is a socket we are interested
from which device (eth0, eth1, lo, ...) the data was received.
I do not think that is possible either.
-`J'
Quoted 13 lines · On Wed, 13 Dec 2006 20:19:51 +0100 (MET) Jan Engelhardt…
Quoted 8 lines
in
fs/read_write.c, thevfs_readfunction does:
file->f_op->read(file, buf, count, pos);after this call is it possible to determine where the data is coming from?
e.g., the first hard disk, a pipe or from a socket.For hard disks:
file->f_dentry->d_inode->d_sb->s_bdevgives you the block device in case it is a non-virtual filesystem.
Quoted 7 lines
For pipes/sockets I do not know of a may to go from a filp to a struct sock or struct socket.
Quoted 2 lines
If it is a socket we are interested
from which device (eth0, eth1, lo, ...) the data was received.I do not think that is possible either.
The connection between file and network device is through many layers and there is no direct binding. It could be 0 to N interfaces and even be data dependent.
Signature · 1 line
Stephen Hemminger <[email protected]>
Quoted 3 lines · Stephen Hemminger
The connection between file and network device is through many layers and there is no direct binding. It could be 0 to N interfaces and even be data dependent.
you mean protocol dependent? yes,it goes trough the layer of the vfs but I thought there may be a way to get to the struct net_device from the struct file. You have the dev_base which contains all devices and in the net_device there is the ifindex which is the unique identifier. I guess there is no way to know the ifindex directly from a socket struct.
thanks
silviu
Quoted 5 lines · On Thu, 14 Dec 2006 14:03:28 +0100 Silviu Craciunas…
Quoted 3 lines · Stephen Hemminger
The connection between file and network device is through many layers and there is no direct binding. It could be 0 to N interfaces and even be data dependent.
Quoted 9 lines
you mean protocol dependent? yes,it goes trough the layer of the vfs but I thought there may be a way to get to the struct
net_devicefrom the struct file. You have thedev_basewhich contains all devices and in thenet_devicethere is the ifindex which is the unique identifier. I guess there is no way to know the ifindex directly from a socket struct.thanks
silviu
You can have things like netfilter and traffic classifiers that look at packet.
Signature · 1 line
Stephen Hemminger <[email protected]>