svn commit: r214357 - in projects/binutils-2.17: . bin/sh contrib/bsnmp/snmpd contrib/top etc/mtree lib/libc/mips lib/libfetch lib/libthr/thread sbin/camcontrol sbin/geom/class/part sbin/hastd shar...

Dimitry Andric dim at FreeBSD.org
Mon Oct 25 19:58:29 UTC 2010


Author: dim
Date: Mon Oct 25 19:58:28 2010
New Revision: 214357
URL: http://svn.freebsd.org/changeset/base/214357

Log:
  Sync: merge r214221 through r214352 from ^/head.

Added:
  projects/binutils-2.17/share/examples/jails/
     - copied from r214352, head/share/examples/jails/
  projects/binutils-2.17/share/examples/netgraph/virtual.chain
     - copied unchanged from r214352, head/share/examples/netgraph/virtual.chain
  projects/binutils-2.17/share/examples/netgraph/virtual.lan
     - copied unchanged from r214352, head/share/examples/netgraph/virtual.lan
  projects/binutils-2.17/sys/net/if_debug.c
     - copied unchanged from r214352, head/sys/net/if_debug.c
  projects/binutils-2.17/sys/netinet/in_debug.c
     - copied unchanged from r214352, head/sys/netinet/in_debug.c
  projects/binutils-2.17/tools/regression/bin/sh/execution/func3.0
     - copied unchanged from r214352, head/tools/regression/bin/sh/execution/func3.0
  projects/binutils-2.17/tools/regression/bin/sh/execution/redir3.0
     - copied unchanged from r214352, head/tools/regression/bin/sh/execution/redir3.0
  projects/binutils-2.17/tools/regression/bin/sh/execution/redir4.0
     - copied unchanged from r214352, head/tools/regression/bin/sh/execution/redir4.0
  projects/binutils-2.17/tools/regression/bin/sh/parser/alias1.0
     - copied unchanged from r214352, head/tools/regression/bin/sh/parser/alias1.0
  projects/binutils-2.17/tools/regression/bin/sh/parser/alias2.0
     - copied unchanged from r214352, head/tools/regression/bin/sh/parser/alias2.0
  projects/binutils-2.17/tools/regression/bin/sh/parser/func1.0
     - copied unchanged from r214352, head/tools/regression/bin/sh/parser/func1.0
  projects/binutils-2.17/tools/regression/bin/sh/parser/pipe-not1.0
     - copied unchanged from r214352, head/tools/regression/bin/sh/parser/pipe-not1.0
Modified:
  projects/binutils-2.17/UPDATING
  projects/binutils-2.17/bin/sh/mksyntax.c
  projects/binutils-2.17/bin/sh/parser.c
  projects/binutils-2.17/bin/sh/redir.c
  projects/binutils-2.17/contrib/bsnmp/snmpd/bsnmpd.1
  projects/binutils-2.17/etc/mtree/BSD.usr.dist
  projects/binutils-2.17/lib/libc/mips/SYS.h
  projects/binutils-2.17/lib/libfetch/common.c
  projects/binutils-2.17/lib/libthr/thread/thr_attr.c
  projects/binutils-2.17/lib/libthr/thread/thr_private.h
  projects/binutils-2.17/sbin/camcontrol/camcontrol.c
  projects/binutils-2.17/sbin/geom/class/part/geom_part.c
  projects/binutils-2.17/sbin/geom/class/part/gpart.8
  projects/binutils-2.17/sbin/hastd/hastd.c
  projects/binutils-2.17/sbin/hastd/nv.c
  projects/binutils-2.17/sbin/hastd/nv.h
  projects/binutils-2.17/sbin/hastd/parse.y
  projects/binutils-2.17/sbin/hastd/primary.c
  projects/binutils-2.17/sbin/hastd/secondary.c
  projects/binutils-2.17/sbin/hastd/synch.h
  projects/binutils-2.17/share/examples/Makefile
  projects/binutils-2.17/share/man/man4/ada.4
  projects/binutils-2.17/share/man/man9/Makefile
  projects/binutils-2.17/share/man/man9/make_dev.9
  projects/binutils-2.17/sys/amd64/amd64/fpu.c
  projects/binutils-2.17/sys/amd64/include/profile.h
  projects/binutils-2.17/sys/boot/pc98/boot2/boot2.c
  projects/binutils-2.17/sys/cam/ata/ata_da.c
  projects/binutils-2.17/sys/cam/cam_xpt.c
  projects/binutils-2.17/sys/cam/scsi/scsi_da.c
  projects/binutils-2.17/sys/conf/files
  projects/binutils-2.17/sys/dev/ahci/ahci.c
  projects/binutils-2.17/sys/dev/bge/if_bge.c
  projects/binutils-2.17/sys/dev/bge/if_bgereg.h
  projects/binutils-2.17/sys/dev/fxp/if_fxp.c
  projects/binutils-2.17/sys/dev/iwi/if_iwi.c
  projects/binutils-2.17/sys/dev/mii/mii_physubr.c
  projects/binutils-2.17/sys/dev/mii/miivar.h
  projects/binutils-2.17/sys/dev/mii/mlphy.c
  projects/binutils-2.17/sys/dev/mii/pnaphy.c
  projects/binutils-2.17/sys/dev/mii/smcphy.c
  projects/binutils-2.17/sys/dev/mii/tlphy.c
  projects/binutils-2.17/sys/dev/pci/pci.c
  projects/binutils-2.17/sys/dev/siis/siis.c
  projects/binutils-2.17/sys/dev/sound/pcm/channel.c
  projects/binutils-2.17/sys/dev/tl/if_tl.c
  projects/binutils-2.17/sys/dev/tl/if_tlreg.h
  projects/binutils-2.17/sys/dev/usb/controller/ehci.c
  projects/binutils-2.17/sys/dev/usb/controller/ehcireg.h
  projects/binutils-2.17/sys/dev/usb/usb_device.c
  projects/binutils-2.17/sys/dev/usb/usb_freebsd.h
  projects/binutils-2.17/sys/fs/nfs/nfs_var.h
  projects/binutils-2.17/sys/fs/nfs/nfsdport.h
  projects/binutils-2.17/sys/fs/nfsserver/nfs_nfsdport.c
  projects/binutils-2.17/sys/geom/eli/g_eli.c
  projects/binutils-2.17/sys/geom/eli/g_eli_ctl.c
  projects/binutils-2.17/sys/geom/eli/g_eli_key.c
  projects/binutils-2.17/sys/geom/part/g_part.c
  projects/binutils-2.17/sys/geom/part/g_part.h
  projects/binutils-2.17/sys/geom/part/g_part_gpt.c
  projects/binutils-2.17/sys/geom/part/g_part_if.m
  projects/binutils-2.17/sys/i386/i386/elan-mmcr.c
  projects/binutils-2.17/sys/i386/i386/identcpu.c
  projects/binutils-2.17/sys/i386/i386/initcpu.c
  projects/binutils-2.17/sys/i386/i386/longrun.c
  projects/binutils-2.17/sys/i386/i386/perfmon.c
  projects/binutils-2.17/sys/i386/include/profile.h
  projects/binutils-2.17/sys/i386/isa/npx.c
  projects/binutils-2.17/sys/kern/kern_cpuset.c
  projects/binutils-2.17/sys/kern/kern_kthread.c
  projects/binutils-2.17/sys/kern/kern_shutdown.c
  projects/binutils-2.17/sys/kern/kern_thr.c
  projects/binutils-2.17/sys/kern/subr_acl_nfs4.c
  projects/binutils-2.17/sys/kern/vfs_bio.c
  projects/binutils-2.17/sys/net/if.c
  projects/binutils-2.17/sys/netinet/ip_ipsec.c
  projects/binutils-2.17/sys/netinet6/ip6_ipsec.c
  projects/binutils-2.17/sys/netipsec/ipsec_input.c
  projects/binutils-2.17/sys/netipsec/ipsec_output.c
  projects/binutils-2.17/sys/netipsec/key.c
  projects/binutils-2.17/sys/netipsec/keydb.h
  projects/binutils-2.17/sys/pc98/pc98/machdep.c
  projects/binutils-2.17/sys/powerpc/mambo/mambo_console.c
  projects/binutils-2.17/sys/security/mac/mac_vfs.c
  projects/binutils-2.17/sys/x86/x86/local_apic.c
  projects/binutils-2.17/tools/tools/syscall_timing/syscall_timing.c
  projects/binutils-2.17/usr.bin/lex/flex.skl
  projects/binutils-2.17/usr.sbin/usbconfig/usbconfig.c
