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

Robert Millan rmh at alioth.debian.org
Sat Jun 18 14:52:40 UTC 2011


Author: rmh
Date: 2011-06-18 14:52:40 +0000 (Sat, 18 Jun 2011)
New Revision: 3469

Added:
   trunk/glibc-ports/kfreebsd/getosreldate.c
   trunk/glibc-ports/kfreebsd/getvfsbyname.c
Modified:
   trunk/glibc-ports/kfreebsd/Makefile
   trunk/glibc-ports/kfreebsd/Versions
Log:
Add getvfsbyname() and getosreldate() (stolen from FreeBSD HEAD).  (Closes: #629556)

Modified: trunk/glibc-ports/kfreebsd/Makefile
===================================================================
--- trunk/glibc-ports/kfreebsd/Makefile	2011-06-18 14:50:44 UTC (rev 3468)
+++ trunk/glibc-ports/kfreebsd/Makefile	2011-06-18 14:52:40 UTC (rev 3469)
@@ -58,7 +58,7 @@
 # For <sched.h>.
 sysdep_routines += clone start_thread
 # For <unistd.h>.
-sysdep_routines += nfssvc nlm_syscall sys_ftruncate sys_freebsd6_ftruncate sys_truncate sys_freebsd6_truncate
+sysdep_routines += getosreldate nfssvc nlm_syscall sys_ftruncate sys_freebsd6_ftruncate sys_truncate sys_freebsd6_truncate
 # For <sys/acl.h>.
 sysdep_routines += acl_aclcheck_fd acl_aclcheck_file acl_delete_fd acl_delete_file acl_get_fd acl_get_file acl_set_fd acl_set_file
 # For <sys/extattr.h>.
@@ -72,7 +72,7 @@
 # For <sys/mman.h>.
 sysdep_routines += minherit sys_mmap sys_freebsd6_mmap sys_munmap
 # For <sys/mount.h>.
-sysdep_routines += fhopen sys_fhstat sys_fhstatfs fhstat fhstat64 fhstatfs fhstatfs64 getfh getfsstat getfsstat64 sys_getfsstat getmntinfo getmntinfo64 mount nmount unmount
+sysdep_routines += fhopen sys_fhstat sys_fhstatfs fhstat fhstat64 fhstatfs fhstatfs64 getfh getfsstat getfsstat64 getvfsbyname sys_getfsstat getmntinfo getmntinfo64 mount nmount unmount
 # For <sys/rfork.h>.
 sysdep_routines += rfork
 # For <sys/rtprio.h>.

Modified: trunk/glibc-ports/kfreebsd/Versions
===================================================================
--- trunk/glibc-ports/kfreebsd/Versions	2011-06-18 14:50:44 UTC (rev 3468)
+++ trunk/glibc-ports/kfreebsd/Versions	2011-06-18 14:52:40 UTC (rev 3469)
@@ -93,6 +93,10 @@
     _sys_errlist; sys_errlist; _sys_nerr; sys_nerr;
   }
   GLIBC_2.13 {
+    # g*
+    getosreldate;
+    getvfsbyname;
+
     # j*
     jail_attach;
     jail_remove;

Added: trunk/glibc-ports/kfreebsd/getosreldate.c
===================================================================
--- trunk/glibc-ports/kfreebsd/getosreldate.c	                        (rev 0)
+++ trunk/glibc-ports/kfreebsd/getosreldate.c	2011-06-18 14:52:40 UTC (rev 3469)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 1989, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stddef.h>
+#include <sys/sysctl.h>
+#include <stdlib.h>
+
+int
+__getosreldate(void)
+{
+	int mib[2];
+	size_t size;
+	int value;
+	char *temp;
+
+	if ((temp = getenv("OSVERSION"))) {
+		value = atoi(temp);
+		return (value);
+	}
+
+	mib[0] = CTL_KERN;
+	mib[1] = KERN_OSRELDATE;
+	size = sizeof value;
+	if (sysctl(mib, 2, &value, &size, NULL, 0) == -1)
+		return (-1);
+	return (value);
+}
+weak_alias (__getosreldate, getosreldate)

Added: trunk/glibc-ports/kfreebsd/getvfsbyname.c
===================================================================
--- trunk/glibc-ports/kfreebsd/getvfsbyname.c	                        (rev 0)
+++ trunk/glibc-ports/kfreebsd/getvfsbyname.c	2011-06-18 14:52:40 UTC (rev 3469)
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 1995
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stddef.h>
+#include <sys/mount.h>
+#include <sys/sysctl.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+
+/*
+ * Given a filesystem name, determine if it is resident in the kernel,
+ * and if it is resident, return its xvfsconf structure.
+ */
+int
+__getvfsbyname(fsname, vfcp)
+	const char *fsname;
+	struct xvfsconf *vfcp;
+{
+	struct xvfsconf *xvfsp;
+	size_t buflen;
+	int cnt, i;
+
+	if (sysctlbyname("vfs.conflist", NULL, &buflen, NULL, 0) < 0)
+		return (-1);
+	xvfsp = malloc(buflen);
+	if (xvfsp == NULL)
+		return (-1);
+	if (sysctlbyname("vfs.conflist", xvfsp, &buflen, NULL, 0) < 0) {
+		free(xvfsp);
+		return (-1);
+	}
+	cnt = buflen / sizeof(struct xvfsconf);
+	for (i = 0; i < cnt; i++) {
+		if (strcmp(fsname, xvfsp[i].vfc_name) == 0) {
+			memcpy(vfcp, xvfsp + i, sizeof(struct xvfsconf));
+			free(xvfsp);
+			return (0);
+		}
+	}
+	free(xvfsp);
+	__set_errno (ENOENT);
+	return (-1);
+}
+weak_alias (__getvfsbyname, getvfsbyname)




More information about the Glibc-bsd-commits mailing list