[Glibc-bsd-commits] r2668 - trunk/glibc-ports/kfreebsd

Aurelien Jarno aurel32 at alioth.debian.org
Fri Jul 24 16:22:06 UTC 2009


Author: aurel32
Date: 2009-07-24 16:22:05 +0000 (Fri, 24 Jul 2009)
New Revision: 2668

Added:
   trunk/glibc-ports/kfreebsd/sysctlnametomib.c
Modified:
   trunk/glibc-ports/kfreebsd/Makefile
   trunk/glibc-ports/kfreebsd/sysctlbyname.c
Log:
Add sysctlnametomib() as on plain FreeBSD. Currently this is provided by
libfreebsd.


Modified: trunk/glibc-ports/kfreebsd/Makefile
===================================================================
--- trunk/glibc-ports/kfreebsd/Makefile	2009-07-24 14:29:49 UTC (rev 2667)
+++ trunk/glibc-ports/kfreebsd/Makefile	2009-07-24 16:22:05 UTC (rev 2668)
@@ -79,7 +79,7 @@
 # For <sys/socket.h>.
 sysdep_routines += bsd_sendfile
 # For <sys/sysctl.h>.
-sysdep_routines += sysctl sysctlbyname
+sysdep_routines += sysctl sysctlbyname sysctlnametomib
 # For <sys/uio.h>.
 sysdep_routines += sys_readv sys_writev
 # Other.

Modified: trunk/glibc-ports/kfreebsd/sysctlbyname.c
===================================================================
--- trunk/glibc-ports/kfreebsd/sysctlbyname.c	2009-07-24 14:29:49 UTC (rev 2667)
+++ trunk/glibc-ports/kfreebsd/sysctlbyname.c	2009-07-24 16:22:05 UTC (rev 2668)
@@ -27,13 +27,7 @@
   int request[CTL_MAXNAME];
   size_t requestlen = sizeof (request);
 
-  /* Convert the string NAME to a binary encoded request.  The kernel
-     contains a routine for doing this, called "name2oid".  But the way
-     to call it is a little bit strange.  */
-  int name2oid_request[2] = { 0, 3 };
-  if (__sysctl (name2oid_request, 2, request, &requestlen,
-		(void *) name, strlen (name))
-      < 0)
+  if (__sysctlnametomib(name, request, &requestlen) < 0)
     return -1;
 
   /* Now call sysctl using the binary encoded request.  */

Added: trunk/glibc-ports/kfreebsd/sysctlnametomib.c
===================================================================
--- trunk/glibc-ports/kfreebsd/sysctlnametomib.c	                        (rev 0)
+++ trunk/glibc-ports/kfreebsd/sysctlnametomib.c	2009-07-24 16:22:05 UTC (rev 2668)
@@ -0,0 +1,37 @@
+/* Copyright (C) 2009 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <sys/types.h>
+#include <sys/sysctl.h>
+#include <string.h>
+
+int
+__sysctlnametomib (const char *name, int *mibp, size_t *sizep)
+{
+  int request[CTL_MAXNAME];
+  size_t requestlen = sizeof (request);
+
+  /* Convert the string NAME to a binary encoded request.  The kernel
+     contains a routine for doing this, called "name2oid".  But the way
+     to call it is a little bit strange.  */
+  int name2oid_request[2] = { 0, 3 };
+  return __sysctl (name2oid_request, 2, mibp, sizep, (void *) name, 
+		   strlen (name));
+}
+
+weak_alias (__sysctlnametomib, sysctlnametomib)




More information about the Glibc-bsd-commits mailing list