CVS commit: src/usr.bin/unzip

2011-07-14 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Thu Jul 14 06:35:30 UTC 2011

Modified Files:
src/usr.bin/unzip: unzip.c

Log Message:
Fix a logic error: when renaming a file, strip trailing \n from file name.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/unzip/unzip.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/unzip/unzip.c
diff -u src/usr.bin/unzip/unzip.c:1.14 src/usr.bin/unzip/unzip.c:1.15
--- src/usr.bin/unzip/unzip.c:1.14	Mon May 10 15:45:22 2010
+++ src/usr.bin/unzip/unzip.c	Thu Jul 14 06:35:30 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: unzip.c,v 1.14 2010/05/10 15:45:22 joerg Exp $ */
+/* $NetBSD: unzip.c,v 1.15 2011/07/14 06:35:30 wiz Exp $ */
 
 /*-
  * Copyright (c) 2009, 2010 Joerg Sonnenberger jo...@netbsd.org
@@ -37,7 +37,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: unzip.c,v 1.14 2010/05/10 15:45:22 joerg Exp $);
+__RCSID($NetBSD: unzip.c,v 1.15 2011/07/14 06:35:30 wiz Exp $);
 
 #include sys/queue.h
 #include sys/stat.h
@@ -449,7 +449,7 @@
 			*path = NULL;
 			alen = 0;
 			len = getline(path, alen, stdin);
-			if ((*path)[len - 1] != '\n')
+			if ((*path)[len - 1] == '\n')
 (*path)[len - 1] = '\0';
 			return 0;
 		default:



CVS commit: src/tests/lib/libc/string

2011-07-14 Thread Jukka Ruohonen
Module Name:src
Committed By:   jruoho
Date:   Thu Jul 14 07:33:20 UTC 2011

Modified Files:
src/tests/lib/libc/string: t_memset.c t_strcmp.c t_strlen.c

Log Message:
Use ATF_CHECK() when appropriate.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/string/t_memset.c
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/string/t_strcmp.c
cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/string/t_strlen.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libc/string/t_memset.c
diff -u src/tests/lib/libc/string/t_memset.c:1.1 src/tests/lib/libc/string/t_memset.c:1.2
--- src/tests/lib/libc/string/t_memset.c:1.1	Fri Jun  3 06:39:52 2011
+++ src/tests/lib/libc/string/t_memset.c	Thu Jul 14 07:33:20 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: t_memset.c,v 1.1 2011/06/03 06:39:52 jruoho Exp $ */
+/* $NetBSD: t_memset.c,v 1.2 2011/07/14 07:33:20 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__RCSID($NetBSD: t_memset.c,v 1.1 2011/06/03 06:39:52 jruoho Exp $);
+__RCSID($NetBSD: t_memset.c,v 1.2 2011/07/14 07:33:20 jruoho Exp $);
 
 #include sys/stat.h
 
@@ -142,16 +142,16 @@
 
 	(void)memset(st, 0, sizeof(struct stat));
 
-	ATF_REQUIRE(st.st_dev == 0);
-	ATF_REQUIRE(st.st_ino == 0);
-	ATF_REQUIRE(st.st_mode == 0);
-	ATF_REQUIRE(st.st_nlink == 0);
-	ATF_REQUIRE(st.st_uid == 0);
-	ATF_REQUIRE(st.st_gid == 0);
-	ATF_REQUIRE(st.st_rdev == 0);
-	ATF_REQUIRE(st.st_size == 0);
-	ATF_REQUIRE(st.st_atime == 0);
-	ATF_REQUIRE(st.st_mtime == 0);
+	ATF_CHECK(st.st_dev == 0);
+	ATF_CHECK(st.st_ino == 0);
+	ATF_CHECK(st.st_mode == 0);
+	ATF_CHECK(st.st_nlink == 0);
+	ATF_CHECK(st.st_uid == 0);
+	ATF_CHECK(st.st_gid == 0);
+	ATF_CHECK(st.st_rdev == 0);
+	ATF_CHECK(st.st_size == 0);
+	ATF_CHECK(st.st_atime == 0);
+	ATF_CHECK(st.st_mtime == 0);
 }
 
 static void

Index: src/tests/lib/libc/string/t_strcmp.c
diff -u src/tests/lib/libc/string/t_strcmp.c:1.2 src/tests/lib/libc/string/t_strcmp.c:1.3
--- src/tests/lib/libc/string/t_strcmp.c:1.2	Thu Jul  7 09:31:27 2011
+++ src/tests/lib/libc/string/t_strcmp.c	Thu Jul 14 07:33:20 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: t_strcmp.c,v 1.2 2011/07/07 09:31:27 jruoho Exp $ */
+/* $NetBSD: t_strcmp.c,v 1.3 2011/07/14 07:33:20 jruoho Exp $ */
 
 /*
  * Written by J.T. Conklin j...@acorntoolworks.com
@@ -108,22 +108,22 @@
 	char buf1[10] = xxx;
 	char buf2[10] = xxy;
 
-	ATF_REQUIRE(strcmp(buf1, buf1) == 0);
-	ATF_REQUIRE(strcmp(buf2, buf2) == 0);
+	ATF_CHECK(strcmp(buf1, buf1) == 0);
+	ATF_CHECK(strcmp(buf2, buf2) == 0);
 
-	ATF_REQUIRE(strcmp(xöx, xox)  0);
-	ATF_REQUIRE(strcmp(xxx, xxxyyy)  0);
-	ATF_REQUIRE(strcmp(xxxyyy, xxx)  0);
-
-	ATF_REQUIRE(strcmp(buf1 + 0, buf2 + 0)  0);
-	ATF_REQUIRE(strcmp(buf1 + 1, buf2 + 1)  0);
-	ATF_REQUIRE(strcmp(buf1 + 2, buf2 + 2)  0);
-	ATF_REQUIRE(strcmp(buf1 + 3, buf2 + 3) == 0);
-
-	ATF_REQUIRE(strcmp(buf2 + 0, buf1 + 0)  0);
-	ATF_REQUIRE(strcmp(buf2 + 1, buf1 + 1)  0);
-	ATF_REQUIRE(strcmp(buf2 + 2, buf1 + 2)  0);
-	ATF_REQUIRE(strcmp(buf2 + 3, buf1 + 3) == 0);
+	ATF_CHECK(strcmp(xöx, xox)  0);
+	ATF_CHECK(strcmp(xxx, xxxyyy)  0);
+	ATF_CHECK(strcmp(xxxyyy, xxx)  0);
+
+	ATF_CHECK(strcmp(buf1 + 0, buf2 + 0)  0);
+	ATF_CHECK(strcmp(buf1 + 1, buf2 + 1)  0);
+	ATF_CHECK(strcmp(buf1 + 2, buf2 + 2)  0);
+	ATF_CHECK(strcmp(buf1 + 3, buf2 + 3) == 0);
+
+	ATF_CHECK(strcmp(buf2 + 0, buf1 + 0)  0);
+	ATF_CHECK(strcmp(buf2 + 1, buf1 + 1)  0);
+	ATF_CHECK(strcmp(buf2 + 2, buf1 + 2)  0);
+	ATF_CHECK(strcmp(buf2 + 3, buf1 + 3) == 0);
 }
 
 ATF_TP_ADD_TCS(tp)

Index: src/tests/lib/libc/string/t_strlen.c
diff -u src/tests/lib/libc/string/t_strlen.c:1.4 src/tests/lib/libc/string/t_strlen.c:1.5
--- src/tests/lib/libc/string/t_strlen.c:1.4	Tue Jul 12 12:08:07 2011
+++ src/tests/lib/libc/string/t_strlen.c	Thu Jul 14 07:33:20 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: t_strlen.c,v 1.4 2011/07/12 12:08:07 njoly Exp $ */
+/* $NetBSD: t_strlen.c,v 1.5 2011/07/14 07:33:20 jruoho Exp $ */
 
 /*
  * Written by J.T. Conklin j...@acorntoolworks.com
@@ -178,14 +178,14 @@
 
 	buf[0] = '\0';
 
-	ATF_REQUIRE(strnlen(buf, 000) == 0);
-	ATF_REQUIRE(strnlen(buf, 111) == 0);
+	ATF_CHECK(strnlen(buf, 000) == 0);
+	ATF_CHECK(strnlen(buf, 111) == 0);
 
-	ATF_REQUIRE(strnlen(xxx, 0) == 0);
-	ATF_REQUIRE(strnlen(xxx, 1) == 1);
-	ATF_REQUIRE(strnlen(xxx, 2) == 2);
-	ATF_REQUIRE(strnlen(xxx, 3) == 3);
-	ATF_REQUIRE(strnlen(xxx, 9) == 3);
+	ATF_CHECK(strnlen(xxx, 0) == 0);
+	ATF_CHECK(strnlen(xxx, 1) == 1);
+	ATF_CHECK(strnlen(xxx, 2) == 2);
+	ATF_CHECK(strnlen(xxx, 3) == 3);
+	ATF_CHECK(strnlen(xxx, 9) == 3);
 }
 
 ATF_TP_ADD_TCS(tp)



CVS commit: src/tests/lib/libc/sys

2011-07-14 Thread Jukka Ruohonen
Module Name:src
Committed By:   jruoho
Date:   Thu Jul 14 08:09:48 UTC 2011

Modified Files:
src/tests/lib/libc/sys: t_mincore.c

Log Message:
Add the test cases from the old ../regress/sys/uvm/mmap/mmap.c.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/sys/t_mincore.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libc/sys/t_mincore.c
diff -u src/tests/lib/libc/sys/t_mincore.c:1.1 src/tests/lib/libc/sys/t_mincore.c:1.2
--- src/tests/lib/libc/sys/t_mincore.c:1.1	Thu Jul  7 06:57:53 2011
+++ src/tests/lib/libc/sys/t_mincore.c	Thu Jul 14 08:09:48 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: t_mincore.c,v 1.1 2011/07/07 06:57:53 jruoho Exp $ */
+/* $NetBSD: t_mincore.c,v 1.2 2011/07/14 08:09:48 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -28,19 +28,78 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
+
+/*-
+ * Copyright (c) 1999 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
+ * NASA Ames Research Center.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
 #include sys/cdefs.h
-__RCSID($NetBSD: t_mincore.c,v 1.1 2011/07/07 06:57:53 jruoho Exp $);
+__RCSID($NetBSD: t_mincore.c,v 1.2 2011/07/14 08:09:48 jruoho Exp $);
 
 #include sys/mman.h
+#include sys/shm.h
 
 #include atf-c.h
 #include errno.h
 #include fcntl.h
+#include stdio.h
 #include stdlib.h
+#include string.h
 #include unistd.h
 
 static long		page = 0;
 static const char	path[] = mincore;
+static size_t		check_residency(void *, size_t);
+
+static size_t
+check_residency(void *addr, size_t npgs)
+{
+	size_t i, resident;
+	char *vec;
+
+	vec = malloc(npgs);
+
+	ATF_REQUIRE(vec != NULL);
+	ATF_REQUIRE(mincore(addr, npgs * page, vec) == 0);
+
+	for (i = resident = 0; i  npgs; i++) {
+
+		if (vec[i] != 0)
+			resident++;
+
+		(void)fprintf(stderr, page 0x%p is %sresident\n,
+		(char *)addr + (i * page), vec[i] ?  : not );
+	}
+
+	free(vec);
+
+	return resident;
+}
 
 ATF_TC(mincore_err);
 ATF_TC_HEAD(mincore_err, tc)
@@ -176,6 +235,162 @@
 	(void)unlink(path);
 }
 
+ATF_TC_WITH_CLEANUP(mincore_residency);
+ATF_TC_HEAD(mincore_residency, tc)
+{
+	atf_tc_set_md_var(tc, descr, mmap(2) residency with mincore(2));
+}
+
+ATF_TC_BODY(mincore_residency, tc)
+{
+	void *addr, *addr2, *addr3, *buf;
+	size_t npgs = 0;
+	struct stat st;
+	ssize_t tot;
+	int fd, rv;
+
+	(void)memset(st, 0, sizeof(struct stat));
+
+	fd = open(path, O_RDWR | O_CREAT, 0700);
+	buf = malloc(page * 5);
+
+	ATF_REQUIRE(fd = 0);
+	ATF_REQUIRE(buf != NULL);
+
+	tot = 0;
+
+	while (tot  page) {
+
+		rv = write(fd, buf, sizeof(buf));
+		ATF_REQUIRE(rv = 0);
+
+		tot += rv;
+	}
+
+	ATF_REQUIRE(fd = 0);
+	ATF_REQUIRE(fstat(fd, st) == 0);
+
+	addr = mmap(NULL, (size_t)st.st_size, PROT_READ,
+	MAP_FILE | MAP_SHARED, fd, (off_t) 0);
+
+	ATF_REQUIRE(addr != MAP_FAILED);
+
+	(void)close(fd);
+
+	npgs = st.st_size / page;
+
+	if (st.st_size % page != 0)
+		npgs++;
+
+	(void)check_residency(addr, npgs);
+
+	ATF_REQUIRE(mlock(addr, npgs * page) == 0);
+	ATF_REQUIRE(munmap(addr, st.st_size) == 0);
+
+	npgs = 128;
+
+	addr = mmap(NULL, npgs * page, PROT_READ | PROT_WRITE,
+	MAP_ANON | MAP_PRIVATE | MAP_WIRED, -1, (off_t)0);
+
+	if (addr == MAP_FAILED)
+		return;
+
+	ATF_REQUIRE(check_residency(addr, npgs) == npgs);
+	ATF_REQUIRE(munmap(addr, npgs * page) == 0);
+
+	npgs = 128;
+
+	addr = mmap(NULL, npgs * page, PROT_READ | PROT_WRITE,
+	

CVS commit: src/regress/sys/uvm/mmap

2011-07-14 Thread Jukka Ruohonen
Module Name:src
Committed By:   jruoho
Date:   Thu Jul 14 08:12:20 UTC 2011

Removed Files:
src/regress/sys/uvm/mmap: Makefile mmap.c

Log Message:
../regress/sys/uvm/mmap/mmap.c is now part of tests(7).


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r0 src/regress/sys/uvm/mmap/Makefile
cvs rdiff -u -r1.19 -r0 src/regress/sys/uvm/mmap/mmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/postinstall

2011-07-14 Thread Iain Hibbert
Module Name:src
Committed By:   plunky
Date:   Thu Jul 14 09:31:19 UTC 2011

Modified Files:
src/usr.sbin/postinstall: postinstall

Log Message:
introduce rcvar_is_enabled to test if a rcvar is enabled

use this instead of rcconf_is_set to warn about superseded
rc.d scripts, to silence spurious warnings produced before
/etc/defaults/rc.conf script was updated.

(spurious warnings noted by Martin Husemann)


To generate a diff of this commit:
cvs rdiff -u -r1.118 -r1.119 src/usr.sbin/postinstall/postinstall

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/postinstall/postinstall
diff -u src/usr.sbin/postinstall/postinstall:1.118 src/usr.sbin/postinstall/postinstall:1.119
--- src/usr.sbin/postinstall/postinstall:1.118	Fri May 27 09:28:42 2011
+++ src/usr.sbin/postinstall/postinstall	Thu Jul 14 09:31:19 2011
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: postinstall,v 1.118 2011/05/27 09:28:42 plunky Exp $
+# $NetBSD: postinstall,v 1.119 2011/07/14 09:31:19 plunky Exp $
 #
 # Copyright (c) 2002-2008 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -354,6 +354,29 @@
 	)
 }
 
+# rcvar_is_enabled var
+#	Check if rcvar is enabled
+#
+rcvar_is_enabled()
+{
+	[ $# -eq 1 ] || err 3 USAGE: rcvar_is_enabled var
+	_rcie_var=$1
+	(
+		[ -f ${DEST_DIR}/etc/rc.conf ]  . ${DEST_DIR}/etc/rc.conf
+		eval _rcie_val=\${${_rcie_var}}
+		case $_rcie_val in
+		#	yes, true, on, or 1
+		[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
+			exit 0
+			;;
+
+		*)
+			exit 1
+			;;
+		esac
+	)
+}
+
 # find_file_in_dirlist() file message dir1 [...] --
 #	Find which directory file is in, and sets ${dir} to match.
 #	Returns 0 if matched, otherwise 1 (and sets ${dir} to ).
@@ -675,7 +698,7 @@
 		notfixed=${NOT_FIXED}
 	fi
 	for _v in btattach btconfig btdevctl; do
-		if rcconf_is_set ${op} ${_v} ${_v}; then
+		if rcvar_is_enabled ${_v}; then
 			msg \
 ${_v} is obsolete in rc.conf(5)${notfixed}: use bluetooth=YES
 			failed=$(( ${failed} + 1 ))



CVS commit: src/usr.sbin/postinstall

2011-07-14 Thread Iain Hibbert
Module Name:src
Committed By:   plunky
Date:   Thu Jul 14 09:35:24 UTC 2011

Modified Files:
src/usr.sbin/postinstall: postinstall

Log Message:
rcconf_is_set takes a tuple of script variable, so add
in a couple of missing script names

network ip6forwarding
sysctl defcorename

and remove the trailing sysctl


To generate a diff of this commit:
cvs rdiff -u -r1.119 -r1.120 src/usr.sbin/postinstall/postinstall

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/postinstall/postinstall
diff -u src/usr.sbin/postinstall/postinstall:1.119 src/usr.sbin/postinstall/postinstall:1.120
--- src/usr.sbin/postinstall/postinstall:1.119	Thu Jul 14 09:31:19 2011
+++ src/usr.sbin/postinstall/postinstall	Thu Jul 14 09:35:24 2011
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: postinstall,v 1.119 2011/07/14 09:31:19 plunky Exp $
+# $NetBSD: postinstall,v 1.120 2011/07/14 09:35:24 plunky Exp $
 #
 # Copyright (c) 2002-2008 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -1159,14 +1159,13 @@
 	set --	amd amd_master \
 		btcontrol btcontrol_devices \
 		critical_filesystems critical_filesystems_beforenet \
-		defcorename \
-		ip6forwarding \
 		mountcritlocal mountcritremote \
+		network ip6forwarding \
 		network nfsiod_flags \
 		sdpd sdpd_control \
 		sdpd sdpd_groupname \
 		sdpd sdpd_username \
-		sysctl
+		sysctl defcorename
 	while [ $# -gt 1 ]; do
 		if rcconf_is_set ${op} $1 $2 1; then
 			failed=1



CVS commit: src/sys/lib/libkern/arch/sh3

2011-07-14 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Jul 14 09:48:04 UTC 2011

Modified Files:
src/sys/lib/libkern/arch/sh3: sdivsi3.S udivsi3.S

Log Message:
revert the _i4i aliases.  they are not the right thing.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/lib/libkern/arch/sh3/sdivsi3.S
cvs rdiff -u -r1.9 -r1.10 src/sys/lib/libkern/arch/sh3/udivsi3.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/lib/libkern/arch/sh3/sdivsi3.S
diff -u src/sys/lib/libkern/arch/sh3/sdivsi3.S:1.10 src/sys/lib/libkern/arch/sh3/sdivsi3.S:1.11
--- src/sys/lib/libkern/arch/sh3/sdivsi3.S:1.10	Wed Jul  6 01:29:54 2011
+++ src/sys/lib/libkern/arch/sh3/sdivsi3.S	Thu Jul 14 09:48:03 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdivsi3.S,v 1.10 2011/07/06 01:29:54 mrg Exp $	*/
+/*	$NetBSD: sdivsi3.S,v 1.11 2011/07/14 09:48:03 mrg Exp $	*/
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -36,7 +36,7 @@
 
 #include machine/asm.h
 #if defined(LIBC_SCCS)
