Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 3 Sep 2002 15:02:59 -0700 (PDT)
From:      Peter Wemm <peter@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 17011 for review
Message-ID:  <200209032202.g83M2xmv001422@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://people.freebsd.org/~peter/p4db/chv.cgi?CH=17011

Change 17011 by peter@peter_daintree on 2002/09/03 15:02:47

	IFC @17008

Affected files ...

.. //depot/projects/ia64/UPDATING#19 integrate
.. //depot/projects/ia64/bin/ps/ps.c#8 integrate
.. //depot/projects/ia64/etc/rc.d/nfsd#6 integrate
.. //depot/projects/ia64/gnu/usr.bin/man/man/man.c#7 integrate
.. //depot/projects/ia64/lib/csu/sparc64/crt1.c#6 integrate
.. //depot/projects/ia64/lib/libc/sparc64/sys/Makefile.inc#7 integrate
.. //depot/projects/ia64/lib/libc/sparc64/sys/sigaction.S#1 branch
.. //depot/projects/ia64/sys/conf/NOTES#22 integrate
.. //depot/projects/ia64/sys/dev/pccard/pccard.c#8 integrate
.. //depot/projects/ia64/sys/dev/puc/puc.c#6 integrate
.. //depot/projects/ia64/sys/dev/puc/puc_pccard.c#2 integrate
.. //depot/projects/ia64/sys/dev/sio/sio_puc.c#3 integrate
.. //depot/projects/ia64/sys/dev/sound/pci/fm801.c#4 integrate
.. //depot/projects/ia64/sys/kern/imgact_elf.c#19 integrate
.. //depot/projects/ia64/sys/kern/kern_descrip.c#31 integrate
.. //depot/projects/ia64/sys/kern/kern_mutex.c#12 integrate
.. //depot/projects/ia64/sys/kern/kern_sig.c#26 integrate
.. //depot/projects/ia64/sys/kern/kern_thread.c#9 integrate
.. //depot/projects/ia64/sys/modules/Makefile#19 integrate
.. //depot/projects/ia64/sys/sys/proc.h#29 integrate
.. //depot/projects/ia64/usr.bin/uudecode/uudecode.c#10 integrate
.. //depot/projects/ia64/usr.bin/uuencode/uuencode.1#6 integrate
.. //depot/projects/ia64/usr.sbin/pkg_install/add/perform.c#5 integrate

Differences ...

==== //depot/projects/ia64/UPDATING#19 (text+ko) ====

@@ -22,6 +22,14 @@
 	integrity.  Re-enabling write caching can substantially improve
 	performance.
 
+20020831:
+	gcc has been upgraded to 3.2.  It is not all binary compatible
+	with earlier versions of gcc for c++ programs.  All c++
+	programs and libraries need to be recompiled.
+
+	Also, if you encounter g++ issues, rm /usr/include/g++/* before
+	doing an installworld to make sure that stale files are removed.
+
 20020827:
 	Our /etc/termcap now has all the entries from the XFree86 xterm
 	almost unchanged. This means xterm now supports color by default.
@@ -987,6 +995,7 @@
 	make installkernel KERNCONF=YOUR_KERNEL_HERE
 	reboot in single user [3]
 	mergemaster -p		[5]
+	rm -rf /usr/include/g++
 	make installworld
 	mergemaster		[4]
 	[1]
@@ -1068,4 +1077,4 @@
 Contact Warner Losh if you have any questions about your use of
 this document.
 
-$FreeBSD: src/UPDATING,v 1.216 2002/08/28 19:34:49 schweikh Exp $
+$FreeBSD: src/UPDATING,v 1.217 2002/09/03 06:13:43 imp Exp $

==== //depot/projects/ia64/bin/ps/ps.c#8 (text+ko) ====

@@ -43,7 +43,7 @@
 #endif /* not lint */
 #endif
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/bin/ps/ps.c,v 1.57 2002/07/08 09:08:51 robert Exp $");
+__FBSDID("$FreeBSD: src/bin/ps/ps.c,v 1.58 2002/09/03 05:44:00 jmallett Exp $");
 
 #include <sys/param.h>
 #include <sys/user.h>
@@ -591,9 +591,16 @@
 static char *
 kludge_oldps_options(char *s)
 {
+	int have_fmt;
 	size_t len;
 	char *newopts, *ns, *cp;
 
+	/*
+	 * If we have an 'o' option, then note it, since we don't want to do
+	 * some types of munging.
+	 */
+	have_fmt = index(s, 'o') != NULL;
+
 	len = strlen(s);
 	if ((newopts = ns = malloc(len + 2)) == NULL)
 		errx(1, "malloc failed");
@@ -634,7 +641,7 @@
 	 */
 	if (isdigit(*cp) &&
 	    (cp == s || (cp[-1] != 't' && cp[-1] != 'p')) &&
-	    (cp - 1 == s || cp[-2] != 't'))
+	    (cp - 1 == s || cp[-2] != 't') && !have_fmt)
 		*ns++ = 'p';
 	(void)strcpy(ns, cp);		/* and append the number */
 

