linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Export sockfd_lookup function
@ 2002-10-14 20:45 Maksim (Max) Krasnyanskiy
  2002-10-14 21:01 ` Alexander Viro
  0 siblings, 1 reply; 5+ messages in thread
From: Maksim (Max) Krasnyanskiy @ 2002-10-14 20:45 UTC (permalink / raw)
  To: linux-kernel; +Cc: davem


Can we export sockfd_lookup function ?
I need it in one of the Bluetooth modules which has to look up 'struct socket'
from fd in the ioctl handler.

Here is the patch

----------
# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
#                  ChangeSet    1.741   -> 1.742
#               net/socket.c    1.29    -> 1.30
#        include/linux/net.h    1.4     -> 1.5
#              net/netsyms.c    1.29    -> 1.30
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 02/10/13      maxk@qualcomm.com       1.742
# Export sockfd_lookup and sockfd_put functions
# --------------------------------------------
#
diff -Nru a/include/linux/net.h b/include/linux/net.h
--- a/include/linux/net.h       Sun Oct 13 05:05:42 2002
+++ b/include/linux/net.h       Sun Oct 13 05:05:42 2002
@@ -139,6 +139,9 @@
                                   const struct iovec * iov, long count, 
long size);
  extern int     sock_map_fd(struct socket *sock);

+extern struct socket *sockfd_lookup(int fd, int *err);
+#define         sockfd_put(sock) fput(sock->file)
+
  extern int     net_ratelimit(void);
  extern unsigned long net_random(void);
  extern void net_srandom(unsigned long);
diff -Nru a/net/netsyms.c b/net/netsyms.c
--- a/net/netsyms.c     Sun Oct 13 05:05:42 2002
+++ b/net/netsyms.c     Sun Oct 13 05:05:42 2002
@@ -161,6 +161,7 @@
  EXPORT_SYMBOL(sock_kmalloc);
  EXPORT_SYMBOL(sock_kfree_s);
  EXPORT_SYMBOL(sock_map_fd);
+EXPORT_SYMBOL(sockfd_lookup);

  #ifdef CONFIG_FILTER
  EXPORT_SYMBOL(sk_run_filter);
diff -Nru a/net/socket.c b/net/socket.c
--- a/net/socket.c      Sun Oct 13 05:05:42 2002
+++ b/net/socket.c      Sun Oct 13 05:05:42 2002
@@ -447,11 +447,6 @@
         return sock;
  }

-extern __inline__ void sockfd_put(struct socket *sock)
-{
-       fput(sock->file);
-}
-
  /**
   *     sock_alloc      -       allocate a socket
   *
-------------

Note. sockfd_put is #define instead of inline because fput() definition
is not available at this point.



Max

http://bluez.sf.net
http://vtun.sf.net


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Export sockfd_lookup function
  2002-10-14 20:45 [PATCH] Export sockfd_lookup function Maksim (Max) Krasnyanskiy
@ 2002-10-14 21:01 ` Alexander Viro
  2002-10-14 22:00   ` Maksim (Max) Krasnyanskiy
  0 siblings, 1 reply; 5+ messages in thread
From: Alexander Viro @ 2002-10-14 21:01 UTC (permalink / raw)
  To: Maksim (Max) Krasnyanskiy; +Cc: linux-kernel, davem



On Mon, 14 Oct 2002, Maksim (Max) Krasnyanskiy wrote:

> 
> Can we export sockfd_lookup function ?
> I need it in one of the Bluetooth modules which has to look up 'struct socket'
> from fd in the ioctl handler.

What the hell does that ioctl do with file descriptors in the first place?


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Export sockfd_lookup function
  2002-10-14 21:01 ` Alexander Viro
