Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 8 Sep 2008 12:09:03 GMT
From:      Rafal Jaworowski <raj@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 149415 for review
Message-ID:  <200809081209.m88C93SH075488@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=149415

Change 149415 by raj@raj_mimi on 2008/09/08 12:08:35

	IFC @149413

Affected files ...

.. //depot/projects/arm/src/contrib/ntp/libparse/clk_rawdcf.c#3 integrate
.. //depot/projects/arm/src/lib/libarchive/archive_write_disk.c#16 integrate
.. //depot/projects/arm/src/lib/libarchive/test/Makefile#12 integrate
.. //depot/projects/arm/src/lib/libarchive/test/test_read_format_gtar_sparse.c#7 integrate
.. //depot/projects/arm/src/lib/libarchive/test/test_write_disk_secure.c#6 integrate
.. //depot/projects/arm/src/lib/libgeom/geom_util.c#3 integrate
.. //depot/projects/arm/src/lib/libgeom/libgeom.3#4 integrate
.. //depot/projects/arm/src/lib/libgeom/libgeom.h#4 integrate
.. //depot/projects/arm/src/sbin/fdisk/fdisk.c#5 integrate
.. //depot/projects/arm/src/sbin/ipfw/ipfw2.c#17 integrate
.. //depot/projects/arm/src/sbin/md5/md5.1#2 integrate
.. //depot/projects/arm/src/sbin/natd/natd.c#4 integrate
.. //depot/projects/arm/src/share/man/man4/if_bridge.4#11 integrate
.. //depot/projects/arm/src/sys/amd64/amd64/cpu_switch.S#12 integrate
.. //depot/projects/arm/src/sys/amd64/amd64/genassym.c#13 integrate
.. //depot/projects/arm/src/sys/amd64/amd64/machdep.c#32 integrate
.. //depot/projects/arm/src/sys/amd64/amd64/mp_machdep.c#21 integrate
.. //depot/projects/arm/src/sys/amd64/amd64/trap.c#24 integrate
.. //depot/projects/arm/src/sys/amd64/include/pcb.h#6 integrate
.. //depot/projects/arm/src/sys/amd64/include/pcpu.h#9 integrate
.. //depot/projects/arm/src/sys/amd64/include/segments.h#3 integrate
.. //depot/projects/arm/src/sys/amd64/linux32/linux32_genassym.c#2 integrate
.. //depot/projects/arm/src/sys/amd64/linux32/linux32_locore.s#3 integrate
.. //depot/projects/arm/src/sys/amd64/linux32/linux32_machdep.c#21 integrate
.. //depot/projects/arm/src/sys/arm/conf/KB920X#50 integrate
.. //depot/projects/arm/src/sys/arm/conf/NSLU#2 integrate
.. //depot/projects/arm/src/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c#4 integrate
.. //depot/projects/arm/src/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c#5 integrate
.. //depot/projects/arm/src/sys/conf/NOTES#65 integrate
.. //depot/projects/arm/src/sys/dev/acpi_support/acpi_fujitsu.c#4 integrate
.. //depot/projects/arm/src/sys/dev/asmc/asmc.c#4 integrate
.. //depot/projects/arm/src/sys/dev/asmc/asmcvar.h#4 integrate
.. //depot/projects/arm/src/sys/dev/ic/i8251.h#2 integrate
.. //depot/projects/arm/src/sys/dev/ic/i8255.h#1 branch
.. //depot/projects/arm/src/sys/dev/iicbus/ds133x.c#2 integrate
.. //depot/projects/arm/src/sys/dev/si/si.c#7 integrate
.. //depot/projects/arm/src/sys/dev/sound/pci/hda/hdac.c#23 integrate
.. //depot/projects/arm/src/sys/dev/uart/uart_cpu_pc98.c#6 integrate
.. //depot/projects/arm/src/sys/geom/geom_dev.c#10 integrate
.. //depot/projects/arm/src/sys/i386/isa/isa.c#5 integrate
.. //depot/projects/arm/src/sys/i386/linux/linux_genassym.c#2 integrate
.. //depot/projects/arm/src/sys/i386/linux/linux_locore.s#2 integrate
.. //depot/projects/arm/src/sys/kern/uipc_sockbuf.c#13 integrate
.. //depot/projects/arm/src/sys/net/if_bridge.c#40 integrate
.. //depot/projects/arm/src/sys/net80211/ieee80211.h#11 integrate
.. //depot/projects/arm/src/sys/net80211/ieee80211_ddb.c#3 integrate
.. //depot/projects/arm/src/sys/net80211/ieee80211_freebsd.h#13 integrate
.. //depot/projects/arm/src/sys/net80211/ieee80211_ht.c#6 integrate
.. //depot/projects/arm/src/sys/net80211/ieee80211_ht.h#6 integrate
.. //depot/projects/arm/src/sys/net80211/ieee80211_ioctl.c#22 integrate
.. //depot/projects/arm/src/sys/net80211/ieee80211_ioctl.h#13 integrate
.. //depot/projects/arm/src/sys/net80211/ieee80211_node.c#22 integrate
.. //depot/projects/arm/src/sys/net80211/ieee80211_node.h#11 integrate
.. //depot/projects/arm/src/sys/net80211/ieee80211_phy.c#3 integrate
.. //depot/projects/arm/src/sys/net80211/ieee80211_sta.c#2 integrate
.. //depot/projects/arm/src/sys/netinet/ip_fw.h#15 integrate
.. //depot/projects/arm/src/sys/netinet/ip_fw2.c#46 integrate
.. //depot/projects/arm/src/sys/netinet/tcp_debug.c#5 integrate
.. //depot/projects/arm/src/sys/netinet/tcp_input.c#43 integrate
.. //depot/projects/arm/src/sys/netinet/tcp_output.c#28 integrate
.. //depot/projects/arm/src/sys/netinet/tcp_subr.c#38 integrate
.. //depot/projects/arm/src/sys/netinet/tcp_var.h#27 integrate
.. //depot/projects/arm/src/sys/pc98/cbus/sio.c#12 integrate
.. //depot/projects/arm/src/sys/pc98/include/bus.h#4 integrate
.. //depot/projects/arm/src/sys/pc98/pc98/busiosubr.c#3 integrate
.. //depot/projects/arm/src/sys/sys/disk.h#4 integrate
.. //depot/projects/arm/src/sys/sys/param.h#47 integrate
.. //depot/projects/arm/src/tools/tools/nanobsd/nanobsd.sh#13 integrate
.. //depot/projects/arm/src/usr.sbin/boot0cfg/boot0cfg.c#2 integrate
.. //depot/projects/arm/src/usr.sbin/setfib/setfib.c#2 integrate

