Get struct file from of a given struct socket in kernel space

I need to get the struct file that is associated with a specific struct socket. I saw in the kernel source, in the socket.c file, that there the function struct socket *sockfd_lookup(int fd, int *err), which given a fd returns the socket that this fd belongs to. Is there any way to do the opposite thing? i mean to take the fd of the struct socket. I need to do this in a loadable kernel module.

Thank you

Answers


socket struct has a member that is pointer back to its file struct. See linux/net.h struct socket definition


Does the file member of struct socket not hold what you're looking for?


Need Your Help

Write to Binary files in Java

java binary

I am trying to write a lot of data into a binary file. Because it is a lot of data, it is important that this is done fast and I want to be able to write the data as ints one by one. I have tried

Node.js server files above root directory

node.js

I have the following directory structure:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.