@ 2002-10-14 22:00   ` Maksim (Max) Krasnyanskiy
  0 siblings, 0 replies; 5+ messages in thread
From: Maksim (Max) Krasnyanskiy @ 2002-10-14 22:00 UTC (permalink / raw)
  To: Alexander Viro; +Cc: linux-kernel, davem

At 05:01 PM 10/14/2002 -0400, Alexander Viro wrote:


>On Mon, 14 Oct 2002, Maksim (Max) Krasnyanskiy wrote:
>
> >
> > Can we export sockfd_lookup function ?
> > I need it in one of the Bluetooth modules which has to look up 'struct 
> socket'
> > from fd in the ioctl handler.
>
>What the hell does that ioctl do with file descriptors in the first place?
What is so unusual in dealing with file descriptors in ioctl ?

Anyway, that ioctl takes file descriptor, finds struct socket and starts 
kernel
thread, struct socket is then used in that kernel thread 
(sock->ops->sendmsg, etc).
Take a look in net/bluetooth/bnep/sock.c:bnep_sock_ioctl() if you're 
interested.

Max


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Export sockfd_lookup function
@ 2002-10-15 21:31 Maksim (Max) Krasnyanskiy
  2002-10-15 21:26 ` David S. Miller
  0 siblings, 1 reply; 5+ messages in thread
From: Maksim (Max) Krasnyanskiy @ 2002-10-15 21:31 UTC (permalink / raw)
  To: davem; +Cc: linux-kernel

Dave,

Any comments on that one ?

>Can we export sockfd_lookup function ?
>I need it in one of the Bluetooth modules which has to look up 'struct socket'
>from fd in the ioctl handler.
>
>Here is the patch

----------
# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
#                  ChangeSet    1.741   -> 1.742
#               net/socket.c    1.29    -> 1.30
#       include/linux/net.h     1.4     -> 1.5
#              net/netsyms.c    1.29    -> 1.30
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 02/10/13      maxk@qualcomm.com       1.742
# Export sockfd_lookup and sockfd_put functions
# --------------------------------------------
#
diff -Nru a/include/linux/net.h b/include/linux/net.h
--- a/include/linux/net.h       Sun Oct 13 05:05:42 2002
+++ b/include/linux/net.h       Sun Oct 13 05:05:42 2002
@@ -139,6 +139,9 @@
                                   const struct iovec * iov, long count, 
long size);
  extern int     sock_map_fd(struct socket *sock);

+extern struct socket *sockfd_lookup(int fd, int *err);
+#define         sockfd_put(sock) fput(sock->file)
+
  extern int     net_ratelimit(void);
  extern unsigned long net_random(void);
  extern void net_srandom(unsigned long);
diff -Nru a/net/netsyms.c b/net/netsyms.c
--- a/net/netsyms.c     Sun Oct 13 05:05:42 2002
+++ b/net/netsyms.c     Sun Oct 13 05:05:42 2002
@@ -161,6 +161,7 @@
  EXPORT_SYMBOL(sock_kmalloc);
  EXPORT_SYMBOL(sock_kfree_s);
  EXPORT_SYMBOL(sock_map_fd);
+EXPORT_SYMBOL(sockfd_lookup);

  #ifdef CONFIG_FILTER
  EXPORT_SYMBOL(sk_run_filter);
diff -Nru a/net/socket.c b/net/socket.c
--- a/net/socket.c      Sun Oct 13 05:05:42 2002
+++ b/net/socket.c      Sun Oct 13 05:05:42 2002
@@ -447,11 +447,6 @@
         return sock;
  }

-extern __inline__ void sockfd_put(struct socket *sock)
-{
-       fput(sock->file);
-}
-
  /**
   *     sock_alloc      -       allocate a socket
   *
-------------

Note. sockfd_put is #define instead of inline because fput() definition
is not available at this point.



Max

http://bluez.sf.net
http://vtun.sf.net


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Export sockfd_lookup function
  2002-10-15 21:31 Maksim (Max) Krasnyanskiy
@ 2002-10-15 21:26 ` David S. Miller
  0 siblings, 0 replies; 5+ messages in thread
From: David S. Miller @ 2002-10-15 21:26 UTC (permalink / raw)
  To: maxk; +Cc: linux-kernel

   From: "Maksim (Max) Krasnyanskiy" <maxk@qualcomm.com>
   Date: Tue, 15 Oct 2002 14:31:32 -0700
   
   Any comments on that one ?

I'm pretty sure I'll apply it.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2002-10-15 21:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-14 20:45 [PATCH] Export sockfd_lookup function Maksim (Max) Krasnyanskiy
2002-10-14 21:01 ` Alexander Viro
2002-10-14 22:00   ` Maksim (Max) Krasnyanskiy
2002-10-15 21:31 Maksim (Max) Krasnyanskiy
2002-10-15 21:26 ` David S. Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).