==== //depot/projects/ia64/etc/rc.d/nfsd#6 (text+ko) ====

@@ -1,7 +1,7 @@
 #!/bin/sh
 #
 # $NetBSD: nfsd,v 1.4 2001/06/16 06:13:10 lukem Exp $
-# $FreeBSD: src/etc/rc.d/nfsd,v 1.5 2002/08/20 00:14:11 gordon Exp $
+# $FreeBSD: src/etc/rc.d/nfsd,v 1.6 2002/09/03 16:02:57 gordon Exp $
 #
 
 # PROVIDE: nfsd
@@ -18,6 +18,7 @@
 FreeBSD)
 	command_args="${nfs_server_flags}"
 	start_precmd="nfsd_precmd"
+	sig_stop="USR1"
 	;;
 NetBSD)
 	required_vars="mountd rpcbind"

==== //depot/projects/ia64/gnu/usr.bin/man/man/man.c#7 (text+ko) ====

@@ -16,7 +16,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-  "$FreeBSD: src/gnu/usr.bin/man/man/man.c,v 1.57 2002/08/27 09:31:27 eric Exp $";
+  "$FreeBSD: src/gnu/usr.bin/man/man/man.c,v 1.58 2002/09/03 17:39:26 eric Exp $";
 #endif /* not lint */
 
 #define MAN_MAIN
@@ -459,7 +459,7 @@
 #endif /* __FreeBSD__ */
 
   if (pager == NULL || *pager == '\0')
-    if ((pager = getenv ("PAGER")) == NULL || *pager == NULL)
+    if ((pager = getenv ("PAGER")) == NULL || *pager == '\0')
       pager = strdup (PAGER);
 
   if (debug)

==== //depot/projects/ia64/lib/csu/sparc64/crt1.c#6 (text+ko) ====

@@ -122,7 +122,6 @@
 				__progname = s + 1;
 	}
 
-	__sparc_sigtramp_setup();
 	__sparc_utrap_setup();
 
 	/*
@@ -152,4 +151,4 @@
 __asm__(".previous");
 #endif
 
-__asm__(".ident\t\"$FreeBSD: src/lib/csu/sparc64/crt1.c,v 1.9 2002/07/16 12:28:50 markm Exp $\"");
+__asm__(".ident\t\"$FreeBSD: src/lib/csu/sparc64/crt1.c,v 1.10 2002/09/03 14:59:41 jake Exp $\"");

==== //depot/projects/ia64/lib/libc/sparc64/sys/Makefile.inc#7 (text+ko) ====

@@ -1,4 +1,4 @@
-# $FreeBSD: src/lib/libc/sparc64/sys/Makefile.inc,v 1.7 2002/05/23 23:51:57 jake Exp $
+# $FreeBSD: src/lib/libc/sparc64/sys/Makefile.inc,v 1.8 2002/09/03 14:55:29 jake Exp $
 
 SRCS+=	__sparc_sigtramp_setup.c \
 	__sparc_utrap.c \
@@ -12,7 +12,7 @@
 
 CFLAGS+= -I${.CURDIR}/sparc64/fpu
 
-MDASM+=	brk.S cerror.S exect.S pipe.S ptrace.S sbrk.S setlogin.S
+MDASM+=	brk.S cerror.S exect.S pipe.S ptrace.S sbrk.S setlogin.S sigaction.S
 
 # Don't generate default code for these syscalls:
 NOASM=	break.o exit.o ftruncate.o getdomainname.o getlogin.o \

==== //depot/projects/ia64/sys/conf/NOTES#22 (text+ko) ====

@@ -1,8 +1,9 @@
+# $FreeBSD: src/sys/conf/NOTES,v 1.1071 2002/09/03 19:21:39 jhb Exp $
 #
 # NOTES -- Lines that can be cut/pasted into kernel and hints configs.
 #
 # Lines that begin with 'device', 'options', 'machine', 'ident', 'maxusers',
-# 'makeoptions', 'hints' etc go into the kernel configuration that you
+# 'makeoptions', 'hints', etc. go into the kernel configuration that you
 # run config(8) with.
 #
 # Lines that begin with 'hint.' are NOT for config(8), they go into your
@@ -14,7 +15,25 @@
 # This file contains machine independent kernel configuration notes.  For
 # machine dependent notes, look in /sys/<arch>/conf/NOTES.
 #
-# $FreeBSD: src/sys/conf/NOTES,v 1.1070 2002/09/02 20:10:18 brooks Exp $
+
+#
+# NOTES conventions and style guide:
+#
+# Large block comments should begin and end with a line containing only a
+# comment character.
+#
+# To describe a particular object, a block comment (if it exists) should
+# come first.  Next should come device, options, and hints lines in that
+# order.  All device and option lines must be described by a comment that
+# doesn't just expand the device or option name.  Use only a concise
+# comment on the same line if possible.  Very detailed descriptions of
+# devices and subsystems belong in manpages.
+#
+# A space followed by a tab separates 'option' from an option name.  Two
+# spaces followed by a tab separate 'device' from a device name.  Comments
+# after an option or device should use one space after the comment character.
+# To comment out a negative option that disables code and thus should not be
+# enabled for LINT builds, precede 'option' with "#!".
 #
 
 #

==== //depot/projects/ia64/sys/dev/pccard/pccard.c#8 (text+ko) ====

@@ -1,5 +1,5 @@
 /*	$NetBSD: pcmcia.c,v 1.23 2000/07/28 19:17:02 drochner Exp $	*/
