From owner-svn-src-projects@FreeBSD.ORG Wed Jan 30 22:40:50 2013 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 09F13C39; Wed, 30 Jan 2013 22:40:50 +0000 (UTC) (envelope-from benno@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id CD5C1ADD; Wed, 30 Jan 2013 22:40:49 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r0UMenkr019210; Wed, 30 Jan 2013 22:40:49 GMT (envelope-from benno@svn.freebsd.org) Received: (from benno@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r0UMeiF2019171; Wed, 30 Jan 2013 22:40:44 GMT (envelope-from benno@svn.freebsd.org) Message-Id: <201301302240.r0UMeiF2019171@svn.freebsd.org> From: Benno Rice Date: Wed, 30 Jan 2013 22:40:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r246132 - in projects/uefi: . etc include lib/libc/amd64/sys lib/libc/arm/sys lib/libc/i386/sys lib/libc/ia64/sys lib/libc/mips/sys lib/libc/powerpc lib/libc/powerpc/sys lib/libc/powerp... X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Jan 2013 22:40:50 -0000 Author: benno Date: Wed Jan 30 22:40:43 2013 New Revision: 246132 URL: http://svnweb.freebsd.org/changeset/base/246132 Log: IFC Added: projects/uefi/lib/libc/arm/sys/__vdso_gettc.c - copied unchanged from r246131, head/lib/libc/arm/sys/__vdso_gettc.c projects/uefi/lib/libc/ia64/sys/__vdso_gettc.c - copied unchanged from r246131, head/lib/libc/ia64/sys/__vdso_gettc.c projects/uefi/lib/libc/mips/sys/__vdso_gettc.c - copied unchanged from r246131, head/lib/libc/mips/sys/__vdso_gettc.c projects/uefi/lib/libc/powerpc/sys/__vdso_gettc.c - copied unchanged from r246131, head/lib/libc/powerpc/sys/__vdso_gettc.c projects/uefi/lib/libc/powerpc64/sys/__vdso_gettc.c - copied unchanged from r246131, head/lib/libc/powerpc64/sys/__vdso_gettc.c projects/uefi/lib/libc/sparc64/sys/__vdso_gettc.c - copied unchanged from r246131, head/lib/libc/sparc64/sys/__vdso_gettc.c projects/uefi/lib/libc/stdio/fmemopen.c - copied unchanged from r246131, head/lib/libc/stdio/fmemopen.c projects/uefi/sys/dev/usb/usb_freebsd_loader.h - copied unchanged from r246131, head/sys/dev/usb/usb_freebsd_loader.h projects/uefi/tools/regression/lib/libc/stdio/test-fmemopen.c - copied unchanged from r246131, head/tools/regression/lib/libc/stdio/test-fmemopen.c projects/uefi/tools/regression/lib/libc/stdio/test-fmemopen.t - copied unchanged from r246131, head/tools/regression/lib/libc/stdio/test-fmemopen.t Modified: projects/uefi/UPDATING projects/uefi/etc/Makefile projects/uefi/include/stdio.h (contents, props changed) projects/uefi/lib/libc/amd64/sys/__vdso_gettc.c projects/uefi/lib/libc/arm/sys/Makefile.inc projects/uefi/lib/libc/i386/sys/__vdso_gettc.c projects/uefi/lib/libc/ia64/sys/Makefile.inc projects/uefi/lib/libc/mips/sys/Makefile.inc projects/uefi/lib/libc/powerpc/Makefile.inc projects/uefi/lib/libc/powerpc64/Makefile.inc projects/uefi/lib/libc/sparc64/Makefile.inc projects/uefi/lib/libc/stdio/Makefile.inc (contents, props changed) projects/uefi/lib/libc/stdio/Symbol.map (contents, props changed) projects/uefi/lib/libc/stdio/fopen.3 (contents, props changed) projects/uefi/lib/libc/sys/__vdso_gettimeofday.c projects/uefi/lib/libc/sys/gettimeofday.c projects/uefi/libexec/tftpd/tftp-io.c projects/uefi/sbin/devd/devd.8 projects/uefi/sbin/devd/devd.cc projects/uefi/share/mk/bsd.own.mk projects/uefi/sys/amd64/include/vmm_instruction_emul.h (contents, props changed) projects/uefi/sys/amd64/vmm/vmm_instruction_emul.c projects/uefi/sys/dev/acpi_support/acpi_asus_wmi.c projects/uefi/sys/dev/acpi_support/acpi_fujitsu.c (contents, props changed) projects/uefi/sys/dev/acpi_support/acpi_hp.c projects/uefi/sys/dev/acpi_support/acpi_ibm.c (contents, props changed) projects/uefi/sys/dev/acpi_support/acpi_panasonic.c (contents, props changed) projects/uefi/sys/dev/acpi_support/acpi_sony.c (contents, props changed) projects/uefi/sys/dev/acpi_support/acpi_toshiba.c (contents, props changed) projects/uefi/sys/dev/acpica/acpi.c (contents, props changed) projects/uefi/sys/dev/acpica/acpi_acad.c (contents, props changed) projects/uefi/sys/dev/acpica/acpi_button.c (contents, props changed) projects/uefi/sys/dev/acpica/acpi_cmbat.c (contents, props changed) projects/uefi/sys/dev/acpica/acpi_dock.c (contents, props changed) projects/uefi/sys/dev/acpica/acpi_ec.c (contents, props changed) projects/uefi/sys/dev/acpica/acpi_hpet.c (contents, props changed) projects/uefi/sys/dev/acpica/acpi_lid.c (contents, props changed) projects/uefi/sys/dev/acpica/acpi_pci.c (contents, props changed) projects/uefi/sys/dev/acpica/acpi_pci_link.c (contents, props changed) projects/uefi/sys/dev/acpica/acpi_pcib_pci.c (contents, props changed) projects/uefi/sys/dev/acpica/acpi_perf.c (contents, props changed) projects/uefi/sys/dev/acpica/acpi_resource.c (contents, props changed) projects/uefi/sys/dev/acpica/acpi_smbat.c (contents, props changed) projects/uefi/sys/dev/acpica/acpi_thermal.c (contents, props changed) projects/uefi/sys/dev/acpica/acpi_throttle.c (contents, props changed) projects/uefi/sys/dev/acpica/acpi_timer.c (contents, props changed) projects/uefi/sys/dev/adlink/adlink.c (contents, props changed) projects/uefi/sys/dev/amdsbwd/amdsbwd.c projects/uefi/sys/dev/amdtemp/amdtemp.c (contents, props changed) projects/uefi/sys/dev/auxio/auxio.c (contents, props changed) projects/uefi/sys/dev/ce/if_ce.c (contents, props changed) projects/uefi/sys/dev/cfi/cfi_bus_fdt.c projects/uefi/sys/dev/cfi/cfi_bus_ixp4xx.c projects/uefi/sys/dev/coretemp/coretemp.c (contents, props changed) projects/uefi/sys/dev/cp/if_cp.c (contents, props changed) projects/uefi/sys/dev/cpufreq/ichss.c (contents, props changed) projects/uefi/sys/dev/ctau/if_ct.c (contents, props changed) projects/uefi/sys/dev/cx/if_cx.c (contents, props changed) projects/uefi/sys/dev/digi/digi_isa.c (contents, props changed) projects/uefi/sys/dev/digi/digi_pci.c (contents, props changed) projects/uefi/sys/dev/e1000/if_em.c (contents, props changed) projects/uefi/sys/dev/e1000/if_igb.c (contents, props changed) projects/uefi/sys/dev/e1000/if_lem.c projects/uefi/sys/dev/ep/if_ep_eisa.c (contents, props changed) projects/uefi/sys/dev/ep/if_ep_isa.c (contents, props changed) projects/uefi/sys/dev/ep/if_ep_mca.c (contents, props changed) projects/uefi/sys/dev/ep/if_ep_pccard.c (contents, props changed) projects/uefi/sys/dev/fdc/fdc_acpi.c (contents, props changed) projects/uefi/sys/dev/iicbus/ad7418.c (contents, props changed) projects/uefi/sys/dev/iicbus/ds133x.c (contents, props changed) projects/uefi/sys/dev/iicbus/ds1672.c (contents, props changed) projects/uefi/sys/dev/iicbus/icee.c (contents, props changed) projects/uefi/sys/dev/ixgb/if_ixgb.c (contents, props changed) projects/uefi/sys/dev/ixgbe/ixgbe.c (contents, props changed) projects/uefi/sys/dev/ixgbe/ixv.c projects/uefi/sys/dev/mfi/mfi_cam.c (contents, props changed) projects/uefi/sys/dev/mn/if_mn.c (contents, props changed) projects/uefi/sys/dev/mxge/if_mxge.c (contents, props changed) projects/uefi/sys/dev/my/if_my.c (contents, props changed) projects/uefi/sys/dev/nvram2env/nvram2env.c (contents, props changed) projects/uefi/sys/dev/nxge/if_nxge.c (contents, props changed) projects/uefi/sys/dev/oce/oce_if.c (contents, props changed) projects/uefi/sys/dev/sdhci/sdhci_pci.c projects/uefi/sys/dev/sound/pci/emu10kx-midi.c (contents, props changed) projects/uefi/sys/dev/sound/pci/emu10kx-pcm.c (contents, props changed) projects/uefi/sys/dev/sound/pci/emu10kx.c (contents, props changed) projects/uefi/sys/dev/sound/sbus/cs4231.c (contents, props changed) projects/uefi/sys/dev/sound/usb/uaudio_pcm.c projects/uefi/sys/dev/usb/controller/at91dci.c projects/uefi/sys/dev/usb/controller/atmegadci.c projects/uefi/sys/dev/usb/controller/avr32dci.c projects/uefi/sys/dev/usb/controller/dwc_otg.c projects/uefi/sys/dev/usb/controller/ehci.c projects/uefi/sys/dev/usb/controller/musb_otg.c projects/uefi/sys/dev/usb/controller/ohci.c projects/uefi/sys/dev/usb/controller/uhci.c projects/uefi/sys/dev/usb/controller/usb_controller.c projects/uefi/sys/dev/usb/controller/uss820dci.c projects/uefi/sys/dev/usb/controller/xhci.c projects/uefi/sys/dev/usb/input/uhid.c projects/uefi/sys/dev/usb/input/ukbd.c projects/uefi/sys/dev/usb/input/ums.c projects/uefi/sys/dev/usb/misc/udbp.c projects/uefi/sys/dev/usb/misc/ufm.c projects/uefi/sys/dev/usb/net/if_cdce.c projects/uefi/sys/dev/usb/net/if_cue.c projects/uefi/sys/dev/usb/net/if_ipheth.c projects/uefi/sys/dev/usb/net/if_kue.c projects/uefi/sys/dev/usb/net/if_smsc.c projects/uefi/sys/dev/usb/storage/umass.c projects/uefi/sys/dev/usb/storage/urio.c projects/uefi/sys/dev/usb/storage/ustorage_fs.c projects/uefi/sys/dev/usb/template/usb_template.c projects/uefi/sys/dev/usb/template/usb_template_audio.c projects/uefi/sys/dev/usb/template/usb_template_cdce.c projects/uefi/sys/dev/usb/template/usb_template_kbd.c projects/uefi/sys/dev/usb/template/usb_template_modem.c projects/uefi/sys/dev/usb/template/usb_template_mouse.c projects/uefi/sys/dev/usb/template/usb_template_msc.c projects/uefi/sys/dev/usb/template/usb_template_mtp.c projects/uefi/sys/dev/usb/ufm_ioctl.h projects/uefi/sys/dev/usb/usb.h projects/uefi/sys/dev/usb/usb_busdma.c projects/uefi/sys/dev/usb/usb_busdma.h projects/uefi/sys/dev/usb/usb_compat_linux.c projects/uefi/sys/dev/usb/usb_core.c projects/uefi/sys/dev/usb/usb_core.h projects/uefi/sys/dev/usb/usb_debug.c projects/uefi/sys/dev/usb/usb_dev.c projects/uefi/sys/dev/usb/usb_dev.h projects/uefi/sys/dev/usb/usb_device.c projects/uefi/sys/dev/usb/usb_dynamic.c projects/uefi/sys/dev/usb/usb_endian.h projects/uefi/sys/dev/usb/usb_error.c projects/uefi/sys/dev/usb/usb_freebsd.h projects/uefi/sys/dev/usb/usb_generic.c projects/uefi/sys/dev/usb/usb_handle_request.c projects/uefi/sys/dev/usb/usb_hid.c projects/uefi/sys/dev/usb/usb_hub.c projects/uefi/sys/dev/usb/usb_ioctl.h projects/uefi/sys/dev/usb/usb_lookup.c projects/uefi/sys/dev/usb/usb_mbuf.c projects/uefi/sys/dev/usb/usb_msctest.c projects/uefi/sys/dev/usb/usb_parse.c projects/uefi/sys/dev/usb/usb_pci.h projects/uefi/sys/dev/usb/usb_pf.c projects/uefi/sys/dev/usb/usb_process.c projects/uefi/sys/dev/usb/usb_process.h projects/uefi/sys/dev/usb/usb_request.c projects/uefi/sys/dev/usb/usb_transfer.c projects/uefi/sys/dev/usb/usb_util.c projects/uefi/sys/dev/usb/usbdi.h projects/uefi/sys/dev/usb/usbhid.h projects/uefi/sys/dev/vx/if_vx_eisa.c (contents, props changed) projects/uefi/sys/dev/vx/if_vx_pci.c (contents, props changed) projects/uefi/sys/dev/vxge/vxge.c (contents, props changed) projects/uefi/sys/dev/xen/console/console.c projects/uefi/sys/kern/kern_exit.c projects/uefi/sys/netinet/libalias/alias.c projects/uefi/sys/sys/vdso.h projects/uefi/sys/x86/x86/tsc.c projects/uefi/tools/test/pthread_vfork/pthread_vfork_test.c projects/uefi/usr.sbin/bhyve/pci_emul.c projects/uefi/usr.sbin/bhyve/pci_emul.h projects/uefi/usr.sbin/bhyve/pci_virtio_net.c projects/uefi/usr.sbin/bhyve/virtio.h projects/uefi/usr.sbin/tcpdrop/tcpdrop.8 projects/uefi/usr.sbin/tcpdrop/tcpdrop.c Directory Properties: projects/uefi/ (props changed) projects/uefi/lib/libc/ (props changed) projects/uefi/sbin/ (props changed) projects/uefi/sys/ (props changed) projects/uefi/sys/amd64/vmm/ (props changed) projects/uefi/usr.sbin/bhyve/ (props changed) Modified: projects/uefi/UPDATING ============================================================================== --- projects/uefi/UPDATING Wed Jan 30 19:51:16 2013 (r246131) +++ projects/uefi/UPDATING Wed Jan 30 22:40:43 2013 (r246132) @@ -31,7 +31,7 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 10 as bsdpatch, being the GNU version the default patch. To inverse the logic and use the BSD-licensed one as default, while having the GNU version installed as gnupatch, rebuild - ans install world with the WITH_BSD_PATCH knob set. + and install world with the WITH_BSD_PATCH knob set. 20130118: The install(1) option -M has changed meaning and now takes an Modified: projects/uefi/etc/Makefile ============================================================================== --- projects/uefi/etc/Makefile Wed Jan 30 19:51:16 2013 (r246131) +++ projects/uefi/etc/Makefile Wed Jan 30 22:40:43 2013 (r246132) @@ -348,9 +348,10 @@ distrib-dirs: test "$$d" == "/" && d=""; \ d=${DISTBASE}$$d; \ shift; \ - ${ECHO} "${MTREE_CMD} -C -f $$m | sed s#^\.#.$$d# |" \ - "${METALOG.add}" ; \ - ${MTREE_CMD} -C -f $$m | sed s#^\.#.$$d# | ${METALOG.add} ; \ + ${ECHO} "${MTREE_CMD:N-W} -C -f $$m -K uname,gname | " \ + "sed s#^\.#.$$d# | ${METALOG.add}" ; \ + ${MTREE_CMD:N-W} -C -f $$m -K uname,gname | sed s#^\.#.$$d# | \ + ${METALOG.add} ; \ done; true .endif ${INSTALL_SYMLINK} usr/src/sys ${DESTDIR}/sys Modified: projects/uefi/include/stdio.h ============================================================================== --- projects/uefi/include/stdio.h Wed Jan 30 19:51:16 2013 (r246131) +++ projects/uefi/include/stdio.h Wed Jan 30 22:40:43 2013 (r246132) @@ -343,6 +343,7 @@ char *tempnam(const char *, const char * #endif #if __BSD_VISIBLE || __POSIX_VISIBLE >= 200809 +FILE *fmemopen(void * __restrict, size_t, const char * __restrict); ssize_t getdelim(char ** __restrict, size_t * __restrict, int, FILE * __restrict); int renameat(int, const char *, int, const char *); Modified: projects/uefi/lib/libc/amd64/sys/__vdso_gettc.c ============================================================================== --- projects/uefi/lib/libc/amd64/sys/__vdso_gettc.c Wed Jan 30 19:51:16 2013 (r246131) +++ projects/uefi/lib/libc/amd64/sys/__vdso_gettc.c Wed Jan 30 22:40:43 2013 (r246132) @@ -27,9 +27,11 @@ __FBSDID("$FreeBSD$"); #include +#include #include #include #include +#include "libc_private.h" static u_int __vdso_gettc_low(const struct vdso_timehands *th) @@ -41,9 +43,18 @@ __vdso_gettc_low(const struct vdso_timeh return (rv); } +#pragma weak __vdso_gettc u_int __vdso_gettc(const struct vdso_timehands *th) { return (th->th_x86_shift > 0 ? __vdso_gettc_low(th) : rdtsc32()); } + +#pragma weak __vdso_gettimekeep +int +__vdso_gettimekeep(struct vdso_timekeep **tk) +{ + + return (_elf_aux_info(AT_TIMEKEEP, tk, sizeof(*tk))); +} Modified: projects/uefi/lib/libc/arm/sys/Makefile.inc ============================================================================== --- projects/uefi/lib/libc/arm/sys/Makefile.inc Wed Jan 30 19:51:16 2013 (r246131) +++ projects/uefi/lib/libc/arm/sys/Makefile.inc Wed Jan 30 22:40:43 2013 (r246132) @@ -1,5 +1,7 @@ # $FreeBSD$ +SRCS+= __vdso_gettc.c + MDASM= Ovfork.S brk.S cerror.S pipe.S ptrace.S sbrk.S shmat.S sigreturn.S syscall.S # Don't generate default code for these syscalls: Copied: projects/uefi/lib/libc/arm/sys/__vdso_gettc.c (from r246131, head/lib/libc/arm/sys/__vdso_gettc.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/uefi/lib/libc/arm/sys/__vdso_gettc.c Wed Jan 30 22:40:43 2013 (r246132, copy of r246131, head/lib/libc/arm/sys/__vdso_gettc.c) @@ -0,0 +1,48 @@ +/*- + * Copyright (c) 2013 Konstantin Belousov + * + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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 +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include + +#pragma weak __vdso_gettc +u_int +__vdso_gettc(const struct vdso_timehands *th) +{ + + return (0); +} + +#pragma weak __vdso_gettimekeep +int +__vdso_gettimekeep(struct vdso_timekeep **tk) +{ + + return (ENOSYS); +} Modified: projects/uefi/lib/libc/i386/sys/__vdso_gettc.c ============================================================================== --- projects/uefi/lib/libc/i386/sys/__vdso_gettc.c Wed Jan 30 19:51:16 2013 (r246131) +++ projects/uefi/lib/libc/i386/sys/__vdso_gettc.c Wed Jan 30 22:40:43 2013 (r246132) @@ -27,9 +27,11 @@ __FBSDID("$FreeBSD$"); #include +#include #include #include #include +#include "libc_private.h" static u_int __vdso_gettc_low(const struct vdso_timehands *th) @@ -48,3 +50,11 @@ __vdso_gettc(const struct vdso_timehands return (th->th_x86_shift > 0 ? __vdso_gettc_low(th) : rdtsc32()); } + +#pragma weak __vdso_gettimekeep +int +__vdso_gettimekeep(struct vdso_timekeep **tk) +{ + + return (_elf_aux_info(AT_TIMEKEEP, tk, sizeof(*tk))); +} Modified: projects/uefi/lib/libc/ia64/sys/Makefile.inc ============================================================================== --- projects/uefi/lib/libc/ia64/sys/Makefile.inc Wed Jan 30 19:51:16 2013 (r246131) +++ projects/uefi/lib/libc/ia64/sys/Makefile.inc Wed Jan 30 22:40:43 2013 (r246132) @@ -1,5 +1,7 @@ # $FreeBSD$ +SRCS+= __vdso_gettc.c + MDASM+= Ovfork.S brk.S cerror.S exect.S fork.S getcontext.S pipe.S ptrace.S \ sbrk.S setlogin.S sigreturn.S swapcontext.S Copied: projects/uefi/lib/libc/ia64/sys/__vdso_gettc.c (from r246131, head/lib/libc/ia64/sys/__vdso_gettc.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/uefi/lib/libc/ia64/sys/__vdso_gettc.c Wed Jan 30 22:40:43 2013 (r246132, copy of r246131, head/lib/libc/ia64/sys/__vdso_gettc.c) @@ -0,0 +1,48 @@ +/*- + * Copyright (c) 2013 Konstantin Belousov + * + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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 +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include + +#pragma weak __vdso_gettc +u_int +__vdso_gettc(const struct vdso_timehands *th) +{ + + return (0); +} + +#pragma weak __vdso_gettimekeep +int +__vdso_gettimekeep(struct vdso_timekeep **tk) +{ + + return (ENOSYS); +} Modified: projects/uefi/lib/libc/mips/sys/Makefile.inc ============================================================================== --- projects/uefi/lib/libc/mips/sys/Makefile.inc Wed Jan 30 19:51:16 2013 (r246131) +++ projects/uefi/lib/libc/mips/sys/Makefile.inc Wed Jan 30 22:40:43 2013 (r246132) @@ -1,5 +1,7 @@ # $FreeBSD$ +SRCS+= __vdso_gettc.c + MDASM= Ovfork.S brk.S cerror.S exect.S \ fork.S pipe.S ptrace.S sbrk.S syscall.S Copied: projects/uefi/lib/libc/mips/sys/__vdso_gettc.c (from r246131, head/lib/libc/mips/sys/__vdso_gettc.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/uefi/lib/libc/mips/sys/__vdso_gettc.c Wed Jan 30 22:40:43 2013 (r246132, copy of r246131, head/lib/libc/mips/sys/__vdso_gettc.c) @@ -0,0 +1,48 @@ +/*- + * Copyright (c) 2013 Konstantin Belousov + * + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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 +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include + +#pragma weak __vdso_gettc +u_int +__vdso_gettc(const struct vdso_timehands *th) +{ + + return (0); +} + +#pragma weak __vdso_gettimekeep +int +__vdso_gettimekeep(struct vdso_timekeep **tk) +{ + + return (ENOSYS); +} Modified: projects/uefi/lib/libc/powerpc/Makefile.inc ============================================================================== --- projects/uefi/lib/libc/powerpc/Makefile.inc Wed Jan 30 19:51:16 2013 (r246131) +++ projects/uefi/lib/libc/powerpc/Makefile.inc Wed Jan 30 22:40:43 2013 (r246132) @@ -1,5 +1,7 @@ # $FreeBSD$ +SRCS+= __vdso_gettc.c + # Long double is 64-bits MDSRCS+=machdep_ldisd.c SYM_MAPS+=${.CURDIR}/powerpc/Symbol.map Copied: projects/uefi/lib/libc/powerpc/sys/__vdso_gettc.c (from r246131, head/lib/libc/powerpc/sys/__vdso_gettc.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/uefi/lib/libc/powerpc/sys/__vdso_gettc.c Wed Jan 30 22:40:43 2013 (r246132, copy of r246131, head/lib/libc/powerpc/sys/__vdso_gettc.c) @@ -0,0 +1,48 @@ +/*- + * Copyright (c) 2013 Konstantin Belousov + * + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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 +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include + +#pragma weak __vdso_gettc +u_int +__vdso_gettc(const struct vdso_timehands *th) +{ + + return (0); +} + +#pragma weak __vdso_gettimekeep +int +__vdso_gettimekeep(struct vdso_timekeep **tk) +{ + + return (ENOSYS); +} Modified: projects/uefi/lib/libc/powerpc64/Makefile.inc ============================================================================== --- projects/uefi/lib/libc/powerpc64/Makefile.inc Wed Jan 30 19:51:16 2013 (r246131) +++ projects/uefi/lib/libc/powerpc64/Makefile.inc Wed Jan 30 22:40:43 2013 (r246132) @@ -1,5 +1,7 @@ # $FreeBSD$ +SRCS+= __vdso_gettc.c + # Long double is 64-bits MDSRCS+=machdep_ldisd.c SYM_MAPS+=${.CURDIR}/powerpc64/Symbol.map Copied: projects/uefi/lib/libc/powerpc64/sys/__vdso_gettc.c (from r246131, head/lib/libc/powerpc64/sys/__vdso_gettc.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/uefi/lib/libc/powerpc64/sys/__vdso_gettc.c Wed Jan 30 22:40:43 2013 (r246132, copy of r246131, head/lib/libc/powerpc64/sys/__vdso_gettc.c) @@ -0,0 +1,48 @@ +/*- + * Copyright (c) 2013 Konstantin Belousov + * + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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 +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include + +#pragma weak __vdso_gettc +u_int +__vdso_gettc(const struct vdso_timehands *th) +{ + + return (0); +} + +#pragma weak __vdso_gettimekeep +int +__vdso_gettimekeep(struct vdso_timekeep **tk) +{ + + return (ENOSYS); +} Modified: projects/uefi/lib/libc/sparc64/Makefile.inc ============================================================================== --- projects/uefi/lib/libc/sparc64/Makefile.inc Wed Jan 30 19:51:16 2013 (r246131) +++ projects/uefi/lib/libc/sparc64/Makefile.inc Wed Jan 30 22:40:43 2013 (r246132) @@ -5,6 +5,8 @@ .include "fpu/Makefile.inc" +SRCS+= __vdso_gettc.c + # Long double is quad precision GDTOASRCS+=strtorQ.c MDSRCS+=machdep_ldisQ.c Copied: projects/uefi/lib/libc/sparc64/sys/__vdso_gettc.c (from r246131, head/lib/libc/sparc64/sys/__vdso_gettc.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/uefi/lib/libc/sparc64/sys/__vdso_gettc.c Wed Jan 30 22:40:43 2013 (r246132, copy of r246131, head/lib/libc/sparc64/sys/__vdso_gettc.c) @@ -0,0 +1,48 @@ +/*- + * Copyright (c) 2013 Konstantin Belousov + * + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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 +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include + +#pragma weak __vdso_gettc +u_int +__vdso_gettc(const struct vdso_timehands *th) +{ + + return (0); +} + +#pragma weak __vdso_gettimekeep +int +__vdso_gettimekeep(struct vdso_timekeep **tk) +{ + + return (ENOSYS); +} Modified: projects/uefi/lib/libc/stdio/Makefile.inc ============================================================================== --- projects/uefi/lib/libc/stdio/Makefile.inc Wed Jan 30 19:51:16 2013 (r246131) +++ projects/uefi/lib/libc/stdio/Makefile.inc Wed Jan 30 22:40:43 2013 (r246132) @@ -8,7 +8,8 @@ SRCS+= _flock_stub.c asprintf.c clrerr.c fclose.c fcloseall.c fdopen.c \ feof.c ferror.c fflush.c fgetc.c fgetln.c fgetpos.c fgets.c fgetwc.c \ fgetwln.c fgetws.c \ - fileno.c findfp.c flags.c fopen.c fprintf.c fpurge.c fputc.c fputs.c \ + fileno.c findfp.c flags.c fmemopen.c fopen.c fprintf.c fpurge.c \ + fputc.c fputs.c \ fputwc.c fputws.c fread.c freopen.c fscanf.c fseek.c fsetpos.c \ ftell.c funopen.c fvwrite.c fwalk.c fwide.c fwprintf.c fwscanf.c \ fwrite.c getc.c getchar.c getdelim.c getline.c \ @@ -48,7 +49,7 @@ MLINKS+=ferror.3 ferror_unlocked.3 \ MLINKS+=fflush.3 fpurge.3 MLINKS+=fgets.3 gets.3 MLINKS+=flockfile.3 ftrylockfile.3 flockfile.3 funlockfile.3 -MLINKS+=fopen.3 fdopen.3 fopen.3 freopen.3 +MLINKS+=fopen.3 fdopen.3 fopen.3 freopen.3 fopen.3 fmemopen.3 MLINKS+=fputs.3 puts.3 MLINKS+=fread.3 fwrite.3 MLINKS+=fseek.3 fgetpos.3 fseek.3 fseeko.3 fseek.3 fsetpos.3 fseek.3 ftell.3 \ Modified: projects/uefi/lib/libc/stdio/Symbol.map ============================================================================== --- projects/uefi/lib/libc/stdio/Symbol.map Wed Jan 30 19:51:16 2013 (r246131) +++ projects/uefi/lib/libc/stdio/Symbol.map Wed Jan 30 22:40:43 2013 (r246132) @@ -155,6 +155,7 @@ FBSD_1.3 { getwchar_l; putwc_l; putwchar_l; + fmemopen; }; FBSDprivate_1.0 { Copied: projects/uefi/lib/libc/stdio/fmemopen.c (from r246131, head/lib/libc/stdio/fmemopen.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/uefi/lib/libc/stdio/fmemopen.c Wed Jan 30 22:40:43 2013 (r246132, copy of r246131, head/lib/libc/stdio/fmemopen.c) @@ -0,0 +1,182 @@ +/*- +Copyright (C) 2013 Pietro Cerutti + +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. + +THIS SOFTWARE IS PROVIDED BY AUTHOR 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 AUTHOR 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 +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include + +struct __fmemopen_cookie +{ + char *buf; /* pointer to the memory region */ + char own; /* did we allocate the buffer ourselves? */ + long len; /* buffer length in bytes */ + long off; /* current offset into the buffer */ +}; + +static int fmemopen_read (void *cookie, char *buf, int nbytes); +static int fmemopen_write (void *cookie, const char *buf, int nbytes); +static fpos_t fmemopen_seek (void *cookie, fpos_t offset, int whence); +static int fmemopen_close (void *cookie); + +FILE * +fmemopen (void * __restrict buf, size_t size, const char * __restrict mode) +{ + /* allocate cookie */ + struct __fmemopen_cookie *ck = malloc (sizeof (struct __fmemopen_cookie)); + if (ck == NULL) { + errno = ENOMEM; + return (NULL); + } + + ck->off = 0; + ck->len = size; + + /* do we have to allocate the buffer ourselves? */ + ck->own = ((ck->buf = buf) == NULL); + if (ck->own) { + ck->buf = malloc (size); + if (ck->buf == NULL) { + free (ck); + errno = ENOMEM; + return (NULL); + } + ck->buf[0] = '\0'; + } + + if (mode[0] == 'a') + ck->off = strnlen(ck->buf, ck->len); + + /* actuall wrapper */ + FILE *f = funopen ((void *)ck, fmemopen_read, fmemopen_write, + fmemopen_seek, fmemopen_close); + + if (f == NULL) { + if (ck->own) + free (ck->buf); + free (ck); + return (NULL); + } + + /* turn off buffering, so a write past the end of the buffer + * correctly returns a short object count */ + setvbuf (f, (char *) NULL, _IONBF, 0); + + return (f); +} + +static int +fmemopen_read (void *cookie, char *buf, int nbytes) +{ + struct __fmemopen_cookie *ck = cookie; + + if (nbytes > ck->len - ck->off) + nbytes = ck->len - ck->off; + + if (nbytes == 0) + return (0); + + memcpy (buf, ck->buf + ck->off, nbytes); + + ck->off += nbytes; + + return (nbytes); +} + +static int +fmemopen_write (void *cookie, const char *buf, int nbytes) +{ + struct __fmemopen_cookie *ck = cookie; + + if (nbytes > ck->len - ck->off) + nbytes = ck->len - ck->off; + + if (nbytes == 0) + return (0); + + memcpy (ck->buf + ck->off, buf, nbytes); + + ck->off += nbytes; + + if (ck->off < ck->len && ck->buf[ck->off - 1] != '\0') + ck->buf[ck->off] = '\0'; + + return (nbytes); +} + +static fpos_t +fmemopen_seek (void *cookie, fpos_t offset, int whence) +{ + struct __fmemopen_cookie *ck = cookie; + + + switch (whence) { + case SEEK_SET: + if (offset > ck->len) { + errno = EINVAL; + return (-1); + } + ck->off = offset; + break; + + case SEEK_CUR: + if (ck->off + offset > ck->len) { + errno = EINVAL; + return (-1); + } + ck->off += offset; + break; + + case SEEK_END: + if (offset > 0 || -offset > ck->len) { + errno = EINVAL; + return (-1); + } + ck->off = ck->len + offset; + break; + + default: + errno = EINVAL; + return (-1); + } + + return (ck->off); +} + +static int +fmemopen_close (void *cookie) +{ + struct __fmemopen_cookie *ck = cookie; + + if (ck->own) + free (ck->buf); + + free (ck); + + return (0); +} Modified: projects/uefi/lib/libc/stdio/fopen.3 ============================================================================== --- projects/uefi/lib/libc/stdio/fopen.3 Wed Jan 30 19:51:16 2013 (r246131) +++ projects/uefi/lib/libc/stdio/fopen.3 Wed Jan 30 22:40:43 2013 (r246132) @@ -32,13 +32,14 @@ .\" @(#)fopen.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd November 30, 2012 +.Dd January 30, 2013 .Dt FOPEN 3 .Os .Sh NAME .Nm fopen , .Nm fdopen , -.Nm freopen +.Nm freopen , +.Nm fmemopen .Nd stream open functions .Sh LIBRARY .Lb libc @@ -50,6 +51,8 @@ .Fn fdopen "int fildes" "const char *mode" .Ft FILE * .Fn freopen "const char *path" "const char *mode" "FILE *stream" +.Ft FILE * +.Fn fmemopen "void *restrict *buf" "size_t size" "const char * restrict mode" .Sh DESCRIPTION The .Fn fopen @@ -202,6 +205,29 @@ standard text stream .Dv ( stderr , stdin , or .Dv stdout ) . +.Pp +The +.Fn fmemopen +function +associates the buffer given by the +.Fa buf +and +.Fa size +arguments with a stream. +The +.Fa buf +argument shall be either a null pointer or point to a buffer that +is at least +.Fa size +bytes long. +If a null pointer is specified as the +.Fa buf +argument, +.Fn fmemopen +shall allocate +.Fa size +bytes of memory. This buffer shall be automatically freed when the +stream is closed. .Sh RETURN VALUES Upon successful completion .Fn fopen , @@ -225,16 +251,18 @@ argument to .Fn fopen , .Fn fdopen , +.Fn freopen , or -.Fn freopen +.Fn fmemopen was invalid. .El .Pp The .Fn fopen , -.Fn fdopen -and +.Fn fdopen , .Fn freopen +and +.Fn fmemopen functions may also fail and set .Va errno @@ -294,3 +322,8 @@ The .Dq Li e mode option does not conform to any standard but is also supported by glibc. +The +.Fn fmemopen +function +conforms to +.St -p1003.1-2008 . Modified: projects/uefi/lib/libc/sys/__vdso_gettimeofday.c ============================================================================== --- projects/uefi/lib/libc/sys/__vdso_gettimeofday.c Wed Jan 30 19:51:16 2013 (r246131) +++ projects/uefi/lib/libc/sys/__vdso_gettimeofday.c Wed Jan 30 22:40:43 2013 (r246132) @@ -79,6 +79,7 @@ binuptime(struct bintime *bt, struct vds static struct vdso_timekeep *tk; +#pragma weak __vdso_gettimeofday int __vdso_gettimeofday(struct timeval *tv, struct timezone *tz) { @@ -88,7 +89,7 @@ __vdso_gettimeofday(struct timeval *tv, if (tz != NULL) return (ENOSYS); if (tk == NULL) { - error = _elf_aux_info(AT_TIMEKEEP, &tk, sizeof(tk)); + error = __vdso_gettimekeep(&tk); if (error != 0 || tk == NULL) return (ENOSYS); } @@ -101,6 +102,7 @@ __vdso_gettimeofday(struct timeval *tv, return (0); } +#pragma weak __vdso_clock_gettime int __vdso_clock_gettime(clockid_t clock_id, struct timespec *ts) { Modified: projects/uefi/lib/libc/sys/gettimeofday.c ============================================================================== --- projects/uefi/lib/libc/sys/gettimeofday.c Wed Jan 30 19:51:16 2013 (r246131) +++ projects/uefi/lib/libc/sys/gettimeofday.c Wed Jan 30 22:40:43 2013 (r246132) @@ -41,10 +41,7 @@ __gettimeofday(struct timeval *tv, struc { int error; - if (__vdso_gettimeofday != NULL && __vdso_gettc != NULL) - error = __vdso_gettimeofday(tv, tz); - else - error = ENOSYS; + error = __vdso_gettimeofday(tv, tz); if (error == ENOSYS) error = __sys_gettimeofday(tv, tz); return (error); Modified: projects/uefi/libexec/tftpd/tftp-io.c ============================================================================== --- projects/uefi/libexec/tftpd/tftp-io.c Wed Jan 30 19:51:16 2013 (r246131) +++ projects/uefi/libexec/tftpd/tftp-io.c Wed Jan 30 22:40:43 2013 (r246132) @@ -142,7 +142,7 @@ send_error(int peer, int error) char buf[MAXPKTSIZE]; if (debug&DEBUG_PACKETS) - tftp_log(LOG_DEBUG, "Sending ERROR %d: %s", error); + tftp_log(LOG_DEBUG, "Sending ERROR %d", error); DROPPACKET("send_error"); Modified: projects/uefi/sbin/devd/devd.8 ============================================================================== --- projects/uefi/sbin/devd/devd.8 Wed Jan 30 19:51:16 2013 (r246131) +++ projects/uefi/sbin/devd/devd.8 Wed Jan 30 22:40:43 2013 (r246132) @@ -35,6 +35,7 @@ .Nm .Op Fl Ddn .Op Fl f Ar file +.Op Fl l Ar num .Sh DESCRIPTION The .Nm @@ -55,6 +56,12 @@ instead of the default If option .Fl f is specified more than once, the last file specified is used. +.It Fl l Ar num +Limit concurrent +.Pa /var/run/devd.pipe +connections to +.Ar num . +The default connection limit is 10. .It Fl n Do not process all pending events before becoming a daemon. Instead, call daemon right away. Modified: projects/uefi/sbin/devd/devd.cc ============================================================================== --- projects/uefi/sbin/devd/devd.cc Wed Jan 30 19:51:16 2013 (r246131) +++ projects/uefi/sbin/devd/devd.cc Wed Jan 30 22:40:43 2013 (r246132) @@ -80,6 +80,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -814,23 +815,58 @@ create_socket(const char *name) return (fd); } +unsigned int max_clients = 10; /* Default, can be overriden on cmdline. */ +unsigned int num_clients; list clients; void notify_clients(const char *data, int len) { - list bad; - list::const_iterator i; + list::iterator i; - for (i = clients.begin(); i != clients.end(); ++i) { - if (write(*i, data, len) <= 0) { - bad.push_back(*i); + /* + * Deliver the data to all clients. Throw clients overboard at the + * first sign of trouble. This reaps clients who've died or closed + * their sockets, and also clients who are alive but failing to keep up + * (or who are maliciously not reading, to consume buffer space in + * kernel memory or tie up the limited number of available connections). + */ + for (i = clients.begin(); i != clients.end(); ) { + if (write(*i, data, len) != len) { + --num_clients; close(*i); - } + i = clients.erase(i); + } else + ++i; } +} + +void +check_clients(void) +{ + int s; + struct pollfd pfd; + list::iterator i; - for (i = bad.begin(); i != bad.end(); ++i) - clients.erase(find(clients.begin(), clients.end(), *i)); + /* + * Check all existing clients to see if any of them have disappeared. + * Normally we reap clients when we get an error trying to send them an + * event. This check eliminates the problem of an ever-growing list of + * zombie clients because we're never writing to them on a system + * without frequent device-change activity. + */ + pfd.events = 0; + for (i = clients.begin(); i != clients.end(); ) { + pfd.fd = *i; + s = poll(&pfd, 1, 0); + if ((s < 0 && s != EINTR ) || + (s > 0 && (pfd.revents & POLLHUP))) { + --num_clients; + close(*i); + i = clients.erase(i); + } else + ++i; + } } void @@ -838,9 +874,18 @@ new_client(int fd) { int s; + /* + * First go reap any zombie clients, then accept the connection, and + * shut down the read side to stop clients from consuming kernel memory + * by sending large buffers full of data we'll never read. + */ + check_clients(); s = accept(fd, NULL, NULL); - if (s != -1) + if (s != -1) { + shutdown(s, SHUT_RD); clients.push_back(s); + ++num_clients; + } } static void @@ -851,6 +896,7 @@ event_loop(void) char buffer[DEVCTL_MAXBUF]; int once = 0; int server_fd, max_fd; + int accepting; timeval tv; fd_set fds; @@ -858,6 +904,7 @@ event_loop(void) if (fd == -1) err(1, "Can't open devctl device %s", PATH_DEVCTL); server_fd = create_socket(PIPE); + accepting = 1; max_fd = max(fd, server_fd) + 1; while (1) { if (romeo_must_die) @@ -880,15 +927,38 @@ event_loop(void) once++; } } + /* + * When we've already got the max number of clients, stop + * accepting new connections (don't put server_fd in the set), + * shrink the accept() queue to reject connections quickly, and + * poll the existing clients more often, so that we notice more + * quickly when any of them disappear to free up client slots. + */ FD_ZERO(&fds); FD_SET(fd, &fds); - FD_SET(server_fd, &fds); - rv = select(max_fd, &fds, NULL, NULL, NULL); + if (num_clients < max_clients) { + if (!accepting) { + listen(server_fd, max_clients); + accepting = 1; + } + FD_SET(server_fd, &fds); + tv.tv_sec = 60; + tv.tv_usec = 0; + } else { + if (accepting) { + listen(server_fd, 0); + accepting = 0; + } + tv.tv_sec = 2; + tv.tv_usec = 0; + } + rv = select(max_fd, &fds, NULL, NULL, &tv); if (rv == -1) { if (errno == EINTR) continue; err(1, "select"); - } + } else if (rv == 0) + check_clients(); if (FD_ISSET(fd, &fds)) { rv = read(fd, buffer, sizeof(buffer) - 1); if (rv > 0) { @@ -1007,7 +1077,8 @@ gensighand(int) static void *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***