From: Evgeniy Polyakov <[EMAIL PROTECTED]> Date: Sat, 21 Jan 2006 13:15:49 +0300
> On Fri, Jan 20, 2006 at 05:06:36PM -0600, Christopher Friesen ([EMAIL > PROTECTED]) wrote: > > > > I've been asked if there is any way to map a "struct socket *" in > > kernelspace, to the userspace fd that corresponds to it. > > > > I came up with looping through current->files->fd[i] and matching it > > against socket->file--if they match then "i" is the fd. > > > > Is there a better way? > > struct file *file = fget(fd)/fget_light(fd); > struct inode *inode = igrab(file->f_dentry->d_inode); > struct socket *socket = SOCKET_I(inode); He wants to go the other direction, from socket to file descriptor. Typically people doing this are implementing desktop notifiers for socket activity and stuff like that in order to fill in a feature checkbox that Windows happens to have... In my opinion, such things have little sense because of the one to many mapping from sockets to filedescriptors. Which app gets to make a decision or get the notifier? There is no good clean answer to that question. - To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html