-/* $FreeBSD: src/sys/dev/pccard/pccard.c,v 1.62 2002/08/31 18:34:30 imp Exp $ */
+/* $FreeBSD: src/sys/dev/pccard/pccard.c,v 1.63 2002/09/03 11:24:25 phk Exp $ */
 
 /*
  * Copyright (c) 1997 Marc Horowitz.  All rights reserved.
@@ -1174,6 +1174,7 @@
 pccard_intr(void *arg)
 {
 	struct pccard_function *pf = (struct pccard_function*) arg;
+#ifdef COOKIE_FOR_WARNER
 	int reg;
 
 	if (pf->intr_handler == NULL)
@@ -1189,6 +1190,11 @@
 				 reg & ~PCCARD_CCR_STATUS_INTR);
 		pf->intr_handler(pf->intr_handler_arg);
 	}
+#else
+	if (pf->intr_handler == NULL)
+		return;
+	pf->intr_handler(pf->intr_handler_arg);
+#endif
 }
 
 static int

==== //depot/projects/ia64/sys/dev/puc/puc.c#6 (text+ko) ====

@@ -58,7 +58,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/puc/puc.c,v 1.11 2002/09/01 01:59:38 jmallett Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/puc/puc.c,v 1.14 2002/09/03 11:22:13 phk Exp $");
 
 /*
  * PCI "universal" communication card device driver, glues com, lpt,
@@ -112,6 +112,8 @@
 static void puc_print_resource_list(struct resource_list *);
 #endif
 
+devclass_t puc_devclass;
+
 static int
 puc_port_bar_index(struct puc_softc *sc, int bar)
 {
@@ -157,15 +159,8 @@
 
 	sc->irqres = res;
 	sc->irqrid = rid;
-#ifdef PUC_FASTINTR
 	irq_setup = BUS_SETUP_INTR(device_get_parent(dev), dev, res,
-	    INTR_TYPE_TTY | INTR_FAST, puc_intr, sc, &sc->intr_cookie);
-#else
-	irq_setup = ENXIO;
-#endif
-	if (irq_setup != 0)
-		irq_setup = BUS_SETUP_INTR(device_get_parent(dev), dev, res,
-		    INTR_TYPE_TTY, puc_intr, sc, &sc->intr_cookie);
+	    INTR_TYPE_TTY, puc_intr, sc, &sc->intr_cookie);
 	if (irq_setup != 0)
 		return (ENXIO);
 
@@ -307,7 +302,6 @@
 	int i;
 	struct puc_softc *sc;
 
-printf("puc_intr\n");
 	sc = (struct puc_softc *)arg;
 	for (i = 0; i < PUC_MAX_PORTS; i++)
 		if (sc->sc_ports[i].ihand != NULL)
@@ -335,7 +329,9 @@
 
 	return (NULL);
 }
-static int puc_find_free_unit(char *name)
+
+static int
+puc_find_free_unit(char *name)
 {
 	devclass_t dc;
 	int start;
@@ -454,7 +450,8 @@
 	int i;
 	struct puc_softc *sc;
 
-printf("puc_setup_intr()\n");
+	if (flags & INTR_FAST)
+		return (ENXIO);
 	sc = (struct puc_softc *)device_get_softc(dev);
 	for (i = 0; PUC_PORT_VALID(sc->sc_desc, i); i++) {
 		if (sc->sc_ports[i].dev == child) {
@@ -476,7 +473,6 @@
 	int i;
 	struct puc_softc *sc;
 
-printf("puc_teardown_intr()\n");
 	sc = (struct puc_softc *)device_get_softc(dev);
 	for (i = 0; PUC_PORT_VALID(sc->sc_desc, i); i++) {
 		if (sc->sc_ports[i].dev == child) {
@@ -506,6 +502,3 @@
 	}
 	return (0);
 }
-
-devclass_t puc_devclass;
-

==== //depot/projects/ia64/sys/dev/puc/puc_pccard.c#2 (text+ko) ====

@@ -22,7 +22,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/dev/puc/puc_pccard.c,v 1.3 2002/09/01 01:59:38 jmallett Exp $
+ * $FreeBSD: src/sys/dev/puc/puc_pccard.c,v 1.4 2002/09/03 11:31:34 phk Exp $
  */
 
 #include "opt_puc.h"