Differences ...

==== //depot/projects/arm/src/contrib/ntp/libparse/clk_rawdcf.c#3 (text+ko) ====

@@ -229,7 +229,7 @@
 	unsigned char *c = dcfprm->zerobits;
 	int i;
 
-	parseprintf(DD_RAWDCF,("parse: convert_rawdcf: \"%s\"\n", buffer));
+	parseprintf(DD_RAWDCF,("parse: convert_rawdcf: \"%.*s\"\n", size, buffer));
 
 	if (size < 57)
 	{
@@ -320,7 +320,7 @@
 		 * bad format - not for us
 		 */
 #ifndef PARSEKERNEL
-		msyslog(LOG_ERR, "parse: convert_rawdcf: parity check FAILED for \"%s\"\n", buffer);
+		msyslog(LOG_ERR, "parse: convert_rawdcf: parity check FAILED for \"%.*s\"\n", size, buffer);
 #endif
 		return CVT_FAIL|CVT_BADFMT;
 	}

==== //depot/projects/arm/src/lib/libarchive/archive_write_disk.c#16 (text+ko) ====

@@ -25,7 +25,7 @@
  */
 
 #include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_disk.c,v 1.35 2008/09/05 06:13:11 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_disk.c,v 1.36 2008/09/07 05:22:33 kientzle Exp $");
 
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
@@ -907,14 +907,26 @@
 		 * We know something is in the way, but we don't know what;
 		 * we need to find out before we go any further.
 		 */