-	RCSID($NetBSD: sdivsi3.S,v 1.10 2011/07/06 01:29:54 mrg Exp $)
+	RCSID($NetBSD: sdivsi3.S,v 1.11 2011/07/14 09:48:03 mrg Exp $)
 #endif
 
 
@@ -46,7 +46,6 @@
 
 
 /* r0 = r4 / r5 */
-WEAK_ALIAS(__sdivsi3_i4i,__sdivsi3)
 NENTRY(__sdivsi3)
 	mov	r4, r0
 	mov	r5, r1

Index: src/sys/lib/libkern/arch/sh3/udivsi3.S
diff -u src/sys/lib/libkern/arch/sh3/udivsi3.S:1.9 src/sys/lib/libkern/arch/sh3/udivsi3.S:1.10
--- src/sys/lib/libkern/arch/sh3/udivsi3.S:1.9	Wed Jul  6 01:29:54 2011
+++ src/sys/lib/libkern/arch/sh3/udivsi3.S	Thu Jul 14 09:48:04 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: udivsi3.S,v 1.9 2011/07/06 01:29:54 mrg Exp $	*/
+/*	$NetBSD: udivsi3.S,v 1.10 2011/07/14 09:48:04 mrg Exp $	*/
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -36,7 +36,7 @@
 
 #include machine/asm.h
 #if defined(LIBC_SCCS)
-	RCSID($NetBSD: udivsi3.S,v 1.9 2011/07/06 01:29:54 mrg Exp $)
+	RCSID($NetBSD: udivsi3.S,v 1.10 2011/07/14 09:48:04 mrg Exp $)
 #endif
 
 /*
@@ -65,7 +65,6 @@
 
 
 /* r0 = r4 / r5 */
-WEAK_ALIAS(__udivsi3_i4i,__udivsi3)
 NENTRY(__udivsi3)
 	tst	r5, r5
 	bt	div_by_zero



CVS commit: src/tests/lib/libc/sys

2011-07-14 Thread Jukka Ruohonen
Module Name:src
Committed By:   jruoho
Date:   Thu Jul 14 10:24:56 UTC 2011

Modified Files:
src/tests/lib/libc/sys: t_mincore.c

Log Message:
Remove the 't_mincore' test case, as it is essentially a less elegant
version of the recently added page residency checks.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/sys/t_mincore.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libc/sys/t_mincore.c
diff -u src/tests/lib/libc/sys/t_mincore.c:1.2 src/tests/lib/libc/sys/t_mincore.c:1.3
--- src/tests/lib/libc/sys/t_mincore.c:1.2	Thu Jul 14 08:09:48 2011
+++ src/tests/lib/libc/sys/t_mincore.c	Thu Jul 14 10:24:56 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: t_mincore.c,v 1.2 2011/07/14 08:09:48 jruoho Exp $ */
+/* $NetBSD: t_mincore.c,v 1.3 2011/07/14 10:24:56 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__RCSID($NetBSD: t_mincore.c,v 1.2 2011/07/14 08:09:48 jruoho Exp $);
+__RCSID($NetBSD: t_mincore.c,v 1.3 2011/07/14 10:24:56 jruoho Exp $);
 
 #include sys/mman.h
 #include sys/shm.h
@@ -130,118 +130,13 @@
 	ATF_REQUIRE(munmap(map, page) == 0);
 }
 
-ATF_TC_WITH_CLEANUP(mincore_incore);
-ATF_TC_HEAD(mincore_incore, tc)
+ATF_TC_WITH_CLEANUP(mincore_resid);
+ATF_TC_HEAD(mincore_resid, tc)
 {
-	atf_tc_set_md_var(tc, descr, Test that mincore(2) works);
+	atf_tc_set_md_var(tc, descr, Test page residency with mincore(2));
 }
 
-ATF_TC_BODY(mincore_incore, tc)
-{
-	char *buf, *vec, *map = MAP_FAILED;
-	const char *str = NULL;
-	const size_t n = 3;
-	ssize_t tot;
-	int fd, rv;
-	size_t i, j;
-
-	/*
-	 * Create a temporary file, write
-	 * few pages to it, and map the file.
-	 */
-	buf = calloc(n, page);
-	vec = calloc(n, page);
-
-	if (buf == NULL || vec == NULL)
-		return;
-
-	for (i = 0; i  (size_t)page * n; i++)
-		buf[i] = 'x';
-
-	fd = open(path, O_RDWR | O_CREAT, 0600);
-
-	if (fd  0) {
-		str = failed to open;
-		goto out;
-	}
-
-	tot = 0;
-
-	while (tot  page * (long)n) {
-
-		rv = write(fd, buf, sizeof(buf));
-
-		if (rv  0) {
-			str = failed to write;
-			goto out;
-		}
-
-		tot += rv;
-	}
-
-	map = mmap(NULL, page * n, PROT_READ | PROT_WRITE,
-	MAP_FILE | MAP_PRIVATE, fd, 0);
-
-	if (map == MAP_FAILED) {
-		str = failed to map;
-		goto out;
-	}
-
-	/*
-	 * Lock the mapping such that only
-	 * in-core page status is returned.
-	 */
-	if (mlock(map, page * n) != 0) {
-		str = failed to lock;
-		goto out;
-	}
-
-	if (mincore(map, page * n, vec) != 0) {
-		str = mincore failed;
-		goto out;
-	}
-
-	/*
-	 * Check that the in-core pages
-	 * match the locked pages.
-	 */
-	for (i = j = 0; i  (size_t)page * n; i++) {
-
-		if (vec[i] != 0)
-			j++;
-	}
-
-	if (j != n)
-		str = mismatch of in-core pages;
-
-out:
-	free(buf);
-	free(vec);
-
-	(void)close(fd);
-	(void)unlink(path);
-
-	if (map != MAP_FAILED) {
-		(void)munlock(map, page);
-		(void)munmap(map, page);
-	}
-
-	if (str != NULL)
-		atf_tc_fail(%s, str);
-}
-
-ATF_TC_CLEANUP(mincore_incore, tc)
-{
-	(void)unlink(path);
-}
-
-ATF_TC_WITH_CLEANUP(mincore_residency);
-ATF_TC_HEAD(mincore_residency, tc)
-{
-	atf_tc_set_md_var(tc, descr, mmap(2) residency with mincore(2));
-}
-
-ATF_TC_BODY(mincore_residency, tc)
+ATF_TC_BODY(mincore_resid, tc)
 {
 	void *addr, *addr2, *addr3, *buf;
 	size_t npgs = 0;
@@ -306,6 +201,9 @@
 	if (addr == MAP_FAILED)
 		return;
 
+	/*
+	 * Check that the in-core pages match the locked pages.
+	 */
 	ATF_REQUIRE(check_residency(addr, npgs) == 0);
 	ATF_REQUIRE(mlockall(MCL_CURRENT|MCL_FUTURE) == 0);
 	ATF_REQUIRE(check_residency(addr, npgs) == npgs);
@@ -338,7 +236,7 @@
 	(void)unlink(path);
 }
 
-ATF_TC_CLEANUP(mincore_residency, tc)
+ATF_TC_CLEANUP(mincore_resid, tc)
 {
 	(void)unlink(path);
 }
@@ -398,8 +296,7 @@
 	ATF_REQUIRE(page = 0);
 
 	ATF_TP_ADD_TC(tp, mincore_err);
-	ATF_TP_ADD_TC(tp, mincore_incore);
-	ATF_TP_ADD_TC(tp, mincore_residency);
+	ATF_TP_ADD_TC(tp, mincore_resid);
 	ATF_TP_ADD_TC(tp, mincore_shmseg);
 
 	return atf_no_error();



CVS commit: src/regress/sys/uvm

2011-07-14 Thread Jukka Ruohonen
Module Name:src
Committed By:   jruoho
Date:   Thu Jul 14 10:27:36 UTC 2011

Modified Files:
src/regress/sys/uvm: Makefile

Log Message:
Remove mmap subdir.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/regress/sys/uvm/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/regress/sys/uvm/Makefile
diff -u src/regress/sys/uvm/Makefile:1.8 src/regress/sys/uvm/Makefile:1.9
--- src/regress/sys/uvm/Makefile:1.8	Fri May 20 13:36:12 2011
+++ src/regress/sys/uvm/Makefile	Thu Jul 14 10:27:36 2011
@@ -1,8 +1,8 @@
-#	$NetBSD: Makefile,v 1.8 2011/05/20 13:36:12 joerg Exp $
+#	$NetBSD: Makefile,v 1.9 2011/07/14 10:27:36 jruoho Exp $
 
 .include bsd.own.mk
 
-SUBDIR+= mmap loan1
+SUBDIR+= loan1
 
 .if !empty(SUPPORTED_CC:Mgcc)
 SUBDIR+= stack_exec



CVS commit: src/sys/net

2011-07-14 Thread Matthias Drochner
Module Name:src
Committed By:   drochner
Date:   Thu Jul 14 10:43:55 UTC 2011

Modified Files:
src/sys/net: bpf_filter.c

Log Message:
clear the packet filter's scratch memory before running the filter
program, otherwise kernel memory can be leaked, from Guy Harris
per PR kern/45142


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sys/net/bpf_filter.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/net/bpf_filter.c
diff -u src/sys/net/bpf_filter.c:1.46 src/sys/net/bpf_filter.c:1.47
--- src/sys/net/bpf_filter.c:1.46	Sat Feb 19 17:21:48 2011
+++ src/sys/net/bpf_filter.c	Thu Jul 14 10:43:55 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: bpf_filter.c,v 1.46 2011/02/19 17:21:48 christos Exp $	*/
+/*	$NetBSD: bpf_filter.c,v 1.47 2011/07/14 10:43:55 drochner Exp $	*/
 
 /*-
  * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
@@ -37,7 +37,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: bpf_filter.c,v 1.46 2011/02/19 17:21:48 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: bpf_filter.c,v 1.47 2011/07/14 10:43:55 drochner Exp $);
 
 #if 0
 #if !(defined(lint) || defined(KERNEL))
@@ -148,6 +148,7 @@
 		return (u_int)-1;
 	A = 0;
 	X = 0;
+	memset(mem, 0, sizeof(mem));
 	--pc;
 	for (;;) {
 		++pc;



CVS commit: src

2011-07-14 Thread Jukka Ruohonen
Module Name:src
Committed By:   jruoho
Date:   Thu Jul 14 11:08:45 UTC 2011

Modified Files:
src/regress/sys/uvm: Makefile
src/tests/lib/libc/sys: t_mmap.c
Removed Files:
src/regress/sys/uvm/loan1: Makefile loan1.c

Log Message:
Move the uvm loan test to tests(7).


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/regress/sys/uvm/Makefile
cvs rdiff -u -r1.2 -r0 src/regress/sys/uvm/loan1/Makefile
cvs rdiff -u -r1.5 -r0 src/regress/sys/uvm/loan1/loan1.c
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/sys/t_mmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/regress/sys/uvm/Makefile
diff -u src/regress/sys/uvm/Makefile:1.9 src/regress/sys/uvm/Makefile:1.10
--- src/regress/sys/uvm/Makefile:1.9	Thu Jul 14 10:27:36 2011
+++ src/regress/sys/uvm/Makefile	Thu Jul 14 11:08:44 2011
@@ -1,9 +1,7 @@
-#	$NetBSD: Makefile,v 1.9 2011/07/14 10:27:36 jruoho Exp $
+#	$NetBSD: Makefile,v 1.10 2011/07/14 11:08:44 jruoho Exp $
 
 .include bsd.own.mk
 
-SUBDIR+= loan1
-
 .if !empty(SUPPORTED_CC:Mgcc)
 SUBDIR+= stack_exec
 .endif

Index: src/tests/lib/libc/sys/t_mmap.c
diff -u src/tests/lib/libc/sys/t_mmap.c:1.1 src/tests/lib/libc/sys/t_mmap.c:1.2
--- src/tests/lib/libc/sys/t_mmap.c:1.1	Thu Jul  7 06:57:54 2011
+++ src/tests/lib/libc/sys/t_mmap.c	Thu Jul 14 11:08:45 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: t_mmap.c,v 1.1 2011/07/07 06:57:54 jruoho Exp $ */
+/* $NetBSD: t_mmap.c,v 1.2 2011/07/14 11:08:45 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -28,14 +28,42 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
+
+/*-
+ * Copyright (c)2004 YAMAMOTO Takashi,
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
 #include sys/cdefs.h
-__RCSID($NetBSD: t_mmap.c,v 1.1 2011/07/07 06:57:54 jruoho Exp $);
+__RCSID($NetBSD: t_mmap.c,v 1.2 2011/07/14 11:08:45 jruoho Exp $);
 
 #include sys/param.h
 #include sys/mman.h
+#include sys/socket.h
 #include sys/sysctl.h
 #include sys/wait.h
 
+#include atf-c.h
 #include errno.h
 #include fcntl.h
 #include signal.h
@@ -43,12 +71,13 @@
 #include string.h
 #include unistd.h
 
-#include atf-c.h
-
 static long	page = 0;
 static char	path[] = mmap;
 static void	map_check(void *, int);
 static void	map_sighandler(int);
+static void	testloan(void *, void *, char, int);
+
+#define	BUFSIZE	(32 * 1024)	/* enough size to trigger sosend_loan */
 
 static void
 map_check(void *map, int flag)
@@ -63,6 +92,60 @@
 	ATF_REQUIRE(munmap(map, page) == 0);
 }
 