Directory Properties:
  projects/binutils-2.17/   (props changed)
  projects/binutils-2.17/cddl/contrib/opensolaris/   (props changed)
  projects/binutils-2.17/contrib/bind9/   (props changed)
  projects/binutils-2.17/contrib/binutils/   (props changed)
  projects/binutils-2.17/contrib/bzip2/   (props changed)
  projects/binutils-2.17/contrib/ee/   (props changed)
  projects/binutils-2.17/contrib/expat/   (props changed)
  projects/binutils-2.17/contrib/file/   (props changed)
  projects/binutils-2.17/contrib/gdb/   (props changed)
  projects/binutils-2.17/contrib/gdtoa/   (props changed)
  projects/binutils-2.17/contrib/gnu-sort/   (props changed)
  projects/binutils-2.17/contrib/groff/   (props changed)
  projects/binutils-2.17/contrib/less/   (props changed)
  projects/binutils-2.17/contrib/libpcap/   (props changed)
  projects/binutils-2.17/contrib/llvm/   (props changed)
  projects/binutils-2.17/contrib/llvm/tools/clang/   (props changed)
  projects/binutils-2.17/contrib/ncurses/   (props changed)
  projects/binutils-2.17/contrib/netcat/   (props changed)
  projects/binutils-2.17/contrib/ntp/   (props changed)
  projects/binutils-2.17/contrib/one-true-awk/   (props changed)
  projects/binutils-2.17/contrib/openbsm/   (props changed)
  projects/binutils-2.17/contrib/openpam/   (props changed)
  projects/binutils-2.17/contrib/pf/   (props changed)
  projects/binutils-2.17/contrib/sendmail/   (props changed)
  projects/binutils-2.17/contrib/tcpdump/   (props changed)
  projects/binutils-2.17/contrib/tcsh/   (props changed)
  projects/binutils-2.17/contrib/top/   (props changed)
  projects/binutils-2.17/contrib/top/install-sh   (props changed)
  projects/binutils-2.17/contrib/tzcode/stdtime/   (props changed)
  projects/binutils-2.17/contrib/tzcode/zic/   (props changed)
  projects/binutils-2.17/contrib/tzdata/   (props changed)
  projects/binutils-2.17/contrib/wpa/   (props changed)
  projects/binutils-2.17/contrib/xz/   (props changed)
  projects/binutils-2.17/crypto/openssh/   (props changed)
  projects/binutils-2.17/crypto/openssl/   (props changed)
  projects/binutils-2.17/lib/libc/   (props changed)
  projects/binutils-2.17/lib/libc/stdtime/   (props changed)
  projects/binutils-2.17/lib/libutil/   (props changed)
  projects/binutils-2.17/lib/libz/   (props changed)
  projects/binutils-2.17/sbin/   (props changed)
  projects/binutils-2.17/sbin/ipfw/   (props changed)
  projects/binutils-2.17/share/mk/bsd.arch.inc.mk   (props changed)
  projects/binutils-2.17/share/zoneinfo/   (props changed)
  projects/binutils-2.17/sys/   (props changed)
  projects/binutils-2.17/sys/amd64/include/xen/   (props changed)
  projects/binutils-2.17/sys/cddl/contrib/opensolaris/   (props changed)
  projects/binutils-2.17/sys/contrib/dev/acpica/   (props changed)
  projects/binutils-2.17/sys/contrib/pf/   (props changed)
  projects/binutils-2.17/sys/contrib/x86emu/   (props changed)
  projects/binutils-2.17/sys/dev/xen/xenpci/   (props changed)
  projects/binutils-2.17/usr.bin/calendar/   (props changed)
  projects/binutils-2.17/usr.bin/csup/   (props changed)
  projects/binutils-2.17/usr.bin/procstat/   (props changed)
  projects/binutils-2.17/usr.sbin/zic/   (props changed)

Modified: projects/binutils-2.17/UPDATING
==============================================================================
--- projects/binutils-2.17/UPDATING	Mon Oct 25 19:56:02 2010	(r214356)
+++ projects/binutils-2.17/UPDATING	Mon Oct 25 19:58:28 2010	(r214357)
@@ -35,10 +35,10 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 9.
 20100915:
 	A workaround for a fixed ld bug has been removed in kernel code,
 	so make sure that your system ld is built from sources after
-	revision 210245 (r211583 if building head kernel on stable/8,
-	r211584 for stable/7).  A symptom of incorrect ld version is
-	different addresses for set_pcpu section and __start_set_pcpu
-	symbol in kernel and/or modules.
+	revision 210245 from 2010-07-19 (r211583 if building head kernel
+	on stable/8, r211584 for stable/7; both from 2010-08-21).
+	A symptom of incorrect ld version is different addresses for
+	set_pcpu section and __start_set_pcpu symbol in kernel and/or modules.
 
 20100913:
 	The $ipv6_prefer variable in rc.conf(5) has been split into

Modified: projects/binutils-2.17/bin/sh/mksyntax.c
==============================================================================
--- projects/binutils-2.17/bin/sh/mksyntax.c	Mon Oct 25 19:56:02 2010	(r214356)
+++ projects/binutils-2.17/bin/sh/mksyntax.c	Mon Oct 25 19:58:28 2010	(r214357)
@@ -75,6 +75,7 @@ struct synclass synclass[] = {
 	{ "CEOF",	"end of file" },
 	{ "CCTL",	"like CWORD, except it must be escaped" },
 	{ "CSPCL",	"these terminate a word" },
+	{ "CIGN",       "character should be ignored" },
 	{ NULL,		NULL }
 };
 
