On Sun, Jan 22, 2006 at 12:24:10PM -0800, David S. Miller ([EMAIL PROTECTED])
wrote:
> 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.
Argh, I see.
Then probably it could be possible to keep a track from application and it's
table into socket
structure. Or run through all possible descriptors.
Or create some "request" from those application, which wants such a
notifier, keep it in some structure in a socket.
Or just register a wait_queue_t entry in the given socket's sk_sleep
head...
--
Evgeniy Polyakov
-
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