+void
+testloan(void *vp, void *vp2, char pat, int docheck)
+{
+	char buf[BUFSIZE];
+	char backup[BUFSIZE];
+	ssize_t nwritten;
+	ssize_t nread;
+	int fds[2];
+	int val;
+
+	val = BUFSIZE;
+
+	if (docheck != 0)
+		(void)memcpy(backup, vp, BUFSIZE);
+
+	if (socketpair(AF_LOCAL, SOCK_STREAM, PF_UNSPEC, fds) != 0)
+		atf_tc_fail(socketpair() failed);
+
+	val = BUFSIZE;
+
+	if (setsockopt(fds[1], SOL_SOCKET, SO_RCVBUF, val, sizeof(val)) != 0)
+		atf_tc_fail(setsockopt() failed, SO_RCVBUF);
+
+	val = BUFSIZE;
+
+	if (setsockopt(fds[0], SOL_SOCKET, SO_SNDBUF, val, sizeof(val)) != 0)
+		atf_tc_fail(setsockopt() failed, SO_SNDBUF);
+
+	if (fcntl(fds[0], F_SETFL, O_NONBLOCK) != 0)
+		atf_tc_fail(fcntl() failed);
+
+	nwritten = write(fds[0], (char *)vp + page, BUFSIZE - page);
+
+	if (nwritten == -1)
+		atf_tc_fail(write() failed);
+
+	/* Break loan. */
+	(void)memset(vp2, pat, BUFSIZE);
+
+	nread = read(fds[1], buf + page, BUFSIZE - page);
+
+	if (nread == -1)
+		atf_tc_fail(read() failed);
+
+	if (nread != nwritten)
+		atf_tc_fail(too short read);
+
+	if (docheck != 0  

CVS commit: src/sys/net

2011-07-14 Thread Matthias Drochner
Module Name:src
Committed By:   drochner
Date:   Thu Jul 14 12:44:11 UTC 2011

Modified Files:
src/sys/net: bpf_filter.c

Log Message:
back out previous - this should be unnecessary on NetBSD due to
the extra validation introduced in rev.1.42 (and pulled up to netbsd-5)


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/sys/net/bpf_filter.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/net/bpf_filter.c
diff -u src/sys/net/bpf_filter.c:1.47 src/sys/net/bpf_filter.c:1.48
--- src/sys/net/bpf_filter.c:1.47	Thu Jul 14 10:43:55 2011
+++ src/sys/net/bpf_filter.c	Thu Jul 14 12:44:10 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: bpf_filter.c,v 1.47 2011/07/14 10:43:55 drochner Exp $	*/
+/*	$NetBSD: bpf_filter.c,v 1.48 2011/07/14 12:44:10 drochner Exp $	*/
 
 /*-
  * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
@@ -37,7 +37,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: bpf_filter.c,v 1.47 2011/07/14 10:43:55 drochner Exp $);
+__KERNEL_RCSID(0, $NetBSD: bpf_filter.c,v 1.48 2011/07/14 12:44:10 drochner Exp $);
 
 #if 0
 #if !(defined(lint) || defined(KERNEL))
@@ -148,7 +148,6 @@
 		return (u_int)-1;
 	A = 0;
 	X = 0;
-	memset(mem, 0, sizeof(mem));
 	--pc;
 	for (;;) {
 		++pc;



CVS commit: src/usr.bin/extattr

2011-07-14 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Thu Jul 14 15:25:27 UTC 2011

Modified Files:
src/usr.bin/extattr: getextattr.1 getextattr.c

Log Message:
Improve extended attribute commands:
- allow namespace to be omitted when using a namespace-prefixed attribute
  name, a la Linux.
- Improve hexdump for getextattr -x
- Add more display option for binary attributes, using vis(3)
- Add a -i option to setextattr to get the attribute value from file, so
  that we can set binary values


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/extattr/getextattr.1
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/extattr/getextattr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/extattr/getextattr.1
diff -u src/usr.bin/extattr/getextattr.1:1.3 src/usr.bin/extattr/getextattr.1:1.4
--- src/usr.bin/extattr/getextattr.1:1.3	Fri Jun 17 18:19:58 2011
+++ src/usr.bin/extattr/getextattr.1	Thu Jul 14 15:25:27 2011
@@ -1,4 +1,4 @@
-.\	$NetBSD: getextattr.1,v 1.3 2011/06/17 18:19:58 wiz Exp $
+.\	$NetBSD: getextattr.1,v 1.4 2011/07/14 15:25:27 manu Exp $
 .\
 .\-
 .\ Copyright (c) 2000, 2001 Robert N. M. Watson
@@ -44,35 +44,61 @@
 .Nd manipulate extended attributes
 .Sh SYNOPSIS
 .Nm getextattr
-.Op Fl fhqsx
-.Ar attrnamespace
+.Op Fl fhq 
+.Op Fl s | Fl x | Fl v Ar style
+.Op Ar namespace
 .Ar attrname
 .Ar filename ...
 .Nm lsextattr
 .Op Fl fhq
-.Ar attrnamespace
+.Ar namespace
 .Ar filename ...
 .Nm rmextattr
 .Op Fl fhq
-.Ar attrnamespace
+.Op Ar namespace
 .Ar attrname
 .Ar filename ...
 .Nm setextattr
 .Op Fl fhnq
-.Ar attrnamespace
+.Op Ar namespace
 .Ar attrname
 .Ar attrvalue
 .Ar filename ...
+.Nm setextattr
+.Op Fl fhnq
+.Fl i Ar valuefile
+.Op Ar namespace
+.Ar attrname
+.Ar filename ...
 .Sh DESCRIPTION
 These utilities are user tools to manipulate the named extended
 attributes on files and directories.
+.Pp
 The
-.Ar attrnamespace
+.Ar namespace
 argument should be the namespace of the attribute to retrieve: legal
 values are
 .Cm user
 and
 .Cm system .
+For all operations except
+.Nm lsextattr ,
+the namespace argument may be omitted if the attribute name is namespace
+prefixed, like in
+.Cm user.test .
+In that later case, the 
+.Cm user
+namespace prefix obviously selects 
+.Cm user
+namespace.
+.Cm system ,
+.Cm security ,
+and
+.Cm trusted 
+namespace prefixes select the
+.Cm system
+namespace.
+.Pp
 The
 .Ar attrname
 argument should be the name of the attribute,
@@ -91,6 +117,11 @@
 (No follow.)
 If the file is a symbolic link, perform the operation on the
 link itself rather than the file that the link points to.
+.It Fl i Ar valuefile
+(Input file.)
+Read the attribute value from file
+.Ar valuefile .
+Use this flag in order to set a binary value for an attribute.
 .It Fl n
 .Dv ( NUL Ns
 -terminate.)
@@ -102,6 +133,39 @@
 .It Fl s
 (Stringify.)
 Escape nonprinting characters and put quotes around the output.
+.It Fl v Ar style
+(Visual.)
+Process the attribute value through 
+.Xr vis 3 ,
+using 
+.Ar style .
+Valid values for 
+.Ar style 
+are: 
+.Bl -tag -width indent
+.It Ar default
+Use default
+.Xr vis 3
+encoding.
+.It Ar c
+Use C-style backslash sequences, like in 
+.Nm vis Fl c .
+.It Ar http
+Use URI encoding from RFC 1808, like in
+.Nm vis Fl h .
+.It Ar octal
+Display in octal, like in 
+.Nm vis Fl o .
+.It Ar vis
+Alias for 
+.Ar default .
+.It Ar cstyle
+Alias for 
+.Ar c .
+.It Ar httpstyle
+Alias for 
+.Ar http .
+.El
 .It Fl x
 (Hex.)
 Print the output in hexadecimal.
@@ -113,6 +177,12 @@
 lsextattr system /boot/kernel/kernel
 rmextattr system md5 /boot/kernel/kernel
 .Ed
+.Pp
+Examples omitting namespace (and attribute value) argument:
+.Bd -literal
+setextattr -i valuefile trusted.gfid /export/wd3a
+getextattr -x trusted.gfid /export/wd3a
+.Ed
 .Sh SEE ALSO
 .\ .Xr extattr 2 ,
 .Xr extattr 3 ,
@@ -128,10 +198,10 @@
 .Nx 3.0 .
 It was developed to support security extensions requiring additional labels
 to be associated with each file or directory.
+.Pp
+Exented attribute support was resurected and made more usable in
+.Nx 5.2 .
 .Sh AUTHORS
 .An Robert N M Watson
 .An Poul-Henning Kamp
-.Sh BUGS
-The
-.Nm setextattr
-utility can only be used to set attributes to strings.
+.An Emmanuel Dreyfus

Index: src/usr.bin/extattr/getextattr.c
diff -u src/usr.bin/extattr/getextattr.c:1.7 src/usr.bin/extattr/getextattr.c:1.8
--- src/usr.bin/extattr/getextattr.c:1.7	Mon Jul  4 08:07:32 2011
+++ src/usr.bin/extattr/getextattr.c	Thu Jul 14 15:25:27 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: getextattr.c,v 1.7 2011/07/04 08:07:32 manu Exp $	*/
+/*	$NetBSD: getextattr.c,v 1.8 2011/07/14 15:25:27 manu Exp $	*/
 
 /*-
  * Copyright (c) 2002, 2003 Networks Associates Technology, Inc.
@@ -50,6 +50,8 @@
 #include string.h
 #include unistd.h
 #include vis.h
+#include fcntl.h
+#include sys/stat.h
 //#include util.h
 
 static enum { EADUNNO, EAGET, EASET, EARM, EALS } what = EADUNNO;
@@ 

CVS commit: src/lib/libperfuse

2011-07-14 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Thu Jul 14 15:37:32 UTC 2011

Modified Files:
src/lib/libperfuse: ops.c perfuse_priv.h

Log Message:
FUSE struct dirent's off is not the offset in the buffer, it is an opaque
cookie that the filesystem passes us, and that we need to send back on
the next READDIR. Most filesystem just ignore the value and send the
next chunk of buffer, but not all of them. Fixing this allows glusterfs
distributed volume to work.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/lib/libperfuse/ops.c
cvs rdiff -u -r1.20 -r1.21 src/lib/libperfuse/perfuse_priv.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libperfuse/ops.c
diff -u src/lib/libperfuse/ops.c:1.32 src/lib/libperfuse/ops.c:1.33
--- src/lib/libperfuse/ops.c:1.32	Mon Jul  4 08:07:29 2011
+++ src/lib/libperfuse/ops.c	Thu Jul 14 15:37:32 2011
@@ -1,4 +1,4 @@
-/*  $NetBSD: ops.c,v 1.32 2011/07/04 08:07:29 manu Exp $ */
+/*  $NetBSD: ops.c,v 1.33 2011/07/14 15:37:32 manu Exp $ */
 
 /*-
  *  Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved.
@@ -58,10 +58,11 @@
 struct puffs_newinfo *, const struct puffs_cn *pcn, perfuse_msg_t *);
 static int node_mk_common_final(struct puffs_usermount *, puffs_cookie_t,
 struct puffs_node *, const struct puffs_cn *pcn);
+static uint64_t readdir_last_cookie(struct fuse_dirent *, size_t); 
 static ssize_t fuse_to_dirent(struct puffs_usermount *, puffs_cookie_t,
 struct fuse_dirent *, size_t);
 static int readdir_buffered(puffs_cookie_t, struct dirent *, off_t *, 
-size_t *, const struct puffs_cred *, int *, off_t *, size_t *);
+size_t *);
 static void requeue_request(struct puffs_usermount *, 
 puffs_cookie_t opc, enum perfuse_qtype);
 static int dequeue_requests(struct perfuse_state *, 
@@ -521,6 +522,28 @@
 	return error;
 }
 
+static uint64_t
+readdir_last_cookie(fd, fd_len)
+	struct fuse_dirent *fd;
+	size_t fd_len;
+{
+	size_t len;
+	size_t seen = 0;
+	char *ndp;
+
+	do {
+		len = FUSE_DIRENT_ALIGN(sizeof(*fd) + fd-namelen);
+		seen += len;
+
+		if (seen = fd_len)
+			break;
+
+		ndp = (char *)(void *)fd + (size_t)len;
+		fd = (struct fuse_dirent *)(void *)ndp;
+	} while (1 /* CONSTCOND */);
+
+	return fd-off;
+}
 
 static ssize_t
 fuse_to_dirent(pu, opc, fd, fd_len)
@@ -577,8 +600,6 @@
 			dents = (struct dirent *)(void *)ndp;
 		}
 		
-
-
 		/*
 		 * Filesystem was mounted without -o use_ino
 		 * Perform a lookup to find it.
@@ -612,10 +633,10 @@
 
 		/*
 		 * Move to the next record.
-		 * fd-off seems unreliable, for instance, flusterfs 
-		 * does not clear the unused bits, and we get 
-		 * 0xb9b95040 instead of just 0x40. Use 
-		 * record alignement instead.
+		 * fd-off is not the offset, it is an opaque cookie
+		 * given by the filesystem to keep state across multiple
+		 * readdir() operation.
+		 * Use record alignement instead.
 		 */
 		len = FUSE_DIRENT_ALIGN(sizeof(*fd) + fd-namelen);
 #ifdef PERFUSE_DEBUG
@@ -654,18 +675,12 @@
 	return written;
 }
 
-/* ARGSUSED4 */
 static int 
-readdir_buffered(opc, dent, readoff, 
-		 reslen, pcr, eofflag, cookies, ncookies)
+readdir_buffered(opc, dent, readoff, reslen)
 	puffs_cookie_t opc;
 	struct dirent *dent;
 	off_t *readoff;
 	size_t *reslen;
-	const struct puffs_cred *pcr;
-	int *eofflag;
-	off_t *cookies;
-	size_t *ncookies;
 {
 	struct dirent *fromdent;
 	struct perfuse_node_data *pnd;
@@ -700,7 +715,6 @@
 		free(pnd-pnd_dirent);
 		pnd-pnd_dirent = NULL;
 		pnd-pnd_dirent_len = 0;
-		*eofflag = 1;
 	}
 
 	return 0;
@@ -2177,6 +2191,7 @@
 	return node_mk_common(pu, opc, pni, pcn_src, pm);
 }
 
+/* ARGSUSED4 */
 int 
 perfuse_node_readdir(pu, opc, dent, readoff, 
 		 reslen, pcr, eofflag, cookies, ncookies)
@@ -2199,7 +2214,6 @@
 	struct fuse_dirent *fd;
 	size_t foh_len;
 	int error;
-	uint64_t fd_offset;
 	size_t fd_maxlen;
 	
 	pm = NULL;
@@ -2223,6 +2237,12 @@
 			__func__, (void *)opc);
 #endif
 	/*
+	 * Re-initialize pnd-pnd_fd_cookie on the first readdir for a node
+	 */
+	if (*readoff == 0)
+		pnd-pnd_fd_cookie = 0;
+
+	/*
 	 * Do we already have the data bufered?
 	 */
 	if (pnd-pnd_dirent != NULL)
@@ -2249,9 +2269,8 @@
 
 	pnd-pnd_all_fd = NULL;
 	pnd-pnd_all_fd_len = 0;
-	fd_offset = 0;
 	fd_maxlen = ps-ps_max_readahead - sizeof(*foh);