-		if (lstat(a->name, &a->st) != 0) {
+		int r = 0;
+		/*
+		 * The SECURE_SYMLINK logic has already removed a
+		 * symlink to a dir if the client wants that.  So
+		 * follow the symlink if we're creating a dir.
+		 */
+		if (S_ISDIR(a->mode))
+			r = stat(a->name, &a->st);
+		/*
+		 * If it's not a dir (or it's a broken symlink),
+		 * then don't follow it.
+		 */
+		if (r != 0 || !S_ISDIR(a->mode))
+			r = lstat(a->name, &a->st);
+		if (r != 0) {
 			archive_set_error(&a->archive, errno,
 			    "Can't stat existing object");
 			return (ARCHIVE_WARN);
 		}
 
-		/* TODO: if it's a symlink... */
-
 		/*
 		 * NO_OVERWRITE_NEWER doesn't apply to directories.
 		 */

==== //depot/projects/arm/src/lib/libarchive/test/Makefile#12 (text+ko) ====

@@ -1,4 +1,4 @@
-# $FreeBSD: src/lib/libarchive/test/Makefile,v 1.24 2008/08/25 06:08:22 kientzle Exp $
+# $FreeBSD: src/lib/libarchive/test/Makefile,v 1.25 2008/09/08 00:58:12 kientzle Exp $
 
 # Where to find the libarchive sources
 LA_SRCDIR=${.CURDIR}/..
@@ -89,7 +89,7 @@
 # Uncomment to link against dmalloc
 #LDADD+= -L/usr/local/lib -ldmalloc
 #CFLAGS+= -I/usr/local/include -DUSE_DMALLOC
-#WARNS=6
+WARNS=6
 
 # Build libarchive_test and run it.
 check test: libarchive_test

==== //depot/projects/arm/src/lib/libarchive/test/test_read_format_gtar_sparse.c#7 (text+ko) ====

@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_format_gtar_sparse.c,v 1.9 2008/09/01 05:38:33 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_format_gtar_sparse.c,v 1.10 2008/09/08 00:58:12 kientzle Exp $");
 
 
 struct contents {
@@ -187,6 +187,7 @@
 	struct contents expect;
 	/* data, size, offset of block read from archive. */
 	struct contents actual;
+	const void *p;
 	struct archive *a;
 
 	extract_reference_file(name);
@@ -206,10 +207,10 @@
 
 		expect = *cts++;
 		while (0 == (err = archive_read_data_block(a,
-				 (const void **)&actual.d,
-				 &actual.s, &actual.o))) {
+				 &p, &actual.s, &actual.o))) {
+			actual.d = p;
 			while (actual.s > 0) {
-				char c = *(const char *)actual.d;
+				char c = *actual.d;
 				if(actual.o < expect.o) {
 					/*
 					 * Any byte before the expected

==== //depot/projects/arm/src/lib/libarchive/test/test_write_disk_secure.c#6 (text+ko) ====

@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_write_disk_secure.c,v 1.5 2008/09/01 05:38:33 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/test/test_write_disk_secure.c,v 1.8 2008/09/07 23:59:27 kientzle Exp $");
 
 #define UMASK 022
 
@@ -105,6 +105,80 @@
 	archive_entry_free(ae);
 	assert(0 == archive_write_finish_entry(a));
 
+	/*
+	 * Without security checks, extracting a dir over a link to a
+	 * dir should follow the link.
+	 */
+	/* Create a symlink to a dir. */
+	assert((ae = archive_entry_new()) != NULL);
+	archive_entry_copy_pathname(ae, "link_to_dir3");
+	archive_entry_set_mode(ae, S_IFLNK | 0777);
+	archive_entry_set_symlink(ae, "dir");
+	archive_write_disk_set_options(a, 0);
+	assert(0 == archive_write_header(a, ae));
+	assert(0 == archive_write_finish_entry(a));
+	/* Extract a dir whose name matches the symlink. */
+	assert(archive_entry_clear(ae) != NULL);
+	archive_entry_copy_pathname(ae, "link_to_dir3");
+	archive_entry_set_mode(ae, S_IFDIR | 0777);
+	assert(0 == archive_write_header(a, ae));
+	assert(0 == archive_write_finish_entry(a));
+	/* Verify link was followed. */
+	assertEqualInt(0, lstat("link_to_dir3", &st));
+	assert(S_ISLNK(st.st_mode));
+	archive_entry_free(ae);
+
+	/*
+	 * As above, but a broken link, so the link should get replaced.
+	 */
+	/* Create a symlink to a dir. */
+	assert((ae = archive_entry_new()) != NULL);
+	archive_entry_copy_pathname(ae, "link_to_dir4");
+	archive_entry_set_mode(ae, S_IFLNK | 0777);
+	archive_entry_set_symlink(ae, "nonexistent_dir");
+	archive_write_disk_set_options(a, 0);
+	assert(0 == archive_write_header(a, ae));
+	assert(0 == archive_write_finish_entry(a));
+	/* Extract a dir whose name matches the symlink. */
+	assert(archive_entry_clear(ae) != NULL);
+	archive_entry_copy_pathname(ae, "link_to_dir4");
+	archive_entry_set_mode(ae, S_IFDIR | 0777);
+	assert(0 == archive_write_header(a, ae));
+	assert(0 == archive_write_finish_entry(a));
+	/* Verify link was replaced. */
+	assertEqualInt(0, lstat("link_to_dir4", &st));
+	assert(S_ISDIR(st.st_mode));
+	archive_entry_free(ae);
+
+	/*
+	 * As above, but a link to a non-dir, so the link should get replaced.
+	 */
+	/* Create a regular file and a symlink to it */
+	assert((ae = archive_entry_new()) != NULL);
+	archive_entry_copy_pathname(ae, "non_dir");
+	archive_entry_set_mode(ae, S_IFREG | 0777);
+	archive_write_disk_set_options(a, 0);
+	assert(0 == archive_write_header(a, ae));
+	assert(0 == archive_write_finish_entry(a));
+	/* Create symlink to the file. */
+	archive_entry_copy_pathname(ae, "link_to_dir5");
+	archive_entry_set_mode(ae, S_IFLNK | 0777);
+	archive_entry_set_symlink(ae, "non_dir");
+	archive_write_disk_set_options(a, 0);
+	assert(0 == archive_write_header(a, ae));
+	assert(0 == archive_write_finish_entry(a));
+	/* Extract a dir whose name matches the symlink. */
+	assert(archive_entry_clear(ae) != NULL);
+	archive_entry_copy_pathname(ae, "link_to_dir5");
+	archive_entry_set_mode(ae, S_IFDIR | 0777);
+	assert(0 == archive_write_header(a, ae));
+	assert(0 == archive_write_finish_entry(a));
+	/* Verify link was replaced. */
+	assertEqualInt(0, lstat("link_to_dir5", &st));
+	assert(S_ISDIR(st.st_mode));
+	archive_entry_free(ae);
+
+
 #if ARCHIVE_VERSION_NUMBER < 2000000
 	archive_write_finish(a);
 #else

==== //depot/projects/arm/src/lib/libgeom/geom_util.c#3 (text+ko) ====

@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/lib/libgeom/geom_util.c,v 1.2 2008/05/20 11:45:05 pjd Exp $");
+__FBSDID("$FreeBSD: src/lib/libgeom/geom_util.c,v 1.3 2008/09/07 13:54:57 lulf Exp $");
 
 #include <sys/param.h>
 #include <sys/disk.h>
@@ -42,29 +42,22 @@
 
 #include <libgeom.h>
 
+static char	*g_device_path_open(const char *, int *, int);
+
 /*
  * Open the given provider and at least check if this is a block device.
  */
 int
 g_open(const char *name, int dowrite)
 {
-	char path[MAXPATHLEN];
+	char *path;
 	int fd;
 
-	if (name[0] == '/')
-		strlcpy(path, name, sizeof(path));
-	else
-		snprintf(path, sizeof(path), "%s%s", _PATH_DEV, name);
-
-	fd = open(path, dowrite ? O_RDWR : O_RDONLY);
+	path = g_device_path_open(name, &fd, dowrite);
+	if (path != NULL)
+		free(path);
 	if (fd == -1)
 		return (-1);
-	/* Let try to get sectorsize, which will prove it is a GEOM provider. */
-	if (g_sectorsize(fd) == -1) {
-		close(fd);
-		errno = EFTYPE;
-		return (-1);
-	}
 	return (fd);
 }
 
@@ -121,6 +114,19 @@
 }
 
 /*
+ * Return the correct provider name.
+ */
+char *
+g_providername(int fd)
+{
+	char name[MAXPATHLEN];
+
+	if (g_ioctl_arg(fd, DIOCGPROVIDERNAME, name) == -1)
+		return (NULL);
+	return (strdup(name));
+}
+
+/*
  * Call BIO_FLUSH for the given provider.
  */
 int
@@ -234,3 +240,77 @@
 	}
 	return (fd);
 }