@@ -46,7 +46,8 @@
 
 const struct puc_device_description rscom_devices = {
 
-	"RS-com 2 port",
+	"ARGOSY SP320 Dual port serial PCMCIA",
+	/* http://www.argosy.com.tw/product/sp320.htm */
 	NULL,
 		{	0,	0,	0,	0	},
 		{	0,	0,	0,	0	},
@@ -69,7 +70,6 @@
 	error = pccard_get_product_str(dev, &product);
 	if (error)
 		return(error);
-	printf("puc_pccard_probe <%s><%s>\n", vendor, product);
 	if (!strcmp(vendor, "PCMCIA") && !strcmp(product, "RS-COM 2P")) {
 		device_set_desc(dev, rscom_devices.name);
 		return (0);

==== //depot/projects/ia64/sys/dev/sio/sio_puc.c#3 (text+ko) ====

@@ -24,7 +24,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/sio/sio_puc.c,v 1.3 2002/03/20 02:07:41 alfred Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/sio/sio_puc.c,v 1.4 2002/09/03 11:17:38 phk Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -86,7 +86,7 @@
 #ifdef PC98
 	SET_FLAG(dev, SET_IFTYPE(COM_IF_NS16550));
 #endif
-	return (sioprobe(dev, 0, (u_long)rclk, 0));
+	return (sioprobe(dev, 0, (u_long)rclk, 1));
 }
 
 DRIVER_MODULE(sio, puc, sio_puc_driver, sio_devclass, 0, 0);

==== //depot/projects/ia64/sys/dev/sound/pci/fm801.c#4 (text+ko) ====

@@ -29,7 +29,7 @@
 #include <pci/pcireg.h>
 #include <pci/pcivar.h>
 
-SND_DECLARE_FILE("$FreeBSD: src/sys/dev/sound/pci/fm801.c,v 1.14 2002/08/30 14:21:01 sobomax Exp $");
+SND_DECLARE_FILE("$FreeBSD: src/sys/dev/sound/pci/fm801.c,v 1.15 2002/09/03 08:58:15 sobomax Exp $");
 
 #define PCI_VENDOR_FORTEMEDIA	0x1319
 #define PCI_DEVICE_FORTEMEDIA1	0x08011319
@@ -161,6 +161,8 @@
 	unsigned int		bufsz;
 
 	struct fm801_chinfo	pch, rch;
+
+	device_t		radio;
 };
 
 /* Bus Read / Write routines */
@@ -223,7 +225,7 @@
 	}
 	if (i >= TIMO) {
 		printf("fm801 rdcd: write codec invalid\n");
-		return -1;
+		return 0;
 	}
 
 	return fm801_rd(fm801,FM_CODEC_DATA,2);
@@ -613,13 +615,6 @@
 	codec = AC97_CREATE(dev, fm801, fm801_ac97);
 	if (codec == NULL) goto oops;
 
-	/*
-	 * XXX: quick check that device actually has sound capabilities.
-	 * The problem is that some cards built around fm801 chip only
-	 * have radio tuner onboard, but no sound capabilities.
-	 */
-	if (fm801_rdcd(NULL, fm801, AC97_REG_POWER) == -1) goto oops;
-
 	if (mixer_init(dev, ac97_getmixerclass(), codec) == -1) goto oops;
 
 	fm801->irqid = 0;
@@ -650,6 +645,9 @@
 	pcm_addchan(dev, PCMDIR_REC, &fm801ch_class, fm801);
 	pcm_setstatus(dev, status);
 
+	fm801->radio = device_add_child(dev, "radio", -1);
+	bus_generic_attach(dev);
+
 	return 0;
 
 oops:
@@ -670,11 +668,22 @@
 
 	DPRINT("Forte Media FM801 detach\n");
 
+	fm801 = pcm_getdevinfo(dev);
+
+	r = bus_generic_detach(dev);
+	if (r)
+		return r;
+	if (fm801->radio != NULL) {
+		r = device_delete_child(dev, fm801->radio);
+		if (r)
+			return r;
+		fm801->radio = NULL;
+	}
+
 	r = pcm_unregister(dev);
 	if (r)
 		return r;
 
-	fm801 = pcm_getdevinfo(dev);
 	bus_release_resource(dev, fm801->regtype, fm801->regid, fm801->reg);
 	bus_teardown_intr(dev, fm801->irq, fm801->ih);
 	bus_release_resource(dev, SYS_RES_IRQ, fm801->irqid, fm801->irq);
