bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Implement getsockopt (fd, SOL_SOCKET, SO_TYPE, ...)


From: Emilio Pozuelo Monfort
Subject: Re: [PATCH] Implement getsockopt (fd, SOL_SOCKET, SO_TYPE, ...)
Date: Thu, 15 Jul 2010 17:15:25 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.10) Gecko/20100619 Icedove/3.0.5

On 15/07/10 17:05, Emilio Pozuelo Monfort wrote:
> On 15/07/10 16:49, Emilio Pozuelo Monfort wrote:
>> Here it goes, with a good commit message:
> 
> Forgot to add the file before committing :(

Also check that the buffer is big enough.

>From 4adb3ab202d945139555a325460fc4a39f774e26 Mon Sep 17 00:00:00 2001
From: Emilio Pozuelo Monfort <address@hidden>
Date: Wed, 14 Jul 2010 18:40:36 +0200
Subject: [PATCH] Implement getsockopt (SO_TYPE)

        * pflocal/socket.c (S_socket_getopt): Add SO_TYPE support.
---
 pflocal/socket.c |   23 ++++++++++++++++++++---
 1 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/pflocal/socket.c b/pflocal/socket.c
index 06777ca..9ebe05c 100644
--- a/pflocal/socket.c
+++ b/pflocal/socket.c
@@ -1,6 +1,6 @@
 /* Socket-specific operations

-   Copyright (C) 1995, 2008 Free Software Foundation, Inc.
+   Copyright (C) 1995, 2008, 2010 Free Software Foundation, Inc.

    Written by Miles Bader <address@hidden>

@@ -410,14 +410,31 @@ S_socket_recv (struct sock_user *user,

   return err;
 }
-

-/* Stubs for currently unsupported rpcs.  */

 error_t
 S_socket_getopt (struct sock_user *user,
                 int level, int opt,
                 char **value, size_t *value_len)
 {
+  switch (level)
+    {
+    case SOL_SOCKET:
+      switch (opt)
+       {
+       case SO_TYPE:
+         if (value_len == NULL || value == NULL || *value == NULL
+           || value_len < sizeof (user->sock->pipe_class->sock_type))
+           return EINVAL;
+         *(int*)*value = user->sock->pipe_class->sock_type;
+         *value_len = sizeof (user->sock->pipe_class->sock_type);
+         return 0;
+       default:
+         break;
+       }
+    default:
+      break;
+    }
+
   return EOPNOTSUPP;
 }

-- 
1.7.1



reply via email to

[Prev in Thread] Current Thread [Next in Thread]