+
+/*
+ * Return the device path device given a partial or full path to its node.
+ * A pointer can be provided, which will be set to an opened file descriptor of
+ * not NULL.
+ */
+static char *
+g_device_path_open(const char *devpath, int *fdp, int dowrite)
+{
+	char *path;
+	int fd;
+
+	/* Make sure that we can fail. */
+	if (fdp != NULL)
+		*fdp = -1;
+	/* Use the device node if we're able to open it. */
+	do {
+		fd = open(devpath, dowrite ? O_RDWR : O_RDONLY);
+		if (fd == -1)
+			break;
+		/*
+		 * Let try to get sectorsize, which will prove it is a GEOM
+		 * provider. 
+		 */
+		if (g_sectorsize(fd) == -1) {
+			close(fd);
+			errno = EFTYPE;
+			return (NULL);
+		}
+		if ((path = strdup(devpath)) == NULL) {
+			close(fd);
+			return (NULL);
+		}
+		if (fdp != NULL)
+			*fdp = fd;
+		else
+			close(fd);
+		return (path);
+	} while (0);
+
+	/* If we're not given an absolute path, assume /dev/ prefix. */
+	if (*devpath != '/') {
+		asprintf(&path, "%s%s", _PATH_DEV, devpath);
+		if (path == NULL)
+			return (NULL);
+		fd = open(path, dowrite ? O_RDWR : O_RDONLY);
+		if (fd == -1) {
+			free(path);
+			return (NULL);
+		}
+		/*
+		 * Let try to get sectorsize, which will prove it is a GEOM
+		 * provider.
+		 */
+		if (g_sectorsize(fd) == -1) {
+			free(path);
+			close(fd);
+			errno = EFTYPE;
+			return (NULL);
+		}
+		if (fdp != NULL)
+			*fdp = fd;
+		else
+			close(fd);
+		return (path);
+	}
+	return (NULL);
+}
+
+char *
+g_device_path(const char *devpath)
+{
+	return (g_device_path_open(devpath, NULL, 0));
+}

==== //depot/projects/arm/src/lib/libgeom/libgeom.3#4 (text+ko) ====

@@ -26,9 +26,9 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $FreeBSD: src/lib/libgeom/libgeom.3,v 1.10 2008/06/13 21:49:21 thompsa Exp $
+.\" $FreeBSD: src/lib/libgeom/libgeom.3,v 1.11 2008/09/08 06:27:00 lulf Exp $
 .\"
-.Dd May 6, 2007
+.Dd September 8, 2008
 .Dt LIBGEOM 3
 .Os
 .Sh NAME
@@ -52,9 +52,11 @@
 .Nm g_sectorsize ,
 .Nm g_flush ,
 .Nm g_delete ,
+.Nm g_device_path ,
 .Nm g_get_ident ,
 .Nm g_get_name ,
-.Nm g_open_by_ident
+.Nm g_open_by_ident ,
+.Nm g_providername
 .Nd userland API library for kernel GEOM subsystem
 .Sh LIBRARY
 .Lb libgeom
@@ -103,12 +105,16 @@
 .Fn g_flush "int fd"
 .Ft int
 .Fn g_delete "int fd" "off_t offset" "off_t length"
+.Ft "char *"
+.Fn g_device_path "const char *devpath"
 .Ft int
 .Fn g_get_ident "int fd" "char *ident" "size_t size"
 .Ft int
 .Fn g_get_name "const char *ident" "char *name" "size_t size"
 .Ft int
 .Fn g_open_by_ident "const char *ident" "int dowrite" "char *name" "size_t size"
+.Ft "char *"
+.Fn g_providername "int fd"
 .Sh DESCRIPTION
 The
 .Nm geom