-	
+
 	do {
 		size_t fd_len;
 		char *afdp;
@@ -2263,7 +2282,7 @@
 		 */
 		fri = GET_INPAYLOAD(ps, pm, fuse_read_in);
 		fri-fh = fh;
-		fri-offset = fd_offset;
+		fri-offset = pnd-pnd_fd_cookie;
 		fri-size = (uint32_t)fd_maxlen;
 		fri-read_flags = 0;
 		fri-lock_owner = 0;
@@ -2284,11 +2303,13 @@
 		/*
 		 * Empty read: we reached the end of the buffer.
 		 */
-		if (foh_len == sizeof(*foh))
+		if (foh_len == sizeof(*foh)) {
+			*eofflag = 1;
 			break;
+		}
 
 		/*
-		 * Corrupted message.
+		 * Check for corrupted message.
 		 */
 		if (foh_len  sizeof(*foh) + sizeof(*fd)) {
 			DWARNX(readdir 

CVS commit: src/sys/ufs/ufs

2011-07-14 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Thu Jul 14 16:27:43 UTC 2011

Modified Files:
src/sys/ufs/ufs: ufs_vnops.c ufs_wapbl.c

Log Message:
Clean up handling of ufs_lookup_results in rename.


To generate a diff of this commit:
cvs rdiff -u -r1.192 -r1.193 src/sys/ufs/ufs/ufs_vnops.c
cvs rdiff -u -r1.15 -r1.16 src/sys/ufs/ufs/ufs_wapbl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/ufs/ufs/ufs_vnops.c
diff -u src/sys/ufs/ufs/ufs_vnops.c:1.192 src/sys/ufs/ufs/ufs_vnops.c:1.193
--- src/sys/ufs/ufs/ufs_vnops.c:1.192	Tue Jul 12 16:59:49 2011
+++ src/sys/ufs/ufs/ufs_vnops.c	Thu Jul 14 16:27:43 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_vnops.c,v 1.192 2011/07/12 16:59:49 dholland Exp $	*/
+/*	$NetBSD: ufs_vnops.c,v 1.193 2011/07/14 16:27:43 dholland Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ufs_vnops.c,v 1.192 2011/07/12 16:59:49 dholland Exp $);
+__KERNEL_RCSID(0, $NetBSD: ufs_vnops.c,v 1.193 2011/07/14 16:27:43 dholland Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_ffs.h
@@ -989,6 +989,7 @@
 	struct mount		*mp;
 	struct direct		*newdir;
 	int			doingdirectory, oldparent, newparent, error;
+	struct ufs_lookup_results from_ulr, to_ulr;
 
 #ifdef WAPBL
 	if (ap-a_tdvp-v_mount-mnt_wapbl)
@@ -1003,6 +1004,12 @@
 	fcnp = ap-a_fcnp;
 	doingdirectory = oldparent = newparent = error = 0;
 
+	/* save the supplemental lookup results as they currently exist */
+	from_ulr = VTOI(fdvp)-i_crap;
+	to_ulr = VTOI(tdvp)-i_crap;
+	UFS_CHECK_CRAPCOUNTER(VTOI(fdvp));
+	UFS_CHECK_CRAPCOUNTER(VTOI(tdvp));
+
 	/*
 	 * Check for cross-device rename.
 	 */
@@ -1145,6 +1152,11 @@
 			goto out;
 		}
 		dp = VTOI(tdvp);
+
+		/* update the supplemental reasults */
+		to_ulr = dp-i_crap;
+		UFS_CHECK_CRAPCOUNTER(dp);
+
 		xp = NULL;
 		if (tvp)
 			xp = VTOI(tvp);
@@ -1182,7 +1194,7 @@
 		}
 		newdir = pool_cache_get(ufs_direct_cache, PR_WAITOK);
 		ufs_makedirentry(ip, tcnp, newdir);
-		error = ufs_direnter(tdvp, VTOI(tdvp)-i_crap,
+		error = ufs_direnter(tdvp, to_ulr,
  NULL, newdir, tcnp, NULL);
 		pool_cache_put(ufs_direct_cache, newdir);
 		if (error != 0) {
@@ -1239,7 +1251,7 @@
 			error = EISDIR;
 			goto bad;
 		}
-		if ((error = ufs_dirrewrite(dp, dp-i_crap.ulr_offset,
+		if ((error = ufs_dirrewrite(dp, to_ulr.ulr_offset,
 		xp, ip-i_number,
 		IFTODT(ip-i_mode), doingdirectory  newparent ?
 		newparent : doingdirectory, IN_CHANGE | IN_UPDATE)) != 0)
@@ -1282,6 +1294,10 @@
 		vrele(ap-a_fvp);
 		goto out2;
 	}
+	/* update supplemental lookup results */
+	from_ulr = VTOI(fdvp)-i_crap;
+	UFS_CHECK_CRAPCOUNTER(VTOI(fdvp));
+
 	if (fvp != NULL) {
 		xp = VTOI(fvp);
 		dp = VTOI(fdvp);
@@ -1316,15 +1332,11 @@
 		 */
 		if (doingdirectory  newparent) {
 			KASSERT(dp != NULL);
-
-			/* match old behavior; probably dead assignment XXX */
-			xp-i_crap.ulr_offset = mastertemplate.dot_reclen;
-
 			ufs_dirrewrite(xp, mastertemplate.dot_reclen,
 			dp, newparent, DT_DIR, 0, IN_CHANGE);
 			cache_purge(fdvp);
 		}
-		error = ufs_dirremove(fdvp, VTOI(fdvp)-i_crap,
+		error = ufs_dirremove(fdvp, from_ulr,
   xp, fcnp-cn_flags, 0);
 		xp-i_flag = ~IN_RENAME;
 	}

Index: src/sys/ufs/ufs/ufs_wapbl.c
diff -u src/sys/ufs/ufs/ufs_wapbl.c:1.15 src/sys/ufs/ufs/ufs_wapbl.c:1.16
--- src/sys/ufs/ufs/ufs_wapbl.c:1.15	Tue Jul 12 16:59:49 2011
+++ src/sys/ufs/ufs/ufs_wapbl.c	Thu Jul 14 16:27:43 2011
@@ -1,4 +1,4 @@
-/*  $NetBSD: ufs_wapbl.c,v 1.15 2011/07/12 16:59:49 dholland Exp $ */
+/*  $NetBSD: ufs_wapbl.c,v 1.16 2011/07/14 16:27:43 dholland Exp $ */
 
 /*-
  * Copyright (c) 2003,2006,2008 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ufs_wapbl.c,v 1.15 2011/07/12 16:59:49 dholland Exp $);
+__KERNEL_RCSID(0, $NetBSD: ufs_wapbl.c,v 1.16 2011/07/14 16:27:43 dholland Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -113,6 +113,41 @@
 };
 
 /*
+ * Check if either entry referred to by FROM_ULR is within the range
+ * of entries named by TO_ULR.
+ */
+static int
+ulr_overlap(const struct ufs_lookup_results *from_ulr,
+	const struct ufs_lookup_results *to_ulr)
+{
+	doff_t from_start, from_prevstart;
+	doff_t to_start, to_end;
+
+	/*
+	 * FROM is a DELETE result; offset points to the entry to
+	 * remove and subtracting count gives the previous entry.
+	 */
+	from_start = from_ulr-ulr_offset - from_ulr-ulr_count;
+	from_prevstart = from_ulr-ulr_offset;
+
+	/*
+	 * TO is a RENAME (thus non-DELETE) result; offset points
+	 * to the beginning of a region to write in, and adding
+	 * count gives the end of the region.
+	 */
+	to_start = to_ulr-ulr_offset;
+	to_end = to_ulr-ulr_offset + to_ulr-ulr_count;
+
+	if (from_prevstart = to_start  from_prevstart  to_end) {
+		return 1;
+	}
+	if (from_start = to_start  from_start  to_end) {
+		return 

CVS commit: src/gnu/dist

2011-07-14 Thread Alan Barrett
Module Name:src
Committed By:   apb
Date:   Thu Jul 14 17:29:43 UTC 2011

Modified Files:
src/gnu/dist/autoconf: Makefile.in
src/gnu/dist/gettext/gettext-runtime: Makefile.in
src/gnu/dist/gettext/gettext-runtime/libasprintf: Makefile.in
src/gnu/dist/gettext/gettext-tools: Makefile.in

Log Message:
Sprinkle some NetBSD_DISABLED_ prefixes in file names in Makefile
targets, to ensure that the associated commands do not run.  This should
prevent source files from being overwritten at build time by autoconf
and friends.  Fixes PR 45132.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/gnu/dist/autoconf/Makefile.in
cvs rdiff -u -r1.2 -r1.3 src/gnu/dist/gettext/gettext-runtime/Makefile.in
cvs rdiff -u -r1.1.1.1 -r1.2 \
src/gnu/dist/gettext/gettext-runtime/libasprintf/Makefile.in
cvs rdiff -u -r1.2 -r1.3 src/gnu/dist/gettext/gettext-tools/Makefile.in

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/gnu/dist/autoconf/Makefile.in
diff -u src/gnu/dist/autoconf/Makefile.in:1.4 src/gnu/dist/autoconf/Makefile.in:1.5
--- src/gnu/dist/autoconf/Makefile.in:1.4	Wed Nov 14 20:00:40 2001
+++ src/gnu/dist/autoconf/Makefile.in	Thu Jul 14 17:29:43 2011
@@ -427,7 +427,7 @@
 #   is changed, acversion.m4 is built only after the new version number is
 #   propagated to the Makefile.  (Libtool uses the same guarantee.)
 
-$(srcdir)/acversion.m4: $(srcdir)/acversion.in $(srcdir)/configure.ac
+$(srcdir)/NetBSD_DISABLED_acversion.m4: $(srcdir)/acversion.in $(srcdir)/configure.ac
 	sed 's,@VERSION\@,$(VERSION),g' $(srcdir)/acversion.in acversion.tm4
 	mv acversion.tm4 $(srcdir)/acversion.m4
 

Index: src/gnu/dist/gettext/gettext-runtime/Makefile.in
diff -u src/gnu/dist/gettext/gettext-runtime/Makefile.in:1.2 src/gnu/dist/gettext/gettext-runtime/Makefile.in:1.3
--- src/gnu/dist/gettext/gettext-runtime/Makefile.in:1.2	Mon May 30 01:32:44 2005
+++ src/gnu/dist/gettext/gettext-runtime/Makefile.in	Thu Jul 14 17:29:43 2011
@@ -314,7 +314,7 @@
 .SUFFIXES:
 am--refresh:
 	@:
-$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+$(srcdir)/NetBSD_DISABLED_Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	*$$dep*) \
@@ -341,7 +341,7 @@
 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
 	$(SHELL) ./config.status --recheck
 
-$(top_srcdir)/configure:  $(am__configure_deps)
+$(top_srcdir)/NetBSD_DISABLED_configure:  $(am__configure_deps)
 	cd $(srcdir)  $(AUTOCONF)
 $(ACLOCAL_M4):  $(am__aclocal_m4_deps)
 	cd $(srcdir)  $(ACLOCAL) $(ACLOCAL_AMFLAGS)
@@ -355,14 +355,14 @@
 stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
 	@rm -f stamp-h1
 	cd $(top_builddir)  $(SHELL) ./config.status config.h
-$(srcdir)/config.h.in:  $(am__configure_deps) 
+$(srcdir)/NetBSD_DISABLED_config.h.in:  $(am__configure_deps) 
 	cd $(top_srcdir)  $(AUTOHEADER)
 	rm -f stamp-h1
 	touch $@
 
 distclean-hdr:
 	-rm -f config.h stamp-h1
-intl/Makefile: $(top_builddir)/config.status $(top_srcdir)/intl/Makefile.in
+intl/NetBSD_DISABLED_Makefile: $(top_builddir)/config.status $(top_srcdir)/intl/Makefile.in
 	cd $(top_builddir)  $(SHELL) ./config.status $@
 
 mostlyclean-libtool:
@@ -843,7 +843,7 @@
 # vms_jackets.h is a header that comes with Compaq's porting library.
 # KEEP_CRTL_SETLOCALE tells it to not override the native locale support.
 
-intl/libgnuintl.h_vms: intl/libgnuintl.h.in
+intl/NetBSD_DISABLED_libgnuintl.h_vms: intl/libgnuintl.h.in
 	sed -e 's,@''HAVE_POSIX_PRINTF''@,1,g ' \
 	-e 's,@''HAVE_ASPRINTF''@,0,g' \
 	-e 's,@''HAVE_SNPRINTF''@,0,g' \
@@ -901,14 +901,14 @@
 	-e '/#undef INSTALLPREFIX$$/d' \
 	   $(srcdir)/config.h.in  $@
 
-intl/libgnuintl.h.msvc-static: intl/libgnuintl.h.in
+intl/NetBSD_DISABLED_libgnuintl.h.msvc-static: intl/libgnuintl.h.in
 	sed -e 's,@''HAVE_POSIX_PRINTF''@,0,g ' \
 	-e 's,@''HAVE_ASPRINTF''@,0,g' \
 	-e 's,@''HAVE_SNPRINTF''@,0,g' \
 	-e 's,@''HAVE_WPRINTF''@,1,g' \
 	   $(srcdir)/intl/libgnuintl.h.in  $@
 
-intl/libgnuintl.h.msvc-shared: intl/libgnuintl.h.in windows/dllexport.h
+intl/NetBSD_DISABLED_libgnuintl.h.msvc-shared: intl/libgnuintl.h.in windows/dllexport.h
 	sed -e 's,@''HAVE_POSIX_PRINTF''@,0,g ' \
 	-e 's,@''HAVE_ASPRINTF''@,0,g' \
 	-e 's,@''HAVE_SNPRINTF''@,0,g' \

Index: src/gnu/dist/gettext/gettext-runtime/libasprintf/Makefile.in
diff -u src/gnu/dist/gettext/gettext-runtime/libasprintf/Makefile.in:1.1.1.1 src/gnu/dist/gettext/gettext-runtime/libasprintf/Makefile.in:1.2
--- src/gnu/dist/gettext/gettext-runtime/libasprintf/Makefile.in:1.1.1.1	Fri Apr 29 15:00:41 2005
+++ src/gnu/dist/gettext/gettext-runtime/libasprintf/Makefile.in	Thu Jul 14 17:29:43 2011
@@ -302,7 +302,7 @@
 .SUFFIXES: .pdf .c .cc .dvi .html .info .lo .o .obj .ps .texi
 am--refresh:
 	@:
-$(srcdir)/Makefile.in:  

CVS commit: src/share/mk

2011-07-14 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Thu Jul 14 18:12:35 UTC 2011

Modified Files:
src/share/mk: bsd.kmodule.mk

Log Message:
VAX kernel modules need to be built with -fno-pic


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/share/mk/bsd.kmodule.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/share/mk/bsd.kmodule.mk
diff -u src/share/mk/bsd.kmodule.mk:1.30 src/share/mk/bsd.kmodule.mk:1.31
--- src/share/mk/bsd.kmodule.mk:1.30	Mon Jun 20 07:44:00 2011
+++ src/share/mk/bsd.kmodule.mk	Thu Jul 14 18:12:35 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: bsd.kmodule.mk,v 1.30 2011/06/20 07:44:00 mrg Exp $
+#	$NetBSD: bsd.kmodule.mk,v 1.31 2011/07/14 18:12:35 matt Exp $
 
 # We are not building this with PIE
 MKPIE=no
@@ -33,6 +33,8 @@
 CFLAGS+=	-mlong-calls
 .elif ${MACHINE_CPU} == powerpc
 CFLAGS+=	-mlongcall
+.elif ${MACHINE_CPU} == vax
+CFLAGS+=	-fno-pic
 .endif
 
 # evbppc needs some special help



CVS commit: src/sys/modules/dtv

2011-07-14 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Thu Jul 14 18:19:49 UTC 2011

Modified Files:
src/sys/modules/dtv: dtv.ioconf

Log Message:
files.dtv is included by conf/files


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/modules/dtv/dtv.ioconf

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/modules/dtv/dtv.ioconf
diff -u src/sys/modules/dtv/dtv.ioconf:1.1 src/sys/modules/dtv/dtv.ioconf:1.2
--- src/sys/modules/dtv/dtv.ioconf:1.1	Sat Jul  9 14:53:37 2011
+++ src/sys/modules/dtv/dtv.ioconf	Thu Jul 14 18:19:49 2011
@@ -1,9 +1,8 @@
-# $NetBSD: dtv.ioconf,v 1.1 2011/07/09 14:53:37 jmcneill Exp $
+# $NetBSD: dtv.ioconf,v 1.2 2011/07/14 18:19:49 matt Exp $
 
 ioconf dtv
 
 include conf/files
-include dev/dtv/files.dtv
 
 pseudo-root dtvbus*
 dtv* at dtvbus?



CVS commit: src/lib/libc/net

2011-07-14 Thread Jukka Ruohonen
Module Name:src
Committed By:   jruoho
Date:   Thu Jul 14 21:25:43 UTC 2011

Modified Files:
src/lib/libc/net: getprotoent.3

Log Message:
Complete prototypes, markup NULL, complete return values, more markup.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/lib/libc/net/getprotoent.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/net/getprotoent.3
diff -u src/lib/libc/net/getprotoent.3:1.11 src/lib/libc/net/getprotoent.3:1.12
--- src/lib/libc/net/getprotoent.3:1.11	Thu Aug  7 16:43:09 2003
+++ src/lib/libc/net/getprotoent.3	Thu Jul 14 21:25:42 2011
@@ -1,4 +1,4 @@
-.\	$NetBSD: getprotoent.3,v 1.11 2003/08/07 16:43:09 agc Exp $
+.\	$NetBSD: getprotoent.3,v 1.12 2011/07/14 21:25:42 jruoho Exp $
 .\
 .\ Copyright (c) 1983, 1991, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\
 .\ @(#)getprotoent.3	8.1 (Berkeley) 6/4/93
 .\
-.Dd June 4, 1993
+.Dd July 15, 2011
 .Dt GETPROTOENT 3
 .Os
 .Sh NAME
@@ -49,8 +49,10 @@
 .Fn getprotobyname const char *name
 .Ft struct protoent *
 .Fn getprotobynumber int proto
+.Ft void
 .Fn setprotoent int stayopen
-.Fn endprotoent
+.Ft void
+.Fn endprotoent void
 .Sh DESCRIPTION
 The
 .Fn getprotoent ,
@@ -73,7 +75,7 @@
 .Ed
 .Pp
 The members of this structure are:
-.Bl -tag -width p_aliases
+.Bl -tag -width p_aliases -offset indent
 .It Fa p_name
 The official name of the protocol.
 .It Fa p_aliases
@@ -116,8 +118,17 @@
 .Dv EOF
 is encountered.
 .Sh RETURN VALUES
-Null pointer
-(0) returned on
+Upon success,
+.Fn getprotoent ,
+.Fn getprotobyname ,
+and
+.Fn getprotobynumber
+return a pointer to the
+.Vt protoent
+structure as described above.
+A
+.Dv NULL
+pointer is returned on
 .Dv EOF
 or error.
 .Sh FILES



CVS commit: src

2011-07-14 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Thu Jul 14 21:38:57 UTC 2011

Modified Files:
src/distrib/sets/lists/comp: mi
src/external/bsd/llvm/bin/clang: Makefile

Log Message:
Install cpp frontend link too


To generate a diff of this commit:
cvs rdiff -u -r1.1643 -r1.1644 src/distrib/sets/lists/comp/mi
cvs rdiff -u -r1.12 -r1.13 src/external/bsd/llvm/bin/clang/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/sets/lists/comp/mi
diff -u src/distrib/sets/lists/comp/mi:1.1643 src/distrib/sets/lists/comp/mi:1.1644
--- src/distrib/sets/lists/comp/mi:1.1643	Sat Jul  9 14:52:02 2011
+++ src/distrib/sets/lists/comp/mi	Thu Jul 14 21:38:56 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: mi,v 1.1643 2011/07/09 14:52:02 jmcneill Exp $
+#	$NetBSD: mi,v 1.1644 2011/07/14 21:38:56 joerg Exp $
 #
 # Note: don't delete entries from here - mark them as obsolete instead.
 #
@@ -15,6 +15,7 @@
 ./usr/bin/cc	comp-c-bin		gcccmds
 ./usr/bin/clang	comp-c-bin		llvm
 ./usr/bin/clang++comp-c-bin		llvm
+./usr/bin/clang-cppcomp-c-bin		llvm
 ./usr/bin/configcomp-util-bin
 ./usr/bin/crunchgencomp-c-bin
 ./usr/bin/crunchidecomp-c-bin

Index: src/external/bsd/llvm/bin/clang/Makefile
diff -u src/external/bsd/llvm/bin/clang/Makefile:1.12 src/external/bsd/llvm/bin/clang/Makefile:1.13
--- src/external/bsd/llvm/bin/clang/Makefile:1.12	Wed Jul 13 23:48:29 2011
+++ src/external/bsd/llvm/bin/clang/Makefile	Thu Jul 14 21:38:57 2011
@@ -1,10 +1,11 @@
-#	$NetBSD: Makefile,v 1.12 2011/07/13 23:48:29 joerg Exp $
+#	$NetBSD: Makefile,v 1.13 2011/07/14 21:38:57 joerg Exp $
 
 PROG_CXX=	clang
 NOMAN=		yes
 
 .if !defined(HOSTPROG)
 SYMLINKS+=	clang ${BINDIR}/clang++
+SYMLINKS+=	clang ${BINDIR}/clang-cpp
 .endif
 
 .include bsd.init.mk



CVS commit: src/lib/libc/net

2011-07-14 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Thu Jul 14 22:12:30 UTC 2011

Modified Files:
src/lib/libc/net: getprotoent.3

Log Message:
New sentence, new line.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/lib/libc/net/getprotoent.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/net/getprotoent.3
diff -u src/lib/libc/net/getprotoent.3:1.12 src/lib/libc/net/getprotoent.3:1.13
--- src/lib/libc/net/getprotoent.3:1.12	Thu Jul 14 21:25:42 2011
+++ src/lib/libc/net/getprotoent.3	Thu Jul 14 22:12:30 2011
@@ -1,4 +1,4 @@
-.\	$NetBSD: getprotoent.3,v 1.12 2011/07/14 21:25:42 jruoho Exp $
+.\	$NetBSD: getprotoent.3,v 1.13 2011/07/14 22:12:30 wiz Exp $
 .\
 .\ Copyright (c) 1983, 1991, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -92,7 +92,8 @@
 The
 .Fn setprotoent
 function
-opens and rewinds the file.  If the
+opens and rewinds the file.
+If the
 .Fa stayopen
 flag is non-zero,
 the net data base will not be closed after each call to



CVS commit: src/usr.bin/extattr

2011-07-14 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Thu Jul 14 22:14:03 UTC 2011

Modified Files:
src/usr.bin/extattr: getextattr.1

Log Message:
Fix typos, remove trailing whitespace.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/extattr/getextattr.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/extattr/getextattr.1
diff -u src/usr.bin/extattr/getextattr.1:1.4 src/usr.bin/extattr/getextattr.1:1.5
--- src/usr.bin/extattr/getextattr.1:1.4	Thu Jul 14 15:25:27 2011
+++ src/usr.bin/extattr/getextattr.1	Thu Jul 14 22:14:03 2011
@@ -1,4 +1,4 @@
-.\	$NetBSD: getextattr.1,v 1.4 2011/07/14 15:25:27 manu Exp $
+.\	$NetBSD: getextattr.1,v 1.5 2011/07/14 22:14:03 wiz Exp $
 .\
 .\-
 .\ Copyright (c) 2000, 2001 Robert N. M. Watson
@@ -44,7 +44,7 @@
 .Nd manipulate extended attributes
 .Sh SYNOPSIS
 .Nm getextattr
-.Op Fl fhq 
+.Op Fl fhq
 .Op Fl s | Fl x | Fl v Ar style
 .Op Ar namespace
 .Ar attrname
@@ -86,15 +86,15 @@
 the namespace argument may be omitted if the attribute name is namespace
 prefixed, like in
 .Cm user.test .
-In that later case, the 
+In that later case, the
 .Cm user
-namespace prefix obviously selects 
+namespace prefix obviously selects
 .Cm user
 namespace.
 .Cm system ,
 .Cm security ,
 and
-.Cm trusted 
+.Cm trusted
 namespace prefixes select the
 .Cm system
 namespace.
@@ -135,35 +135,35 @@
 Escape nonprinting characters and put quotes around the output.
 .It Fl v Ar style
 (Visual.)
-Process the attribute value through 
+Process the attribute value through
 .Xr vis 3 ,
-using 
+using
 .Ar style .
-Valid values for 
-.Ar style 
-are: 
+Valid values for
+.Ar style
+are:
 .Bl -tag -width indent
 .It Ar default
 Use default
 .Xr vis 3
 encoding.
 .It Ar c
-Use C-style backslash sequences, like in 
+Use C-style backslash sequences, like in
 .Nm vis Fl c .
 .It Ar http
 Use URI encoding from RFC 1808, like in
 .Nm vis Fl h .
 .It Ar octal
-Display in octal, like in 
+Display in octal, like in
 .Nm vis Fl o .
 .It Ar vis
-Alias for 
+Alias for
 .Ar default .
 .It Ar cstyle
-Alias for 
+Alias for
 .Ar c .
 .It Ar httpstyle
-Alias for 
+Alias for
 .Ar http .
 .El
 .It Fl x
@@ -199,7 +199,7 @@
 It was developed to support security extensions requiring additional labels
 to be associated with each file or directory.
 .Pp
-Exented attribute support was resurected and made more usable in
+Extended attribute support was resurrected and made more usable in
 .Nx 5.2 .
 .Sh AUTHORS
 .An Robert N M Watson



CVS commit: src/sys/arch/mips/mips

2011-07-14 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Thu Jul 14 22:31:22 UTC 2011

Modified Files:
src/sys/arch/mips/mips: process_machdep.c

Log Message:
Remove out-of-date KASSERT


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/arch/mips/mips/process_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/mips/mips/process_machdep.c
diff -u src/sys/arch/mips/mips/process_machdep.c:1.35 src/sys/arch/mips/mips/process_machdep.c:1.36
--- src/sys/arch/mips/mips/process_machdep.c:1.35	Mon May  2 00:29:54 2011
+++ src/sys/arch/mips/mips/process_machdep.c	Thu Jul 14 22:31:22 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: process_machdep.c,v 1.35 2011/05/02 00:29:54 rmind Exp $	*/
+/*	$NetBSD: process_machdep.c,v 1.36 2011/07/14 22:31:22 matt Exp $	*/
 
 /*
  * Copyright (c) 1993 The Regents of the University of California.
@@ -76,7 +76,7 @@
  */
 
 #include sys/cdefs.h			/* RCS ID  Copyright macro defns */
-__KERNEL_RCSID(0, $NetBSD: process_machdep.c,v 1.35 2011/05/02 00:29:54 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: process_machdep.c,v 1.36 2011/07/14 22:31:22 matt Exp $);
 
 /*
  * This file may seem a bit stylized, but that so that it's easier to port.
@@ -144,7 +144,6 @@
 		*regslen_p = sizeof(struct fpreg_oabi);
 #endif
 
-	KASSERT(l == curlwp);
 	fpu_save();
 	memcpy(regs, pcb-pcb_fpregs, sizeof(*regs));
 	return 0;



CVS commit: src/sys/dev/i2c

2011-07-14 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Jul 14 23:43:37 UTC 2011

Modified Files:
src/sys/dev/i2c: files.i2c

Log Message:
nxt2k depends on firmload


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/dev/i2c/files.i2c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/i2c/files.i2c
diff -u src/sys/dev/i2c/files.i2c:1.37 src/sys/dev/i2c/files.i2c:1.38
--- src/sys/dev/i2c/files.i2c:1.37	Mon Jul 11 18:00:06 2011
+++ src/sys/dev/i2c/files.i2c	Thu Jul 14 23:43:37 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: files.i2c,v 1.37 2011/07/11 18:00:06 jmcneill Exp $
+#	$NetBSD: files.i2c,v 1.38 2011/07/14 23:43:37 jmcneill Exp $
 
 defflag	opt_i2cbus.hI2C_SCAN
 define	i2cbus { }
@@ -35,7 +35,7 @@
 file	dev/i2c/tvpll_tuners.c			tvpll
 
 # Nextwave NXT200x demodulator
-define	nxt2k: i2cexec
+define	nxt2k: i2cexec, firmload
 file	dev/i2c/nxt2k.cnxt2k
 
 #



CVS commit: src/sys/dev/i2c

2011-07-14 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Jul 14 23:44:34 UTC 2011

Modified Files:
src/sys/dev/i2c: nxt2k.c

Log Message:
add module support


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/i2c/nxt2k.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/i2c/nxt2k.c
diff -u src/sys/dev/i2c/nxt2k.c:1.1 src/sys/dev/i2c/nxt2k.c:1.2
--- src/sys/dev/i2c/nxt2k.c:1.1	Mon Jul 11 00:30:23 2011
+++ src/sys/dev/i2c/nxt2k.c	Thu Jul 14 23:44:34 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: nxt2k.c,v 1.1 2011/07/11 00:30:23 jakllsch Exp $ */
+/* $NetBSD: nxt2k.c,v 1.2 2011/07/14 23:44:34 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2008, 2011 Jonathan A. Kollasch
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nxt2k.c,v 1.1 2011/07/11 00:30:23 jakllsch Exp $);
+__KERNEL_RCSID(0, $NetBSD: nxt2k.c,v 1.2 2011/07/14 23:44:34 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/kernel.h
@@ -36,6 +36,7 @@
 #include sys/kmem.h
 #include sys/condvar.h
 #include sys/mutex.h
+#include sys/module.h
 
 #include dev/firmload.h
 
@@ -137,7 +138,7 @@
 nxt2k_readreg(struct nxt2k *nxt, uint8_t reg, uint8_t *data, size_t len)
 {
 	uint8_t buf, len2, attr;
-	int i;
+	unsigned int i;
 
 	nxt2k_writedata(nxt, 0x35, reg, 1);
 
@@ -828,3 +829,13 @@
 {
 	return nxt2k_fe_set_frontend(nxt, modulation);
 }
+
+MODULE(MODULE_CLASS_DRIVER, nxt2k, NULL);
+
+static int
+nxt2k_modcmd(modcmd_t cmd, void *opaque)
+{
+	if (cmd == MODULE_CMD_INIT || cmd == MODULE_CMD_FINI)
+		return 0;
+	return ENOTTY;
+}



CVS commit: src/sys/dev/i2c

2011-07-14 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Jul 14 23:45:43 UTC 2011

Modified Files:
src/sys/dev/i2c: tvpll.c

Log Message:
add module support


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/i2c/tvpll.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/i2c/tvpll.c
diff -u src/sys/dev/i2c/tvpll.c:1.1 src/sys/dev/i2c/tvpll.c:1.2
--- src/sys/dev/i2c/tvpll.c:1.1	Mon Jul 11 00:01:52 2011
+++ src/sys/dev/i2c/tvpll.c	Thu Jul 14 23:45:43 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: tvpll.c,v 1.1 2011/07/11 00:01:52 jakllsch Exp $ */
+/* $NetBSD: tvpll.c,v 1.2 2011/07/14 23:45:43 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2008, 2011 Jonathan A. Kollasch
@@ -27,13 +27,14 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: tvpll.c,v 1.1 2011/07/11 00:01:52 jakllsch Exp $);
+__KERNEL_RCSID(0, $NetBSD: tvpll.c,v 1.2 2011/07/14 23:45:43 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/systm.h
 #include sys/device.h
 #include sys/kmem.h
 #include sys/syslog.h
+#include sys/module.h
 
 #include dev/dtv/dtvio.h
 #include dev/i2c/i2cvar.h
@@ -136,3 +137,13 @@
 
 	return rv;
 }
+
+MODULE(MODULE_CLASS_DRIVER, tvpll, NULL);
+
+static int
+tvpll_modcmd(modcmd_t cmd, void *opaque)
+{
+	if (cmd == MODULE_CMD_INIT || cmd == MODULE_CMD_FINI)
+		return 0;
+	return ENOTTY;
+}



CVS commit: src/sys/dev/i2c

2011-07-14 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Jul 14 23:46:52 UTC 2011

Modified Files:
src/sys/dev/i2c: lg3303.c lg3303var.h

Log Message:
add a flags argument to lg3303, and use it for the caller to request
serial mpeg mode


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/i2c/lg3303.c src/sys/dev/i2c/lg3303var.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/i2c/lg3303.c
diff -u src/sys/dev/i2c/lg3303.c:1.1 src/sys/dev/i2c/lg3303.c:1.2
--- src/sys/dev/i2c/lg3303.c:1.1	Mon Jul 11 18:00:06 2011
+++ src/sys/dev/i2c/lg3303.c	Thu Jul 14 23:46:52 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: lg3303.c,v 1.1 2011/07/11 18:00:06 jmcneill Exp $ */
+/* $NetBSD: lg3303.c,v 1.2 2011/07/14 23:46:52 jmcneill Exp $ */
 
 /*-
  * Copyright 2007 Jason Harmening
@@ -28,7 +28,7 @@
  */
 
 #include sys/param.h
-__KERNEL_RCSID(0, $NetBSD: lg3303.c,v 1.1 2011/07/11 18:00:06 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: lg3303.c,v 1.2 2011/07/14 23:46:52 jmcneill Exp $);
 
 #include sys/types.h
 #include sys/kmem.h
@@ -80,7 +80,7 @@
 static int	lg3303_init(struct lg3303 *);
 
 struct lg3303 *
-lg3303_open(device_t parent, i2c_tag_t i2c, i2c_addr_t addr)
+lg3303_open(device_t parent, i2c_tag_t i2c, i2c_addr_t addr, int flags)
 {
 	struct lg3303 *lg;
 
@@ -91,6 +91,7 @@
 	lg-i2c = i2c;
 	lg-i2c_addr = addr;
 	lg-current_modulation = -1;
+	lg-flags = flags;
 
 	if (lg3303_init(lg) != 0) {
 		kmem_free(lg, sizeof(*lg));
@@ -205,10 +206,9 @@
 
 	if (lg-current_modulation != modulation) {
 		uint8_t top_ctrl[] = {REG_TOP_CONTROL, 0x00};
-#if 0
-		if (m_input == DVB_INPUT_SERIAL)
+
+		if (lg-flags  LG3303_CFG_SERIAL_INPUT)
 			top_ctrl[1] = 0x40;  
-#endif
 
 		switch (modulation) {
 		case VSB_8:
Index: src/sys/dev/i2c/lg3303var.h
diff -u src/sys/dev/i2c/lg3303var.h:1.1 src/sys/dev/i2c/lg3303var.h:1.2
--- src/sys/dev/i2c/lg3303var.h:1.1	Mon Jul 11 18:00:06 2011
+++ src/sys/dev/i2c/lg3303var.h	Thu Jul 14 23:46:52 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: lg3303var.h,v 1.1 2011/07/11 18:00:06 jmcneill Exp $ */
+/* $NetBSD: lg3303var.h,v 1.2 2011/07/14 23:46:52 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2011 Jared D. McNeill jmcne...@invisible.ca
@@ -32,15 +32,19 @@
 #include dev/i2c/i2cvar.h
 #include dev/dtv/dtvio.h
 
+#define	LG3303_CFG_SERIAL_INPUT	0x01
+
 struct lg3303 {
 	device_t	parent;
 	i2c_tag_t	i2c;
 	i2c_addr_t	i2c_addr;
 
 	fe_modulation_t	current_modulation;
+
+	int		flags;
 };
 
-struct lg3303 *	lg3303_open(device_t, i2c_tag_t, i2c_addr_t);
+struct lg3303 *	lg3303_open(device_t, i2c_tag_t, i2c_addr_t, int);
 void		lg3303_close(struct lg3303 *);
 int		lg3303_set_modulation(struct lg3303 *, fe_modulation_t);
 fe_status_t	lg3303_get_dtv_status(struct lg3303 *);



CVS commit: src/sys/dev/pci

2011-07-14 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Jul 14 23:47:46 UTC 2011

Modified Files:
src/sys/dev/pci: cxdtv.c cxdtv_boards.c files.pci

Log Message:
hook in lg3303 demod support and modularize


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/pci/cxdtv.c \
src/sys/dev/pci/cxdtv_boards.c
cvs rdiff -u -r1.341 -r1.342 src/sys/dev/pci/files.pci

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/cxdtv.c
diff -u src/sys/dev/pci/cxdtv.c:1.1 src/sys/dev/pci/cxdtv.c:1.2
--- src/sys/dev/pci/cxdtv.c:1.1	Mon Jul 11 00:46:03 2011
+++ src/sys/dev/pci/cxdtv.c	Thu Jul 14 23:47:45 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: cxdtv.c,v 1.1 2011/07/11 00:46:03 jakllsch Exp $ */
+/* $NetBSD: cxdtv.c,v 1.2 2011/07/14 23:47:45 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2008, 2011 Jonathan A. Kollasch
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: cxdtv.c,v 1.1 2011/07/11 00:46:03 jakllsch Exp $);
+__KERNEL_RCSID(0, $NetBSD: cxdtv.c,v 1.2 2011/07/14 23:47:45 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/kernel.h
@@ -35,7 +35,7 @@
 #include sys/kmem.h
 #include sys/mutex.h
 #include sys/condvar.h
-
+#include sys/module.h
 #include sys/bus.h
 
 #include dev/pci/pcivar.h
@@ -48,6 +48,7 @@
 #include dev/i2c/tvpll_tuners.h
 
 #include dev/i2c/nxt2kvar.h
+#include dev/i2c/lg3303var.h
 
 #include dev/pci/cxdtvreg.h
 #include dev/pci/cxdtvvar.h
@@ -63,6 +64,7 @@
 
 static int cxdtv_match(struct device *, struct cfdata *, void *);
 static void cxdtv_attach(struct device *, struct device *, void *);
+static int cxdtv_detach(struct device *, int);
 static int cxdtv_intr(void *);
 
 static bool cxdtv_resume(device_t, const pmf_qual_t *);
@@ -126,7 +128,7 @@
 };
 
 CFATTACH_DECL_NEW(cxdtv, sizeof(struct cxdtv_softc),
-cxdtv_match, cxdtv_attach, NULL, NULL);
+cxdtv_match, cxdtv_attach, cxdtv_detach, NULL);
 
 static int
 cxdtv_match(device_t parent, cfdata_t match, void *aux)
@@ -244,6 +246,12 @@
 	return;
 }
 
+static int
+cxdtv_detach(device_t self, int flags)
+{
+	return EBUSY;
+}
+
 static bool
 cxdtv_resume(device_t dv, const pmf_qual_t *qual)
 {
@@ -425,6 +433,10 @@
 	case CXDTV_DEMOD_NXT2004:
 		sc-sc_demod = nxt2k_open(sc-sc_dev, sc-sc_i2c, 0x0a, 0);
 		break;
+	case CXDTV_DEMOD_LG3303:
+		sc-sc_demod = lg3303_open(sc-sc_dev, sc-sc_i2c, 0x59,
+		LG3303_CFG_SERIAL_INPUT);
+		break;
 	default:
 		break;
 	}
@@ -515,6 +527,9 @@
 	case CXDTV_DEMOD_NXT2004:
 		error = nxt2k_set_modulation(sc-sc_demod, params-u.vsb.modulation);
 		break;
+	case CXDTV_DEMOD_LG3303:
+		error = lg3303_set_modulation(sc-sc_demod, params-u.vsb.modulation);
+		break;
 	default:
 		break;
 	}
@@ -531,6 +546,8 @@
 	switch(sc-sc_board-cb_demod) {
 	case CXDTV_DEMOD_NXT2004:
 		return nxt2k_get_dtv_status(sc-sc_demod);
+	case CXDTV_DEMOD_LG3303:
+		return lg3303_get_dtv_status(sc-sc_demod);
 	default:
 		return 0;
 	}
@@ -1069,3 +1086,32 @@
 	cv_timedwait(sc-sc_delaycv, sc-sc_delaylock, mstohz(15));
 	mutex_exit(sc-sc_delaylock);
 }
+
+MODULE(MODULE_CLASS_DRIVER, cxdtv, dtv,tvpll,nxt2k,lg3303);
+
+#ifdef _MODULE
+#include ioconf.c
+#endif
+
+static int
+cxdtv_modcmd(modcmd_t cmd, void *opaque)
+{
+	switch (cmd) {
+	case MODULE_CMD_INIT:
+#ifdef _MODULE
+		return config_init_component(cfdriver_ioconf_cxdtv,
+		cfattach_ioconf_cxdtv, cfdata_ioconf_cxdtv);
+#else
+		return 0;
+#endif
+	case MODULE_CMD_FINI:
+#ifdef _MODULE
+		return config_fini_component(cfdriver_ioconf_cxdtv,
+		cfattach_ioconf_cxdtv, cfdata_ioconf_cxdtv);
+#else
+		return 0;
+#endif
+	default:
+		return ENOTTY;
+	}
+}
Index: src/sys/dev/pci/cxdtv_boards.c
diff -u src/sys/dev/pci/cxdtv_boards.c:1.1 src/sys/dev/pci/cxdtv_boards.c:1.2
--- src/sys/dev/pci/cxdtv_boards.c:1.1	Mon Jul 11 00:46:04 2011
+++ src/sys/dev/pci/cxdtv_boards.c	Thu Jul 14 23:47:45 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: cxdtv_boards.c,v 1.1 2011/07/11 00:46:04 jakllsch Exp $ */
+/* $NetBSD: cxdtv_boards.c,v 1.2 2011/07/14 23:47:45 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2008, 2011 Jonathan A. Kollasch
@@ -28,7 +28,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: cxdtv_boards.c,v 1.1 2011/07/11 00:46:04 jakllsch Exp $);
+__KERNEL_RCSID(0, $NetBSD: cxdtv_boards.c,v 1.2 2011/07/14 23:47:45 jmcneill Exp $);
 
 #include sys/types.h
 #include sys/device.h
@@ -60,7 +60,7 @@
 cxdtv_board_lookup(pci_vendor_id_t vendor, pci_product_id_t product)
 {
 	const struct cxdtv_board *cb;
-	int i;
+	unsigned int i;
 
 	for (i = 0; i  __arraycount(cxdtv_boards); i++) {
 		cb = cxdtv_boards[i];

Index: src/sys/dev/pci/files.pci
diff -u src/sys/dev/pci/files.pci:1.341 src/sys/dev/pci/files.pci:1.342
--- src/sys/dev/pci/files.pci:1.341	Mon Jul 11 00:46:04 2011
+++ src/sys/dev/pci/files.pci	Thu Jul 14 23:47:45 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: files.pci,v 1.341 2011/07/11 00:46:04 jakllsch Exp $
+#	$NetBSD: files.pci,v 1.342 2011/07/14 23:47:45 

CVS commit: src/sys/modules

2011-07-14 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Jul 14 23:50:13 UTC 2011

Added Files:
src/sys/modules/cxdtv: Makefile cxdtv.ioconf
src/sys/modules/nxt2k: Makefile
src/sys/modules/tvpll: Makefile

Log Message:
module glue for nxt2k, tvpll, cxdtv


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/modules/cxdtv/Makefile \
src/sys/modules/cxdtv/cxdtv.ioconf
cvs rdiff -u -r0 -r1.1 src/sys/modules/nxt2k/Makefile
cvs rdiff -u -r0 -r1.1 src/sys/modules/tvpll/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Added files:

Index: src/sys/modules/cxdtv/Makefile
diff -u /dev/null src/sys/modules/cxdtv/Makefile:1.1
--- /dev/null	Thu Jul 14 23:50:13 2011
+++ src/sys/modules/cxdtv/Makefile	Thu Jul 14 23:50:13 2011
@@ -0,0 +1,13 @@
+#	$NetBSD: Makefile,v 1.1 2011/07/14 23:50:13 jmcneill Exp $
+
+.include ../Makefile.inc
+
+.PATH:	${S}/dev/pci
+
+KMOD=	cxdtv
+IOCONF=	cxdtv.ioconf
+SRCS=	cxdtv.c cxdtv_boards.c
+
+WARNS=	4
+
+.include bsd.kmodule.mk
Index: src/sys/modules/cxdtv/cxdtv.ioconf
diff -u /dev/null src/sys/modules/cxdtv/cxdtv.ioconf:1.1
--- /dev/null	Thu Jul 14 23:50:13 2011
+++ src/sys/modules/cxdtv/cxdtv.ioconf	Thu Jul 14 23:50:13 2011
@@ -0,0 +1,10 @@
+#	$NetBSD: cxdtv.ioconf,v 1.1 2011/07/14 23:50:13 jmcneill Exp $
+
+ioconf cxdtv
+
+include conf/files
+include dev/pci/files.pci
+
+pseudo-root pci*
+
+cxdtv* at pci? dev ? function ?

Index: src/sys/modules/nxt2k/Makefile
diff -u /dev/null src/sys/modules/nxt2k/Makefile:1.1
--- /dev/null	Thu Jul 14 23:50:13 2011
+++ src/sys/modules/nxt2k/Makefile	Thu Jul 14 23:50:12 2011
@@ -0,0 +1,12 @@
+#	$NetBSD: Makefile,v 1.1 2011/07/14 23:50:12 jmcneill Exp $
+
+.include ../Makefile.inc
+
+.PATH:	${S}/dev/i2c
+
+KMOD=	nxt2k
+SRCS=	nxt2k.c
+
+WARNS=	4
+
+.include bsd.kmodule.mk

Index: src/sys/modules/tvpll/Makefile
diff -u /dev/null src/sys/modules/tvpll/Makefile:1.1
--- /dev/null	Thu Jul 14 23:50:13 2011
+++ src/sys/modules/tvpll/Makefile	Thu Jul 14 23:50:12 2011
@@ -0,0 +1,12 @@
+#	$NetBSD: Makefile,v 1.1 2011/07/14 23:50:12 jmcneill Exp $
+
+.include ../Makefile.inc
+
+.PATH:	${S}/dev/i2c
+
+KMOD=	tvpll
+SRCS=	tvpll.c tvpll_tuners.c
+
+WARNS=	4
+
+.include bsd.kmodule.mk



CVS commit: src/sys/dev/pci

2011-07-14 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Jul 15 00:21:26 UTC 2011

Modified Files:
src/sys/dev/pci: cxdtv.c cxdtvvar.h

Log Message:
add detach support


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/pci/cxdtv.c
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/pci/cxdtvvar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/cxdtv.c
diff -u src/sys/dev/pci/cxdtv.c:1.2 src/sys/dev/pci/cxdtv.c:1.3
--- src/sys/dev/pci/cxdtv.c:1.2	Thu Jul 14 23:47:45 2011
+++ src/sys/dev/pci/cxdtv.c	Fri Jul 15 00:21:26 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: cxdtv.c,v 1.2 2011/07/14 23:47:45 jmcneill Exp $ */
+/* $NetBSD: cxdtv.c,v 1.3 2011/07/15 00:21:26 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2008, 2011 Jonathan A. Kollasch
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: cxdtv.c,v 1.2 2011/07/14 23:47:45 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: cxdtv.c,v 1.3 2011/07/15 00:21:26 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/kernel.h
@@ -65,6 +65,7 @@
 static int cxdtv_match(struct device *, struct cfdata *, void *);
 static void cxdtv_attach(struct device *, struct device *, void *);
 static int cxdtv_detach(struct device *, int);
+static void cxdtv_childdet(struct device *, struct device *);
 static int cxdtv_intr(void *);
 
 static bool cxdtv_resume(device_t, const pmf_qual_t *);
@@ -90,6 +91,7 @@
 static int	cxdtv_risc_field(struct cxdtv_softc *, uint32_t *, uint32_t);
 
 static int cxdtv_mpeg_attach(struct cxdtv_softc *);
+static int cxdtv_mpeg_detach(struct cxdtv_softc *, int flags);
 static int cxdtv_mpeg_intr(struct cxdtv_softc *);
 static int cxdtv_mpeg_reset(struct cxdtv_softc *);
 
@@ -127,8 +129,8 @@
 	},
 };
 
-CFATTACH_DECL_NEW(cxdtv, sizeof(struct cxdtv_softc),
-cxdtv_match, cxdtv_attach, cxdtv_detach, NULL);
+CFATTACH_DECL2_NEW(cxdtv, sizeof(struct cxdtv_softc),
+cxdtv_match, cxdtv_attach, cxdtv_detach, NULL, NULL, cxdtv_childdet);
 
 static int
 cxdtv_match(device_t parent, cfdata_t match, void *aux)
@@ -164,6 +166,7 @@
 	sc = device_private(self);
 
 	sc-sc_dev = self;
+	sc-sc_pc = pa-pa_pc;
 
 	aprint_naive(\n);
 
@@ -249,7 +252,33 @@
 static int
 cxdtv_detach(device_t self, int flags)
 {
-	return EBUSY;
+	struct cxdtv_softc *sc = device_private(self);
+	int error;
+
+	error = cxdtv_mpeg_detach(sc, flags);
+	if (error)
+		return error;
+
+	if (sc-sc_ih)
+		pci_intr_disestablish(sc-sc_pc, sc-sc_ih);
+
+	if (sc-sc_mems)
+		bus_space_unmap(sc-sc_memt, sc-sc_memh, sc-sc_mems);
+
+	mutex_destroy(sc-sc_i2c_buslock);
+	mutex_destroy(sc-sc_delaylock);
+	cv_destroy(sc-sc_delaycv);
+
+	return 0;
+}
+
+static void
+cxdtv_childdet(device_t self, device_t child)
+{
+	struct cxdtv_softc *sc = device_private(self);
+
+	if (child == sc-sc_dtvdev)
+		sc-sc_dtvdev = NULL;
 }
 
 static bool
@@ -463,6 +492,50 @@
 	return (sc-sc_dtvdev != NULL);
 }
 
+int
+cxdtv_mpeg_detach(struct cxdtv_softc *sc, int flags)
+{
+	int error = 0;
+
+	if (sc-sc_dtvdev) {
+		error = config_detach(sc-sc_dtvdev, flags);
+		if (error)
+			return error;
+	}
+
+	if (sc-sc_demod) {
+		switch (sc-sc_board-cb_demod) {
+		case CXDTV_DEMOD_NXT2004:
+			nxt2k_close(sc-sc_demod);
+			break;
+		case CXDTV_DEMOD_LG3303:
+			lg3303_close(sc-sc_demod);
+			break;
+		default:
+			break;
+		}
+		sc-sc_demod = NULL;
+	}
+	if (sc-sc_tuner) {
+		switch (sc-sc_board-cb_tuner) {
+		case CXDTV_TUNER_PLL:
+			tvpll_close(sc-sc_tuner);
+			break;
+		default:
+			break;
+		}
+		sc-sc_tuner = NULL;
+	}
+
+	if (sc-sc_riscbuf) {
+		kmem_free(sc-sc_riscbuf, sc-sc_riscbufsz);
+		sc-sc_riscbuf = NULL;
+		sc-sc_riscbufsz = 0;
+	}
+
+	return error;
+}
+
 static void
 cxdtv_dtv_get_devinfo(void *priv, struct dvb_frontend_info *info)
 {
@@ -1076,15 +1149,11 @@
 
 	val = ~1;
 	bus_space_write_4(sc-sc_memt, sc-sc_memh, CXDTV_GP0_IO, val);
-	mutex_enter(sc-sc_delaylock);
-	cv_timedwait(sc-sc_delaycv, sc-sc_delaylock, mstohz(10));
-	mutex_exit(sc-sc_delaylock);
+	delay(10);
 
 	val |= 1;
 	bus_space_write_4(sc-sc_memt, sc-sc_memh, CXDTV_GP0_IO, val);
-	mutex_enter(sc-sc_delaylock);
-	cv_timedwait(sc-sc_delaycv, sc-sc_delaylock, mstohz(15));
-	mutex_exit(sc-sc_delaylock);
+	delay(20);
 }
 
 MODULE(MODULE_CLASS_DRIVER, cxdtv, dtv,tvpll,nxt2k,lg3303);

Index: src/sys/dev/pci/cxdtvvar.h
diff -u src/sys/dev/pci/cxdtvvar.h:1.1 src/sys/dev/pci/cxdtvvar.h:1.2
--- src/sys/dev/pci/cxdtvvar.h:1.1	Mon Jul 11 00:46:04 2011
+++ src/sys/dev/pci/cxdtvvar.h	Fri Jul 15 00:21:26 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: cxdtvvar.h,v 1.1 2011/07/11 00:46:04 jakllsch Exp $ */
+/* $NetBSD: cxdtvvar.h,v 1.2 2011/07/15 00:21:26 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2008, 2011 Jonathan A. Kollasch
@@ -76,6 +76,8 @@
 	device_t		sc_dev;
 	device_t		sc_dtvdev;
 
+	pci_chipset_tag_t	sc_pc;
+
 	bus_space_tag_t		sc_memt;
 	bus_space_handle_t	sc_memh;
 	bus_size_t		sc_mems;



CVS commit: src/sys/dev/i2c

2011-07-14 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Jul 15 03:29:24 UTC 2011

Modified Files:
src/sys/dev/i2c: lg3303.c

Log Message:
if no carrier, other status fields are invalid


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/i2c/lg3303.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/i2c/lg3303.c
diff -u src/sys/dev/i2c/lg3303.c:1.2 src/sys/dev/i2c/lg3303.c:1.3
--- src/sys/dev/i2c/lg3303.c:1.2	Thu Jul 14 23:46:52 2011
+++ src/sys/dev/i2c/lg3303.c	Fri Jul 15 03:29:23 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: lg3303.c,v 1.2 2011/07/14 23:46:52 jmcneill Exp $ */
+/* $NetBSD: lg3303.c,v 1.3 2011/07/15 03:29:23 jmcneill Exp $ */
 
 /*-
  * Copyright 2007 Jason Harmening
@@ -28,7 +28,7 @@
  */
 
 #include sys/param.h
-__KERNEL_RCSID(0, $NetBSD: lg3303.c,v 1.2 2011/07/14 23:46:52 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: lg3303.c,v 1.3 2011/07/15 03:29:23 jmcneill Exp $);
 
 #include sys/types.h
 #include sys/kmem.h
@@ -275,9 +275,12 @@
 		device_printf(lg-parent,
 		lg3303: unsupported modulation type (%d)\n,
 		lg-current_modulation);
-		return EINVAL;
+		return 0;
 	}
 
+	if ((festatus  FE_HAS_CARRIER) == 0)
+		return festatus;
+
 	error = lg3303_read(lg, reg, value, sizeof(value));
 	if (!error  (value  0x01))
 		festatus |= FE_HAS_LOCK;



CVS commit: src/sys/dev/i2c

2011-07-14 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Jul 15 03:30:08 UTC 2011

Modified Files:
src/sys/dev/i2c: tvpll_tuners.h

Log Message:
struct tvpll_data foo - extern struct tvpll_data foo


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/i2c/tvpll_tuners.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/i2c/tvpll_tuners.h
diff -u src/sys/dev/i2c/tvpll_tuners.h:1.1 src/sys/dev/i2c/tvpll_tuners.h:1.2
--- src/sys/dev/i2c/tvpll_tuners.h:1.1	Mon Jul 11 00:01:52 2011
+++ src/sys/dev/i2c/tvpll_tuners.h	Fri Jul 15 03:30:08 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: tvpll_tuners.h,v 1.1 2011/07/11 00:01:52 jakllsch Exp $ */
+/* $NetBSD: tvpll_tuners.h,v 1.2 2011/07/15 03:30:08 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2008 Jonathan A. Kollasch
@@ -29,7 +29,7 @@
 #ifndef _DEV_I2C_TVPLL_TUNERS_H_
 #define _DEV_I2C_TVPLL_TUNERS_H_
 
-struct tvpll_data tvpll_tuv1236d_pll;
-struct tvpll_data tvpll_tdvs_h06xf_pll;
+extern struct tvpll_data tvpll_tuv1236d_pll;
+extern struct tvpll_data tvpll_tdvs_h06xf_pll;
 
 #endif /* !_DEV_I2C_TVPLL_TUNERS_H_ */



CVS commit: src/sys/dev/i2c

2011-07-14 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Jul 15 03:31:38 UTC 2011

Modified Files:
src/sys/dev/i2c: tvpll.c tvpll_tuners.c tvpllvar.h

Log Message:
add LG TDVS-H06xF support


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/i2c/tvpll.c \
src/sys/dev/i2c/tvpll_tuners.c
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/i2c/tvpllvar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/i2c/tvpll.c
diff -u src/sys/dev/i2c/tvpll.c:1.2 src/sys/dev/i2c/tvpll.c:1.3
--- src/sys/dev/i2c/tvpll.c:1.2	Thu Jul 14 23:45:43 2011
+++ src/sys/dev/i2c/tvpll.c	Fri Jul 15 03:31:37 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: tvpll.c,v 1.2 2011/07/14 23:45:43 jmcneill Exp $ */
+/* $NetBSD: tvpll.c,v 1.3 2011/07/15 03:31:37 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2008, 2011 Jonathan A. Kollasch
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: tvpll.c,v 1.2 2011/07/14 23:45:43 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: tvpll.c,v 1.3 2011/07/15 03:31:37 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -55,8 +55,9 @@
 tvpll_open(device_t parent, i2c_tag_t t, i2c_addr_t a, struct tvpll_data *p)
 {
 	struct tvpll *tvpll;
+	int rv;
 
-	tvpll = kmem_alloc(sizeof(struct tvpll), KM_NOSLEEP);
+	tvpll = kmem_alloc(sizeof(struct tvpll), KM_SLEEP);
 if (tvpll == NULL)
 return NULL;
 
@@ -65,6 +66,16 @@
 
 	tvpll-pll = p;
 
+	if (tvpll-pll-initdata) {
+		iic_acquire_bus(tvpll-tag, I2C_F_POLL);
+		rv = iic_exec(tvpll-tag, I2C_OP_WRITE_WITH_STOP, tvpll-addr,
+		tvpll-pll-initdata[1], tvpll-pll-initdata[0],
+		NULL, 0, I2C_F_POLL);
+		iic_release_bus(tvpll-tag, I2C_F_POLL);
+	}
+
+	device_printf(parent, tvpll: %s\n, tvpll-pll-name);
+
 	return tvpll;
 }
 
@@ -104,10 +115,11 @@
 	b[1] = (d  0)  0xff;
 	b[2] = pll-entries[i].config;
 	b[3] = pll-entries[i].cb;
+	b[4] = pll-entries[i].aux;
 
 	*fr = (d * pll-entries[i].stepsize) - pll-iffreq;
 
-	log(LOG_DEBUG, pllw %d %02x %02x %02x %02x\n, *fr, b[0], b[1], b[2], b[3]);
+	log(LOG_DEBUG, pllw %d %02x %02x %02x %02x %02x\n, *fr, b[0], b[1], b[2], b[3], b[4]);
 	return 0;
 }
 
@@ -117,16 +129,20 @@
 {
 	int rv;
 	uint32_t fr;
-	uint8_t b[4];
+	uint8_t b[5], ab[2];
 
 	fr = 0;
 
 	if((rv = tvpll_algo(tvpll, b, params, fr)) != 0)
 		return rv;
 
-	/* gate ctrl? */
-
 	iic_acquire_bus(tvpll-tag, I2C_F_POLL);
+	/* gate ctrl? */
+	if (b[4] != TVPLL_IGNORE_AUX) {
+		ab[0] = b[2] | 0x18;
+		ab[1] = b[4];
+		rv = iic_exec(tvpll-tag, I2C_OP_WRITE_WITH_STOP, tvpll-addr, ab, 2, NULL, 0, I2C_F_POLL);
+	}
 	rv = iic_exec(tvpll-tag, I2C_OP_WRITE_WITH_STOP, tvpll-addr, b, 4, NULL, 0, I2C_F_POLL);
 	iic_release_bus(tvpll-tag, I2C_F_POLL);
 
Index: src/sys/dev/i2c/tvpll_tuners.c
diff -u src/sys/dev/i2c/tvpll_tuners.c:1.2 src/sys/dev/i2c/tvpll_tuners.c:1.3
--- src/sys/dev/i2c/tvpll_tuners.c:1.2	Thu Jul 14 23:45:26 2011
+++ src/sys/dev/i2c/tvpll_tuners.c	Fri Jul 15 03:31:37 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: tvpll_tuners.c,v 1.2 2011/07/14 23:45:26 jmcneill Exp $ */
+/* $NetBSD: tvpll_tuners.c,v 1.3 2011/07/15 03:31:37 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2008, 2011 Jonathan A. Kollasch
@@ -27,16 +27,16 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: tvpll_tuners.c,v 1.2 2011/07/14 23:45:26 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: tvpll_tuners.c,v 1.3 2011/07/15 03:31:37 jmcneill Exp $);
 
 #include sys/param.h
 #include dev/i2c/tvpllvar.h
 #include dev/i2c/tvpll_tuners.h
 
 static struct tvpll_entry tuv1236d_pll_entries[] = {  
-	{ 15725, 62500, 0xc6, 0x41 },
-	{ 45400, 62500, 0xc6, 0x42 },
-	{ 9, 62500, 0xc6, 0x44 },
+	{ 15725, 62500, 0xc6, 0x41, TVPLL_IGNORE_AUX },
+	{ 45400, 62500, 0xc6, 0x42, TVPLL_IGNORE_AUX },
+	{ 9, 62500, 0xc6, 0x44, TVPLL_IGNORE_AUX },
 };
 struct tvpll_data tvpll_tuv1236d_pll = {
 	Philips TUV1236D,
@@ -45,14 +45,15 @@
 	__arraycount(tuv1236d_pll_entries), tuv1236d_pll_entries
 };
 
+static uint8_t tdvs_h06xf_initdata[] = { 2, 0xdf, 0x50 };
 static struct tvpll_entry tdvs_h06xf_pll_entries[] = {
-	{ 16500, 62500, 0xce, 0x01 },
-{ 45000, 62500, 0xce, 0x02 },
-	{ 9, 62500, 0xce, 0x04 },
+	{ 16500, 62500, 0xce, 0x01, 0x50 },
+	{ 45000, 62500, 0xce, 0x02, 0x50 },
+	{ 9, 62500, 0xce, 0x04, 0x50 },
 };
 struct tvpll_data tvpll_tdvs_h06xf_pll = {
 	LG TDVS-H06xF,
 	5400, 86300, 4400,
-	NULL, NULL,
+	tdvs_h06xf_initdata, NULL,
 	__arraycount(tdvs_h06xf_pll_entries), tdvs_h06xf_pll_entries
 };

Index: src/sys/dev/i2c/tvpllvar.h
diff -u src/sys/dev/i2c/tvpllvar.h:1.1 src/sys/dev/i2c/tvpllvar.h:1.2
--- src/sys/dev/i2c/tvpllvar.h:1.1	Mon Jul 11 00:01:52 2011
+++ src/sys/dev/i2c/tvpllvar.h	Fri Jul 15 03:31:37 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: tvpllvar.h,v 1.1 2011/07/11 00:01:52 jakllsch Exp $ */
+/* $NetBSD: tvpllvar.h,v 1.2 2011/07/15 03:31:37 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2008 

CVS commit: src/sys/dev/pci

2011-07-14 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Jul 15 03:35:13 UTC 2011

Modified Files:
src/sys/dev/pci: cxdtv.c

Log Message:
add pcHDTV HD-5500 support:

cxdtv0 at pci0 dev 14 function 2: pcHDTV HD-5500 HDTV Video Capture (rev. 0x05)
cxdtv0: interrupting at irq 10
cxdtv0: lg3303: found @ 0x59
cxdtv0: tvpll: LG TDVS-H06xF
dtv0 at cxdtv0: CX23880 [ATSC]


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/pci/cxdtv.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/cxdtv.c
diff -u src/sys/dev/pci/cxdtv.c:1.3 src/sys/dev/pci/cxdtv.c:1.4
--- src/sys/dev/pci/cxdtv.c:1.3	Fri Jul 15 00:21:26 2011
+++ src/sys/dev/pci/cxdtv.c	Fri Jul 15 03:35:13 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: cxdtv.c,v 1.3 2011/07/15 00:21:26 jmcneill Exp $ */
+/* $NetBSD: cxdtv.c,v 1.4 2011/07/15 03:35:13 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2008, 2011 Jonathan A. Kollasch
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: cxdtv.c,v 1.3 2011/07/15 00:21:26 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: cxdtv.c,v 1.4 2011/07/15 03:35:13 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/kernel.h
@@ -61,7 +61,6 @@
 #define CXDTV_SRAM_CH_MPEG	0
 #define CXDTV_TS_PKTSIZE	(188 * 8)
 
-
 static int cxdtv_match(struct device *, struct cfdata *, void *);
 static void cxdtv_attach(struct device *, struct device *, void *);
 static int cxdtv_detach(struct device *, int);
@@ -860,30 +859,34 @@
 	cxdtv_sram_ch_setup(sc, ch, CXDTV_TS_PKTSIZE);
 
 	/* software reset */
-	bus_space_write_4(sc-sc_memt, sc-sc_memh, CXDTV_TS_GEN_CONTROL,
-	0x40);
-	mutex_enter(sc-sc_delaylock);
-	cv_timedwait(sc-sc_delaycv, sc-sc_delaylock, mstohz(100));
-	mutex_exit(sc-sc_delaylock);
 
 	/* serial MPEG port on HD5500 */
 	switch(sc-sc_vendor) {
 	case PCI_VENDOR_ATI:
 		/* both ATI boards with DTV are the same */
+		bus_space_write_4(sc-sc_memt, sc-sc_memh,
+		CXDTV_TS_GEN_CONTROL, 0x40);
+		delay(100);
 		/* parallel MPEG port */
 		bus_space_write_4(sc-sc_memt, sc-sc_memh,
 		CXDTV_PINMUX_IO, 0x80); /* XXX bit defines */
 		break;
 	case PCI_VENDOR_PCHDTV:
 		if (sc-sc_product == PCI_PRODUCT_PCHDTV_HD5500) {
+			bus_space_write_4(sc-sc_memt, sc-sc_memh,
+			CXDTV_TS_GEN_CONTROL, 0x48);
+			delay(100);
 			/* serial MPEG port */
 			bus_space_write_4(sc-sc_memt, sc-sc_memh,
 			CXDTV_PINMUX_IO, 0x00); /* XXX bit defines */
-			bus_space_write_4(sc-sc_memt, sc-sc_memh,
-			CXDTV_TS_GEN_CONTROL, 0x08);
 			/* byte-width start-of-packet */
 			bus_space_write_4(sc-sc_memt, sc-sc_memh,
+			CXDTV_HW_SOP_CONTROL,
+			0x47  16 | 188  4 | 1);
+			bus_space_write_4(sc-sc_memt, sc-sc_memh,
 			CXDTV_TS_SOP_STATUS, 1  13);
+			bus_space_write_4(sc-sc_memt, sc-sc_memh,
+			CXDTV_TS_GEN_CONTROL, 0x08);
 		}
 		break;
 	default:
@@ -899,7 +902,7 @@
 
 	offset = CXDTV_TS_GEN_CONTROL;
 	v = bus_space_read_4(sc-sc_memt, sc-sc_memh, offset);
-	printf(%06x %08x\n, offset, v);
+	printf(CXDTV_TS_GEN_CONTROL %06x %08x\n, offset, v);
 
 #if 0
 	bus_space_write_4(sc-sc_memt, sc-sc_memh, CXDTV_TS_GEN_CONTROL, 0x00);
@@ -1139,20 +1142,26 @@
 }
 
 /* pcHDTV HD5500 */
+#define	cxdtv_write_field(_mask, _shift, _value)	\
+	(((_value)  (_mask))  (_shift))
+
 static void
-cxdtv_card_init_hd5500(struct cxdtv_softc *sc)
+cxdtv_write_gpio(struct cxdtv_softc *sc, uint32_t mask, uint32_t value)
 {
-	uint32_t val;
+	uint32_t v = 0;
+	v |= cxdtv_write_field(0xff, 16, mask);
+	v |= cxdtv_write_field(0xff, 8, mask);
+	v |= cxdtv_write_field(0xff, 0, (mask  value));
+	bus_space_write_4(sc-sc_memt, sc-sc_memh, CXDTV_GP0_IO, v);
+}
 
+static void
+cxdtv_card_init_hd5500(struct cxdtv_softc *sc)
+{
 	/* hardware (demod) reset */
-	val = bus_space_read_4(sc-sc_memt, sc-sc_memh, CXDTV_GP0_IO);
-
-	val = ~1;
-	bus_space_write_4(sc-sc_memt, sc-sc_memh, CXDTV_GP0_IO, val);
+	cxdtv_write_gpio(sc, 1, 0);
 	delay(10);
-
-	val |= 1;
-	bus_space_write_4(sc-sc_memt, sc-sc_memh, CXDTV_GP0_IO, val);
+	cxdtv_write_gpio(sc, 1, 1);
 	delay(20);
 }
 



CVS commit: othersrc/external/bsd/getopt2

2011-07-14 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Fri Jul 15 05:30:48 UTC 2011

Update of /cvsroot/othersrc/external/bsd/getopt2
In directory ivanova.netbsd.org:/tmp/cvs-serv24534

Log Message:
Initial import of getopt2 into othersrc repository.

getopt2(3) is similar to getopt(3), except that a structure is used to
allow multiple instances of command line parsing to take place
simultaneously, with no explicit stack saving or local copies of
global variables needing to take place.

In addition, the optstring does the usual ':' for an option with an
argument, and uses ';' to denote an option that optionally takes an
argument.

This functionality will be used by mat (and, indirectly, sharedkey) to
parse their arguments.

Status:

Vendor Tag: CROOKS
Release Tags:   getopt2-base

N othersrc/external/bsd/getopt2/Makefile
N othersrc/external/bsd/getopt2/dist/getopt2.3
N othersrc/external/bsd/getopt2/dist/Makefile
N othersrc/external/bsd/getopt2/dist/TODO
N othersrc/external/bsd/getopt2/dist/getopt2.c
N othersrc/external/bsd/getopt2/dist/getopt2.h
N othersrc/external/bsd/getopt2/dist/main.c
N othersrc/external/bsd/getopt2/dist/expected
N othersrc/external/bsd/getopt2/libgetopt2/shlib_version
N othersrc/external/bsd/getopt2/libgetopt2/Makefile
N othersrc/external/bsd/getopt2/getopt2/Makefile

No conflicts created by this import



CVS commit: othersrc/external/bsd/mat

2011-07-14 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Fri Jul 15 05:33:42 UTC 2011

Modified Files:
othersrc/external/bsd/mat/dist: frontends.c
othersrc/external/bsd/mat/libmat: Makefile
othersrc/external/bsd/mat/mat: Makefile

Log Message:
Use the getopt2(3) library to parse arguments in mat_tar() and mat_pax().
This protects the global getopt(3) arguments from modification by lower-level
routines in a destructive way.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 othersrc/external/bsd/mat/dist/frontends.c
cvs rdiff -u -r1.2 -r1.3 othersrc/external/bsd/mat/libmat/Makefile
cvs rdiff -u -r1.4 -r1.5 othersrc/external/bsd/mat/mat/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: othersrc/external/bsd/mat/dist/frontends.c
diff -u othersrc/external/bsd/mat/dist/frontends.c:1.3 othersrc/external/bsd/mat/dist/frontends.c:1.4
--- othersrc/external/bsd/mat/dist/frontends.c:1.3	Sat Jun 25 17:05:34 2011
+++ othersrc/external/bsd/mat/dist/frontends.c	Fri Jul 15 05:33:42 2011
@@ -31,6 +31,8 @@
 #include string.h
 #include unistd.h
 
+#include getopt2.h
+
 #include mat.h
 
 #ifndef TMPDIR
@@ -148,6 +150,7 @@
 mat_tar(int argc, char **argv)
 {
 	const char	*action;
+	getopt2_t	 options;
 	mat_t	 	 mat;
 	char		 newarg[MAT_PATH_MAX + 256];
 	char		 temp[MAT_PATH_MAX];
@@ -170,13 +173,14 @@
 		(void) snprintf(newarg, sizeof(newarg), -%s, argv[1]);
 		argv[1] = newarg;
 	}
-	while ((i = getopt(argc, argv, C:T:Vacf:ps:tvx)) != -1) {
+	getopt2_init(options);
+	while ((i = getopt2(options, argc, argv, C:T:Vacf:ps:tvx)) != -1) {
 		switch(i) {
 		case 'C':
-			dir = optarg;
+			dir = options.optarg;
 			break;
 		case 'T':
-			metalog = optarg;
+			metalog = options.optarg;
 			break;
 		case 'V':
 			action = verify;
@@ -188,13 +192,13 @@
 			action = create;
 			break;
 		case 'f':
-			f = optarg;
+			f = options.optarg;
 			break;
 		case 'p':
 			mat.preserve = 1;
 			break;
 		case 's':
-			if (!compile_subst(mat, optarg)) {
+			if (!compile_subst(mat, options.optarg)) {
 return 0;
 			}
 			break;
@@ -234,7 +238,7 @@
 	}
 	if (metalog) {
 		ok = read_metalog(mat, metalog);
-	} else if (argc == optind) {
+	} else if (argc == options.optind) {
 		if (strcmp(action, list) == 0) {
 			ok = mat_list(mat, NULL, stdout);
 		} else if (strcmp(action, verify) == 0) {
@@ -248,7 +252,7 @@
 			return 0;
 		}
 	} else {
-		for (ok = 1, i = optind ; i  argc ; i++) {
+		for (ok = 1, i = options.optind ; i  argc ; i++) {
 			if (strcmp(action, create) == 0) {
 if (!mat_add(mat, argv[i])) {
 	ok = 0;
@@ -305,6 +309,7 @@
 mat_pax(int argc, char **argv)
 {
 	const char	*action;
+	getopt2_t	 options;
 	mat_t		 mat;
 	char		 temp[MAT_PATH_MAX];
 	char		 cwd[MAT_PATH_MAX];
@@ -323,10 +328,11 @@
 	ok = 1;
 	action = list;
 	deltemp = 0;
-	while ((i = getopt(argc, argv, C:Vaf:lrs:wv)) != -1) {
+	getopt2_init(options);
+	while ((i = getopt2(options, argc, argv, C:Vaf:lrs:wv)) != -1) {
 		switch(i) {
 		case 'C':
-			dir = optarg;
+			dir = options.optarg;
 			break;
 		case 'V':
 			action = verify;
@@ -335,7 +341,7 @@
 			action = audit;
 			break;
 		case 'f':
-			archive = optarg;
+			archive = options.optarg;
 			break;
 		case 'l':
 			action = list;
@@ -344,8 +350,8 @@
 			action = extract;
 			break;
 		case 's':
-			if (!compile_subst(mat, optarg)) {
-(void) fprintf(stderr, bad regexp '%s'\n, optarg);
+			if (!compile_subst(mat, options.optarg)) {
+(void) fprintf(stderr, bad regexp '%s'\n, options.optarg);
 return 0;
 			}
 			break;
@@ -378,7 +384,7 @@
 	}
 	if (metalog != NULL) {
 		ok = read_metalog(mat, metalog);
-	} else if (argc == optind) {
+	} else if (argc == options.optind) {
 		if (strcmp(action, list) == 0) {
 			ok = mat_list(mat, NULL, stdout);
 		} else if (strcmp(action, verify) == 0) {
@@ -390,7 +396,7 @@
 			return 0;
 		}
 	} else {
-		for (ok = 1, i = optind ; i  argc ; i++) {
+		for (ok = 1, i = options.optind ; i  argc ; i++) {
 			if (strcmp(action, create) == 0) {
 if (!mat_add(mat, argv[i])) {
 	ok = 0;

Index: othersrc/external/bsd/mat/libmat/Makefile
diff -u othersrc/external/bsd/mat/libmat/Makefile:1.2 othersrc/external/bsd/mat/libmat/Makefile:1.3
--- othersrc/external/bsd/mat/libmat/Makefile:1.2	Mon Jun 20 14:58:53 2011
+++ othersrc/external/bsd/mat/libmat/Makefile	Fri Jul 15 05:33:42 2011
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.2 2011/06/20 14:58:53 agc Exp $
+# $NetBSD: Makefile,v 1.3 2011/07/15 05:33:42 agc Exp $
 
 .include bsd.own.mk
 
@@ -16,4 +16,6 @@
 INCS+= mat.h
 INCSDIR=/usr/include
 
+LIBDPLIBS+=	getopt2	${.CURDIR}/../../getopt2/libgetopt2
+
 .include bsd.lib.mk

Index: othersrc/external/bsd/mat/mat/Makefile
diff -u othersrc/external/bsd/mat/mat/Makefile:1.4 othersrc/external/bsd/mat/mat/Makefile:1.5
--- othersrc/external/bsd/mat/mat/Makefile:1.4	Sat Jun 25 17:05:35 2011
+++ othersrc/external/bsd/mat/mat/Makefile	Fri Jul 15 

CVS commit: othersrc/crypto/external/bsd/sharedkey

2011-07-14 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Fri Jul 15 05:37:33 UTC 2011

Modified Files:
othersrc/crypto/external/bsd/sharedkey/dist/src/libsharedkey:
libsharedkey.c
othersrc/crypto/external/bsd/sharedkey/sharedkey: Makefile

Log Message:
move from using a system(3) call to tar to package up the individual shares,
to using libmat(3). Removes the remaining XXX from this code.

the getopt2 lib is specified explicitly in the Makefiles for the benefit of
all of the sun2 port users out there.

also fix some lint


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 \
othersrc/crypto/external/bsd/sharedkey/dist/src/libsharedkey/libsharedkey.c
cvs rdiff -u -r1.1.1.1 -r1.2 \
othersrc/crypto/external/bsd/sharedkey/sharedkey/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: othersrc/crypto/external/bsd/sharedkey/dist/src/libsharedkey/libsharedkey.c
diff -u othersrc/crypto/external/bsd/sharedkey/dist/src/libsharedkey/libsharedkey.c:1.1.1.1 othersrc/crypto/external/bsd/sharedkey/dist/src/libsharedkey/libsharedkey.c:1.2
--- othersrc/crypto/external/bsd/sharedkey/dist/src/libsharedkey/libsharedkey.c:1.1.1.1	Mon Mar 21 07:10:42 2011
+++ othersrc/crypto/external/bsd/sharedkey/dist/src/libsharedkey/libsharedkey.c	Fri Jul 15 05:37:33 2011
@@ -39,8 +39,13 @@
 #include time.h
 #include unistd.h
 
+#include mat.h
 #include sharedkey.h
 
+#ifndef __UNCONST
+#define __UNCONST(a)	((void *)(unsigned long)(const void *)(a))
+#endif
+
 /* copy from one file to another */
 static int
 copy(const char *fromdir, const char *from, const char *todir, const char *to)
@@ -52,8 +57,8 @@
 	char		*mem;
 	FILE		*fpr;
 	FILE		*fpw;
-	int		 wc;
-	int		 cc;
+	ssize_t		 wc;
+	ssize_t		 cc;
 
 	(void) snprintf(fromname, sizeof(fromname), %s/%s, fromdir, from);
 	(void) snprintf(toname, sizeof(toname), %s/%s, todir, to);
@@ -102,14 +107,14 @@
 {
 	va_list	args;
 	char	name[MAXPATHLEN];
-	int	cc;
+	ssize_t	cc;
 
 	va_start(args, fmt);
 	vsnprintf(name, sizeof(name), fmt, args);
 	va_end(args);
 	cc = readlink(name, contents, size);
 	contents[cc] = 0x0;
-	return cc;
+	return (int)cc;
 }
 
 /* varargs stat function */
@@ -144,7 +149,7 @@
 {
 	const char	*last;
 	const char	*s;
-	int	 	 sufflen;
+	size_t	 	 sufflen;
 
 	if ((s = strrchr(name, '/')) == NULL) {
 		s = name;
@@ -240,17 +245,19 @@
 {
 	threshold_t	 threshold;
 	struct stat	 st;
+	const char	*mat = mattar;
 	netpgp_t	 netpgp;
 	unsigned	 i;
 	size_t		 cc;
 	time_t		 t;
+	char		 archive[MAXPATHLEN];
 	char		 keyrings[MAXPATHLEN];
 	char		 secret[MAXPATHLEN];
 	char		 sharedir[MAXPATHLEN];
 	char		 scratch[MAXPATHLEN];
 	char		 d[MAXPATHLEN];
+	char		 sharenum[32];
 	char		 desc[1024];
-	char		 cmd[8192];
 	char		*share;
 
 	(void) memset(netpgp, 0x0, sizeof(netpgp));
@@ -289,7 +296,7 @@
 	(void) snprintf(secret, sizeof(secret), %s/secret.gpg, keyrings);
 	netpgp_encrypt_file(netpgp, sharedkey-keyid, f, secret, 0);
 	/* share the private key */
-	_init(threshold, , (uint8_t)sharedkey-threshold, (uint8_t)sharedkey-shares);
+	_init(threshold, , (unsigned)sharedkey-threshold, (unsigned)sharedkey-shares);
 	(void) snprintf(scratch, sizeof(scratch), %s/secring.gpg, keyrings);
 	_add_share(threshold, THRESH_SPLIT_SOURCE, scratch, -1);
 	_split(threshold);
@@ -302,11 +309,10 @@
 		copy(keyrings, pubring.gpg, sharedir, pubring.gpg);
 		_get_share(threshold, i, (void **)(void *)share, cc);
 		writeshare(share, cc, %s/secring.gpg.share, sharedir);
-		(void) snprintf(cmd, sizeof(cmd),
-			tar -C %s -czf %s/share%.3d.tar.gz share%.3d,
-			sharedkey-splitdir, sharedkey-splitdir, i, i);
-		system(cmd); /* XXX */
-		vsyscall(0600, chmod, %s/share%.3d.tar.gz, sharedkey-splitdir, i);
+		snprintf(archive, sizeof(archive), %s/share%.3d.mat, sharedkey-splitdir, i);
+		snprintf(sharenum, sizeof(sharenum), share%.3d, i);
+		mat_vtar(__UNCONST(mat), -cvvf, archive, -C, sharedkey-splitdir, sharenum, NULL);
+		vsyscall(0600, chmod, %s/share%.3d.mat, sharedkey-splitdir, i);
 		recursive_rm(sharedir);
 	}
 	_end(threshold);
@@ -321,16 +327,14 @@
 {
 	threshold_t	 threshold;
 	struct stat	 st;
+	const char	*mat = mattar;
 	netpgp_t	 netpgp;
-	//size_t		 size;
 	char		*recoverdir;
-	char		 cmd[8192];
 	char		 keyring[MAXPATHLEN];
 	char		 scratch[MAXPATHLEN];
 	char		 secring[MAXPATHLEN];
 	char		 both[MAXPATHLEN];
 	char		 d[MAXPATHLEN];
-	//char		*share;
 	int		 i;
 
 	(void) snprintf(d, sizeof(d), /tmp/recover.XX);
@@ -342,9 +346,8 @@
 		return 0;
 	}
 	for (i = optind ; i  argc ; i++) {
-		(void) snprintf(cmd, sizeof(cmd), tar -C %s -xzf %s, recoverdir, argv[i]);
-		system(cmd); /* XXX */
-		(void) realbasename(argv[i], .tar.gz, scratch, sizeof(scratch));
+		mat_vtar(__UNCONST(mat), -xf, argv[i], -C, recoverdir, NULL);
+		(void) realbasename(argv[i], .mat, scratch, sizeof(scratch));
 		if (sharedkey-keyid[0] == 0x0) {