@@ -686,10 +695,50 @@
 static int
 fm801_pci_probe( device_t dev )
 {
-	int id;
+	u_int32_t data;
+	int id, regtype, regid, result;
+	struct resource *reg;
+	bus_space_tag_t st;
+	bus_space_handle_t sh;
+
+	result = ENXIO;
+	
 	if ((id = pci_get_devid(dev)) == PCI_DEVICE_FORTEMEDIA1 ) {
-		device_set_desc(dev, "Forte Media FM801 Audio Controller");
-		return 0;
+		data = pci_read_config(dev, PCIR_COMMAND, 2);
+		data |= (PCIM_CMD_PORTEN|PCIM_CMD_BUSMASTEREN);
+		pci_write_config(dev, PCIR_COMMAND, data, 2);
+		data = pci_read_config(dev, PCIR_COMMAND, 2);
+
+		regid = PCIR_MAPS;
+		regtype = SYS_RES_IOPORT;
+		reg = bus_alloc_resource(dev, regtype, &regid, 0, ~0, 1,
+		    RF_ACTIVE);
+
+		if (reg == NULL)
+			return ENXIO;
+
+		st = rman_get_bustag(reg);
+		sh = rman_get_bushandle(reg);
+		/*
+		 * XXX: quick check that device actually has sound capabilities.
+		 * The problem is that some cards built around FM801 chip only
+		 * have radio tuner onboard, but no sound capabilities. There
+		 * is no "official" way to quickly check this, because all
+		 * IDs are exactly the same. The only difference is 0x28
+		 * device control register, described in FM801 specification
+		 * as "SRC/Mixer Test Control/DFC Status", but without
+		 * any more detailed explanation. According to specs, and
+		 * available sample cards (SF256-PCP-R and SF256-PCS-R) its
+		 * power-on value should be `0', while on AC97-less tuner
+		 * card (SF64-PCR) it was 0x80.
+		 */
+		if (bus_space_read_1(st, sh, 0x28) == 0) {
+			device_set_desc(dev,
+			    "Forte Media FM801 Audio Controller");
+			result = 0;
+		}
+
+		bus_release_resource(dev, regtype, regid, reg);
 	}
 /*
 	if ((id = pci_get_devid(dev)) == PCI_DEVICE_FORTEMEDIA2 ) {
@@ -697,7 +746,28 @@
 		return ENXIO;
 	}
 */
-	return ENXIO;
+	return (result);
+}
+
+static struct resource *
+fm801_alloc_resource(device_t bus, device_t child, int type, int *rid,
+		     u_long start, u_long end, u_long count, u_int flags)
+{
+	struct fm801_info *fm801;
+
+	fm801 = pcm_getdevinfo(bus);
+
+	if (type == SYS_RES_IOPORT && *rid == PCIR_MAPS)
+		return (fm801->reg);
+
+	return (NULL);
+}
+
+static int
+fm801_release_resource(device_t bus, device_t child, int type, int rid,
+		       struct resource *r)
+{
+	return (0);
 }
 
 static device_method_t fm801_methods[] = {
@@ -705,6 +775,16 @@
 	DEVMETHOD(device_probe,		fm801_pci_probe),
 	DEVMETHOD(device_attach,	fm801_pci_attach),
 	DEVMETHOD(device_detach,	fm801_pci_detach),
+	DEVMETHOD(device_shutdown,	bus_generic_shutdown),
+	DEVMETHOD(device_suspend,	bus_generic_suspend),
+	DEVMETHOD(device_resume,	bus_generic_resume),
+
+	/* Bus interface */
+	DEVMETHOD(bus_print_child,	bus_generic_print_child),
+	DEVMETHOD(bus_alloc_resource,	fm801_alloc_resource),
+	DEVMETHOD(bus_release_resource,	fm801_release_resource),
+	DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
+	DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
 	{ 0, 0}
 };
 
@@ -717,4 +797,3 @@
 DRIVER_MODULE(snd_fm801, pci, fm801_driver, pcm_devclass, 0, 0);
 MODULE_DEPEND(snd_fm801, snd_pcm, PCM_MINVER, PCM_PREFVER, PCM_MAXVER);
 MODULE_VERSION(snd_fm801, 1);
-

==== //depot/projects/ia64/sys/kern/imgact_elf.c#19 (text+ko) ====

@@ -27,7 +27,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/kern/imgact_elf.c,v 1.124 2002/09/02 17:27:30 dillon Exp $
+ * $FreeBSD: src/sys/kern/imgact_elf.c,v 1.125 2002/09/03 21:18:17 peter Exp $
  */
 
 #include <sys/param.h>
@@ -734,18 +734,20 @@
 			    phdr[i].p_vaddr - seg_addr);
 
 			/*
-			 * Is this .text or .data?  Use VM_PROT_WRITE
-			 * to distinguish between the two for the purpose
-			 * of limit checking and vmspace fields.
+			 * Check whether the entry point is in this segment
+			 * to determine whether to count is as text or data.
+			 * XXX: this needs to be done better!
 			 */
-			if (prot & VM_PROT_WRITE) {
+			if (hdr->e_entry >= phdr[i].p_vaddr &&
+			    hdr->e_entry < (phdr[i].p_vaddr +
+			    phdr[i].p_memsz)) {
+				text_size = seg_size;
+				text_addr = seg_addr;
+				entry = (u_long)hdr->e_entry;
+			} else {
 				data_size += seg_size;
 				if (data_addr == 0)
 					data_addr = seg_addr;
-			} else {
-				text_size += seg_size;
-				if (text_addr == 0)
-					text_addr = seg_addr;
 			}
 
 			/*
@@ -761,13 +763,6 @@
 				error = ENOMEM;
 				goto fail;
 			}
-
-			/* Does the entry point belong to this segment? */
-			if (hdr->e_entry >= phdr[i].p_vaddr &&
-			    hdr->e_entry < (phdr[i].p_vaddr +
-			    phdr[i].p_memsz)) {
-				entry = (u_long)hdr->e_entry;
-			}
 			break;
 		case PT_PHDR: 	/* Program header table info */
 			proghdr = phdr[i].p_vaddr;

==== //depot/projects/ia64/sys/kern/kern_descrip.c#31 (text+ko) ====

@@ -36,7 +36,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)kern_descrip.c	8.6 (Berkeley) 4/19/94
- * $FreeBSD: src/sys/kern/kern_descrip.c,v 1.157 2002/09/02 22:24:14 iedowse Exp $
+ * $FreeBSD: src/sys/kern/kern_descrip.c,v 1.158 2002/09/03 20:16:31 jhb Exp $
  */
 
 #include "opt_compat.h"