@@ -301,6 +307,13 @@
 function tells the provider that the given data range is no longer used.
 .Pp
 The
+.Fn g_device_path
+function returns the full path to a provider given a partial or full path to the
+device node.
+If the device can not be found or is not a valid geom provider, NULL is
+returned.
+.Pp
+The
 .Fn g_get_ident
 function returns provider's fixed and unique identifier.
 The
@@ -326,7 +339,17 @@
 .Dv NULL ,
 the function will store provider's name there.
 .Pp
-All functions return value greater than or equal to
+The
+.Fn g_providername
+function returns the provider name of an open file descriptor.
+If the file descriptor does not point to a valid geom provider, NULL is
+returned.
+.Pp
+All functions except
+.Fn g_providername
+and
+.Fn g_device_path
+return a value greater than or equal to
 .Va 0
 on success or
 .Va -1

==== //depot/projects/arm/src/lib/libgeom/libgeom.h#4 (text+ko) ====

@@ -26,7 +26,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/lib/libgeom/libgeom.h,v 1.12 2007/05/06 10:00:27 des Exp $
+ * $FreeBSD: src/lib/libgeom/libgeom.h,v 1.13 2008/09/07 13:54:57 lulf Exp $
  */
 #ifndef _LIBGEOM_H_
 #define _LIBGEOM_H_
@@ -154,6 +154,8 @@
 int g_get_ident(int, char *, size_t);
 int g_get_name(const char *, char *, size_t);
 int g_open_by_ident(const char *, int, char *, size_t);
+char *g_device_path(const char *);
+char *g_providername(int);
 
 __END_DECLS
 

==== //depot/projects/arm/src/sbin/fdisk/fdisk.c#5 (text+ko) ====

@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sbin/fdisk/fdisk.c,v 1.85 2008/07/31 00:55:29 obrien Exp $");
+__FBSDID("$FreeBSD: src/sbin/fdisk/fdisk.c,v 1.86 2008/09/07 13:58:35 lulf Exp $");
 
 #include <sys/disk.h>
 #include <sys/disklabel.h>