@@ -232,7 +233,7 @@ main(int argc __unused, char **argv __un
 	add("\n", "CNL");
 	add("\\", "CBACK");
 	add("`", "CBQUOTE");
-	add("\"", "CDQUOTE");
+	add("\"", "CIGN");
 	add("$", "CVAR");
 	add("}", "CENDVAR");
 	add("(", "CLP");

Modified: projects/binutils-2.17/bin/sh/parser.c
==============================================================================
--- projects/binutils-2.17/bin/sh/parser.c	Mon Oct 25 19:56:02 2010	(r214356)
+++ projects/binutils-2.17/bin/sh/parser.c	Mon Oct 25 19:58:28 2010	(r214357)
@@ -57,6 +57,7 @@ __FBSDID("$FreeBSD$");
 #include "alias.h"
 #include "show.h"
 #include "eval.h"
+#include "exec.h"	/* to check for special builtins */
 #ifndef NO_HISTORY
 #include "myhistedit.h"
 #endif
@@ -328,7 +329,7 @@ pipeline(void)
 {
 	union node *n1, *n2, *pipenode;
 	struct nodelist *lp, *prev;
-	int negate;
+	int negate, t;
 
 	negate = 0;
 	checkkwd = 2;
@@ -347,7 +348,13 @@ pipeline(void)
 		do {
 			prev = lp;
 			lp = (struct nodelist *)stalloc(sizeof (struct nodelist));
-			lp->n = command();
+			checkkwd = 2;
+			t = readtoken();
+			tokpushback++;
+			if (t == TNOT)
+				lp->n = pipeline();
+			else
+				lp->n = command();
 			prev->next = lp;
 		} while (readtoken() == TPIPE);
 		lp->next = NULL;
@@ -372,7 +379,7 @@ command(void)
 	union node *ap, **app;
 	union node *cp, **cpp;
 	union node *redir, **rpp;
-	int t, negate = 0;
+	int t;
 
 	checkkwd = 2;
 	redir = NULL;
@@ -387,12 +394,6 @@ command(void)
 	}
 	tokpushback++;
 
-	while (readtoken() == TNOT) {
-		TRACE(("command: TNOT recognized\n"));
-		negate = !negate;
-	}
-	tokpushback++;
-
 	switch (readtoken()) {
 	case TIF:
 		n1 = (union node *)stalloc(sizeof (struct nif));
@@ -573,7 +574,7 @@ TRACE(("expecting DO got %s %s\n", tokna
 	case TRP:
 		tokpushback++;
 		n1 = simplecmd(rpp, redir);
-		goto checkneg;
+		return n1;
 	default:
 		synexpect(-1);
 	}
@@ -596,15 +597,7 @@ TRACE(("expecting DO got %s %s\n", tokna
 		n1->nredir.redirect = redir;
 	}
 
-checkneg:
-	if (negate) {
-		n2 = (union node *)stalloc(sizeof (struct nnot));
-		n2->type = NNOT;
-		n2->nnot.com = n1;
-		return n2;
-	}
-	else
-		return n1;
+	return n1;
 }
 
 
@@ -614,6 +607,7 @@ simplecmd(union node **rpp, union node *
 	union node *args, **app;
 	union node **orig_rpp = rpp;
 	union node *n = NULL;
+	int special;
 
 	/* If we don't have any redirections already, then we must reset */
 	/* rpp to be the address of the local redir variable.  */
@@ -647,10 +641,17 @@ simplecmd(union node **rpp, union node *
 			if (readtoken() != TRP)
 				synexpect(TRP);
 			funclinno = plinno;
-#ifdef notdef
-			if (! goodname(n->narg.text))
+			/*
+			 * - Require plain text.
+			 * - Functions with '/' cannot be called.
+			 */
+			if (!noexpand(n->narg.text) || quoteflag ||
+			    strchr(n->narg.text, '/'))
 				synerror("Bad function name");
-#endif
+			rmescapes(n->narg.text);
+			if (find_builtin(n->narg.text, &special) >= 0 &&
+			    special)
+				synerror("Cannot override a special builtin with a function");
 			n->type = NDEFUN;
 			n->narg.next = command();
 			funclinno = 0;
@@ -1223,10 +1224,7 @@ readtoken1(int firstc, char const *initi
 				if (eofmark != NULL && newvarnest == 0)
 					USTPUTC(c, out);
 				else {
-					if (state[level].category == TSTATE_ARITH)
-						state[level].syntax = ARISYNTAX;
-					else
-						state[level].syntax = BASESYNTAX;
+					state[level].syntax = BASESYNTAX;
 					quotef++;
 				}
 				break;
@@ -1281,6 +1279,8 @@ readtoken1(int firstc, char const *initi
 				break;
 			case CEOF:
 				goto endword;		/* exit outer loop */
+			case CIGN:
+				break;
 			default:
 				if (level == 0)
 					goto endword;	/* exit outer loop */

Modified: projects/binutils-2.17/bin/sh/redir.c
==============================================================================
--- projects/binutils-2.17/bin/sh/redir.c	Mon Oct 25 19:56:02 2010	(r214356)
+++ projects/binutils-2.17/bin/sh/redir.c	Mon Oct 25 19:58:28 2010	(r214357)
@@ -217,8 +217,11 @@ movefd:
 		if (redir->ndup.dupfd >= 0) {	/* if not ">&-" */
 			if (memory[redir->ndup.dupfd])
 				memory[fd] = 1;
-			else
-				dup2(redir->ndup.dupfd, fd);
+			else {
+				if (dup2(redir->ndup.dupfd, fd) < 0)
+					error("%d: %s", redir->ndup.dupfd,
+							strerror(errno));
+			}
 		} else {
 			close(fd);
 		}

Modified: projects/binutils-2.17/contrib/bsnmp/snmpd/bsnmpd.1
==============================================================================
--- projects/binutils-2.17/contrib/bsnmp/snmpd/bsnmpd.1	Mon Oct 25 19:56:02 2010	(r214356)
+++ projects/binutils-2.17/contrib/bsnmp/snmpd/bsnmpd.1	Mon Oct 25 19:58:28 2010	(r214357)
@@ -31,7 +31,7 @@
 .\"
 .\" $Begemot: bsnmp/snmpd/bsnmpd.1,v 1.12 2006/02/27 09:50:03 brandt_h Exp $
 .\"
-.Dd August 16, 2010
+.Dd October 23, 2010
 .Dt BSNMPD 1
 .Os
 .Sh NAME
@@ -68,11 +68,9 @@ Use
 .Ar file
 as configuration file instead of the standard one.
 .It Fl D Ar options
-Debugging options are specified with a
-.Fl o
-flag followed by a comma separated string of options.
+Debugging options are specified as a comma separated string.
 The following options are available.
-.Bl -tag -width ".It Cm trace Ns Cm = Ns Cm level"
+.Bl -tag -width "trace=level"
 .It Cm dump
 Dump all sent and received PDUs to the terminal.
 .It Cm events

Modified: projects/binutils-2.17/etc/mtree/BSD.usr.dist
==============================================================================
--- projects/binutils-2.17/etc/mtree/BSD.usr.dist	Mon Oct 25 19:56:02 2010	(r214356)
+++ projects/binutils-2.17/etc/mtree/BSD.usr.dist	Mon Oct 25 19:58:28 2010	(r214357)
@@ -227,6 +227,8 @@
             ..
             iscsi
             ..
+            jails
+            ..
             kld
                 cdev
                     module

Modified: projects/binutils-2.17/lib/libc/mips/SYS.h
==============================================================================
--- projects/binutils-2.17/lib/libc/mips/SYS.h	Mon Oct 25 19:56:02 2010	(r214356)
+++ projects/binutils-2.17/lib/libc/mips/SYS.h	Mon Oct 25 19:58:28 2010	(r214357)
@@ -91,7 +91,7 @@
 #else
 # define PIC_PROLOGUE(x)
 # define PIC_TAILCALL(l)	j  _C_LABEL(l)
-# define PIC_RETURN()
+# define PIC_RETURN()		j ra
 #endif /* __ABICALLS__ */
 
 # define SYSTRAP(x)	li v0,SYS_ ## x; syscall;

Modified: projects/binutils-2.17/lib/libfetch/common.c
==============================================================================
--- projects/binutils-2.17/lib/libfetch/common.c	Mon Oct 25 19:56:02 2010	(r214356)
+++ projects/binutils-2.17/lib/libfetch/common.c	Mon Oct 25 19:58:28 2010	(r214357)
@@ -321,9 +321,9 @@ fetch_connect(const char *host, int port
 int
 fetch_ssl(conn_t *conn, int verbose)
 {
+#ifdef WITH_SSL
 	int ret, ssl_err;
 
-#ifdef WITH_SSL
 	/* Init the SSL library and context */
 	if (!SSL_library_init()){
 		fprintf(stderr, "SSL library init failed\n");

Modified: projects/binutils-2.17/lib/libthr/thread/thr_attr.c
==============================================================================
--- projects/binutils-2.17/lib/libthr/thread/thr_attr.c	Mon Oct 25 19:56:02 2010	(r214356)
+++ projects/binutils-2.17/lib/libthr/thread/thr_attr.c	Mon Oct 25 19:58:28 2010	(r214357)
@@ -104,6 +104,8 @@
 
 #include "thr_private.h"
 
+static size_t	_get_kern_cpuset_size(void);
+
 __weak_reference(_pthread_attr_destroy, pthread_attr_destroy);
 
 int
@@ -116,6 +118,8 @@ _pthread_attr_destroy(pthread_attr_t *at
 		/* Invalid argument: */
 		ret = EINVAL;
 	else {
+		if ((*attr)->cpuset != NULL)
+			free((*attr)->cpuset);
 		/* Free the memory allocated to the attribute object: */
 		free(*attr);
 
@@ -132,28 +136,43 @@ _pthread_attr_destroy(pthread_attr_t *at
 __weak_reference(_pthread_attr_get_np, pthread_attr_get_np);
 
 int
-_pthread_attr_get_np(pthread_t pthread, pthread_attr_t *dst)
+_pthread_attr_get_np(pthread_t pthread, pthread_attr_t *dstattr)
 {
 	struct pthread *curthread;
-	struct pthread_attr attr;
+	struct pthread_attr attr, *dst;
 	int	ret;
+	size_t	cpusetsize;
 
-	if (pthread == NULL || dst == NULL || *dst == NULL)
+	if (pthread == NULL || dstattr == NULL || (dst = *dstattr) == NULL)
 		return (EINVAL);
-
+	cpusetsize = _get_kern_cpuset_size();
+	if (dst->cpusetsize < cpusetsize) {
+		char *newset = realloc(dst->cpuset, cpusetsize);
+		if (newset == NULL)
+			return (errno);
+		memset(newset + dst->cpusetsize, 0, cpusetsize -
+			dst->cpusetsize);
+		dst->cpuset = (cpuset_t *)newset;
+		dst->cpusetsize = cpusetsize;
+	}
 	curthread = _get_curthread();
 	if ((ret = _thr_find_thread(curthread, pthread, /*include dead*/0)) != 0)
 		return (ret);
 	attr = pthread->attr;
 	if (pthread->flags & THR_FLAGS_DETACHED)
 		attr.flags |= PTHREAD_DETACHED;
+	ret = cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_TID, TID(pthread),
+		dst->cpusetsize, dst->cpuset);
+	if (ret == -1)
+		ret = errno;
 	THR_THREAD_UNLOCK(curthread, pthread);
-
-	memcpy(*dst, &attr, sizeof(struct pthread_attr));
-	/* XXX */
-	(*dst)->cpuset = NULL;
-	(*dst)->cpusetsize = 0;
-	return (0);
+	if (ret == 0) {
+		memcpy(&dst->pthread_attr_start_copy, 
+			&attr.pthread_attr_start_copy, 
+			offsetof(struct pthread_attr, pthread_attr_end_copy) -
+			offsetof(struct pthread_attr, pthread_attr_start_copy));
+	}
+	return (ret);
 }
 
 __weak_reference(_pthread_attr_getdetachstate, pthread_attr_getdetachstate);

Modified: projects/binutils-2.17/lib/libthr/thread/thr_private.h
==============================================================================
--- projects/binutils-2.17/lib/libthr/thread/thr_private.h	Mon Oct 25 19:56:02 2010	(r214356)
+++ projects/binutils-2.17/lib/libthr/thread/thr_private.h	Mon Oct 25 19:58:28 2010	(r214357)
@@ -230,6 +230,7 @@ struct pthread_atfork {
 };
 
 struct pthread_attr {
+#define pthread_attr_start_copy	sched_policy
 	int	sched_policy;
 	int	sched_inherit;
 	int	prio;
@@ -239,6 +240,7 @@ struct pthread_attr {
 	void	*stackaddr_attr;
 	size_t	stacksize_attr;
 	size_t	guardsize_attr;
+#define pthread_attr_end_copy	cpuset
 	cpuset_t	*cpuset;
 	size_t	cpusetsize;
 };

Modified: projects/binutils-2.17/sbin/camcontrol/camcontrol.c
==============================================================================
--- projects/binutils-2.17/sbin/camcontrol/camcontrol.c	Mon Oct 25 19:56:02 2010	(r214356)
+++ projects/binutils-2.17/sbin/camcontrol/camcontrol.c	Mon Oct 25 19:58:28 2010	(r214357)
@@ -116,7 +116,7 @@ typedef enum {
 } cam_argmask;
 
 struct camcontrol_opts {
-	const char	*optname;	
+	const char	*optname;
 	cam_cmdmask	cmdnum;
 	cam_argmask	argnum;
 	const char	*subopt;
@@ -204,7 +204,7 @@ static int readdefects(struct cam_device
 		       char *combinedopt, int retry_count, int timeout);
 static void modepage(struct cam_device *device, int argc, char **argv,
 		     char *combinedopt, int retry_count, int timeout);
-static int scsicmd(struct cam_device *device, int argc, char **argv, 
+static int scsicmd(struct cam_device *device, int argc, char **argv,
 		   char *combinedopt, int retry_count, int timeout);
 static int tagcontrol(struct cam_device *device, int argc, char **argv,
 		      char *combinedopt);
@@ -234,7 +234,7 @@ static int atapm(struct cam_device *devi
 #endif
 
 camcontrol_optret
-getoption(char *arg, cam_cmdmask *cmdnum, cam_argmask *argnum, 
+getoption(char *arg, cam_cmdmask *cmdnum, cam_argmask *argnum,
 	  const char **subopt)
 {
 	struct camcontrol_opts *opts;
@@ -622,7 +622,7 @@ scsistart(struct cam_device *device, int
 		else
 			fprintf(stdout,
 				"Error received from stop unit command\n");
-			
+
 		if (arglist & CAM_ARG_VERBOSE) {
 			cam_error_print(device, ccb, CAM_ESF_ALL,
 					CAM_EPF_ALL, stderr);
@@ -688,7 +688,7 @@ scsiinquiry(struct cam_device *device, i
 	union ccb *ccb;
 	struct scsi_inquiry_data *inq_buf;
 	int error = 0;
-	
+
 	ccb = cam_getccb(device);
 
 	if (ccb == NULL) {
@@ -721,13 +721,13 @@ scsiinquiry(struct cam_device *device, i
 	 *    scsi_inquiry() will convert an inq_len (which is passed in as
 	 *    a u_int32_t, but the field in the CDB is only 1 byte) of 256
 	 *    to 0.  Evidently, very few devices meet the spec in that
-	 *    regard.  Some devices, like many Seagate disks, take the 0 as 
+	 *    regard.  Some devices, like many Seagate disks, take the 0 as
 	 *    0, and don't return any data.  One Pioneer DVD-R drive
 	 *    returns more data than the command asked for.
 	 *
 	 *    So, since there are numerous devices that just don't work
 	 *    right with the full inquiry size, we don't send the full size.
-	 * 
+	 *
 	 *  - The second reason not to use the full inquiry data length is
 	 *    that we don't need it here.  The only reason we issue a
 	 *    standard inquiry is to get the vendor name, device name,
@@ -1181,7 +1181,7 @@ atacapprint(struct ata_params *parm)
 	}
 
 	printf("\nFeature                      "
-		"Support  Enable    Value           Vendor\n");
+		"Support  Enabled   Value           Vendor\n");
 	printf("read ahead                     %s	%s\n",
 		parm->support.command1 & ATA_SUPPORT_LOOKAHEAD ? "yes" : "no",
 		parm->enabled.command1 & ATA_SUPPORT_LOOKAHEAD ? "yes" : "no");
@@ -1201,16 +1201,13 @@ atacapprint(struct ata_params *parm)
 			    ATA_QUEUE_LEN(parm->queue) + 1);
 		} else
 			printf("\n");
-	if (parm->satacapabilities && parm->satacapabilities != 0xffff) {
-		printf("Native Command Queuing (NCQ)   %s	",
-			parm->satacapabilities & ATA_SUPPORT_NCQ ?
-				"yes" : "no");
-		if (parm->satacapabilities & ATA_SUPPORT_NCQ) {
-			printf("	%d tags\n",
-			    ATA_QUEUE_LEN(parm->queue) + 1);
-		} else
-			printf("\n");
-	}
+	printf("Native Command Queuing (NCQ)   ");
+	if (parm->satacapabilities != 0xffff &&
+	    (parm->satacapabilities & ATA_SUPPORT_NCQ)) {
+		printf("yes		%d tags\n",
+		    ATA_QUEUE_LEN(parm->queue) + 1);
+	} else
+		printf("no\n");
 	printf("SMART                          %s	%s\n",
 		parm->support.command1 & ATA_SUPPORT_SMART ? "yes" : "no",
 		parm->enabled.command1 & ATA_SUPPORT_SMART ? "yes" : "no");
@@ -1223,28 +1220,39 @@ atacapprint(struct ata_params *parm)
 	printf("power management               %s	%s\n",
 		parm->support.command1 & ATA_SUPPORT_POWERMGT ? "yes" : "no",
 		parm->enabled.command1 & ATA_SUPPORT_POWERMGT ? "yes" : "no");
-	printf("advanced power management      %s	%s	%d/0x%02X\n",
+	printf("advanced power management      %s	%s",
 		parm->support.command2 & ATA_SUPPORT_APM ? "yes" : "no",
-		parm->enabled.command2 & ATA_SUPPORT_APM ? "yes" : "no",
-		parm->apm_value, parm->apm_value);
-	printf("automatic acoustic management  %s	%s	"
-		"%d/0x%02X	%d/0x%02X\n",
+		parm->enabled.command2 & ATA_SUPPORT_APM ? "yes" : "no");
+		if (parm->support.command2 & ATA_SUPPORT_APM) {
+			printf("	%d/0x%02X\n",
+			    parm->apm_value, parm->apm_value);
+		} else
+			printf("\n");
+	printf("automatic acoustic management  %s	%s",
 		parm->support.command2 & ATA_SUPPORT_AUTOACOUSTIC ? "yes" :"no",
-		parm->enabled.command2 & ATA_SUPPORT_AUTOACOUSTIC ? "yes" :"no",
-		ATA_ACOUSTIC_CURRENT(parm->acoustic),
-		ATA_ACOUSTIC_CURRENT(parm->acoustic),
-		ATA_ACOUSTIC_VENDOR(parm->acoustic),
-		ATA_ACOUSTIC_VENDOR(parm->acoustic));
+		parm->enabled.command2 & ATA_SUPPORT_AUTOACOUSTIC ? "yes" :"no");
+		if (parm->support.command2 & ATA_SUPPORT_AUTOACOUSTIC) {
+			printf("	%d/0x%02X	%d/0x%02X\n",
+			    ATA_ACOUSTIC_CURRENT(parm->acoustic),
+			    ATA_ACOUSTIC_CURRENT(parm->acoustic),
+			    ATA_ACOUSTIC_VENDOR(parm->acoustic),
+			    ATA_ACOUSTIC_VENDOR(parm->acoustic));
+		} else
+			printf("\n");
 	printf("media status notification      %s	%s\n",
 		parm->support.command2 & ATA_SUPPORT_NOTIFY ? "yes" : "no",
 		parm->enabled.command2 & ATA_SUPPORT_NOTIFY ? "yes" : "no");
 	printf("power-up in Standby            %s	%s\n",
 		parm->support.command2 & ATA_SUPPORT_STANDBY ? "yes" : "no",
 		parm->enabled.command2 & ATA_SUPPORT_STANDBY ? "yes" : "no");
-	printf("write-read-verify              %s	%s	%d/0x%x\n",
+	printf("write-read-verify              %s	%s",
 		parm->support2 & ATA_SUPPORT_WRITEREADVERIFY ? "yes" : "no",
-		parm->enabled2 & ATA_SUPPORT_WRITEREADVERIFY ? "yes" : "no",
-		parm->wrv_mode, parm->wrv_mode);
+		parm->enabled2 & ATA_SUPPORT_WRITEREADVERIFY ? "yes" : "no");
+		if (parm->support2 & ATA_SUPPORT_WRITEREADVERIFY) {
+			printf("	%d/0x%x\n",
+			    parm->wrv_mode, parm->wrv_mode);
+		} else
+			printf("\n");
 	printf("unload                         %s	%s\n",
 		parm->support.extension & ATA_SUPPORT_UNLOAD ? "yes" : "no",
 		parm->enabled.extension & ATA_SUPPORT_UNLOAD ? "yes" : "no");
@@ -1255,7 +1263,6 @@ atacapprint(struct ata_params *parm)
 		parm->support_dsm & ATA_SUPPORT_DSM_TRIM ? "yes" : "no");
 }
 
-
 static int
 ataidentify(struct cam_device *device, int retry_count, int timeout)
 {
@@ -1902,7 +1909,7 @@ readdefects(struct cam_device *device, i
 
 	/*
 	 * XXX KDM  I should probably clean up the printout format for the
-	 * disk defects. 
+	 * disk defects.
 	 */
 	switch (returned_format & SRDDH10_DLIST_FORMAT_MASK){
 		case SRDDH10_PHYSICAL_SECTOR_FORMAT:
@@ -2011,7 +2018,7 @@ void
 reassignblocks(struct cam_device *device, u_int32_t *blocks, int num_blocks)
 {
 	union ccb *ccb;
-	
+
 	ccb = cam_getccb(device);
 
 	cam_freeccb(ccb);
@@ -2114,7 +2121,7 @@ mode_select(struct cam_device *device, i
 			err(1, "error sending mode select command");
 		else
 			errx(1, "error sending mode select command");
-		
+
 	}
 
 	cam_freeccb(ccb);
@@ -2294,7 +2301,7 @@ scsicmd(struct cam_device *device, int a
 			if (arglist & CAM_ARG_CMD_IN) {
 				warnx("command must either be "
 				      "read or write, not both");
-				error = 1;	
+				error = 1;
 				goto scsicmd_bailout;
 			}
 			arglist |= CAM_ARG_CMD_OUT;
@@ -2611,7 +2618,7 @@ camdebug(int argc, char **argv, char *co
 			warnx("bus:target, or bus:target:lun to debug");
 		}
 	}
-	
+
 	if (error == 0) {
 
 		ccb.ccb_h.func_code = XPT_DEBUG;
@@ -2874,7 +2881,7 @@ cts_print(struct cam_device *device, str
 }
 
 /*
- * Get a path inquiry CCB for the specified device.  
+ * Get a path inquiry CCB for the specified device.
  */
 static int
 get_cpi(struct cam_device *device, struct ccb_pathinq *cpi)
@@ -2913,7 +2920,7 @@ get_cpi_bailout:
 }
 
 /*
- * Get a get device CCB for the specified device.  
+ * Get a get device CCB for the specified device.
  */
 static int
 get_cgd(struct cam_device *device, struct ccb_getdev *cgd)
@@ -3764,9 +3771,9 @@ doreport:
 					fprintf(stdout,
 						"\rFormatting:  %ju.%02u %% "
 						"(%d/%d) done",
-						(uintmax_t)(percentage / 
+						(uintmax_t)(percentage /
 						(0x10000 * 100)),
-						(unsigned)((percentage / 
+						(unsigned)((percentage /
 						0x10000) % 100),
 						val, 0x10000);
 					fflush(stdout);
@@ -3956,7 +3963,7 @@ retry:
 			case RPL_LUNDATA_ATYP_PERIPH:
 				if ((lundata->luns[i].lundata[j] &
 				    RPL_LUNDATA_PERIPH_BUS_MASK) != 0)
-					fprintf(stdout, "%d:", 
+					fprintf(stdout, "%d:",
 						lundata->luns[i].lundata[j] &
 						RPL_LUNDATA_PERIPH_BUS_MASK);
 				else if ((j == 0)
@@ -3994,7 +4001,7 @@ retry:
 				field_len_code = (lundata->luns[i].lundata[j] &
 					RPL_LUNDATA_EXT_LEN_MASK) >> 4;
 				field_len = field_len_code * 2;
-		
+
 				if ((eam_code == RPL_LUNDATA_EXT_EAM_WK)
 				 && (field_len_code == 0x00)) {
 					fprintf(stdout, "%d",
@@ -4352,7 +4359,7 @@ bailout:
 
 #endif /* MINIMALISTIC */
 
-void 
+void
 usage(int verbose)
 {
 	fprintf(verbose ? stdout : stderr,
@@ -4494,7 +4501,7 @@ usage(int verbose)
 #endif /* MINIMALISTIC */
 }
 
-int 
+int
 main(int argc, char **argv)
 {
 	int c;
@@ -4544,7 +4551,7 @@ main(int argc, char **argv)
 	 * this.  getopt is kinda braindead, so you end up having to run
 	 * through the options twice, and give each invocation of getopt
 	 * the option string for the other invocation.
-	 * 
+	 *
 	 * You would think that you could just have two groups of options.
 	 * The first group would get parsed by the first invocation of
 	 * getopt, and the second group would get parsed by the second
@@ -4553,13 +4560,13 @@ main(int argc, char **argv)
 	 * to the argument _after_ the first argument in the second group.
 	 * So when the second invocation of getopt comes around, it doesn't
 	 * recognize the first argument it gets and then bails out.
-	 * 
+	 *
 	 * A nice alternative would be to have a flag for getopt that says
 	 * "just keep parsing arguments even when you encounter an unknown
 	 * argument", but there isn't one.  So there's no real clean way to
 	 * easily parse two sets of arguments without having one invocation
 	 * of getopt know about the other.
-	 * 
+	 *
 	 * Without this hack, the first invocation of getopt would work as
 	 * long as the generic arguments are first, but the second invocation
 	 * (in the subfunction) would fail in one of two ways.  In the case
@@ -4573,14 +4580,14 @@ main(int argc, char **argv)
 	 * whether optind had been incremented one option too far.  The
 	 * mechanics of that, however, are more daunting than just giving
 	 * both invocations all of the expect options for either invocation.
-	 * 
+	 *
 	 * Needless to say, I wouldn't mind if someone invented a better
 	 * (non-GPL!) command line parsing interface than getopt.  I
 	 * wouldn't mind if someone added more knobs to getopt to make it
 	 * work better.  Who knows, I may talk myself into doing it someday,
 	 * if the standards weenies let me.  As it is, it just leads to
 	 * hackery like this and causes people to avoid it in some cases.
-	 * 
+	 *
 	 * KDM, September 8th, 1998
 	 */
 	if (subopt != NULL)

Modified: projects/binutils-2.17/sbin/geom/class/part/geom_part.c
==============================================================================
--- projects/binutils-2.17/sbin/geom/class/part/geom_part.c	Mon Oct 25 19:56:02 2010	(r214356)
+++ projects/binutils-2.17/sbin/geom/class/part/geom_part.c	Mon Oct 25 19:58:28 2010	(r214357)
@@ -67,7 +67,6 @@ static char ssize[32];
 #define	GPART_PARAM_BOOTCODE	"bootcode"
 #define	GPART_PARAM_INDEX	"index"
 #define	GPART_PARAM_PARTCODE	"partcode"
-#define	GPART_PARAM_FORCE	"force"
 
 static struct gclass *find_class(struct gmesh *, const char *);
 static struct ggeom * find_geom(struct gclass *, const char *);
@@ -85,7 +84,6 @@ static void gpart_show_geom(struct ggeom
 static int gpart_show_hasopt(struct gctl_req *, const char *, const char *);
 static void gpart_write_partcode(struct ggeom *, int, void *, ssize_t);
 static void gpart_write_partcode_vtoc8(struct ggeom *, int, void *);
-static void gpart_destroy(struct gctl_req *, unsigned int);
 static void gpart_print_error(const char *);
 
 struct g_command PUBSYM(class_commands)[] = {
@@ -123,8 +121,8 @@ struct g_command PUBSYM(class_commands)[
 		G_OPT_SENTINEL },
 	    "-i index [-f flags] geom"
 	},
-	{ "destroy", 0, gpart_destroy, {
-		{ 'F', GPART_PARAM_FORCE, NULL, G_TYPE_BOOL },
+	{ "destroy", 0, gpart_issue, {
+		{ 'F', "force", NULL, G_TYPE_BOOL },
 		{ 'f', "flags", GPART_FLAGS, G_TYPE_STRING },
 		G_OPT_SENTINEL },
 	    "[-F] [-f flags] geom"
@@ -167,6 +165,11 @@ struct g_command PUBSYM(class_commands)[
 		G_OPT_SENTINEL },
 	    "[-s size] -i index [-f flags] geom"
 	},
+	{ "recover", 0, gpart_issue, {
+		{ 'f', "flags", GPART_FLAGS, G_TYPE_STRING },
+		G_OPT_SENTINEL },
+	    "[-f flags] geom"
+	},
 	G_CMD_SENTINEL
 };
 
@@ -539,13 +542,17 @@ gpart_show_geom(struct ggeom *gp, const 
 	s = find_geomcfg(gp, "last");
 	last = (off_t)strtoimax(s, NULL, 0);
 	wblocks = strlen(s);
+	s = find_geomcfg(gp, "state");
+	if (s != NULL && *s != 'C')
+		s = NULL;
 	wname = strlen(gp->lg_name);
 	pp = LIST_FIRST(&gp->lg_consumer)->lg_provider;
 	secsz = pp->lg_sectorsize;
-	printf("=>%*jd  %*jd  %*s  %s  (%s)\n",
+	printf("=>%*jd  %*jd  %*s  %s  (%s)%s\n",
 	    wblocks, (intmax_t)first, wblocks, (intmax_t)(last - first + 1),
 	    wname, gp->lg_name,
-	    scheme, fmtsize(pp->lg_mediasize));
+	    scheme, fmtsize(pp->lg_mediasize),
+	    s ? " [CORRUPT]": "");
 
 	while ((pp = find_provider(gp, first)) != NULL) {
 		s = find_provcfg(pp, "start");
@@ -858,83 +865,6 @@ gpart_bootcode(struct gctl_req *req, uns
 }
 
 static void
-gpart_destroy(struct gctl_req *req, unsigned int fl)
-{
-	struct gmesh mesh;
-	struct gclass *classp;
-	struct gctl_req *req2;
-	struct ggeom *gp;
-	struct gprovider *pp;
-	const char *s;
-	int error, val;
-	intmax_t idx;
-
-	if (gctl_has_param(req, GPART_PARAM_FORCE)) {
-		val = gctl_get_int(req, GPART_PARAM_FORCE);
-		error = gctl_delete_param(req, GPART_PARAM_FORCE);
-		if (error)
-			errc(EXIT_FAILURE, error, "internal error");
-		if (val == 0)
-			goto done;
-		s = gctl_get_ascii(req, "class");
-		if (s == NULL)
-			abort();
-		error = geom_gettree(&mesh);
-		if (error != 0)
-			errc(EXIT_FAILURE, error, "Cannot get GEOM tree");
-		classp = find_class(&mesh, s);
-		if (classp == NULL) {
-			geom_deletetree(&mesh);
-			errx(EXIT_FAILURE, "Class %s not found.", s);
-		}
-		s = gctl_get_ascii(req, "arg0");
-		if (s == NULL)
-			abort();
-		gp = find_geom(classp, s);
-		if (gp == NULL)
-			errx(EXIT_FAILURE, "No such geom: %s.", s);
-		val = 0;
-		LIST_FOREACH(pp, &gp->lg_provider, lg_provider){
-			s = find_provcfg(pp, "index");
-			if (s == NULL)
-				errx(EXIT_FAILURE, "Index not found for %s.",
-				    pp->lg_name);
-			idx = strtoimax(s, NULL, 0);
-			req2 = gctl_get_handle();
-			gctl_ro_param(req2, "class", -1, classp->lg_name);
-			gctl_ro_param(req2, "arg0", -1, gp->lg_name);
-			gctl_ro_param(req2, "verb", -1, "delete");
-			gctl_ro_param(req2, GPART_PARAM_INDEX,
-			    sizeof(intmax_t), &idx);
-			gctl_ro_param(req2, "flags", -1, "X");
-			s = gctl_issue(req2);
-			if (s != NULL && s[0] != '\0') {
-				gpart_print_error(s);
-				gctl_free(req2);
-				if (val) { /* try to undo changes */
-					req2 = gctl_get_handle();
-					gctl_ro_param(req2, "verb", -1,
-					    "undo");
-					gctl_ro_param(req2, "class", -1,
-					    classp->lg_name);
-					gctl_ro_param(req2, "arg0", -1,
-					    gp->lg_name);
-					gctl_issue(req2);
-					gctl_free(req2);
-				}
-				geom_deletetree(&mesh);
-				exit(EXIT_FAILURE);
-			}
-			gctl_free(req2);
-			val = 1;
-		}
-		geom_deletetree(&mesh);
-	}
-done:
-	gpart_issue(req, fl);
-}
-
-static void
 gpart_print_error(const char *errstr)
 {
 	char *errmsg;

Modified: projects/binutils-2.17/sbin/geom/class/part/gpart.8
==============================================================================
--- projects/binutils-2.17/sbin/geom/class/part/gpart.8	Mon Oct 25 19:56:02 2010	(r214356)
+++ projects/binutils-2.17/sbin/geom/class/part/gpart.8	Mon Oct 25 19:58:28 2010	(r214357)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd September 28, 2010
+.Dd October 25, 2010
 .Dt GPART 8
 .Os
 .Sh NAME
@@ -129,6 +129,11 @@ utility:
 .Op Fl t Ar type
 .Op Fl f Ar flags
 .Ar geom
+.\" ==== RECOVER ====
+.Nm
+.Cm recover
+.Op Fl f Ar flags
+.Ar geom
 .\" ==== RESIZE ====
 .Nm
 .Cm resize
@@ -353,6 +358,23 @@ See the section entitled
 below for a discussion
 about its use.
 .El
+.\" ==== RECOVER ====
+.It Cm recover
+Recover corrupt partition's scheme metadata on the geom
+.Ar geom .
+See the section entitled
+.Sx "RECOVERING"
+below for the additional information.
+.Pp
+Additional options include:
+.Bl -tag -width 10n
+.It Fl f Ar flags
+Additional operational flags.
+See the section entitled
+.Sx "OPERATIONAL FLAGS"
+below for a discussion
+about its use.
+.El
 .\" ==== RESIZE ====
 .It Cm resize
 Resize a partition from geom
@@ -629,6 +651,68 @@ the
 action or reverted with the
 .Cm undo
 action.
+.Sh RECOVERING
+The GEOM class PART supports recovering of partition tables only for GPT.
+The GUID partition table has a primary and secondary (backup) copy of
+metadata for redundance. They are stored in the begining and in the end
+of device respectively. Therefore it is acceptable to have some corruptions
+in the metadata that are not fatal to work with GPT. When kernel detects
+corrupt metadata it marks this table as corrupt and reports about corruption.
+Any changes in corrupt table are prohibited except
+.Cm destroy
+and
+.Cm recover . 
+.Pp
+In case when only first sector is corrupt kernel can not detect GPT even
+if partition table is not corrupt. You can write protective MBR with
+.Xr dd 1
+command to restore ability of GPT detection. The copy of protective MBR is
+usually located in the
+.Pa /boot/pmbr
+file.
+.Pp
+In case when some of metadata is corrupt you will get to know about this
+from kernel's messages like these:
+.Bd -literal -offset indent
+GEOM: provider: the primary GPT table is corrupt or invalid.
+GEOM: provider: using the secondary instead -- recovery strongly advised.
+.Ed
+.Pp
+or
+.Bd -literal -offset indent
+GEOM: provider: the secondary GPT table is corrupt or invalid.
+GEOM: provider: using the primary only -- recovery suggested.
+.Ed
+.Pp
+Also 
+.Cm gpart 
+commands like 
+.Cm show ,
+.Cm status
+and
+.Cm list
+will report about corrupt table.
+.Pp
+In case when the size of device has changed (e.g. volume expansion) the 
+secondary GPT header will become located not in the last sector. This is 
+not a metadata corruption, but it is dangerous because any corruption of 
+the primary GPT will lead to lost of partition table. Kernel reports about 
+this problem with message:
+.Bd -literal -offset indent
+GEOM: provider: the secondary GPT header is not in the last LBA.
+.Ed
+.Pp
+A corrupt table can be recovered with 
+.Cm gpart recover 
+command. This command does reconstruction of corrupt metadata using 
+known valid metadata. Also it can relocate secondary GPT to the end of 
+device.
+.Pp
+.Pa NOTE :
+The GEOM class PART can detect the same partition table on different GEOM 
+providers and some of them will marked as corrupt. Be careful when choising 
+a provider for recovering. If you did incorrect choise you can destroy 
+metadata of another GEOM class, e.g. GEOM MIRROR or GEOM LABEL.
 .Sh EXIT STATUS
 Exit status is 0 on success, and 1 if the command fails.
 .Sh EXAMPLES
@@ -687,6 +771,7 @@ After having created all required partit
 /sbin/gpart bootcode -p /boot/boot1 da0
 .Ed
 .Sh SEE ALSO
+.Xr dd 1 ,
 .Xr geom 4 ,
 .Xr geom 8
 .Sh HISTORY

Modified: projects/binutils-2.17/sbin/hastd/hastd.c
==============================================================================
--- projects/binutils-2.17/sbin/hastd/hastd.c	Mon Oct 25 19:56:02 2010	(r214356)
+++ projects/binutils-2.17/sbin/hastd/hastd.c	Mon Oct 25 19:58:28 2010	(r214357)
@@ -701,8 +701,6 @@ main(int argc, char *argv[])
 	int debuglevel;
 	sigset_t mask;
 
-	g_gate_load();
-
 	foreground = false;
 	debuglevel = 0;
 	pidfile = HASTD_PIDFILE;
@@ -736,6 +734,8 @@ main(int argc, char *argv[])
 
 	pjdlog_debug_set(debuglevel);
 
+	g_gate_load();
+
 	pfh = pidfile_open(pidfile, 0600, &otherpid);
 	if (pfh == NULL) {
 		if (errno == EEXIST) {

Modified: projects/binutils-2.17/sbin/hastd/nv.c
==============================================================================
--- projects/binutils-2.17/sbin/hastd/nv.c	Mon Oct 25 19:56:02 2010	(r214356)
+++ projects/binutils-2.17/sbin/hastd/nv.c	Mon Oct 25 19:58:28 2010	(r214357)
@@ -46,6 +46,35 @@ __FBSDID("$FreeBSD$");
 #include <ebuf.h>
 #include <nv.h>
 
+#define	NV_TYPE_NONE		0
+
+#define	NV_TYPE_INT8		1
+#define	NV_TYPE_UINT8		2
+#define	NV_TYPE_INT16		3
+#define	NV_TYPE_UINT16		4
+#define	NV_TYPE_INT32		5
+#define	NV_TYPE_UINT32		6
+#define	NV_TYPE_INT64		7
+#define	NV_TYPE_UINT64		8
+#define	NV_TYPE_INT8_ARRAY	9
+#define	NV_TYPE_UINT8_ARRAY	10
+#define	NV_TYPE_INT16_ARRAY	11
+#define	NV_TYPE_UINT16_ARRAY	12
+#define	NV_TYPE_INT32_ARRAY	13
+#define	NV_TYPE_UINT32_ARRAY	14
+#define	NV_TYPE_INT64_ARRAY	15
+#define	NV_TYPE_UINT64_ARRAY	16
+#define	NV_TYPE_STRING		17
+
+#define	NV_TYPE_MASK		0x7f
+#define	NV_TYPE_FIRST		NV_TYPE_INT8
+#define	NV_TYPE_LAST		NV_TYPE_STRING
+
+#define	NV_ORDER_NETWORK	0x00
+#define	NV_ORDER_HOST		0x80
+
+#define	NV_ORDER_MASK		0x80
+
 #define	NV_MAGIC	0xaea1e
 struct nv {
 	int	nv_magic;
@@ -534,6 +563,29 @@ nv_get_string(struct nv *nv, const char 
 	return (str);
 }
 
+bool
+nv_exists(struct nv *nv, const char *namefmt, ...)
+{
+	struct nvhdr *nvh;
+	va_list nameap;
+	int snverror, serrno;
+
+	if (nv == NULL)
+		return (false);
+
+	serrno = errno;
+	snverror = nv->nv_error;
+
+	va_start(nameap, namefmt);
+	nvh = nv_find(nv, NV_TYPE_NONE, namefmt, nameap);
+	va_end(nameap);
+
+	errno = serrno;
+	nv->nv_error = snverror;
+
+	return (nvh != NULL);
+}
+

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***


More information about the svn-src-projects mailing list