@@ -97,8 +97,11 @@
 	/* flags */	0,
 };
 
-static int do_dup(struct filedesc *fdp, int old, int new, register_t *retval,
-    struct thread *td);
+/* How to treat 'new' parameter when allocating a fd for do_dup(). */
+enum dup_type { DUP_VARIABLE, DUP_FIXED };
+
+static int do_dup(struct thread *td, enum dup_type type, int old, int new,
+    register_t *retval);
 static int badfo_readwrite(struct file *fp, struct uio *uio,
     struct ucred *active_cred, int flags, struct thread *td);
 static int badfo_ioctl(struct file *fp, u_long com, void *data,
@@ -166,37 +169,9 @@
 	struct thread *td;
 	struct dup2_args *uap;
 {
-	struct proc *p = td->td_proc;
-	register struct filedesc *fdp = td->td_proc->p_fd;
-	register u_int old = uap->from, new = uap->to;
-	int i, error;
 
-	FILEDESC_LOCK(fdp);
-retry:
-	if (old >= fdp->fd_nfiles ||
-	    fdp->fd_ofiles[old] == NULL ||
-	    new >= p->p_rlimit[RLIMIT_NOFILE].rlim_cur ||
-	    new >= maxfilesperproc) {
-		FILEDESC_UNLOCK(fdp);
-		return (EBADF);
-	}
-	if (old == new) {
-		td->td_retval[0] = new;
-		FILEDESC_UNLOCK(fdp);
-		return (0);
-	}
-	if (new >= fdp->fd_nfiles) {
-		if ((error = fdalloc(td, new, &i))) {
-			FILEDESC_UNLOCK(fdp);
-			return (error);
-		}
-		/*
-		 * fdalloc() may block, retest everything.
-		 */
-		goto retry;
-	}
-	error = do_dup(fdp, (int)old, (int)new, td->td_retval, td);
-	return(error);
+	return (do_dup(td, DUP_FIXED, (int)uap->from, (int)uap->to,
+		    td->td_retval));
 }
 
 /*
@@ -216,23 +191,8 @@
 	struct thread *td;
 	struct dup_args *uap;
 {
-	register struct filedesc *fdp;
-	u_int old;
-	int new, error;
 
-	old = uap->fd;
-	fdp = td->td_proc->p_fd;
-	FILEDESC_LOCK(fdp);
-	if (old >= fdp->fd_nfiles || fdp->fd_ofiles[old] == NULL) {
-		FILEDESC_UNLOCK(fdp);
-		return (EBADF);
-	}
-	if ((error = fdalloc(td, 0, &new))) {
-		FILEDESC_UNLOCK(fdp);
-		return (error);
-	}
-	error = do_dup(fdp, (int)old, new, td->td_retval, td);
-	return (error);
+	return (do_dup(td, DUP_VARIABLE, (int)uap->fd, 0, td->td_retval));
 }
 
 /*
@@ -294,7 +254,7 @@
 	register char *pop;
 	struct vnode *vp;
 	struct flock *flp;
-	int i, tmp, error = 0, flg = F_POSIX;
+	int tmp, error = 0, flg = F_POSIX;
 	u_int newmin;
 	struct proc *leaderp;
 
@@ -312,18 +272,14 @@
 
 	switch (cmd) {
 	case F_DUPFD:
+		FILEDESC_UNLOCK(fdp);
 		newmin = arg;
 		if (newmin >= p->p_rlimit[RLIMIT_NOFILE].rlim_cur ||
 		    newmin >= maxfilesperproc) {
-			FILEDESC_UNLOCK(fdp);
 			error = EINVAL;
 			break;
 		}
-		if ((error = fdalloc(td, newmin, &i))) {
-			FILEDESC_UNLOCK(fdp);
-			break;
-		}
-		error = do_dup(fdp, fd, i, td->td_retval, td);
+		error = do_dup(td, DUP_VARIABLE, fd, newmin, td->td_retval);
 		break;
 
 	case F_GETFD:
@@ -499,16 +455,72 @@
  * filedesc must be locked, but will be unlocked as a side effect.
  */
 static int
-do_dup(fdp, old, new, retval, td)
-	register struct filedesc *fdp;
-	register int old, new;
+do_dup(td, type, old, new, retval)
+	enum dup_type type;
+	int old, new;
 	register_t *retval;
 	struct thread *td;
 {
+	register struct filedesc *fdp;
+	struct proc *p;
 	struct file *fp;
 	struct file *delfp;
+	int error, newfd;
+
+	p = td->td_proc;
+	fdp = p->p_fd;
+
+	/*
+	 * Verify we have a valid descriptor to dup from and possibly to
+	 * dup to.
+	 */
+	FILEDESC_LOCK(fdp);
+	if (old >= fdp->fd_nfiles || fdp->fd_ofiles[old] == NULL ||
+	    new >= p->p_rlimit[RLIMIT_NOFILE].rlim_cur ||
+	    new >= maxfilesperproc) {
+		FILEDESC_UNLOCK(fdp);
+		return (EBADF);
+	}
+	if (type == DUP_FIXED && old == new) {
+		*retval = new;
+		FILEDESC_UNLOCK(fdp);
+		return (0);
+	}
+	fp = fdp->fd_ofiles[old];
+	fhold(fp);
+
+	/*
+	 * Expand the table for the new descriptor if needed.  This may
+	 * block and drop and reacquire the filedesc lock.
+	 */
+	if (type == DUP_VARIABLE || new >= fdp->fd_nfiles) {
+		error = fdalloc(td, new, &newfd);
+		if (error) {
+			FILEDESC_UNLOCK(fdp);
+			return (error);
+		}
+	}
+	if (type == DUP_VARIABLE)
+		new = newfd;
 
-	FILEDESC_LOCK_ASSERT(fdp, MA_OWNED);
+	/*
+	 * If the old file changed out from under us then treat it as a
+	 * bad file descriptor.  Userland should do its own locking to
+	 * avoid this case.
+	 */
+	if (fdp->fd_ofiles[old] != fp) {
+		if (fdp->fd_ofiles[new] == NULL) {
+			if (new < fdp->fd_freefile)
+				fdp->fd_freefile = new;
+			while (fdp->fd_lastfile > 0 &&
+			    fdp->fd_ofiles[fdp->fd_lastfile] == NULL)
+				fdp->fd_lastfile--;
+		}
+		FILEDESC_UNLOCK(fdp);
+		fdrop(fp, td);
+		return (EBADF);
+	}
+	KASSERT(old != new, ("new fd is same as old"));
 
 	/*
 	 * Save info on the descriptor being overwritten.  We have
@@ -516,6 +528,8 @@
 	 * introducing an ownership race for the slot.
 	 */
 	delfp = fdp->fd_ofiles[new];
+	KASSERT(delfp == NULL || type == DUP_FIXED,
+	    ("dup() picked an open file"));
 #if 0
 	if (delfp && (fdp->fd_ofileflags[new] & UF_MAPPED))
 		(void) munmapfd(td, new);
@@ -524,16 +538,13 @@
 	/*
 	 * Duplicate the source descriptor, update lastfile
 	 */
-	fp = fdp->fd_ofiles[old];
 	fdp->fd_ofiles[new] = fp;
-	fdp->fd_ofileflags[new] = fdp->fd_ofileflags[old] &~ UF_EXCLOSE;
-	fhold(fp);
+ 	fdp->fd_ofileflags[new] = fdp->fd_ofileflags[old] &~ UF_EXCLOSE;
 	if (new > fdp->fd_lastfile)
 		fdp->fd_lastfile = new;
+	FILEDESC_UNLOCK(fdp);
 	*retval = new;
 
-	FILEDESC_UNLOCK(fdp);
-
 	/*
 	 * If we dup'd over a valid file, we now own the reference to it
 	 * and must dispose of it using closef() semantics (as if a
@@ -1013,8 +1024,7 @@
 	lim = min((int)p->p_rlimit[RLIMIT_NOFILE].rlim_cur, maxfilesperproc);
 	for (;;) {
 		last = min(fdp->fd_nfiles, lim);
-		if ((i = want) < fdp->fd_freefile)
-			i = fdp->fd_freefile;
+		i = max(want, fdp->fd_freefile);
 		for (; i < last; i++) {
 			if (fdp->fd_ofiles[i] == NULL) {
 				fdp->fd_ofileflags[i] = 0;
@@ -1030,29 +1040,24 @@
 		/*
 		 * No space in current array.  Expand?
 		 */
-		if (fdp->fd_nfiles >= lim)
+		if (i >= lim)
 			return (EMFILE);
 		if (fdp->fd_nfiles < NDEXTENT)
 			nfiles = NDEXTENT;
 		else
 			nfiles = 2 * fdp->fd_nfiles;
+		while (nfiles < want)
+			nfiles <<= 1;
 		FILEDESC_UNLOCK(fdp);
-		mtx_lock(&Giant);
-		MALLOC(newofile, struct file **, nfiles * OFILESIZE,
-		    M_FILEDESC, M_WAITOK);
-		mtx_unlock(&Giant);
-		FILEDESC_LOCK(fdp);
+		newofile = malloc(nfiles * OFILESIZE, M_FILEDESC, M_WAITOK);
 
 		/*
-		 * deal with file-table extend race that might have occured
-		 * when malloc was blocked.
+		 * Deal with file-table extend race that might have
+		 * occurred while filedesc was unlocked.
 		 */
+		FILEDESC_LOCK(fdp);
 		if (fdp->fd_nfiles >= nfiles) {
-			FILEDESC_UNLOCK(fdp);
-			mtx_lock(&Giant);
-			FREE(newofile, M_FILEDESC);
-			mtx_unlock(&Giant);
-			FILEDESC_LOCK(fdp);
+			free(newofile, M_FILEDESC);
 			continue;
 		}
 		newofileflags = (char *) &newofile[nfiles];
@@ -1060,11 +1065,12 @@
 		 * Copy the existing ofile and ofileflags arrays
 		 * and zero the new portion of each array.
 		 */
-		bcopy(fdp->fd_ofiles, newofile,
-			(i = sizeof(struct file *) * fdp->fd_nfiles));
-		bzero((char *)newofile + i, nfiles * sizeof(struct file *) - i);
-		bcopy(fdp->fd_ofileflags, newofileflags,
-			(i = sizeof(char) * fdp->fd_nfiles));
+		i = fdp->fd_nfiles * sizeof(struct file *);
+		bcopy(fdp->fd_ofiles, newofile,	i);
+		bzero((char *)newofile + i,
+		    nfiles * sizeof(struct file *) - i);
+		i = fdp->fd_nfiles * sizeof(char);
+		bcopy(fdp->fd_ofileflags, newofileflags, i);
 		bzero(newofileflags + i, nfiles * sizeof(char) - i);
 		if (fdp->fd_nfiles > NDFILE)
 			oldofile = fdp->fd_ofiles;
@@ -1074,13 +1080,8 @@
 		fdp->fd_ofileflags = newofileflags;
 		fdp->fd_nfiles = nfiles;
 		fdexpand++;
-		if (oldofile != NULL) {
-			FILEDESC_UNLOCK(fdp);
-			mtx_lock(&Giant);
-			FREE(oldofile, M_FILEDESC);
-			mtx_unlock(&Giant);
-			FILEDESC_LOCK(fdp);
-		}
+		if (oldofile != NULL)
+			free(oldofile, M_FILEDESC);
 	}
 	return (0);
 }