@@ -245,7 +245,6 @@
 int
 main(int argc, char *argv[])
 {
-	struct	stat sb;
 	int	c, i;
 	int	partition = -1;
 	struct	dos_partition *partp;
@@ -307,18 +306,9 @@
 	if (argc == 0) {
 		disk = get_rootdisk();
 	} else {
-		if (stat(argv[0], &sb) == 0) {
-			/* OK, full pathname given */
-			disk = argv[0];
-		} else if (errno == ENOENT && argv[0][0] != '/') {
-			/* Try prepending "/dev" */
-			asprintf(&disk, "%s%s", _PATH_DEV, argv[0]);
-			if (disk == NULL)
-				errx(1, "out of memory");
-		} else {
-			/* other stat error, let it fail below */
-			disk = argv[0];
-		}
+		disk = g_device_path(argv[0]);
+		if (disk == NULL)
+			err(1, "unable to get correct path for %s\n", argv[0]);
 	}
 	if (open_disk(u_flag) < 0)
 		err(1, "cannot open disk %s", disk);
@@ -724,21 +714,14 @@
 static int
 open_disk(int flag)
 {
-	struct stat 	st;
 	int rwmode;
 
-	if (stat(disk, &st) == -1) {
-		if (errno == ENOENT)
-			return -2;
-		warnx("can't get file status of %s", disk);
-		return -1;
-	}
-	if ( !(st.st_mode & S_IFCHR) )
-		warnx("device %s is not character special", disk);
-	rwmode = a_flag || I_flag || B_flag || flag ? O_RDWR : O_RDONLY;
-	fd = open(disk, rwmode);
-	if (fd == -1 && errno == EPERM && rwmode == O_RDWR)
-		fd = open(disk, O_RDONLY);
+	/* Write mode if one of these flags are set. */
+	rwmode = (a_flag || I_flag || B_flag || flag);
+	fd = g_open(disk, rwmode);
+	/* If the mode fails, try read-only if we didn't. */
+	if (fd == -1 && errno == EPERM && rwmode)
+		fd = g_open(disk, 0);
 	if (fd == -1 && errno == ENXIO)
 		return -2;
 	if (fd == -1) {
@@ -778,29 +761,30 @@
 {
 	int error;
 	struct gctl_req *grq;
-	const char *q;
-	char fbuf[BUFSIZ];
+	const char *errmsg;
+	char fbuf[BUFSIZ], *pname;
 	int i, fdw;
 
 	grq = gctl_get_handle();
 	gctl_ro_param(grq, "verb", -1, "write MBR");
 	gctl_ro_param(grq, "class", -1, "MBR");
-	q = strrchr(disk, '/');
-	if (q == NULL)
-		q = disk;
-	else
-		q++;
-	gctl_ro_param(grq, "geom", -1, q);
+	pname = g_providername(fd);
+	if (pname == NULL) {
+		warnx("Error getting providername for %s\n", disk);
+		return (-1);
+	}
+	gctl_ro_param(grq, "geom", -1, pname);
 	gctl_ro_param(grq, "data", secsize, buf);
-	q = gctl_issue(grq);
-	if (q == NULL) {
+	errmsg = gctl_issue(grq);
+	free(pname);
+	if (errmsg == NULL) {
 		gctl_free(grq);
 		return(0);
 	}
 	if (!q_flag)	/* GEOM errors are benign, not all devices supported */
-		warnx("%s", q);
+		warnx("%s", errmsg);
 	gctl_free(grq);
-	
+
 	error = pwrite(fd, buf, secsize, (sector * 512));
 	if (error == secsize)
 		return (0);
@@ -841,21 +825,18 @@
 	dos_cylsecs = cylsecs = heads * sectors;
 	disksecs = cyls * heads * sectors;
 
-	error = ioctl(fd, DIOCGSECTORSIZE, &u);
-	if (error != 0 || u == 0)
-		u = 512;
-	else
-		secsize = u;
+	u = g_sectorsize(fd);
+	if (u <= 0)
+		return (-1);
 
-	error = ioctl(fd, DIOCGMEDIASIZE, &o);
-	if (error == 0) {
-		disksecs = o / u;
-		cyls = dos_cyls = o / (u * dos_heads * dos_sectors);
-	}
+	o = g_mediasize(fd);
+	if (o < 0)
+		return (-1);
+	disksecs = o / u;
+	cyls = dos_cyls = o / (u * dos_heads * dos_sectors);
 
 	return (disksecs);
 }
-
 
 static int
 read_s0()

==== //depot/projects/arm/src/sbin/ipfw/ipfw2.c#17 (text+ko) ====

@@ -17,7 +17,7 @@
  *
  * NEW command line interface for IP firewall facility
  *
- * $FreeBSD: src/sbin/ipfw/ipfw2.c,v 1.120 2008/05/10 15:02:56 julian Exp $
+ * $FreeBSD: src/sbin/ipfw/ipfw2.c,v 1.121 2008/09/06 17:23:37 rik Exp $
  */
 
 #include <sys/param.h>
@@ -2429,7 +2429,7 @@
 		rulenum = atoi(av[0]);
 		new_set = atoi(av[2]);
 		if (!isdigit(*(av[0])) || (cmd == 3 && rulenum > RESVD_SET) ||
-			(cmd == 2 && rulenum == 65535) )
+			(cmd == 2 && rulenum == IPFW_DEFAULT_RULE) )
 			errx(EX_DATAERR, "invalid source number %s\n", av[0]);
 		if (!isdigit(*(av[2])) || new_set > RESVD_SET)
 			errx(EX_DATAERR, "invalid dest. set %s\n", av[1]);
@@ -2553,7 +2553,7 @@
 	 * need to scan the list to count them.
 	 */
 	for (nstat = 1, r = data, lim = (char *)data + nbytes;
-		    r->rulenum < 65535 && (char *)r < lim;
+		    r->rulenum < IPFW_DEFAULT_RULE && (char *)r < lim;
 		    ++nstat, r = NEXT(r) )
 		; /* nothing */
 
@@ -5045,7 +5045,8 @@
 			if (have_tag)
 				errx(EX_USAGE, "tag and untag cannot be "
 				    "specified more than once");
-			GET_UINT_ARG(tag, 1, 65534, i, rule_action_params);
+			GET_UINT_ARG(tag, 1, IPFW_DEFAULT_RULE - 1, i,
+			   rule_action_params);
 			have_tag = cmd;
 			fill_cmd(cmd, O_TAG, (i == TOK_TAG) ? 0: F_NOT, tag);
 			ac--; av++;
@@ -5521,8 +5522,8 @@
 			if (c->limit_mask == 0)
 				errx(EX_USAGE, "limit: missing limit mask");
 
-			GET_UINT_ARG(c->conn_limit, 1, 65534, TOK_LIMIT,
-			    rule_options);
+			GET_UINT_ARG(c->conn_limit, 1, IPFW_DEFAULT_RULE - 1,
+			    TOK_LIMIT, rule_options);
 
 			ac--; av++;
 			break;
@@ -5649,8 +5650,8 @@
 			else {
 				uint16_t tag;
 
-				GET_UINT_ARG(tag, 1, 65534, TOK_TAGGED,
-				    rule_options);
+				GET_UINT_ARG(tag, 1, IPFW_DEFAULT_RULE - 1,
+				    TOK_TAGGED, rule_options);
 				fill_cmd(cmd, O_TAGGED, 0, tag);
 			}
 			ac--; av++;
@@ -5978,7 +5979,7 @@
 	size = 0;
 	data = NULL;
 	frule = 0;
-	lrule = 65535; /* max ipfw rule number */
+	lrule = IPFW_DEFAULT_RULE; /* max ipfw rule number */
 	ac--; av++;
 
 	/* Parse parameters. */

==== //depot/projects/arm/src/sbin/md5/md5.1#2 (text+ko) ====

@@ -1,5 +1,5 @@
-.\" $FreeBSD: src/sbin/md5/md5.1,v 1.24 2005/03/10 09:56:39 cperciva Exp $
-.Dd June 6, 2004
+.\" $FreeBSD: src/sbin/md5/md5.1,v 1.25 2008/09/07 15:19:34 trhodes Exp $
+.Dd September 7, 2008
 .Dt MD5 1
 .Os
 .Sh NAME
@@ -49,7 +49,7 @@
 .Tn RSA .
 .Pp
 .Tn MD5
-has not yet (2001-09-03) been broken, but sufficient attacks have been
+has not yet (2007-03-05) been broken, but sufficient attacks have been
 made that its security is in some doubt.
 The attacks on
 .Tn MD5

==== //depot/projects/arm/src/sbin/natd/natd.c#4 (text+ko) ====

@@ -11,7 +11,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sbin/natd/natd.c,v 1.53 2008/06/22 22:14:02 mav Exp $");
+__FBSDID("$FreeBSD: src/sbin/natd/natd.c,v 1.54 2008/09/06 17:26:52 rik Exp $");
 
 #define SYSLOG_NAMES
 
@@ -130,6 +130,7 @@
 static void	SetupSkinnyPort(const char *strValue);
 static void	NewInstance(const char *name);
 static void	DoGlobal (int fd);
+static int	CheckIpfwRulenum(unsigned int rnum);
 
 /*
  * Globals.
@@ -1947,6 +1948,10 @@
 	if (sscanf(strValue, "%u:%u", &base, &num) != 2)
 		errx(1, "punch_fw: basenumber:count parameter required");
 
+	if (CheckIpfwRulenum(base + num - 1) == -1)
+		errx(1, "punch_fw: basenumber:count parameter should fit "
+			"the maximum allowed rule numbers");
+
 	LibAliasSetFWBase(mla, base, num);
 	(void)LibAliasSetMode(mla, PKT_ALIAS_PUNCH_FW, PKT_ALIAS_PUNCH_FW);
 }
@@ -1991,3 +1996,22 @@
 	mla = ip->la;
 	mip = ip;
 }
+
+static int
+CheckIpfwRulenum(unsigned int rnum)
+{
+	unsigned int default_rule;
+	size_t len = sizeof(default_rule);
+
+	if (sysctlbyname("net.inet.ip.fw.default_rule", &default_rule, &len,
+		NULL, 0) == -1) {
+		warn("Failed to get the default ipfw rule number, using "
+		     "default historical value 65535.  The reason was");
+		default_rule = 65535;
+	}
+	if (rnum >= default_rule) {
+		return -1;
+	}
+
+	return 0;
+}

==== //depot/projects/arm/src/share/man/man4/if_bridge.4#11 (text+ko) ====

@@ -33,7 +33,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.\" $FreeBSD: src/share/man/man4/if_bridge.4,v 1.31 2008/08/04 23:16:07 thompsa Exp $
+.\" $FreeBSD: src/share/man/man4/if_bridge.4,v 1.32 2008/09/08 03:28:26 thompsa Exp $
 .\"
 .Dd September 17, 2007
 .Dt IF_BRIDGE 4
@@ -92,6 +92,22 @@
 The address can be changed by assigning the desired link address using
 .Xr ifconfig 8 .
 .Pp
+If
+.Xr sysctl 8
+node
+.Va net.link.bridge.inherit_mac
+has non-zero value, newly created bridge will inherit MAC address
+from its first member instead of choosing random link-level address.
+This will provide more predictable bridge MAC without any
+additional configuration, but currently this feature is known
+to break some L2 protocols, for example PPPoE that is provided
+by
+.Xr ng_pppoe 4
+and
+.Xr ppp 8 .
+Now this feature is considered as experimental and is turned off
+by-default.
+.Pp
 A bridge can be used to provide several services, such as a simple
 802.11-to-Ethernet bridge for wireless hosts, and traffic isolation.
 .Pp

==== //depot/projects/arm/src/sys/amd64/amd64/cpu_switch.S#12 (text+ko) ====

@@ -30,7 +30,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/amd64/amd64/cpu_switch.S,v 1.163 2008/09/02 17:52:11 kib Exp $
+ * $FreeBSD: src/sys/amd64/amd64/cpu_switch.S,v 1.164 2008/09/08 09:59:05 kib Exp $
  */
 
 #include <machine/asmacros.h>
@@ -266,7 +266,7 @@
 	movl	%es,PCB_ES(%r8)
 	movl	%fs,PCB_FS(%r8)
 	jmp	done_store_seg
-2:	movq	PCB_GS32P(%r8),%rax
+2:	movq	PCPU(GS32P),%rax
 	movq	(%rax),%rax
 	movq	%rax,PCB_GS32SD(%r8)
 	jmp	1b
@@ -283,7 +283,7 @@
 	movl	PCB_FS(%r8),%fs
 	jmp	done_load_seg
 	/* Restore userland %gs while preserving kernel gsbase */
-2:	movq	PCB_GS32P(%r8),%rax
+2:	movq	PCPU(GS32P),%rax
 	movq	PCB_GS32SD(%r8),%rcx
 	movq	%rcx,(%rax)
 	jmp	1b

==== //depot/projects/arm/src/sys/amd64/amd64/genassym.c#13 (text+ko) ====

@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/amd64/amd64/genassym.c,v 1.169 2008/07/30 11:30:55 kib Exp $");
+__FBSDID("$FreeBSD: src/sys/amd64/amd64/genassym.c,v 1.170 2008/09/08 09:59:05 kib Exp $");
 
 #include "opt_compat.h"
 #include "opt_kstack_pages.h"
@@ -147,7 +147,6 @@
 ASSYM(PCB_SAVEFPU, offsetof(struct pcb, pcb_save));
 ASSYM(PCB_SAVEFPU_SIZE, sizeof(struct savefpu));
 ASSYM(PCB_ONFAULT, offsetof(struct pcb, pcb_onfault));
-ASSYM(PCB_GS32P, offsetof(struct pcb, pcb_gs32p));
 ASSYM(PCB_GS32SD, offsetof(struct pcb, pcb_gs32sd));
 
 ASSYM(PCB_SIZE, sizeof(struct pcb));
@@ -199,6 +198,7 @@
 ASSYM(PC_CURPMAP, offsetof(struct pcpu, pc_curpmap));
 ASSYM(PC_TSSP, offsetof(struct pcpu, pc_tssp));
 ASSYM(PC_RSP0, offsetof(struct pcpu, pc_rsp0));
+ASSYM(PC_GS32P, offsetof(struct pcpu, pc_gs32p));
  
 ASSYM(LA_VER, offsetof(struct LAPIC, version));
 ASSYM(LA_TPR, offsetof(struct LAPIC, tpr));

==== //depot/projects/arm/src/sys/amd64/amd64/machdep.c#32 (text+ko) ====

@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/amd64/amd64/machdep.c,v 1.688 2008/09/02 17:52:11 kib Exp $");
+__FBSDID("$FreeBSD: src/sys/amd64/amd64/machdep.c,v 1.690 2008/09/08 09:59:05 kib Exp $");
 
 #include "opt_atalk.h"
 #include "opt_atpic.h"
@@ -803,7 +803,7 @@
  * Initialize segments & interrupt table
  */
 
-struct user_segment_descriptor gdt[NGDT * MAXCPU];/* global descriptor table */
+struct user_segment_descriptor gdt[NGDT * MAXCPU];/* global descriptor tables */
 static struct gate_descriptor idt0[NIDT];
 struct gate_descriptor *idt = &idt0[0];	/* interrupt descriptor table */
 
@@ -870,7 +870,7 @@
 /* GPROC0_SEL	6 Proc 0 Tss Descriptor */
 {
 	0x0,			/* segment base address */
-	sizeof(struct amd64tss)-1,/* length - all address space */
+	sizeof(struct amd64tss)-1,/* length */
 	SDT_SYSTSS,		/* segment type */
 	SEL_KPL,		/* segment descriptor priority level */
 	1,			/* segment descriptor present */
@@ -1347,6 +1347,7 @@
 	PCPU_SET(curthread, &thread0);
 	PCPU_SET(curpcb, thread0.td_pcb);
 	PCPU_SET(tssp, &common_tss[0]);
+	PCPU_SET(gs32p, &gdt[GUGS32_SEL]);
 
 	/*
 	 * Initialize mutexes.

==== //depot/projects/arm/src/sys/amd64/amd64/mp_machdep.c#21 (text+ko) ====

@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/amd64/amd64/mp_machdep.c,v 1.291 2008/07/09 19:44:37 peter Exp $");
+__FBSDID("$FreeBSD: src/sys/amd64/amd64/mp_machdep.c,v 1.293 2008/09/08 09:59:05 kib Exp $");
 
 #include "opt_cpu.h"
 #include "opt_kstack_pages.h"
@@ -436,7 +436,8 @@
 {
 	struct pcpu *pc;
 	u_int64_t msr, cr0;
-	int cpu, gsel_tss;
+	int cpu, gsel_tss, x;
+	struct region_descriptor ap_gdt;
 
 	/* Set by the startup code for us to use */
 	cpu = bootAP;
@@ -447,11 +448,17 @@
 	common_tss[cpu].tss_iobase = sizeof(struct amd64tss);
 	common_tss[cpu].tss_ist1 = (long)&doublefault_stack[PAGE_SIZE];
 
+	/* Prepare private GDT */
 	gdt_segs[GPROC0_SEL].ssd_base = (long) &common_tss[cpu];
 	ssdtosyssd(&gdt_segs[GPROC0_SEL],
-	   (struct system_segment_descriptor *)&gdt[GPROC0_SEL]);
-
-	lgdt(&r_gdt);			/* does magic intra-segment return */
+	   (struct system_segment_descriptor *)&gdt[NGDT * cpu + GPROC0_SEL]);
+	for (x = 0; x < NGDT; x++) {
+		if (x != GPROC0_SEL && x != (GPROC0_SEL + 1))
+			ssdtosd(&gdt_segs[x], &gdt[NGDT * cpu + x]);
+	}
+	ap_gdt.rd_limit = NGDT * sizeof(gdt[0]) - 1;
+	ap_gdt.rd_base =  (long) &gdt[NGDT * cpu];
+	lgdt(&ap_gdt);			/* does magic intra-segment return */
 
 	/* Get per-cpu data */
 	pc = &__pcpu[cpu];
@@ -463,6 +470,7 @@
 	pc->pc_curthread = 0;
 	pc->pc_tssp = &common_tss[cpu];
 	pc->pc_rsp0 = 0;
+	pc->pc_gs32p = &gdt[NGDT * cpu + GUGS32_SEL];
 
 	wrmsr(MSR_FSBASE, 0);		/* User value */

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



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