@@ -1143,28 +1144,26 @@
 	 * descriptor to the list of open files at that point, otherwise
 	 * put it at the front of the list of open files.
 	 */
-	FILEDESC_LOCK(p->p_fd);
-	if ((error = fdalloc(td, 0, &i))) {
-		FILEDESC_UNLOCK(p->p_fd);
-		nfiles--;
-		sx_xunlock(&filelist_lock);
-		uma_zfree(file_zone, fp);
-		return (error);
-	}
 	fp->f_mtxp = mtx_pool_alloc();
 	fp->f_gcflag = 0;
 	fp->f_count = 1;
 	fp->f_cred = crhold(td->td_ucred);
 	fp->f_ops = &badfileops;
 	fp->f_seqcount = 1;
+	FILEDESC_LOCK(p->p_fd);
 	if ((fq = p->p_fd->fd_ofiles[0])) {
 		LIST_INSERT_AFTER(fq, fp, f_list);
 	} else {
 		LIST_INSERT_HEAD(&filehead, fp, f_list);
 	}
+	sx_xunlock(&filelist_lock);
+	if ((error = fdalloc(td, 0, &i))) {
+		FILEDESC_UNLOCK(p->p_fd);
+		fdrop(fp, td);
+		return (error);
+	}
 	p->p_fd->fd_ofiles[i] = fp;
 	FILEDESC_UNLOCK(p->p_fd);
-	sx_xunlock(&filelist_lock);
 	if (resultfp)
 		*resultfp = fp;
 	if (resultfd)
@@ -1559,13 +1558,14 @@
 			error = falloc(td, &fp, &fd);
 			if (error != 0)
 				break;
+			KASSERT(fd == i, ("oof, we didn't get our fd"));
 			NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, "/dev/null",
 			    td);
 			flags = FREAD | FWRITE;
 			error = vn_open(&nd, &flags, 0);
 			if (error != 0) {
 				FILEDESC_LOCK(fdp);
-				fdp->fd_ofiles[i] = NULL;
+				fdp->fd_ofiles[fd] = NULL;
 				FILEDESC_UNLOCK(fdp);
 				fdrop(fp, td);
 				break;
@@ -1578,13 +1578,7 @@
 			VOP_UNLOCK(nd.ni_vp, 0, td);
 			devnull = fd;
 		} else {
-			FILEDESC_LOCK(fdp);
-			error = fdalloc(td, 0, &fd);
-			if (error != 0) {
-				FILEDESC_UNLOCK(fdp);
-				break;
-			}
-			error = do_dup(fdp, devnull, fd, &retval, td);
+			error = do_dup(td, DUP_FIXED, devnull, i, &retval);
 			if (error != 0)
 				break;
 		}

==== //depot/projects/ia64/sys/kern/kern_mutex.c#12 (text+ko) ====

@@ -27,7 +27,7 @@
  *

>>> TRUNCATED FOR MAIL (1000 lines) <<<

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe p4-projects" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200209032202.g83M2xmv001422>