summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorngie <ngie@FreeBSD.org>2015-12-06 00:42:11 +0000
committerngie <ngie@FreeBSD.org>2015-12-06 00:42:11 +0000
commit51e48e07fddf9730600dec32c469c760f731bed5 (patch)
tree6b2e4533ad140ab45755c79cef2a60a2308894f2 /tools
parent13fcf1f8c2ed94cbabd6a4bee12f8ffb806252c5 (diff)
parent89ed7c325f5da55542cc3e261954ed9be69622d1 (diff)
downloadFreeBSD-src-51e48e07fddf9730600dec32c469c760f731bed5.zip
FreeBSD-src-51e48e07fddf9730600dec32c469c760f731bed5.tar.gz
MFhead@r291879
Diffstat (limited to 'tools')
-rw-r--r--tools/bsdbox/Makefile.net1
-rw-r--r--tools/build/mk/OptionalObsoleteFiles.inc14
-rwxr-xr-xtools/build/options/makeman2
-rw-r--r--tools/diag/dumpvfscache/Makefile3
-rw-r--r--tools/regression/gaithrstress/Makefile3
-rw-r--r--tools/regression/kgssapi/Makefile3
-rw-r--r--tools/regression/lib/libc/nss/test-getaddr.c134
-rw-r--r--tools/regression/lib/libc/nss/test-getgr.c140
-rw-r--r--tools/regression/lib/libc/nss/test-gethostby.c298
-rw-r--r--tools/regression/lib/libc/nss/test-getproto.c146
-rw-r--r--tools/regression/lib/libc/nss/test-getpw.c96
-rw-r--r--tools/regression/lib/libc/nss/test-getrpc.c146
-rw-r--r--tools/regression/lib/libc/nss/test-getserv.c148
-rw-r--r--tools/regression/lib/libc/nss/test-getusershell.c40
-rw-r--r--tools/regression/lib/libc/nss/testutil.h17
-rw-r--r--tools/regression/lib/libc/resolv/Makefile3
-rw-r--r--tools/regression/mac/mac_bsdextended/Makefile3
-rw-r--r--tools/regression/posixsem/Makefile3
-rw-r--r--tools/regression/priv/Makefile3
-rw-r--r--tools/regression/pthread/cv_cancel1/Makefile3
-rw-r--r--tools/regression/pthread/mutex_isowned_np/Makefile3
-rw-r--r--tools/regression/rpcsec_gss/Makefile3
-rw-r--r--tools/regression/sockets/sendfile/Makefile3
-rw-r--r--tools/regression/tls/ttls2/Makefile3
-rw-r--r--tools/regression/tls/ttls4/Makefile3
-rw-r--r--tools/tools/ath/athratestats/Makefile2
-rw-r--r--tools/tools/atsectl/Makefile3
-rw-r--r--tools/tools/ether_reflect/Makefile3
-rw-r--r--tools/tools/ifpifa/Makefile3
-rw-r--r--tools/tools/mctest/Makefile3
-rwxr-xr-xtools/tools/nanobsd/defaults.sh257
-rw-r--r--tools/tools/nanobsd/embedded/README14
-rw-r--r--tools/tools/nanobsd/embedded/beaglebone.cfg42
-rw-r--r--tools/tools/nanobsd/embedded/common567
-rw-r--r--tools/tools/nanobsd/embedded/qemu-amd64.cfg42
-rw-r--r--tools/tools/nanobsd/embedded/qemu-i386.cfg42
-rw-r--r--tools/tools/nanobsd/embedded/qemu-mips.cfg42
-rw-r--r--tools/tools/nanobsd/embedded/qemu-mips64.cfg42
-rw-r--r--tools/tools/nanobsd/embedded/qemu-powerpc.cfg43
-rw-r--r--tools/tools/nanobsd/embedded/qemu-powerpc64.cfg42
-rw-r--r--tools/tools/nanobsd/embedded/qemu-sparc64.cfg42
-rw-r--r--tools/tools/nanobsd/embedded/rpi.cfg42
-rw-r--r--tools/tools/nanobsd/embedded/rpi2.cfg42
-rw-r--r--tools/tools/nanobsd/embedded/sam9260ek.cfg41
-rw-r--r--tools/tools/nanobsd/embedded/sam9g20ek.cfg41
-rwxr-xr-xtools/tools/nanobsd/mtree-dedup.awk197
-rw-r--r--tools/tools/nanobsd/pcengines/ALIX_NFS115
-rw-r--r--tools/tools/nanobsd/pcengines/common.conf4
-rw-r--r--tools/tools/ncpus/Makefile3
-rw-r--r--tools/tools/net80211/stumbler/Makefile3
-rw-r--r--tools/tools/net80211/wesside/dics/Makefile3
-rw-r--r--tools/tools/net80211/wesside/udps/Makefile3
-rw-r--r--tools/tools/net80211/wesside/wesside/Makefile3
-rw-r--r--tools/tools/netrate/http/Makefile3
-rw-r--r--tools/tools/netrate/httpd/Makefile3
-rw-r--r--tools/tools/netrate/juggle/Makefile3
-rw-r--r--tools/tools/tscdrift/Makefile3
-rw-r--r--tools/tools/umastat/Makefile3
-rw-r--r--tools/tools/usbtest/Makefile3
-rw-r--r--tools/tools/vimage/Makefile3
-rw-r--r--tools/tools/zfsboottest/Makefile2
61 files changed, 2068 insertions, 862 deletions
diff --git a/tools/bsdbox/Makefile.net b/tools/bsdbox/Makefile.net
index 179fe70..ed39dec 100644
--- a/tools/bsdbox/Makefile.net
+++ b/tools/bsdbox/Makefile.net
@@ -21,6 +21,7 @@ CRUNCH_LIBS+= -lmemstat -lnetgraph
# ifconfig
CRUNCH_PROGS_sbin+= ifconfig
+CRUNCH_SHLIBS+= -l80211
# wlan stuff
CRUNCH_PROGS_usr.sbin+= wlandebug
diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc
index 1ef88ff..0e9c955 100644
--- a/tools/build/mk/OptionalObsoleteFiles.inc
+++ b/tools/build/mk/OptionalObsoleteFiles.inc
@@ -978,7 +978,11 @@ OLD_FILES+=usr/lib32/libuutil_p.a
OLD_LIBS+=lib/libdtrace.so.2
OLD_FILES+=usr/sbin/dtrace
OLD_FILES+=usr/sbin/lockstat
+OLD_FILES+=usr/sbin/plockstat
OLD_FILES+=usr/share/man/man1/dtrace.1.gz
+OLD_FILES+=usr/share/man/man1/dtruss.1.gz
+OLD_FILES+=usr/share/man/man1/lockstat.1.gz
+OLD_FILES+=usr/share/man/man1/plockstat.1.gz
OLD_FILES+=usr/share/dtrace/disklatency
OLD_FILES+=usr/share/dtrace/disklatencycmd
OLD_FILES+=usr/share/dtrace/hotopen
@@ -1048,6 +1052,16 @@ OLD_FILES+=usr/bin/clang++
OLD_FILES+=usr/bin/clang-cpp
OLD_FILES+=usr/bin/clang-tblgen
OLD_FILES+=usr/bin/tblgen
+OLD_FILES+=usr/lib/clang/3.7.0/include/sanitizer/allocator_interface.h
+OLD_FILES+=usr/lib/clang/3.7.0/include/sanitizer/asan_interface.h
+OLD_FILES+=usr/lib/clang/3.7.0/include/sanitizer/common_interface_defs.h
+OLD_FILES+=usr/lib/clang/3.7.0/include/sanitizer/coverage_interface.h
+OLD_FILES+=usr/lib/clang/3.7.0/include/sanitizer/dfsan_interface.h
+OLD_FILES+=usr/lib/clang/3.7.0/include/sanitizer/linux_syscall_hooks.h
+OLD_FILES+=usr/lib/clang/3.7.0/include/sanitizer/lsan_interface.h
+OLD_FILES+=usr/lib/clang/3.7.0/include/sanitizer/msan_interface.h
+OLD_FILES+=usr/lib/clang/3.7.0/include/sanitizer/tsan_interface_atomic.h
+OLD_DIRS+=usr/lib/clang/3.7.0/include/sanitizer
OLD_FILES+=usr/lib/clang/3.7.0/include/__stddef_max_align_t.h
OLD_FILES+=usr/lib/clang/3.7.0/include/__wmmintrin_aes.h
OLD_FILES+=usr/lib/clang/3.7.0/include/__wmmintrin_pclmul.h
diff --git a/tools/build/options/makeman b/tools/build/options/makeman
index 0e21499..acc0eb5 100755
--- a/tools/build/options/makeman
+++ b/tools/build/options/makeman
@@ -3,7 +3,7 @@
# This file is in the public domain.
set -o errexit
-LC_ALL=C
+export LC_ALL=C
ident='$FreeBSD$'
diff --git a/tools/diag/dumpvfscache/Makefile b/tools/diag/dumpvfscache/Makefile
index fe81d5c..3cd9c5d 100644
--- a/tools/diag/dumpvfscache/Makefile
+++ b/tools/diag/dumpvfscache/Makefile
@@ -1,8 +1,7 @@
# $FreeBSD$
PROG= dumpvfscache
-DPADD= ${LIBKVM}
-LDADD= -lkvm
+LIBADD= kvm
MAN=
diff --git a/tools/regression/gaithrstress/Makefile b/tools/regression/gaithrstress/Makefile
index 187c973..9c5cdd5 100644
--- a/tools/regression/gaithrstress/Makefile
+++ b/tools/regression/gaithrstress/Makefile
@@ -1,8 +1,7 @@
# $FreeBSD$
PROG= gaithrstress
-DPADD= ${LIBPTHREAD}
-LDADD= -lpthread
+LIBADD= pthread
MAN=
.include <bsd.prog.mk>
diff --git a/tools/regression/kgssapi/Makefile b/tools/regression/kgssapi/Makefile
index 751604f..203b688 100644
--- a/tools/regression/kgssapi/Makefile
+++ b/tools/regression/kgssapi/Makefile
@@ -3,8 +3,7 @@
PROG= gsstest
MAN=
WARNS?= 2
-DPADD= ${LIBGSSAPI} ${LIBGSSAPI_KRB5}
-LDADD= -lgssapi -lgssapi_krb5
+LIBADD= gssapi gssapi_krb5
DEBUG_FLAGS= -g -O0
.include <bsd.prog.mk>
diff --git a/tools/regression/lib/libc/nss/test-getaddr.c b/tools/regression/lib/libc/nss/test-getaddr.c
index aae1605..f0729ec 100644
--- a/tools/regression/lib/libc/nss/test-getaddr.c
+++ b/tools/regression/lib/libc/nss/test-getaddr.c
@@ -67,22 +67,22 @@ IMPLEMENT_TEST_DATA(addrinfo)
IMPLEMENT_TEST_FILE_SNAPSHOT(addrinfo)
IMPLEMENT_2PASS_TEST(addrinfo)
-static void
+static void
clone_addrinfo(struct addrinfo *dest, struct addrinfo const *src)
{
assert(dest != NULL);
assert(src != NULL);
-
+
memcpy(dest, src, sizeof(struct addrinfo));
if (src->ai_canonname != NULL)
dest->ai_canonname = strdup(src->ai_canonname);
-
+
if (src->ai_addr != NULL) {
dest->ai_addr = (struct sockaddr *)malloc(src->ai_addrlen);
assert(dest->ai_addr != NULL);
memcpy(dest->ai_addr, src->ai_addr, src->ai_addrlen);
}
-
+
if (src->ai_next != NULL) {
dest->ai_next = (struct addrinfo *)malloc(
sizeof(struct addrinfo));
@@ -96,7 +96,7 @@ compare_addrinfo_(struct addrinfo *ai1, struct addrinfo *ai2)
{
if ((ai1 == NULL) || (ai2 == NULL))
return (-1);
-
+
if ((ai1->ai_flags != ai2->ai_flags) ||
(ai1->ai_family != ai2->ai_family) ||
(ai1->ai_socktype != ai2->ai_socktype) ||
@@ -107,11 +107,11 @@ compare_addrinfo_(struct addrinfo *ai1, struct addrinfo *ai2)
(((ai1->ai_canonname == NULL) || (ai2->ai_canonname == NULL)) &&
(ai1->ai_canonname != ai2->ai_canonname)))
return (-1);
-
- if ((ai1->ai_canonname != NULL) &&
+
+ if ((ai1->ai_canonname != NULL) &&
(strcmp(ai1->ai_canonname, ai2->ai_canonname) != 0))
return (-1);
-
+
if ((ai1->ai_addr != NULL) &&
(memcmp(ai1->ai_addr, ai2->ai_addr, ai1->ai_addrlen) != 0))
return (-1);
@@ -122,17 +122,17 @@ compare_addrinfo_(struct addrinfo *ai1, struct addrinfo *ai2)
return (compare_addrinfo_(ai1->ai_next, ai2->ai_next));
}
-static int
+static int
compare_addrinfo(struct addrinfo *ai1, struct addrinfo *ai2, void *mdata)
{
int rv;
-
+
if (debug) {
printf("testing equality of 2 addrinfo structures\n");
}
rv = compare_addrinfo_(ai1, ai2);
-
+
if (debug) {
if (rv == 0)
printf("equal\n");
@@ -142,16 +142,16 @@ compare_addrinfo(struct addrinfo *ai1, struct addrinfo *ai2, void *mdata)
printf("not equal\n");
}
}
-
+
return (rv);
}
-void
+void
free_addrinfo(struct addrinfo *ai)
{
if (ai == NULL)
return;
-
+
free(ai->ai_addr);
free(ai->ai_canonname);
free_addrinfo(ai->ai_next);
@@ -159,9 +159,9 @@ free_addrinfo(struct addrinfo *ai)
void
sdump_addrinfo(struct addrinfo *ai, char *buffer, size_t buflen)
-{
+{
int written, i;
-
+
written = snprintf(buffer, buflen, "%d %d %d %d %d ",
ai->ai_flags, ai->ai_family, ai->ai_socktype, ai->ai_protocol,
ai->ai_addrlen);
@@ -169,14 +169,14 @@ sdump_addrinfo(struct addrinfo *ai, char *buffer, size_t buflen)
if (written > buflen)
return;
buflen -= written;
-
+
written = snprintf(buffer, buflen, "%s ",
ai->ai_canonname == NULL ? "(null)" : ai->ai_canonname);
buffer += written;
if (written > buflen)
return;
buflen -= written;
-
+
if (ai->ai_addr == NULL) {
written = snprintf(buffer, buflen, "(null)");
buffer += written;
@@ -185,26 +185,26 @@ sdump_addrinfo(struct addrinfo *ai, char *buffer, size_t buflen)
buflen -= written;
} else {
for (i = 0; i < ai->ai_addrlen; ++i ) {
- written = snprintf(buffer, buflen,
+ written = snprintf(buffer, buflen,
i + 1 != ai->ai_addrlen ? "%d." : "%d",
((unsigned char *)ai->ai_addr)[i]);
buffer += written;
if (written > buflen)
return;
buflen -= written;
-
+
if (buflen == 0)
return;
- }
+ }
}
-
+
if (ai->ai_next != NULL) {
written = snprintf(buffer, buflen, ":");
buffer += written;
if (written > buflen)
return;
buflen -= written;
-
+
sdump_addrinfo(ai->ai_next, buffer, buflen);
}
}
@@ -224,12 +224,12 @@ static int
addrinfo_read_snapshot_addr(char *addr, unsigned char *result, size_t len)
{
char *s, *ps, *ts;
-
+
ps = addr;
while ( (s = strsep(&ps, ".")) != NULL) {
if (len == 0)
return (-1);
-
+
*result = (unsigned char)strtol(s, &ts, 10);
++result;
if (*ts != '\0')
@@ -265,7 +265,7 @@ addrinfo_read_snapshot_ai(struct addrinfo *ai, char *line)
goto fin;
break;
case 4:
- ai->ai_addrlen = (socklen_t)strtol(s, &ts, 10);
+ ai->ai_addrlen = (socklen_t)strtol(s, &ts, 10);
if (*ts != '\0')
goto fin;
break;
@@ -274,7 +274,7 @@ addrinfo_read_snapshot_ai(struct addrinfo *ai, char *line)
ai->ai_canonname = strdup(s);
assert(ai->ai_canonname != NULL);
}
- break;
+ break;
case 6:
if (strcmp(s, "(null)") != 0) {
ai->ai_addr = (struct sockaddr *)malloc(
@@ -284,7 +284,7 @@ addrinfo_read_snapshot_ai(struct addrinfo *ai, char *line)
rv = addrinfo_read_snapshot_addr(s,
(unsigned char *)ai->ai_addr,
ai->ai_addrlen);
-
+
if (rv != 0)
goto fin;
}
@@ -294,18 +294,18 @@ addrinfo_read_snapshot_ai(struct addrinfo *ai, char *line)
rv = -1;
goto fin;
};
-
+
++i;
}
fin:
- if ((i != 7) || (rv != 0)) {
+ if ((i != 7) || (rv != 0)) {
free_addrinfo(ai);
memset(ai, 0, sizeof(struct addrinfo));
return (-1);
}
-
- return (0);
+
+ return (0);
}
static int
@@ -317,33 +317,33 @@ addrinfo_read_snapshot_func(struct addrinfo *ai, char *line)
if (debug)
printf("1 line read from snapshot:\n%s\n", line);
-
+
rv = 0;
i = 0;
ps = line;
-
+
s = strsep(&ps, ":");
if (s == NULL)
return (-1);
-
+
rv = addrinfo_read_snapshot_ai(ai, s);
if (rv != 0)
return (-1);
-
+
ai2 = ai;
while ( (s = strsep(&ps, ":")) != NULL) {
ai2->ai_next = (struct addrinfo *)malloc(
sizeof(struct addrinfo));
assert(ai2->ai_next != NULL);
memset(ai2->ai_next, 0, sizeof(struct addrinfo));
-
+
rv = addrinfo_read_snapshot_ai(ai2->ai_next, s);
if (rv != 0) {
- free_addrinfo(ai);
+ free_addrinfo(ai);
return (-1);
}
- ai2 = ai2->ai_next;
+ ai2 = ai2->ai_next;
}
return (0);
@@ -356,36 +356,36 @@ addrinfo_test_correctness(struct addrinfo *ai, void *mdata)
printf("testing correctness with the following data:\n");
dump_addrinfo(ai);
}
-
+
if (ai == NULL)
goto errfin;
-
+
if (!((ai->ai_family >= 0) && (ai->ai_family < AF_MAX)))
goto errfin;
-
+
if ((ai->ai_socktype != 0) && (ai->ai_socktype != SOCK_STREAM) &&
(ai->ai_socktype != SOCK_DGRAM) && (ai->ai_socktype != SOCK_RAW))
goto errfin;
-
+
if ((ai->ai_protocol != 0) && (ai->ai_protocol != IPPROTO_UDP) &&
(ai->ai_protocol != IPPROTO_TCP))
goto errfin;
-
+
if ((ai->ai_flags & ~(AI_CANONNAME | AI_NUMERICHOST | AI_PASSIVE)) != 0)
goto errfin;
- if ((ai->ai_addrlen != ai->ai_addr->sa_len) ||
+ if ((ai->ai_addrlen != ai->ai_addr->sa_len) ||
(ai->ai_family != ai->ai_addr->sa_family))
goto errfin;
-
+
if (debug)
printf("correct\n");
-
- return (0);
+
+ return (0);
errfin:
if (debug)
printf("incorrect\n");
-
+
return (-1);
}
@@ -393,27 +393,27 @@ static int
addrinfo_read_hostlist_func(struct addrinfo *ai, char *line)
{
struct addrinfo *result;
- int rv;
-
+ int rv;
+
if (debug)
printf("resolving %s: ", line);
rv = getaddrinfo(line, NULL, &hints, &result);
if (rv == 0) {
if (debug)
printf("found\n");
-
+
rv = addrinfo_test_correctness(result, NULL);
if (rv != 0) {
freeaddrinfo(result);
return (rv);
}
-
+
clone_addrinfo(ai, result);
freeaddrinfo(result);
} else {
if (debug)
printf("not found\n");
-
+
memset(ai, 0, sizeof(struct addrinfo));
}
return (0);
@@ -435,10 +435,10 @@ main(int argc, char **argv)
char *snapshot_file, *hostlist_file;
int rv;
int c;
-
+
if (argc < 2)
usage();
-
+
snapshot_file = NULL;
hostlist_file = NULL;
memset(&hints, 0, sizeof(struct addrinfo));
@@ -465,38 +465,38 @@ main(int argc, char **argv)
default:
usage();
}
-
+
TEST_DATA_INIT(addrinfo, &td, clone_addrinfo, free_addrinfo);
TEST_DATA_INIT(addrinfo, &td_snap, clone_addrinfo, free_addrinfo);
-
+
if (hostlist_file == NULL)
usage();
-
+
if (access(hostlist_file, R_OK) != 0) {
if (debug)
printf("can't access the hostlist file %s\n",
hostlist_file);
-
+
usage();
}
-
+
if (debug)
printf("building host lists from %s\n", hostlist_file);
-
+
rv = TEST_SNAPSHOT_FILE_READ(addrinfo, hostlist_file, &td,
addrinfo_read_hostlist_func);
if (rv != 0)
goto fin;
-
+
if (snapshot_file != NULL) {
- if (access(snapshot_file, W_OK | R_OK) != 0) {
+ if (access(snapshot_file, W_OK | R_OK) != 0) {
if (errno == ENOENT)
method = TEST_BUILD_SNAPSHOT;
else {
if (debug)
printf("can't access the snapshot file %s\n",
snapshot_file);
-
+
rv = -1;
goto fin;
}
@@ -510,7 +510,7 @@ main(int argc, char **argv)
}
}
}
-
+
switch (method) {
case TEST_GETADDRINFO:
if (snapshot_file != NULL)
@@ -519,7 +519,7 @@ main(int argc, char **argv)
break;
case TEST_BUILD_SNAPSHOT:
if (snapshot_file != NULL) {
- rv = TEST_SNAPSHOT_FILE_WRITE(addrinfo, snapshot_file, &td,
+ rv = TEST_SNAPSHOT_FILE_WRITE(addrinfo, snapshot_file, &td,
sdump_addrinfo);
}
break;
diff --git a/tools/regression/lib/libc/nss/test-getgr.c b/tools/regression/lib/libc/nss/test-getgr.c
index 322c636..0ccebae 100644
--- a/tools/regression/lib/libc/nss/test-getgr.c
+++ b/tools/regression/lib/libc/nss/test-getgr.c
@@ -63,14 +63,14 @@ static void free_group(struct group *);
static void sdump_group(struct group *, char *, size_t);
static int group_read_snapshot_func(struct group *, char *);
-static int group_check_ambiguity(struct group_test_data *,
+static int group_check_ambiguity(struct group_test_data *,
struct group *);
static int group_fill_test_data(struct group_test_data *);
static int group_test_correctness(struct group *, void *);
static int group_test_getgrnam(struct group *, void *);
static int group_test_getgrgid(struct group *, void *);
static int group_test_getgrent(struct group *, void *);
-
+
static void usage(void) __attribute__((__noreturn__));
IMPLEMENT_TEST_DATA(group)
@@ -83,33 +83,33 @@ clone_group(struct group *dest, struct group const *src)
{
assert(dest != NULL);
assert(src != NULL);
-
+
char **cp;
int members_num;
-
+
memset(dest, 0, sizeof(struct group));
-
+
if (src->gr_name != NULL) {
dest->gr_name = strdup(src->gr_name);
assert(dest->gr_name != NULL);
}
-
+
if (src->gr_passwd != NULL) {
dest->gr_passwd = strdup(src->gr_passwd);
assert(dest->gr_passwd != NULL);
}
dest->gr_gid = src->gr_gid;
-
+
if (src->gr_mem != NULL) {
members_num = 0;
for (cp = src->gr_mem; *cp; ++cp)
++members_num;
-
+
dest->gr_mem = (char **)malloc(
(members_num + 1) * (sizeof(char *)));
assert(dest->gr_mem != NULL);
memset(dest->gr_mem, 0, (members_num+1) * (sizeof(char *)));
-
+
for (cp = src->gr_mem; *cp; ++cp) {
dest->gr_mem[cp - src->gr_mem] = strdup(*cp);
assert(dest->gr_mem[cp - src->gr_mem] != NULL);
@@ -117,52 +117,52 @@ clone_group(struct group *dest, struct group const *src)
}
}
-static void
+static void
free_group(struct group *grp)
{
char **cp;
-
+
assert(grp != NULL);
-
+
free(grp->gr_name);
free(grp->gr_passwd);
-
+
for (cp = grp->gr_mem; *cp; ++cp)
free(*cp);
free(grp->gr_mem);
}
-static int
+static int
compare_group(struct group *grp1, struct group *grp2, void *mdata)
{
char **c1, **c2;
-
+
if (grp1 == grp2)
return (0);
-
+
if ((grp1 == NULL) || (grp2 == NULL))
goto errfin;
-
+
if ((strcmp(grp1->gr_name, grp2->gr_name) != 0) ||
(strcmp(grp1->gr_passwd, grp2->gr_passwd) != 0) ||
(grp1->gr_gid != grp2->gr_gid))
goto errfin;
-
+
c1 = grp1->gr_mem;
c2 = grp2->gr_mem;
-
+
if ((grp1->gr_mem == NULL) || (grp2->gr_mem == NULL))
goto errfin;
-
+
for (;*c1 && *c2; ++c1, ++c2)
if (strcmp(*c1, *c2) != 0)
goto errfin;
-
+
if ((*c1 != '\0') || (*c2 != '\0'))
goto errfin;
-
+
return 0;
-
+
errfin:
if ((debug) && (mdata == NULL)) {
printf("following structures are not equal:\n");
@@ -178,14 +178,14 @@ sdump_group(struct group *grp, char *buffer, size_t buflen)
{
char **cp;
int written;
-
+
written = snprintf(buffer, buflen, "%s %s %d",
- grp->gr_name, grp->gr_passwd, grp->gr_gid);
+ grp->gr_name, grp->gr_passwd, grp->gr_gid);
buffer += written;
if (written > buflen)
return;
buflen -= written;
-
+
if (grp->gr_mem != NULL) {
if (*(grp->gr_mem) != '\0') {
for (cp = grp->gr_mem; *cp; ++cp) {
@@ -194,9 +194,9 @@ sdump_group(struct group *grp, char *buffer, size_t buflen)
if (written > buflen)
return;
buflen -= written;
-
+
if (buflen == 0)
- return;
+ return;
}
} else
snprintf(buffer, buflen, " nomem");
@@ -213,7 +213,7 @@ group_read_snapshot_func(struct group *grp, char *line)
if (debug)
printf("1 line read from snapshot:\n%s\n", line);
-
+
i = 0;
sl = NULL;
ps = line;
@@ -243,10 +243,10 @@ group_read_snapshot_func(struct group *grp, char *line)
if (sl == NULL) {
if (strcmp(s, "(null)") == 0)
return (0);
-
+
sl = sl_init();
assert(sl != NULL);
-
+
if (strcmp(s, "nomem") != 0) {
ts = strdup(s);
assert(ts != NULL);
@@ -257,7 +257,7 @@ group_read_snapshot_func(struct group *grp, char *line)
assert(ts != NULL);
sl_add(sl, ts);
}
- break;
+ break;
};
++i;
}
@@ -268,16 +268,16 @@ group_read_snapshot_func(struct group *grp, char *line)
memset(grp, 0, sizeof(struct group));
return (-1);
}
-
+
sl_add(sl, NULL);
grp->gr_mem = sl->sl_str;
/* NOTE: is it a dirty hack or not? */
- free(sl);
+ free(sl);
return (0);
}
-static void
+static void
dump_group(struct group *result)
{
if (result != NULL) {
@@ -292,7 +292,7 @@ static int
group_fill_test_data(struct group_test_data *td)
{
struct group *grp;
-
+
setgroupent(1);
while ((grp = getgrent()) != NULL) {
if (group_test_correctness(grp, NULL) == 0)
@@ -301,7 +301,7 @@ group_fill_test_data(struct group_test_data *td)
return (-1);
}
endgrent();
-
+
return (0);
}
@@ -312,37 +312,37 @@ group_test_correctness(struct group *grp, void *mdata)
printf("testing correctness with the following data:\n");
dump_group(grp);
}
-
+
if (grp == NULL)
goto errfin;
-
+
if (grp->gr_name == NULL)
goto errfin;
-
+
if (grp->gr_passwd == NULL)
goto errfin;
-
+
if (grp->gr_mem == NULL)
goto errfin;
-
+
if (debug)
printf("correct\n");
-
- return (0);
+
+ return (0);
errfin:
if (debug)
printf("incorrect\n");
-
+
return (-1);
}
/* group_check_ambiguity() is needed here because when doing the getgrent()
- * calls sequence, records from different nsswitch sources can be different,
+ * calls sequence, records from different nsswitch sources can be different,
* though having the same pw_name/pw_uid */
static int
group_check_ambiguity(struct group_test_data *td, struct group *pwd)
{
-
+
return (TEST_DATA_FIND(group, td, pwd, compare_group,
NULL) != NULL ? 0 : -1);
}
@@ -351,7 +351,7 @@ static int
group_test_getgrnam(struct group *grp_model, void *mdata)
{
struct group *grp;
-
+
if (debug) {
printf("testing getgrnam() with the following data:\n");
dump_group(grp_model);
@@ -360,20 +360,20 @@ group_test_getgrnam(struct group *grp_model, void *mdata)
grp = getgrnam(grp_model->gr_name);
if (group_test_correctness(grp, NULL) != 0)
goto errfin;
-
+
if ((compare_group(grp, grp_model, NULL) != 0) &&
- (group_check_ambiguity((struct group_test_data *)mdata, grp)
+ (group_check_ambiguity((struct group_test_data *)mdata, grp)
!=0))
goto errfin;
-
+
if (debug)
printf("ok\n");
return (0);
-
+
errfin:
if (debug)
printf("not ok\n");
-
+
return (-1);
}
@@ -381,14 +381,14 @@ static int
group_test_getgrgid(struct group *grp_model, void *mdata)
{
struct group *grp;
-
+
if (debug) {
printf("testing getgrgid() with the following data...\n");
dump_group(grp_model);
- }
-
+ }
+
grp = getgrgid(grp_model->gr_gid);
- if ((group_test_correctness(grp, NULL) != 0) ||
+ if ((group_test_correctness(grp, NULL) != 0) ||
((compare_group(grp, grp_model, NULL) != 0) &&
(group_check_ambiguity((struct group_test_data *)mdata, grp)
!= 0))) {
@@ -402,7 +402,7 @@ group_test_getgrgid(struct group *grp_model, void *mdata)
}
}
-static int
+static int
group_test_getgrent(struct group *grp, void *mdata)
{
/* Only correctness can be checked when doing 1-pass test for
@@ -426,10 +426,10 @@ main(int argc, char **argv)
char *snapshot_file;
int rv;
int c;
-
+
if (argc < 2)
usage();
-
+
snapshot_file = NULL;
while ((c = getopt(argc, argv, "nge2ds:")) != -1)
switch (c) {
@@ -454,18 +454,18 @@ main(int argc, char **argv)
default:
usage();
}
-
+
TEST_DATA_INIT(group, &td, clone_group, free_group);
TEST_DATA_INIT(group, &td_snap, clone_group, free_group);
if (snapshot_file != NULL) {
- if (access(snapshot_file, W_OK | R_OK) != 0) {
+ if (access(snapshot_file, W_OK | R_OK) != 0) {
if (errno == ENOENT)
method = TEST_BUILD_SNAPSHOT;
else {
if (debug)
printf("can't access the file %s\n",
snapshot_file);
-
+
rv = -1;
goto fin;
}
@@ -474,12 +474,12 @@ main(int argc, char **argv)
rv = 0;
goto fin;
}
-
+
TEST_SNAPSHOT_FILE_READ(group, snapshot_file,
&td_snap, group_read_snapshot_func);
}
}
-
+
rv = group_fill_test_data(&td);
if (rv == -1)
return (-1);
@@ -489,7 +489,7 @@ main(int argc, char **argv)
rv = DO_1PASS_TEST(group, &td,
group_test_getgrnam, (void *)&td);
else
- rv = DO_1PASS_TEST(group, &td_snap,
+ rv = DO_1PASS_TEST(group, &td_snap,
group_test_getgrnam, (void *)&td_snap);
break;
case TEST_GETGRGID:
@@ -497,7 +497,7 @@ main(int argc, char **argv)
rv = DO_1PASS_TEST(group, &td,
group_test_getgrgid, (void *)&td);
else
- rv = DO_1PASS_TEST(group, &td_snap,
+ rv = DO_1PASS_TEST(group, &td_snap,
group_test_getgrgid, (void *)&td_snap);
break;
case TEST_GETGRENT:
@@ -510,7 +510,7 @@ main(int argc, char **argv)
break;
case TEST_GETGRENT_2PASS:
TEST_DATA_INIT(group, &td_2pass, clone_group, free_group);
- rv = group_fill_test_data(&td_2pass);
+ rv = group_fill_test_data(&td_2pass);
if (rv != -1)
rv = DO_2PASS_TEST(group, &td, &td_2pass,
compare_group, NULL);
@@ -518,7 +518,7 @@ main(int argc, char **argv)
break;
case TEST_BUILD_SNAPSHOT:
if (snapshot_file != NULL)
- rv = TEST_SNAPSHOT_FILE_WRITE(group, snapshot_file, &td,
+ rv = TEST_SNAPSHOT_FILE_WRITE(group, snapshot_file, &td,
sdump_group);
break;
default:
@@ -529,6 +529,6 @@ main(int argc, char **argv)
fin:
TEST_DATA_DESTROY(group, &td_snap);
TEST_DATA_DESTROY(group, &td);
- free(snapshot_file);
+ free(snapshot_file);
return (rv);
}
diff --git a/tools/regression/lib/libc/nss/test-gethostby.c b/tools/regression/lib/libc/nss/test-gethostby.c
index 7346544..9e7bdf5 100644
--- a/tools/regression/lib/libc/nss/test-gethostby.c
+++ b/tools/regression/lib/libc/nss/test-gethostby.c
@@ -90,7 +90,7 @@ static int hostent_test_correctness(struct hostent *, void *);
static int hostent_test_gethostbyaddr(struct hostent *, void *);
static int hostent_test_getaddrinfo_eq(struct hostent *, void *);
static int hostent_test_getnameinfo_eq(struct hostent *, void *);
-
+
static void usage(void) __attribute__((__noreturn__));
IMPLEMENT_TEST_DATA(hostent)
@@ -103,7 +103,7 @@ __gethostbyname2(const char *name, int af)
{
struct hostent *he;
int error;
-
+
if (use_ipnode_functions == 0)
he = gethostbyname2(name, af);
else {
@@ -112,7 +112,7 @@ __gethostbyname2(const char *name, int af)
if (he == NULL)
errno = error;
}
-
+
return (he);
}
@@ -121,7 +121,7 @@ __gethostbyaddr(const void *addr, socklen_t len, int af)
{
struct hostent *he;
int error;
-
+
if (use_ipnode_functions == 0)
he = gethostbyaddr(addr, len, af);
else {
@@ -130,8 +130,8 @@ __gethostbyaddr(const void *addr, socklen_t len, int af)
if (he == NULL)
errno = error;
}
-
- return (he);
+
+ return (he);
}
static void
@@ -147,44 +147,44 @@ clone_hostent(struct hostent *dest, struct hostent const *src)
{
assert(dest != NULL);
assert(src != NULL);
-
+
char **cp;
int aliases_num;
int addrs_num;
size_t offset;
-
+
memset(dest, 0, sizeof(struct hostent));
-
+
if (src->h_name != NULL) {
dest->h_name = strdup(src->h_name);
assert(dest->h_name != NULL);
}
-
+
dest->h_addrtype = src->h_addrtype;
dest->h_length = src->h_length;
-
+
if (src->h_aliases != NULL) {
aliases_num = 0;
for (cp = src->h_aliases; *cp; ++cp)
++aliases_num;
-
+
dest->h_aliases = (char **)malloc((aliases_num + 1) *
(sizeof(char *)));
assert(dest->h_aliases != NULL);
memset(dest->h_aliases, 0, (aliases_num + 1) *
(sizeof(char *)));
-
+
for (cp = src->h_aliases; *cp; ++cp) {
dest->h_aliases[cp - src->h_aliases] = strdup(*cp);
assert(dest->h_aliases[cp - src->h_aliases] != NULL);
}
}
-
+
if (src->h_addr_list != NULL) {
addrs_num = 0;
for (cp = src->h_addr_list; *cp; ++cp)
++addrs_num;
-
+
dest->h_addr_list = (char **)malloc((addrs_num + 1) *
(sizeof(char *)));
assert(dest->h_addr_list != NULL);
@@ -193,7 +193,7 @@ clone_hostent(struct hostent *dest, struct hostent const *src)
for (cp = src->h_addr_list; *cp; ++cp) {
offset = cp - src->h_addr_list;
- dest->h_addr_list[offset] =
+ dest->h_addr_list[offset] =
(char *)malloc(src->h_length);
assert(dest->h_addr_list[offset] != NULL);
memcpy(dest->h_addr_list[offset],
@@ -202,15 +202,15 @@ clone_hostent(struct hostent *dest, struct hostent const *src)
}
}
-static void
+static void
free_hostent(struct hostent *ht)
{
char **cp;
-
+
assert(ht != NULL);
-
+
free(ht->h_name);
-
+
if (ht->h_aliases != NULL) {
for (cp = ht->h_aliases; *cp; ++cp)
free(*cp);
@@ -224,33 +224,33 @@ free_hostent(struct hostent *ht)
}
}
-static int
+static int
compare_hostent(struct hostent *ht1, struct hostent *ht2, void *mdata)
{
char **c1, **c2, **ct, **cb;
int b;
-
+
if (ht1 == ht2)
return 0;
-
+
if ((ht1 == NULL) || (ht2 == NULL))
goto errfin;
-
+
if ((ht1->h_name == NULL) || (ht2->h_name == NULL))
goto errfin;
-
+
if ((ht1->h_addrtype != ht2->h_addrtype) ||
- (ht1->h_length != ht2->h_length) ||
+ (ht1->h_length != ht2->h_length) ||
(strcmp(ht1->h_name, ht2->h_name) != 0))
goto errfin;
-
+
c1 = ht1->h_aliases;
c2 = ht2->h_aliases;
-
+
if (((ht1->h_aliases == NULL) || (ht2->h_aliases == NULL)) &&
(ht1->h_aliases != ht2->h_aliases))
goto errfin;
-
+
if ((c1 != NULL) && (c2 != NULL)) {
cb = c1;
for (;*c1; ++c1) {
@@ -286,14 +286,14 @@ compare_hostent(struct hostent *ht1, struct hostent *ht2, void *mdata)
}
}
}
-
+
c1 = ht1->h_addr_list;
c2 = ht2->h_addr_list;
-
+
if (((ht1->h_addr_list == NULL) || (ht2->h_addr_list== NULL)) &&
(ht1->h_addr_list != ht2->h_addr_list))
goto errfin;
-
+
if ((c1 != NULL) && (c2 != NULL)) {
cb = c1;
for (;*c1; ++c1) {
@@ -311,7 +311,7 @@ compare_hostent(struct hostent *ht1, struct hostent *ht2, void *mdata)
goto errfin;
}
}
-
+
c1 = cb;
for (;*c2; ++c2) {
b = 0;
@@ -331,7 +331,7 @@ compare_hostent(struct hostent *ht1, struct hostent *ht2, void *mdata)
}
return 0;
-
+
errfin:
if ((debug) && (mdata == NULL)) {
printf("following structures are not equal:\n");
@@ -346,28 +346,28 @@ static int
check_addrinfo_for_name(struct addrinfo *ai, char const *name)
{
struct addrinfo *ai2;
-
+
for (ai2 = ai; ai2 != NULL; ai2 = ai2->ai_next) {
if (strcmp(ai2->ai_canonname, name) == 0)
return (0);
}
-
+
return (-1);
}
static int
-check_addrinfo_for_addr(struct addrinfo *ai, char const *addr,
+check_addrinfo_for_addr(struct addrinfo *ai, char const *addr,
socklen_t addrlen, int af)
{
struct addrinfo *ai2;
-
+
for (ai2 = ai; ai2 != NULL; ai2 = ai2->ai_next) {
if (af != ai2->ai_family)
continue;
-
+
switch (af) {
case AF_INET:
- if (memcmp(addr,
+ if (memcmp(addr,
(void *)&((struct sockaddr_in *)ai2->ai_addr)->sin_addr,
min(addrlen, ai2->ai_addrlen)) == 0)
return (0);
@@ -382,24 +382,24 @@ check_addrinfo_for_addr(struct addrinfo *ai, char const *addr,
break;
}
}
-
+
return (-1);
}
-static int
+static int
is_hostent_equal(struct hostent *he, struct addrinfo *ai)
{
char **cp;
int rv;
-
+
if (debug)
printf("checking equality of he and ai\n");
-
+
rv = check_addrinfo_for_name(ai, he->h_name);
if (rv != 0) {
if (debug)
printf("not equal - he->h_name couldn't be found\n");
-
+
return (rv);
}
@@ -409,14 +409,14 @@ is_hostent_equal(struct hostent *he, struct addrinfo *ai)
if (rv != 0) {
if (debug)
printf("not equal - one of he->h_addr_list couldn't be found\n");
-
+
return (rv);
}
}
-
+
if (debug)
printf("equal\n");
-
+
return (0);
}
@@ -426,14 +426,14 @@ sdump_hostent(struct hostent *ht, char *buffer, size_t buflen)
char **cp;
size_t i;
int written;
-
+
written = snprintf(buffer, buflen, "%s %d %d",
ht->h_name, ht->h_addrtype, ht->h_length);
buffer += written;
if (written > buflen)
return;
buflen -= written;
-
+
if (ht->h_aliases != NULL) {
if (*(ht->h_aliases) != NULL) {
for (cp = ht->h_aliases; *cp; ++cp) {
@@ -442,53 +442,53 @@ sdump_hostent(struct hostent *ht, char *buffer, size_t buflen)
if (written > buflen)
return;
buflen -= written;
-
+
if (buflen == 0)
- return;
+ return;
}
} else {
written = snprintf(buffer, buflen, " noaliases");
buffer += written;
if (written > buflen)
return;
- buflen -= written;
+ buflen -= written;
}
} else {
written = snprintf(buffer, buflen, " (null)");
buffer += written;
if (written > buflen)
return;
- buflen -= written;
+ buflen -= written;
}
-
+
written = snprintf(buffer, buflen, " : ");
buffer += written;
if (written > buflen)
return;
- buflen -= written;
+ buflen -= written;
if (ht->h_addr_list != NULL) {
if (*(ht->h_addr_list) != NULL) {
for (cp = ht->h_addr_list; *cp; ++cp) {
for (i = 0; i < ht->h_length; ++i ) {
- written = snprintf(buffer, buflen,
+ written = snprintf(buffer, buflen,
i + 1 != ht->h_length ? "%d." : "%d",
(unsigned char)(*cp)[i]);
buffer += written;
if (written > buflen)
return;
buflen -= written;
-
+
if (buflen == 0)
return;
}
-
+
if (*(cp + 1) ) {
written = snprintf(buffer, buflen, " ");
buffer += written;
if (written > buflen)
return;
- buflen -= written;
+ buflen -= written;
}
}
} else {
@@ -496,42 +496,42 @@ sdump_hostent(struct hostent *ht, char *buffer, size_t buflen)
buffer += written;
if (written > buflen)
return;
- buflen -= written;
+ buflen -= written;
}
} else {
written = snprintf(buffer, buflen, " (null)");
buffer += written;
if (written > buflen)
return;
- buflen -= written;
- }
+ buflen -= written;
+ }
}
static int
hostent_read_hostlist_func(struct hostent *he, char *line)
{
struct hostent *result;
- int rv;
-
+ int rv;
+
if (debug)
printf("resolving %s: ", line);
result = __gethostbyname2(line, af_type);
if (result != NULL) {
if (debug)
printf("found\n");
-
+
rv = hostent_test_correctness(result, NULL);
if (rv != 0) {
__freehostent(result);
return (rv);
}
-
+
clone_hostent(he, result);
__freehostent(result);
} else {
if (debug)
printf("not found\n");
-
+
memset(he, 0, sizeof(struct hostent));
he->h_name = strdup(line);
assert(he->h_name != NULL);
@@ -543,12 +543,12 @@ static int
hostent_read_snapshot_addr(char *addr, unsigned char *result, size_t len)
{
char *s, *ps, *ts;
-
+
ps = addr;
while ( (s = strsep(&ps, ".")) != NULL) {
if (len == 0)
return (-1);
-
+
*result = (unsigned char)strtol(s, &ts, 10);
++result;
if (*ts != '\0')
@@ -571,7 +571,7 @@ hostent_read_snapshot_func(struct hostent *ht, char *line)
if (debug)
printf("1 line read from snapshot:\n%s\n", line);
-
+
rv = 0;
i = 0;
sl1 = sl2 = NULL;
@@ -595,15 +595,15 @@ hostent_read_snapshot_func(struct hostent *ht, char *line)
if (*ts != '\0')
goto fin;
break;
-
+
case 3:
if (sl1 == NULL) {
if (strcmp(s, "(null)") == 0)
return (0);
-
+
sl1 = sl_init();
assert(sl1 != NULL);
-
+
if (strcmp(s, "noaliases") != 0) {
ts = strdup(s);
assert(ts != NULL);
@@ -618,16 +618,16 @@ hostent_read_snapshot_func(struct hostent *ht, char *line)
sl_add(sl1, ts);
}
}
- break;
+ break;
case 4:
if (sl2 == NULL) {
if (strcmp(s, "(null)") == 0)
return (0);
-
+
sl2 = sl_init();
assert(sl2 != NULL);
-
+
if (strcmp(s, "noaddrs") != 0) {
ts = (char *)malloc(ht->h_length);
assert(ts != NULL);
@@ -650,9 +650,9 @@ hostent_read_snapshot_func(struct hostent *ht, char *line)
}
break;
default:
- break;
+ break;
};
-
+
if ((i != 3) && (i != 4))
++i;
}
@@ -667,19 +667,19 @@ fin:
ht->h_addr_list = sl2->sl_str;
}
- if ((i != 4) || (rv != 0)) {
+ if ((i != 4) || (rv != 0)) {
free_hostent(ht);
memset(ht, 0, sizeof(struct hostent));
return (-1);
}
-
+
/* NOTE: is it a dirty hack or not? */
free(sl1);
- free(sl2);
+ free(sl2);
return (0);
}
-static void
+static void
dump_hostent(struct hostent *result)
{
if (result != NULL) {
@@ -697,34 +697,34 @@ hostent_test_correctness(struct hostent *ht, void *mdata)
printf("testing correctness with the following data:\n");
dump_hostent(ht);
}
-
+
if (ht == NULL)
goto errfin;
-
+
if (ht->h_name == NULL)
goto errfin;
if (!((ht->h_addrtype >= 0) && (ht->h_addrtype < AF_MAX)))
goto errfin;
-
- if ((ht->h_length != sizeof(struct in_addr)) &&
+
+ if ((ht->h_length != sizeof(struct in_addr)) &&
(ht->h_length != sizeof(struct in6_addr)))
goto errfin;
-
+
if (ht->h_aliases == NULL)
goto errfin;
-
+
if (ht->h_addr_list == NULL)
goto errfin;
-
+
if (debug)
printf("correct\n");
-
- return (0);
+
+ return (0);
errfin:
if (debug)
printf("incorrect\n");
-
+
return (-1);
}
@@ -733,23 +733,23 @@ hostent_test_gethostbyaddr(struct hostent *he, void *mdata)
{
struct hostent *result;
struct hostent_test_data *addr_test_data;
- int rv;
-
+ int rv;
+
addr_test_data = (struct hostent_test_data *)mdata;
-
+
/* We should omit unresolved hostents */
if (he->h_addr_list != NULL) {
char **cp;
for (cp = he->h_addr_list; *cp; ++cp) {
if (debug)
printf("doing reverse lookup for %s\n", he->h_name);
-
+
result = __gethostbyaddr(*cp, he->h_length,
he->h_addrtype);
if (result == NULL) {
if (debug)
printf("warning: reverse lookup failed\n");
-
+
continue;
}
rv = hostent_test_correctness(result, NULL);
@@ -757,14 +757,14 @@ hostent_test_gethostbyaddr(struct hostent *he, void *mdata)
__freehostent(result);
return (rv);
}
-
+
if (addr_test_data != NULL)
TEST_DATA_APPEND(hostent, addr_test_data, result);
-
+
__freehostent(result);
}
}
-
+
return (0);
}
@@ -772,16 +772,16 @@ static int
hostent_test_getaddrinfo_eq(struct hostent *he, void *mdata)
{
struct addrinfo *ai, hints;
- int rv;
-
+ int rv;
+
ai = NULL;
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = af_type;
hints.ai_flags = AI_CANONNAME;
-
+
if (debug)
printf("using getaddrinfo() to resolve %s\n", he->h_name);
-
+
/* struct hostent *he was not resolved */
if (he->h_addr_list == NULL) {
/* We can be sure that he->h_name is not NULL */
@@ -798,20 +798,20 @@ hostent_test_getaddrinfo_eq(struct hostent *he, void *mdata)
printf("not ok - should have beed resolved\n");
return (-1);
}
-
+
rv = is_hostent_equal(he, ai);
if (rv != 0) {
if (debug)
printf("not ok - addrinfo and hostent are not equal\n");
return (-1);
}
-
+
}
-
+
return (0);
}
-static int
+static int
hostent_test_getnameinfo_eq(struct hostent *he, void *mdata)
{
char buffer[NI_MAXHOST];
@@ -820,13 +820,13 @@ hostent_test_getnameinfo_eq(struct hostent *he, void *mdata)
struct sockaddr *saddr;
struct hostent *result;
int rv;
-
+
if (he->h_addr_list != NULL) {
char **cp;
for (cp = he->h_addr_list; *cp; ++cp) {
if (debug)
printf("doing reverse lookup for %s\n", he->h_name);
-
+
result = __gethostbyaddr(*cp, he->h_length,
he->h_addrtype);
if (result != NULL) {
@@ -837,16 +837,16 @@ hostent_test_getnameinfo_eq(struct hostent *he, void *mdata)
}
} else {
if (debug)
- printf("reverse lookup failed\n");
+ printf("reverse lookup failed\n");
}
-
+
switch (he->h_addrtype) {
case AF_INET:
memset(&sin, 0, sizeof(struct sockaddr_in));
sin.sin_len = sizeof(struct sockaddr_in);
sin.sin_family = AF_INET;
memcpy(&sin.sin_addr, *cp, he->h_length);
-
+
saddr = (struct sockaddr *)&sin;
break;
case AF_INET6:
@@ -854,7 +854,7 @@ hostent_test_getnameinfo_eq(struct hostent *he, void *mdata)
sin6.sin6_len = sizeof(struct sockaddr_in6);
sin6.sin6_family = AF_INET6;
memcpy(&sin6.sin6_addr, *cp, he->h_length);
-
+
saddr = (struct sockaddr *)&sin6;
break;
default:
@@ -863,38 +863,38 @@ hostent_test_getnameinfo_eq(struct hostent *he, void *mdata)
he->h_addrtype);
continue;
}
-
+
assert(saddr != NULL);
- rv = getnameinfo(saddr, saddr->sa_len, buffer,
+ rv = getnameinfo(saddr, saddr->sa_len, buffer,
sizeof(buffer), NULL, 0, NI_NAMEREQD);
-
+
if ((rv != 0) && (result != NULL)) {
if (debug)
printf("not ok - getnameinfo() didn't make the reverse lookup, when it should have (%s)\n",
gai_strerror(rv));
return (rv);
}
-
+
if ((rv == 0) && (result == NULL)) {
if (debug)
- printf("not ok - getnameinfo() made the reverse lookup, when it shouldn't have\n");
+ printf("not ok - getnameinfo() made the reverse lookup, when it shouldn't have\n");
return (rv);
}
-
+
if ((rv != 0) && (result == NULL)) {
if (debug)
printf("ok - both getnameinfo() and ***byaddr() failed\n");
-
+
continue;
}
-
+
if (debug)
printf("comparing %s with %s\n", result->h_name,
- buffer);
-
+ buffer);
+
rv = strcmp(result->h_name, buffer);
__freehostent(result);
-
+
if (rv != 0) {
if (debug)
printf("not ok - getnameinfo() and ***byaddr() results are not equal\n");
@@ -903,10 +903,10 @@ hostent_test_getnameinfo_eq(struct hostent *he, void *mdata)
if (debug)
printf("ok - getnameinfo() and ***byaddr() results are equal\n");
}
- }
+ }
}
-
- return (0);
+
+ return (0);
}
static void
@@ -923,13 +923,13 @@ main(int argc, char **argv)
{
struct hostent_test_data td, td_addr, td_snap;
char *snapshot_file, *hostlist_file;
- res_state statp;
+ res_state statp;
int rv;
int c;
-
+
if (argc < 2)
usage();
-
+
snapshot_file = NULL;
hostlist_file = NULL;
while ((c = getopt(argc, argv, "nad2iod46mAcMs:f:")) != -1)
@@ -986,37 +986,37 @@ main(int argc, char **argv)
if (use_ipnode_functions == 0) {
statp = __res_state();
- if ((statp == NULL) || ((statp->options & RES_INIT) == 0 &&
+ if ((statp == NULL) || ((statp->options & RES_INIT) == 0 &&
res_ninit(statp) == -1)) {
if (debug)
printf("error: can't init res_state\n");
-
+
free(snapshot_file);
free(hostlist_file);
return (-1);
}
-
- if (use_ipv6_mapping == 0)
+
+ if (use_ipv6_mapping == 0)
statp->options &= ~RES_USE_INET6;
else
statp->options |= RES_USE_INET6;
}
-
+
TEST_DATA_INIT(hostent, &td, clone_hostent, free_hostent);
TEST_DATA_INIT(hostent, &td_addr, clone_hostent, free_hostent);
TEST_DATA_INIT(hostent, &td_snap, clone_hostent, free_hostent);
-
+
if (hostlist_file == NULL)
usage();
-
+
if (access(hostlist_file, R_OK) != 0) {
if (debug)
printf("can't access the hostlist file %s\n",
hostlist_file);
-
+
usage();
}
-
+
if (debug)
printf("building host lists from %s\n", hostlist_file);
@@ -1024,9 +1024,9 @@ main(int argc, char **argv)
hostent_read_hostlist_func);
if (rv != 0)
goto fin;
-
+
if (snapshot_file != NULL) {
- if (access(snapshot_file, W_OK | R_OK) != 0) {
+ if (access(snapshot_file, W_OK | R_OK) != 0) {
if (errno == ENOENT) {
if (method != TEST_GETHOSTBYADDR)
method = TEST_BUILD_SNAPSHOT;
@@ -1036,7 +1036,7 @@ main(int argc, char **argv)
if (debug)
printf("can't access the snapshot file %s\n",
snapshot_file);
-
+
rv = -1;
goto fin;
}
@@ -1050,7 +1050,7 @@ main(int argc, char **argv)
}
}
}
-
+
switch (method) {
case TEST_GETHOSTBYNAME2:
if (snapshot_file != NULL)
@@ -1062,7 +1062,7 @@ main(int argc, char **argv)
hostent_test_gethostbyaddr, (void *)&td_addr);
if (snapshot_file != NULL)
- rv = DO_2PASS_TEST(hostent, &td_addr, &td_snap,
+ rv = DO_2PASS_TEST(hostent, &td_addr, &td_snap,
compare_hostent, NULL);
break;
case TEST_GETHOSTBYNAME2_GETADDRINFO:
@@ -1075,7 +1075,7 @@ main(int argc, char **argv)
break;
case TEST_BUILD_SNAPSHOT:
if (snapshot_file != NULL) {
- rv = TEST_SNAPSHOT_FILE_WRITE(hostent, snapshot_file, &td,
+ rv = TEST_SNAPSHOT_FILE_WRITE(hostent, snapshot_file, &td,
sdump_hostent);
}
break;
@@ -1083,8 +1083,8 @@ main(int argc, char **argv)
if (snapshot_file != NULL) {
rv = DO_1PASS_TEST(hostent, &td,
hostent_test_gethostbyaddr, (void *)&td_addr);
-
- rv = TEST_SNAPSHOT_FILE_WRITE(hostent, snapshot_file,
+
+ rv = TEST_SNAPSHOT_FILE_WRITE(hostent, snapshot_file,
&td_addr, sdump_hostent);
}
break;
diff --git a/tools/regression/lib/libc/nss/test-getproto.c b/tools/regression/lib/libc/nss/test-getproto.c
index 89ad087..a3ba271 100644
--- a/tools/regression/lib/libc/nss/test-getproto.c
+++ b/tools/regression/lib/libc/nss/test-getproto.c
@@ -63,14 +63,14 @@ static void free_protoent(struct protoent *);
static void sdump_protoent(struct protoent *, char *, size_t);
static int protoent_read_snapshot_func(struct protoent *, char *);
-static int protoent_check_ambiguity(struct protoent_test_data *,
+static int protoent_check_ambiguity(struct protoent_test_data *,
struct protoent *);
static int protoent_fill_test_data(struct protoent_test_data *);
static int protoent_test_correctness(struct protoent *, void *);
static int protoent_test_getprotobyname(struct protoent *, void *);
static int protoent_test_getprotobynumber(struct protoent *, void *);
static int protoent_test_getprotoent(struct protoent *, void *);
-
+
static void usage(void) __attribute__((__noreturn__));
IMPLEMENT_TEST_DATA(protoent)
@@ -83,28 +83,28 @@ clone_protoent(struct protoent *dest, struct protoent const *src)
{
assert(dest != NULL);
assert(src != NULL);
-
+
char **cp;
int aliases_num;
-
+
memset(dest, 0, sizeof(struct protoent));
-
+
if (src->p_name != NULL) {
dest->p_name = strdup(src->p_name);
assert(dest->p_name != NULL);
}
-
+
dest->p_proto = src->p_proto;
-
+
if (src->p_aliases != NULL) {
aliases_num = 0;
for (cp = src->p_aliases; *cp; ++cp)
++aliases_num;
-
+
dest->p_aliases = (char **)malloc((aliases_num+1) * (sizeof(char *)));
assert(dest->p_aliases != NULL);
memset(dest->p_aliases, 0, (aliases_num+1) * (sizeof(char *)));
-
+
for (cp = src->p_aliases; *cp; ++cp) {
dest->p_aliases[cp - src->p_aliases] = strdup(*cp);
assert(dest->p_aliases[cp - src->p_aliases] != NULL);
@@ -112,50 +112,50 @@ clone_protoent(struct protoent *dest, struct protoent const *src)
}
}
-static void
+static void
free_protoent(struct protoent *pe)
{
char **cp;
-
+
assert(pe != NULL);
-
+
free(pe->p_name);
-
+
for (cp = pe->p_aliases; *cp; ++cp)
free(*cp);
free(pe->p_aliases);
}
-static int
+static int
compare_protoent(struct protoent *pe1, struct protoent *pe2, void *mdata)
{
char **c1, **c2;
-
+
if (pe1 == pe2)
return 0;
-
+
if ((pe1 == NULL) || (pe2 == NULL))
goto errfin;
-
+
if ((strcmp(pe1->p_name, pe2->p_name) != 0) ||
(pe1->p_proto != pe2->p_proto))
goto errfin;
-
+
c1 = pe1->p_aliases;
c2 = pe2->p_aliases;
-
+
if ((pe1->p_aliases == NULL) || (pe2->p_aliases == NULL))
goto errfin;
-
+
for (;*c1 && *c2; ++c1, ++c2)
if (strcmp(*c1, *c2) != 0)
goto errfin;
-
+
if ((*c1 != '\0') || (*c2 != '\0'))
goto errfin;
-
+
return 0;
-
+
errfin:
if ((debug) && (mdata == NULL)) {
printf("following structures are not equal:\n");
@@ -171,14 +171,14 @@ sdump_protoent(struct protoent *pe, char *buffer, size_t buflen)
{
char **cp;
int written;
-
+
written = snprintf(buffer, buflen, "%s %d",
- pe->p_name, pe->p_proto);
+ pe->p_name, pe->p_proto);
buffer += written;
if (written > buflen)
return;
buflen -= written;
-
+
if (pe->p_aliases != NULL) {
if (*(pe->p_aliases) != '\0') {
for (cp = pe->p_aliases; *cp; ++cp) {
@@ -187,9 +187,9 @@ sdump_protoent(struct protoent *pe, char *buffer, size_t buflen)
if (written > buflen)
return;
buflen -= written;
-
+
if (buflen == 0)
- return;
+ return;
}
} else
snprintf(buffer, buflen, " noaliases");
@@ -206,7 +206,7 @@ protoent_read_snapshot_func(struct protoent *pe, char *line)
if (debug)
printf("1 line read from snapshot:\n%s\n", line);
-
+
i = 0;
sl = NULL;
ps = line;
@@ -230,10 +230,10 @@ protoent_read_snapshot_func(struct protoent *pe, char *line)
if (sl == NULL) {
if (strcmp(s, "(null)") == 0)
return (0);
-
+
sl = sl_init();
assert(sl != NULL);
-
+
if (strcmp(s, "noaliases") != 0) {
ts = strdup(s);
assert(ts != NULL);
@@ -244,7 +244,7 @@ protoent_read_snapshot_func(struct protoent *pe, char *line)
assert(ts != NULL);
sl_add(sl, ts);
}
- break;
+ break;
};
++i;
}
@@ -254,16 +254,16 @@ protoent_read_snapshot_func(struct protoent *pe, char *line)
memset(pe, 0, sizeof(struct protoent));
return (-1);
}
-
+
sl_add(sl, NULL);
pe->p_aliases = sl->sl_str;
/* NOTE: is it a dirty hack or not? */
- free(sl);
+ free(sl);
return (0);
}
-static void
+static void
dump_protoent(struct protoent *result)
{
if (result != NULL) {
@@ -278,7 +278,7 @@ static int
protoent_fill_test_data(struct protoent_test_data *td)
{
struct protoent *pe;
-
+
setprotoent(1);
while ((pe = getprotoent()) != NULL) {
if (protoent_test_correctness(pe, NULL) == 0)
@@ -287,7 +287,7 @@ protoent_fill_test_data(struct protoent_test_data *td)
return (-1);
}
endprotoent();
-
+
return (0);
}
@@ -298,39 +298,39 @@ protoent_test_correctness(struct protoent *pe, void *mdata)
printf("testing correctness with the following data:\n");
dump_protoent(pe);
}
-
+
if (pe == NULL)
goto errfin;
-
+
if (pe->p_name == NULL)
goto errfin;
-
+
if (pe->p_proto < 0)
goto errfin;
-
+
if (pe->p_aliases == NULL)
goto errfin;
-
+
if (debug)
printf("correct\n");
-
- return (0);
+
+ return (0);
errfin:
if (debug)
printf("incorrect\n");
-
+
return (-1);
}
/* protoent_check_ambiguity() is needed when one port+proto is associated with
* more than one peice (these cases are usually marked as PROBLEM in
- * /etc/peices. This functions is needed also when one peice+proto is
+ * /etc/peices. This functions is needed also when one peice+proto is
* associated with several ports. We have to check all the protoent structures
* to make sure that pe really exists and correct */
static int
protoent_check_ambiguity(struct protoent_test_data *td, struct protoent *pe)
{
-
+
return (TEST_DATA_FIND(protoent, td, pe, compare_protoent,
NULL) != NULL ? 0 : -1);
}
@@ -340,7 +340,7 @@ protoent_test_getprotobyname(struct protoent *pe_model, void *mdata)
{
char **alias;
struct protoent *pe;
-
+
if (debug) {
printf("testing getprotobyname() with the following data:\n");
dump_protoent(pe_model);
@@ -349,32 +349,32 @@ protoent_test_getprotobyname(struct protoent *pe_model, void *mdata)
pe = getprotobyname(pe_model->p_name);
if (protoent_test_correctness(pe, NULL) != 0)
goto errfin;
-
+
if ((compare_protoent(pe, pe_model, NULL) != 0) &&
- (protoent_check_ambiguity((struct protoent_test_data *)mdata, pe)
+ (protoent_check_ambiguity((struct protoent_test_data *)mdata, pe)
!=0))
goto errfin;
-
+
for (alias = pe_model->p_aliases; *alias; ++alias) {
pe = getprotobyname(*alias);
-
+
if (protoent_test_correctness(pe, NULL) != 0)
goto errfin;
-
+
if ((compare_protoent(pe, pe_model, NULL) != 0) &&
(protoent_check_ambiguity(
(struct protoent_test_data *)mdata, pe) != 0))
goto errfin;
}
-
+
if (debug)
printf("ok\n");
return (0);
-
+
errfin:
if (debug)
printf("not ok\n");
-
+
return (-1);
}
@@ -382,14 +382,14 @@ static int
protoent_test_getprotobynumber(struct protoent *pe_model, void *mdata)
{
struct protoent *pe;
-
+
if (debug) {
printf("testing getprotobyport() with the following data...\n");
dump_protoent(pe_model);
- }
-
+ }
+
pe = getprotobynumber(pe_model->p_proto);
- if ((protoent_test_correctness(pe, NULL) != 0) ||
+ if ((protoent_test_correctness(pe, NULL) != 0) ||
((compare_protoent(pe, pe_model, NULL) != 0) &&
(protoent_check_ambiguity((struct protoent_test_data *)mdata, pe)
!= 0))) {
@@ -403,7 +403,7 @@ protoent_test_getprotobynumber(struct protoent *pe_model, void *mdata)
}
}
-static int
+static int
protoent_test_getprotoent(struct protoent *pe, void *mdata)
{
/* Only correctness can be checked when doing 1-pass test for
@@ -427,10 +427,10 @@ main(int argc, char **argv)
char *snapshot_file;
int rv;
int c;
-
+
if (argc < 2)
usage();
-
+
snapshot_file = NULL;
while ((c = getopt(argc, argv, "nve2ds:")) != -1)
switch (c) {
@@ -455,18 +455,18 @@ main(int argc, char **argv)
default:
usage();
}
-
+
TEST_DATA_INIT(protoent, &td, clone_protoent, free_protoent);
TEST_DATA_INIT(protoent, &td_snap, clone_protoent, free_protoent);
if (snapshot_file != NULL) {
- if (access(snapshot_file, W_OK | R_OK) != 0) {
+ if (access(snapshot_file, W_OK | R_OK) != 0) {
if (errno == ENOENT)
method = TEST_BUILD_SNAPSHOT;
else {
if (debug)
printf("can't access the file %s\n",
snapshot_file);
-
+
rv = -1;
goto fin;
}
@@ -475,12 +475,12 @@ main(int argc, char **argv)
rv = 0;
goto fin;
}
-
+
TEST_SNAPSHOT_FILE_READ(protoent, snapshot_file,
&td_snap, protoent_read_snapshot_func);
}
}
-
+
rv = protoent_fill_test_data(&td);
if (rv == -1)
return (-1);
@@ -490,7 +490,7 @@ main(int argc, char **argv)
rv = DO_1PASS_TEST(protoent, &td,
protoent_test_getprotobyname, (void *)&td);
else
- rv = DO_1PASS_TEST(protoent, &td_snap,
+ rv = DO_1PASS_TEST(protoent, &td_snap,
protoent_test_getprotobyname, (void *)&td_snap);
break;
case TEST_GETPROTOBYNUMBER:
@@ -498,12 +498,12 @@ main(int argc, char **argv)
rv = DO_1PASS_TEST(protoent, &td,
protoent_test_getprotobynumber, (void *)&td);
else
- rv = DO_1PASS_TEST(protoent, &td_snap,
+ rv = DO_1PASS_TEST(protoent, &td_snap,
protoent_test_getprotobynumber, (void *)&td_snap);
break;
case TEST_GETPROTOENT:
if (snapshot_file == NULL)
- rv = DO_1PASS_TEST(protoent, &td,
+ rv = DO_1PASS_TEST(protoent, &td,
protoent_test_getprotoent, (void *)&td);
else
rv = DO_2PASS_TEST(protoent, &td, &td_snap,
@@ -520,7 +520,7 @@ main(int argc, char **argv)
break;
case TEST_BUILD_SNAPSHOT:
if (snapshot_file != NULL)
- rv = TEST_SNAPSHOT_FILE_WRITE(protoent, snapshot_file, &td,
+ rv = TEST_SNAPSHOT_FILE_WRITE(protoent, snapshot_file, &td,
sdump_protoent);
break;
default:
@@ -531,6 +531,6 @@ main(int argc, char **argv)
fin:
TEST_DATA_DESTROY(protoent, &td_snap);
TEST_DATA_DESTROY(protoent, &td);
- free(snapshot_file);
+ free(snapshot_file);
return (rv);
}
diff --git a/tools/regression/lib/libc/nss/test-getpw.c b/tools/regression/lib/libc/nss/test-getpw.c
index bb88f6a..a0b348d 100644
--- a/tools/regression/lib/libc/nss/test-getpw.c
+++ b/tools/regression/lib/libc/nss/test-getpw.c
@@ -68,7 +68,7 @@ static int passwd_test_correctness(struct passwd *, void *);
static int passwd_test_getpwnam(struct passwd *, void *);
static int passwd_test_getpwuid(struct passwd *, void *);
static int passwd_test_getpwent(struct passwd *, void *);
-
+
static void usage(void) __attribute__((__noreturn__));
IMPLEMENT_TEST_DATA(passwd)
@@ -76,12 +76,12 @@ IMPLEMENT_TEST_FILE_SNAPSHOT(passwd)
IMPLEMENT_1PASS_TEST(passwd)
IMPLEMENT_2PASS_TEST(passwd)
-static void
+static void
clone_passwd(struct passwd *dest, struct passwd const *src)
{
assert(dest != NULL);
assert(src != NULL);
-
+
memcpy(dest, src, sizeof(struct passwd));
if (src->pw_name != NULL)
dest->pw_name = strdup(src->pw_name);
@@ -97,15 +97,15 @@ clone_passwd(struct passwd *dest, struct passwd const *src)
dest->pw_shell = strdup(dest->pw_shell);
}
-static int
+static int
compare_passwd(struct passwd *pwd1, struct passwd *pwd2, void *mdata)
{
assert(pwd1 != NULL);
assert(pwd2 != NULL);
-
+
if (pwd1 == pwd2)
return (0);
-
+
if ((pwd1->pw_uid != pwd2->pw_uid) ||
(pwd1->pw_gid != pwd2->pw_gid) ||
(pwd1->pw_change != pwd2->pw_change) ||
@@ -116,14 +116,14 @@ compare_passwd(struct passwd *pwd1, struct passwd *pwd2, void *mdata)
(strcmp(pwd1->pw_class, pwd2->pw_class) != 0) ||
(strcmp(pwd1->pw_gecos, pwd2->pw_gecos) != 0) ||
(strcmp(pwd1->pw_dir, pwd2->pw_dir) != 0) ||
- (strcmp(pwd1->pw_shell, pwd2->pw_shell) != 0)
+ (strcmp(pwd1->pw_shell, pwd2->pw_shell) != 0)
)
return (-1);
else
return (0);
}
-static void
+static void
free_passwd(struct passwd *pwd)
{
free(pwd->pw_name);
@@ -134,7 +134,7 @@ free_passwd(struct passwd *pwd)
free(pwd->pw_shell);
}
-static void
+static void
sdump_passwd(struct passwd *pwd, char *buffer, size_t buflen)
{
snprintf(buffer, buflen, "%s:%s:%d:%d:%d:%s:%s:%s:%s:%d:%d",
@@ -154,7 +154,7 @@ dump_passwd(struct passwd *pwd)
printf("(null)\n");
}
-static int
+static int
passwd_read_snapshot_func(struct passwd *pwd, char *line)
{
char *s, *ps, *ts;
@@ -162,7 +162,7 @@ passwd_read_snapshot_func(struct passwd *pwd, char *line)
if (debug)
printf("1 line read from snapshot:\n%s\n", line);
-
+
i = 0;
ps = line;
memset(pwd, 0, sizeof(struct passwd));
@@ -174,7 +174,7 @@ passwd_read_snapshot_func(struct passwd *pwd, char *line)
break;
case 1:
pwd->pw_passwd = strdup(s);
- assert(pwd->pw_passwd != NULL);
+ assert(pwd->pw_passwd != NULL);
break;
case 2:
pwd->pw_uid = (uid_t)strtol(s, &ts, 10);
@@ -218,7 +218,7 @@ passwd_read_snapshot_func(struct passwd *pwd, char *line)
goto fin;
break;
default:
- break;
+ break;
};
++i;
}
@@ -229,7 +229,7 @@ fin:
memset(pwd, 0, sizeof(struct passwd));
return (-1);
}
-
+
return (0);
}
@@ -237,7 +237,7 @@ static int
passwd_fill_test_data(struct passwd_test_data *td)
{
struct passwd *pwd;
-
+
setpassent(1);
while ((pwd = getpwent()) != NULL) {
if (passwd_test_correctness(pwd, NULL) == 0)
@@ -246,7 +246,7 @@ passwd_fill_test_data(struct passwd_test_data *td)
return (-1);
}
endpwent();
-
+
return (0);
}
@@ -257,9 +257,9 @@ passwd_test_correctness(struct passwd *pwd, void *mdata)
printf("testing correctness with the following data:\n");
dump_passwd(pwd);
}
-
+
if (pwd == NULL)
- return (-1);
+ return (-1);
if (pwd->pw_name == NULL)
goto errfin;
@@ -278,25 +278,25 @@ passwd_test_correctness(struct passwd *pwd, void *mdata)
if (pwd->pw_shell == NULL)
goto errfin;
-
+
if (debug)
printf("correct\n");
-
- return (0);
+
+ return (0);
errfin:
if (debug)
printf("incorrect\n");
-
+
return (-1);
}
/* passwd_check_ambiguity() is needed here because when doing the getpwent()
- * calls sequence, records from different nsswitch sources can be different,
+ * calls sequence, records from different nsswitch sources can be different,
* though having the same pw_name/pw_uid */
static int
passwd_check_ambiguity(struct passwd_test_data *td, struct passwd *pwd)
{
-
+
return (TEST_DATA_FIND(passwd, td, pwd, compare_passwd,
NULL) != NULL ? 0 : -1);
}
@@ -305,7 +305,7 @@ static int
passwd_test_getpwnam(struct passwd *pwd_model, void *mdata)
{
struct passwd *pwd;
-
+
if (debug) {
printf("testing getpwnam() with the following data:\n");
dump_passwd(pwd_model);
@@ -314,20 +314,20 @@ passwd_test_getpwnam(struct passwd *pwd_model, void *mdata)
pwd = getpwnam(pwd_model->pw_name);
if (passwd_test_correctness(pwd, NULL) != 0)
goto errfin;
-
+
if ((compare_passwd(pwd, pwd_model, NULL) != 0) &&
- (passwd_check_ambiguity((struct passwd_test_data *)mdata, pwd)
+ (passwd_check_ambiguity((struct passwd_test_data *)mdata, pwd)
!=0))
goto errfin;
-
+
if (debug)
printf("ok\n");
return (0);
-
+
errfin:
if (debug)
printf("not ok\n");
-
+
return (-1);
}
@@ -335,14 +335,14 @@ static int
passwd_test_getpwuid(struct passwd *pwd_model, void *mdata)
{
struct passwd *pwd;
-
+
if (debug) {
printf("testing getpwuid() with the following data...\n");
dump_passwd(pwd_model);
- }
-
+ }
+
pwd = getpwuid(pwd_model->pw_uid);
- if ((passwd_test_correctness(pwd, NULL) != 0) ||
+ if ((passwd_test_correctness(pwd, NULL) != 0) ||
((compare_passwd(pwd, pwd_model, NULL) != 0) &&
(passwd_check_ambiguity((struct passwd_test_data *)mdata, pwd)
!= 0))) {
@@ -356,7 +356,7 @@ passwd_test_getpwuid(struct passwd *pwd_model, void *mdata)
}
}
-static int
+static int
passwd_test_getpwent(struct passwd *pwd, void *mdata)
{
/* Only correctness can be checked when doing 1-pass test for
@@ -380,10 +380,10 @@ main(int argc, char **argv)
char *snapshot_file;
int rv;
int c;
-
+
if (argc < 2)
usage();
-
+
snapshot_file = NULL;
while ((c = getopt(argc, argv, "nue2ds:")) != -1)
switch (c) {
@@ -408,18 +408,18 @@ main(int argc, char **argv)
default:
usage();
}
-
+
TEST_DATA_INIT(passwd, &td, clone_passwd, free_passwd);
TEST_DATA_INIT(passwd, &td_snap, clone_passwd, free_passwd);
if (snapshot_file != NULL) {
- if (access(snapshot_file, W_OK | R_OK) != 0) {
+ if (access(snapshot_file, W_OK | R_OK) != 0) {
if (errno == ENOENT)
method = TEST_BUILD_SNAPSHOT;
else {
if (debug)
printf("can't access the file %s\n",
snapshot_file);
-
+
rv = -1;
goto fin;
}
@@ -428,23 +428,23 @@ main(int argc, char **argv)
rv = 0;
goto fin;
}
-
+
TEST_SNAPSHOT_FILE_READ(passwd, snapshot_file,
&td_snap, passwd_read_snapshot_func);
}
}
-
+
rv = passwd_fill_test_data(&td);
if (rv == -1)
return (-1);
-
+
switch (method) {
case TEST_GETPWNAM:
if (snapshot_file == NULL)
rv = DO_1PASS_TEST(passwd, &td,
passwd_test_getpwnam, (void *)&td);
else
- rv = DO_1PASS_TEST(passwd, &td_snap,
+ rv = DO_1PASS_TEST(passwd, &td_snap,
passwd_test_getpwnam, (void *)&td_snap);
break;
case TEST_GETPWUID:
@@ -452,7 +452,7 @@ main(int argc, char **argv)
rv = DO_1PASS_TEST(passwd, &td,
passwd_test_getpwuid, (void *)&td);
else
- rv = DO_1PASS_TEST(passwd, &td_snap,
+ rv = DO_1PASS_TEST(passwd, &td_snap,
passwd_test_getpwuid, (void *)&td_snap);
break;
case TEST_GETPWENT:
@@ -465,7 +465,7 @@ main(int argc, char **argv)
break;
case TEST_GETPWENT_2PASS:
TEST_DATA_INIT(passwd, &td_2pass, clone_passwd, free_passwd);
- rv = passwd_fill_test_data(&td_2pass);
+ rv = passwd_fill_test_data(&td_2pass);
if (rv != -1)
rv = DO_2PASS_TEST(passwd, &td, &td_2pass,
compare_passwd, NULL);
@@ -473,7 +473,7 @@ main(int argc, char **argv)
break;
case TEST_BUILD_SNAPSHOT:
if (snapshot_file != NULL)
- rv = TEST_SNAPSHOT_FILE_WRITE(passwd, snapshot_file, &td,
+ rv = TEST_SNAPSHOT_FILE_WRITE(passwd, snapshot_file, &td,
sdump_passwd);
break;
default:
@@ -484,6 +484,6 @@ main(int argc, char **argv)
fin:
TEST_DATA_DESTROY(passwd, &td_snap);
TEST_DATA_DESTROY(passwd, &td);
- free(snapshot_file);
+ free(snapshot_file);
return (rv);
}
diff --git a/tools/regression/lib/libc/nss/test-getrpc.c b/tools/regression/lib/libc/nss/test-getrpc.c
index 4041e88..707186e 100644
--- a/tools/regression/lib/libc/nss/test-getrpc.c
+++ b/tools/regression/lib/libc/nss/test-getrpc.c
@@ -63,14 +63,14 @@ static void free_rpcent(struct rpcent *);
static void sdump_rpcent(struct rpcent *, char *, size_t);
static int rpcent_read_snapshot_func(struct rpcent *, char *);
-static int rpcent_check_ambiguity(struct rpcent_test_data *,
+static int rpcent_check_ambiguity(struct rpcent_test_data *,
struct rpcent *);
static int rpcent_fill_test_data(struct rpcent_test_data *);
static int rpcent_test_correctness(struct rpcent *, void *);
static int rpcent_test_getrpcbyname(struct rpcent *, void *);
static int rpcent_test_getrpcbynumber(struct rpcent *, void *);
static int rpcent_test_getrpcent(struct rpcent *, void *);
-
+
static void usage(void) __attribute__((__noreturn__));
IMPLEMENT_TEST_DATA(rpcent)
@@ -83,28 +83,28 @@ clone_rpcent(struct rpcent *dest, struct rpcent const *src)
{
assert(dest != NULL);
assert(src != NULL);
-
+
char **cp;
int aliases_num;
-
+
memset(dest, 0, sizeof(struct rpcent));
-
+
if (src->r_name != NULL) {
dest->r_name = strdup(src->r_name);
assert(dest->r_name != NULL);
}
-
+
dest->r_number = src->r_number;
-
+
if (src->r_aliases != NULL) {
aliases_num = 0;
for (cp = src->r_aliases; *cp; ++cp)
++aliases_num;
-
+
dest->r_aliases = (char **)malloc((aliases_num+1) * (sizeof(char *)));
assert(dest->r_aliases != NULL);
memset(dest->r_aliases, 0, (aliases_num+1) * (sizeof(char *)));
-
+
for (cp = src->r_aliases; *cp; ++cp) {
dest->r_aliases[cp - src->r_aliases] = strdup(*cp);
assert(dest->r_aliases[cp - src->r_aliases] != NULL);
@@ -112,50 +112,50 @@ clone_rpcent(struct rpcent *dest, struct rpcent const *src)
}
}
-static void
+static void
free_rpcent(struct rpcent *rpc)
{
char **cp;
-
+
assert(rpc != NULL);
-
+
free(rpc->r_name);
-
+
for (cp = rpc->r_aliases; *cp; ++cp)
free(*cp);
free(rpc->r_aliases);
}
-static int
+static int
compare_rpcent(struct rpcent *rpc1, struct rpcent *rpc2, void *mdata)
{
char **c1, **c2;
-
+
if (rpc1 == rpc2)
return 0;
-
+
if ((rpc1 == NULL) || (rpc2 == NULL))
goto errfin;
-
+
if ((strcmp(rpc1->r_name, rpc2->r_name) != 0) ||
(rpc1->r_number != rpc2->r_number))
goto errfin;
-
+
c1 = rpc1->r_aliases;
c2 = rpc2->r_aliases;
-
+
if ((rpc1->r_aliases == NULL) || (rpc2->r_aliases == NULL))
goto errfin;
-
+
for (;*c1 && *c2; ++c1, ++c2)
if (strcmp(*c1, *c2) != 0)
goto errfin;
-
+
if ((*c1 != '\0') || (*c2 != '\0'))
goto errfin;
-
+
return 0;
-
+
errfin:
if ((debug) && (mdata == NULL)) {
printf("following structures are not equal:\n");
@@ -171,14 +171,14 @@ sdump_rpcent(struct rpcent *rpc, char *buffer, size_t buflen)
{
char **cp;
int written;
-
+
written = snprintf(buffer, buflen, "%s %d",
- rpc->r_name, rpc->r_number);
+ rpc->r_name, rpc->r_number);
buffer += written;
if (written > buflen)
return;
buflen -= written;
-
+
if (rpc->r_aliases != NULL) {
if (*(rpc->r_aliases) != '\0') {
for (cp = rpc->r_aliases; *cp; ++cp) {
@@ -187,9 +187,9 @@ sdump_rpcent(struct rpcent *rpc, char *buffer, size_t buflen)
if (written > buflen)
return;
buflen -= written;
-
+
if (buflen == 0)
- return;
+ return;
}
} else
snprintf(buffer, buflen, " noaliases");
@@ -206,7 +206,7 @@ rpcent_read_snapshot_func(struct rpcent *rpc, char *line)
if (debug)
printf("1 line read from snapshot:\n%s\n", line);
-
+
i = 0;
sl = NULL;
ps = line;
@@ -230,10 +230,10 @@ rpcent_read_snapshot_func(struct rpcent *rpc, char *line)
if (sl == NULL) {
if (strcmp(s, "(null)") == 0)
return (0);
-
+
sl = sl_init();
assert(sl != NULL);
-
+
if (strcmp(s, "noaliases") != 0) {
ts = strdup(s);
assert(ts != NULL);
@@ -244,7 +244,7 @@ rpcent_read_snapshot_func(struct rpcent *rpc, char *line)
assert(ts != NULL);
sl_add(sl, ts);
}
- break;
+ break;
};
++i;
}
@@ -254,16 +254,16 @@ rpcent_read_snapshot_func(struct rpcent *rpc, char *line)
memset(rpc, 0, sizeof(struct rpcent));
return (-1);
}
-
+
sl_add(sl, NULL);
rpc->r_aliases = sl->sl_str;
/* NOTE: is it a dirty hack or not? */
- free(sl);
+ free(sl);
return (0);
}
-static void
+static void
dump_rpcent(struct rpcent *result)
{
if (result != NULL) {
@@ -278,7 +278,7 @@ static int
rpcent_fill_test_data(struct rpcent_test_data *td)
{
struct rpcent *rpc;
-
+
setrpcent(1);
while ((rpc = getrpcent()) != NULL) {
if (rpcent_test_correctness(rpc, NULL) == 0)
@@ -287,7 +287,7 @@ rpcent_fill_test_data(struct rpcent_test_data *td)
return (-1);
}
endrpcent();
-
+
return (0);
}
@@ -298,39 +298,39 @@ rpcent_test_correctness(struct rpcent *rpc, void *mdata)
printf("testing correctness with the following data:\n");
dump_rpcent(rpc);
}
-
+
if (rpc == NULL)
goto errfin;
-
+
if (rpc->r_name == NULL)
goto errfin;
-
+
if (rpc->r_number < 0)
goto errfin;
-
+
if (rpc->r_aliases == NULL)
goto errfin;
-
+
if (debug)
printf("correct\n");
-
- return (0);
+
+ return (0);
errfin:
if (debug)
printf("incorrect\n");
-
+
return (-1);
}
/* rpcent_check_ambiguity() is needed when one port+rpc is associated with
* more than one peice (these cases are usually marked as PROBLEM in
- * /etc/peices. This functions is needed also when one peice+rpc is
+ * /etc/peices. This functions is needed also when one peice+rpc is
* associated with several ports. We have to check all the rpcent structures
* to make sure that rpc really exists and correct */
static int
rpcent_check_ambiguity(struct rpcent_test_data *td, struct rpcent *rpc)
{
-
+
return (TEST_DATA_FIND(rpcent, td, rpc, compare_rpcent,
NULL) != NULL ? 0 : -1);
}
@@ -340,7 +340,7 @@ rpcent_test_getrpcbyname(struct rpcent *rpc_model, void *mdata)
{
char **alias;
struct rpcent *rpc;
-
+
if (debug) {
printf("testing getrpcbyname() with the following data:\n");
dump_rpcent(rpc_model);
@@ -349,32 +349,32 @@ rpcent_test_getrpcbyname(struct rpcent *rpc_model, void *mdata)
rpc = getrpcbyname(rpc_model->r_name);
if (rpcent_test_correctness(rpc, NULL) != 0)
goto errfin;
-
+
if ((compare_rpcent(rpc, rpc_model, NULL) != 0) &&
- (rpcent_check_ambiguity((struct rpcent_test_data *)mdata, rpc)
+ (rpcent_check_ambiguity((struct rpcent_test_data *)mdata, rpc)
!=0))
goto errfin;
-
+
for (alias = rpc_model->r_aliases; *alias; ++alias) {
rpc = getrpcbyname(*alias);
-
+
if (rpcent_test_correctness(rpc, NULL) != 0)
goto errfin;
-
+
if ((compare_rpcent(rpc, rpc_model, NULL) != 0) &&
(rpcent_check_ambiguity(
(struct rpcent_test_data *)mdata, rpc) != 0))
goto errfin;
}
-
+
if (debug)
printf("ok\n");
return (0);
-
+
errfin:
if (debug)
printf("not ok\n");
-
+
return (-1);
}
@@ -382,14 +382,14 @@ static int
rpcent_test_getrpcbynumber(struct rpcent *rpc_model, void *mdata)
{
struct rpcent *rpc;
-
+
if (debug) {
printf("testing getrpcbyport() with the following data...\n");
dump_rpcent(rpc_model);
- }
-
+ }
+
rpc = getrpcbynumber(rpc_model->r_number);
- if ((rpcent_test_correctness(rpc, NULL) != 0) ||
+ if ((rpcent_test_correctness(rpc, NULL) != 0) ||
((compare_rpcent(rpc, rpc_model, NULL) != 0) &&
(rpcent_check_ambiguity((struct rpcent_test_data *)mdata, rpc)
!= 0))) {
@@ -403,7 +403,7 @@ rpcent_test_getrpcbynumber(struct rpcent *rpc_model, void *mdata)
}
}
-static int
+static int
rpcent_test_getrpcent(struct rpcent *rpc, void *mdata)
{
/* Only correctness can be checked when doing 1-pass test for
@@ -427,10 +427,10 @@ main(int argc, char **argv)
char *snapshot_file;
int rv;
int c;
-
+
if (argc < 2)
usage();
-
+
snapshot_file = NULL;
while ((c = getopt(argc, argv, "nve2ds:")) != -1)
switch (c) {
@@ -455,18 +455,18 @@ main(int argc, char **argv)
default:
usage();
}
-
+
TEST_DATA_INIT(rpcent, &td, clone_rpcent, free_rpcent);
TEST_DATA_INIT(rpcent, &td_snap, clone_rpcent, free_rpcent);
if (snapshot_file != NULL) {
- if (access(snapshot_file, W_OK | R_OK) != 0) {
+ if (access(snapshot_file, W_OK | R_OK) != 0) {
if (errno == ENOENT)
method = TEST_BUILD_SNAPSHOT;
else {
if (debug)
printf("can't access the file %s\n",
snapshot_file);
-
+
rv = -1;
goto fin;
}
@@ -475,12 +475,12 @@ main(int argc, char **argv)
rv = 0;
goto fin;
}
-
+
TEST_SNAPSHOT_FILE_READ(rpcent, snapshot_file,
&td_snap, rpcent_read_snapshot_func);
}
}
-
+
rv = rpcent_fill_test_data(&td);
if (rv == -1)
return (-1);
@@ -490,7 +490,7 @@ main(int argc, char **argv)
rv = DO_1PASS_TEST(rpcent, &td,
rpcent_test_getrpcbyname, (void *)&td);
else
- rv = DO_1PASS_TEST(rpcent, &td_snap,
+ rv = DO_1PASS_TEST(rpcent, &td_snap,
rpcent_test_getrpcbyname, (void *)&td_snap);
break;
case TEST_GETRPCBYNUMBER:
@@ -498,7 +498,7 @@ main(int argc, char **argv)
rv = DO_1PASS_TEST(rpcent, &td,
rpcent_test_getrpcbynumber, (void *)&td);
else
- rv = DO_1PASS_TEST(rpcent, &td_snap,
+ rv = DO_1PASS_TEST(rpcent, &td_snap,
rpcent_test_getrpcbynumber, (void *)&td_snap);
break;
case TEST_GETRPCENT:
@@ -511,7 +511,7 @@ main(int argc, char **argv)
break;
case TEST_GETRPCENT_2PASS:
TEST_DATA_INIT(rpcent, &td_2pass, clone_rpcent, free_rpcent);
- rv = rpcent_fill_test_data(&td_2pass);
+ rv = rpcent_fill_test_data(&td_2pass);
if (rv != -1)
rv = DO_2PASS_TEST(rpcent, &td, &td_2pass,
compare_rpcent, NULL);
@@ -519,7 +519,7 @@ main(int argc, char **argv)
break;
case TEST_BUILD_SNAPSHOT:
if (snapshot_file != NULL)
- rv = TEST_SNAPSHOT_FILE_WRITE(rpcent, snapshot_file, &td,
+ rv = TEST_SNAPSHOT_FILE_WRITE(rpcent, snapshot_file, &td,
sdump_rpcent);
break;
default:
@@ -530,6 +530,6 @@ main(int argc, char **argv)
fin:
TEST_DATA_DESTROY(rpcent, &td_snap);
TEST_DATA_DESTROY(rpcent, &td);
- free(snapshot_file);
+ free(snapshot_file);
return (rv);
}
diff --git a/tools/regression/lib/libc/nss/test-getserv.c b/tools/regression/lib/libc/nss/test-getserv.c
index 79d42f0..31e4700 100644
--- a/tools/regression/lib/libc/nss/test-getserv.c
+++ b/tools/regression/lib/libc/nss/test-getserv.c
@@ -63,14 +63,14 @@ static void free_servent(struct servent *);
static void sdump_servent(struct servent *, char *, size_t);
static int servent_read_snapshot_func(struct servent *, char *);
-static int servent_check_ambiguity(struct servent_test_data *,
+static int servent_check_ambiguity(struct servent_test_data *,
struct servent *);
static int servent_fill_test_data(struct servent_test_data *);
static int servent_test_correctness(struct servent *, void *);
static int servent_test_getservbyname(struct servent *, void *);
static int servent_test_getservbyport(struct servent *, void *);
static int servent_test_getservent(struct servent *, void *);
-
+
static void usage(void) __attribute__((__noreturn__));
IMPLEMENT_TEST_DATA(servent)
@@ -83,32 +83,32 @@ clone_servent(struct servent *dest, struct servent const *src)
{
assert(dest != NULL);
assert(src != NULL);
-
+
char **cp;
int aliases_num;
-
+
memset(dest, 0, sizeof(struct servent));
-
+
if (src->s_name != NULL) {
dest->s_name = strdup(src->s_name);
assert(dest->s_name != NULL);
}
-
+
if (src->s_proto != NULL) {
dest->s_proto = strdup(src->s_proto);
assert(dest->s_proto != NULL);
}
dest->s_port = src->s_port;
-
+
if (src->s_aliases != NULL) {
aliases_num = 0;
for (cp = src->s_aliases; *cp; ++cp)
++aliases_num;
-
+
dest->s_aliases = (char **)malloc((aliases_num+1) * (sizeof(char *)));
assert(dest->s_aliases != NULL);
memset(dest->s_aliases, 0, (aliases_num+1) * (sizeof(char *)));
-
+
for (cp = src->s_aliases; *cp; ++cp) {
dest->s_aliases[cp - src->s_aliases] = strdup(*cp);
assert(dest->s_aliases[cp - src->s_aliases] != NULL);
@@ -116,52 +116,52 @@ clone_servent(struct servent *dest, struct servent const *src)
}
}
-static void
+static void
free_servent(struct servent *serv)
{
char **cp;
-
+
assert(serv != NULL);
-
+
free(serv->s_name);
free(serv->s_proto);
-
+
for (cp = serv->s_aliases; *cp; ++cp)
free(*cp);
free(serv->s_aliases);
}
-static int
+static int
compare_servent(struct servent *serv1, struct servent *serv2, void *mdata)
{
char **c1, **c2;
-
+
if (serv1 == serv2)
return 0;
-
+
if ((serv1 == NULL) || (serv2 == NULL))
goto errfin;
-
+
if ((strcmp(serv1->s_name, serv2->s_name) != 0) ||
(strcmp(serv1->s_proto, serv2->s_proto) != 0) ||
(serv1->s_port != serv2->s_port))
goto errfin;
-
+
c1 = serv1->s_aliases;
c2 = serv2->s_aliases;
-
+
if ((serv1->s_aliases == NULL) || (serv2->s_aliases == NULL))
goto errfin;
-
+
for (;*c1 && *c2; ++c1, ++c2)
if (strcmp(*c1, *c2) != 0)
goto errfin;
-
+
if ((*c1 != '\0') || (*c2 != '\0'))
goto errfin;
-
+
return 0;
-
+
errfin:
if ((debug) && (mdata == NULL)) {
printf("following structures are not equal:\n");
@@ -177,14 +177,14 @@ sdump_servent(struct servent *serv, char *buffer, size_t buflen)
{
char **cp;
int written;
-
+
written = snprintf(buffer, buflen, "%s %d %s",
- serv->s_name, ntohs(serv->s_port), serv->s_proto);
+ serv->s_name, ntohs(serv->s_port), serv->s_proto);
buffer += written;
if (written > buflen)
return;
buflen -= written;
-
+
if (serv->s_aliases != NULL) {
if (*(serv->s_aliases) != '\0') {
for (cp = serv->s_aliases; *cp; ++cp) {
@@ -193,9 +193,9 @@ sdump_servent(struct servent *serv, char *buffer, size_t buflen)
if (written > buflen)
return;
buflen -= written;
-
+
if (buflen == 0)
- return;
+ return;
}
} else
snprintf(buffer, buflen, " noaliases");
@@ -212,7 +212,7 @@ servent_read_snapshot_func(struct servent *serv, char *line)
if (debug)
printf("1 line read from snapshot:\n%s\n", line);
-
+
i = 0;
sl = NULL;
ps = line;
@@ -242,10 +242,10 @@ servent_read_snapshot_func(struct servent *serv, char *line)
if (sl == NULL) {
if (strcmp(s, "(null)") == 0)
return (0);
-
+
sl = sl_init();
assert(sl != NULL);
-
+
if (strcmp(s, "noaliases") != 0) {
ts = strdup(s);
assert(ts != NULL);
@@ -256,7 +256,7 @@ servent_read_snapshot_func(struct servent *serv, char *line)
assert(ts != NULL);
sl_add(sl, ts);
}
- break;
+ break;
};
++i;
}
@@ -267,16 +267,16 @@ servent_read_snapshot_func(struct servent *serv, char *line)
memset(serv, 0, sizeof(struct servent));
return (-1);
}
-
+
sl_add(sl, NULL);
serv->s_aliases = sl->sl_str;
/* NOTE: is it a dirty hack or not? */
- free(sl);
+ free(sl);
return (0);
}
-static void
+static void
dump_servent(struct servent *result)
{
if (result != NULL) {
@@ -291,7 +291,7 @@ static int
servent_fill_test_data(struct servent_test_data *td)
{
struct servent *serv;
-
+
setservent(1);
while ((serv = getservent()) != NULL) {
if (servent_test_correctness(serv, NULL) == 0)
@@ -300,7 +300,7 @@ servent_fill_test_data(struct servent_test_data *td)
return (-1);
}
endservent();
-
+
return (0);
}
@@ -311,42 +311,42 @@ servent_test_correctness(struct servent *serv, void *mdata)
printf("testing correctness with the following data:\n");
dump_servent(serv);
}
-
+
if (serv == NULL)
goto errfin;
-
+
if (serv->s_name == NULL)
goto errfin;
-
+
if (serv->s_proto == NULL)
goto errfin;
-
+
if (ntohs(serv->s_port < 0))
goto errfin;
-
+
if (serv->s_aliases == NULL)
goto errfin;
-
+
if (debug)
printf("correct\n");
-
- return (0);
+
+ return (0);
errfin:
if (debug)
printf("incorrect\n");
-
+
return (-1);
}
/* servent_check_ambiguity() is needed when one port+proto is associated with
* more than one service (these cases are usually marked as PROBLEM in
- * /etc/services. This functions is needed also when one service+proto is
+ * /etc/services. This functions is needed also when one service+proto is
* associated with several ports. We have to check all the servent structures
* to make sure that serv really exists and correct */
static int
servent_check_ambiguity(struct servent_test_data *td, struct servent *serv)
{
-
+
return (TEST_DATA_FIND(servent, td, serv, compare_servent,
NULL) != NULL ? 0 : -1);
}
@@ -356,7 +356,7 @@ servent_test_getservbyname(struct servent *serv_model, void *mdata)
{
char **alias;
struct servent *serv;
-
+
if (debug) {
printf("testing getservbyname() with the following data:\n");
dump_servent(serv_model);
@@ -365,32 +365,32 @@ servent_test_getservbyname(struct servent *serv_model, void *mdata)
serv = getservbyname(serv_model->s_name, serv_model->s_proto);
if (servent_test_correctness(serv, NULL) != 0)
goto errfin;
-
+
if ((compare_servent(serv, serv_model, NULL) != 0) &&
- (servent_check_ambiguity((struct servent_test_data *)mdata, serv)
+ (servent_check_ambiguity((struct servent_test_data *)mdata, serv)
!=0))
goto errfin;
-
+
for (alias = serv_model->s_aliases; *alias; ++alias) {
serv = getservbyname(*alias, serv_model->s_proto);
-
+
if (servent_test_correctness(serv, NULL) != 0)
goto errfin;
-
+
if ((compare_servent(serv, serv_model, NULL) != 0) &&
(servent_check_ambiguity(
(struct servent_test_data *)mdata, serv) != 0))
goto errfin;
}
-
+
if (debug)
printf("ok\n");
return (0);
-
+
errfin:
if (debug)
printf("not ok\n");
-
+
return (-1);
}
@@ -398,14 +398,14 @@ static int
servent_test_getservbyport(struct servent *serv_model, void *mdata)
{
struct servent *serv;
-
+
if (debug) {
printf("testing getservbyport() with the following data...\n");
dump_servent(serv_model);
- }
-
+ }
+
serv = getservbyport(serv_model->s_port, serv_model->s_proto);
- if ((servent_test_correctness(serv, NULL) != 0) ||
+ if ((servent_test_correctness(serv, NULL) != 0) ||
((compare_servent(serv, serv_model, NULL) != 0) &&
(servent_check_ambiguity((struct servent_test_data *)mdata, serv)
!= 0))) {
@@ -419,7 +419,7 @@ servent_test_getservbyport(struct servent *serv_model, void *mdata)
}
}
-static int
+static int
servent_test_getservent(struct servent *serv, void *mdata)
{
/* Only correctness can be checked when doing 1-pass test for
@@ -443,10 +443,10 @@ main(int argc, char **argv)
char *snapshot_file;
int rv;
int c;
-
+
if (argc < 2)
usage();
-
+
snapshot_file = NULL;
while ((c = getopt(argc, argv, "npe2ds:")) != -1)
switch (c) {
@@ -471,18 +471,18 @@ main(int argc, char **argv)
default:
usage();
}
-
+
TEST_DATA_INIT(servent, &td, clone_servent, free_servent);
TEST_DATA_INIT(servent, &td_snap, clone_servent, free_servent);
if (snapshot_file != NULL) {
- if (access(snapshot_file, W_OK | R_OK) != 0) {
+ if (access(snapshot_file, W_OK | R_OK) != 0) {
if (errno == ENOENT)
method = TEST_BUILD_SNAPSHOT;
else {
if (debug)
printf("can't access the file %s\n",
snapshot_file);
-
+
rv = -1;
goto fin;
}
@@ -491,12 +491,12 @@ main(int argc, char **argv)
rv = 0;
goto fin;
}
-
+
TEST_SNAPSHOT_FILE_READ(servent, snapshot_file,
&td_snap, servent_read_snapshot_func);
}
}
-
+
rv = servent_fill_test_data(&td);
if (rv == -1)
return (-1);
@@ -506,7 +506,7 @@ main(int argc, char **argv)
rv = DO_1PASS_TEST(servent, &td,
servent_test_getservbyname, (void *)&td);
else
- rv = DO_1PASS_TEST(servent, &td_snap,
+ rv = DO_1PASS_TEST(servent, &td_snap,
servent_test_getservbyname, (void *)&td_snap);
break;
case TEST_GETSERVBYPORT:
@@ -514,7 +514,7 @@ main(int argc, char **argv)
rv = DO_1PASS_TEST(servent, &td,
servent_test_getservbyport, (void *)&td);
else
- rv = DO_1PASS_TEST(servent, &td_snap,
+ rv = DO_1PASS_TEST(servent, &td_snap,
servent_test_getservbyport, (void *)&td_snap);
break;
case TEST_GETSERVENT:
@@ -527,7 +527,7 @@ main(int argc, char **argv)
break;
case TEST_GETSERVENT_2PASS:
TEST_DATA_INIT(servent, &td_2pass, clone_servent, free_servent);
- rv = servent_fill_test_data(&td_2pass);
+ rv = servent_fill_test_data(&td_2pass);
if (rv != -1)
rv = DO_2PASS_TEST(servent, &td, &td_2pass,
compare_servent, NULL);
@@ -535,7 +535,7 @@ main(int argc, char **argv)
break;
case TEST_BUILD_SNAPSHOT:
if (snapshot_file != NULL)
- rv = TEST_SNAPSHOT_FILE_WRITE(servent, snapshot_file, &td,
+ rv = TEST_SNAPSHOT_FILE_WRITE(servent, snapshot_file, &td,
sdump_servent);
break;
default:
@@ -546,6 +546,6 @@ main(int argc, char **argv)
fin:
TEST_DATA_DESTROY(servent, &td_snap);
TEST_DATA_DESTROY(servent, &td);
- free(snapshot_file);
+ free(snapshot_file);
return (rv);
}
diff --git a/tools/regression/lib/libc/nss/test-getusershell.c b/tools/regression/lib/libc/nss/test-getusershell.c
index 8682591..b7b835f 100644
--- a/tools/regression/lib/libc/nss/test-getusershell.c
+++ b/tools/regression/lib/libc/nss/test-getusershell.c
@@ -67,29 +67,29 @@ IMPLEMENT_TEST_DATA(usershell)
IMPLEMENT_TEST_FILE_SNAPSHOT(usershell)
IMPLEMENT_2PASS_TEST(usershell)
-static void
+static void
clone_usershell(struct usershell *dest, struct usershell const *src)
{
assert(dest != NULL);
assert(src != NULL);
-
+
if (src->path != NULL) {
dest->path = strdup(src->path);
assert(dest->path != NULL);
}
}
-static int
+static int
compare_usershell(struct usershell *us1, struct usershell *us2, void *mdata)
{
int rv;
-
+
assert(us1 != NULL);
assert(us2 != NULL);
-
+
dump_usershell(us1);
dump_usershell(us2);
-
+
if (us1 == us2)
return (0);
@@ -99,17 +99,17 @@ compare_usershell(struct usershell *us1, struct usershell *us2, void *mdata)
dump_usershell(us1);
dump_usershell(us2);
}
-
+
return (rv);
}
-static void
+static void
free_usershell(struct usershell *us)
{
free(us->path);
}
-static void
+static void
sdump_usershell(struct usershell *us, char *buffer, size_t buflen)
{
snprintf(buffer, buflen, "%s", us->path);
@@ -126,12 +126,12 @@ dump_usershell(struct usershell *us)
printf("(null)\n");
}
-static int
+static int
usershell_read_snapshot_func(struct usershell *us, char *line)
{
us->path = strdup(line);
assert(us->path != NULL);
-
+
return (0);
}
@@ -152,7 +152,7 @@ main(int argc, char **argv)
char *snapshot_file;
int rv;
int c;
-
+
if (argc < 2)
usage();
@@ -170,10 +170,10 @@ main(int argc, char **argv)
usage();
}
}
-
+
TEST_DATA_INIT(usershell, &td, clone_usershell, free_usershell);
TEST_DATA_INIT(usershell, &td_snap, clone_usershell, free_usershell);
-
+
setusershell();
while ((ushell.path = getusershell()) != NULL) {
if (debug) {
@@ -183,17 +183,17 @@ main(int argc, char **argv)
TEST_DATA_APPEND(usershell, &td, &ushell);
}
endusershell();
-
-
+
+
if (snapshot_file != NULL) {
- if (access(snapshot_file, W_OK | R_OK) != 0) {
+ if (access(snapshot_file, W_OK | R_OK) != 0) {
if (errno == ENOENT)
method = TEST_BUILD_SNAPSHOT;
else {
if (debug)
printf("can't access the snapshot file %s\n",
snapshot_file);
-
+
rv = -1;
goto fin;
}
@@ -207,7 +207,7 @@ main(int argc, char **argv)
}
}
}
-
+
switch (method) {
case TEST_GETUSERSHELL:
if (snapshot_file != NULL) {
@@ -217,7 +217,7 @@ main(int argc, char **argv)
break;
case TEST_BUILD_SNAPSHOT:
if (snapshot_file != NULL) {
- rv = TEST_SNAPSHOT_FILE_WRITE(usershell, snapshot_file, &td,
+ rv = TEST_SNAPSHOT_FILE_WRITE(usershell, snapshot_file, &td,
sdump_usershell);
}
break;
diff --git a/tools/regression/lib/libc/nss/testutil.h b/tools/regression/lib/libc/nss/testutil.h
index acd69ac..711c49f 100644
--- a/tools/regression/lib/libc/nss/testutil.h
+++ b/tools/regression/lib/libc/nss/testutil.h
@@ -53,8 +53,8 @@ int __##ent##_test_data_compare(struct ent##_test_data *, \
void *), void *); \
struct ent *__##ent##_test_data_find(struct ent##_test_data *, struct ent *,\
int (*)(struct ent *, struct ent *, void *), void *); \
-void __##ent##_test_data_clear(struct ent##_test_data *);
-
+void __##ent##_test_data_clear(struct ent##_test_data *);
+
#define TEST_DATA_INIT(ent, td, clonef, freef)\
__##ent##_test_data_init(td, clonef, freef)
#define TEST_DATA_DESTROY(ent, td) __##ent##_test_data_destroy(td)
@@ -191,9 +191,8 @@ __##ent##_test_data_clear(struct ent##_test_data *td) \
td->free_func(&e->data); \
free(e); \
} \
-}
+}
- \
#define DECLARE_TEST_FILE_SNAPSHOT(ent) \
struct ent##_snp_param { \
FILE *fp; \
@@ -204,8 +203,8 @@ int __##ent##_snapshot_write_func(struct ent *, void *); \
int __##ent##_snapshot_write(char const *, struct ent##_test_data *, \
void (*)(struct ent *, char *, size_t)); \
int __##ent##_snapshot_read(char const *, struct ent##_test_data *, \
- int (*)(struct ent *, char *));
-
+ int (*)(struct ent *, char *));
+
#define TEST_SNAPSHOT_FILE_WRITE(ent, fname, td, f) \
__##ent##_snapshot_write(fname, td, f)
#define TEST_SNAPSHOT_FILE_READ(ent, fname, td, f) \
@@ -294,8 +293,8 @@ fin: \
#define DECLARE_1PASS_TEST(ent) \
int __##ent##_1pass_test(struct ent##_test_data *, \
int (*)(struct ent *, void *), \
- void *);
-
+ void *);
+
#define DO_1PASS_TEST(ent, td, f, mdata) \
__##ent##_1pass_test(td, f, mdata)
@@ -318,7 +317,7 @@ int __##ent##_2pass_test(struct ent##_test_data *, \
#define DO_2PASS_TEST(ent, td1, td2, f, mdata) \
__##ent##_2pass_test(td1, td2, f, mdata)
-
+
#define IMPLEMENT_2PASS_TEST(ent) \
int \
__##ent##_2pass_test(struct ent##_test_data *td1, \
diff --git a/tools/regression/lib/libc/resolv/Makefile b/tools/regression/lib/libc/resolv/Makefile
index fa91ac3..18a71bc 100644
--- a/tools/regression/lib/libc/resolv/Makefile
+++ b/tools/regression/lib/libc/resolv/Makefile
@@ -6,8 +6,7 @@ MAN=
# Note: this test relies on being dynamically linked. You will get a
# spurious PASS for a statically linked test.
-DPADD+= ${LIBPTHREAD}
-LDADD+= -lpthread
+LIBADD+= pthread
regress: ${PROG}
./${PROG} -r ${.CURDIR}/mach
diff --git a/tools/regression/mac/mac_bsdextended/Makefile b/tools/regression/mac/mac_bsdextended/Makefile
index 36464ba..aaa060a 100644
--- a/tools/regression/mac/mac_bsdextended/Makefile
+++ b/tools/regression/mac/mac_bsdextended/Makefile
@@ -1,8 +1,7 @@
# $FreeBSD$
PROG= test_ugidfw
-DPADD= ${LIBUGIDFW}
-LDADD= -lugidfw
+LIBADD= ugidfw
MAN=
.include <bsd.prog.mk>
diff --git a/tools/regression/posixsem/Makefile b/tools/regression/posixsem/Makefile
index 3120313..5f73a72 100644
--- a/tools/regression/posixsem/Makefile
+++ b/tools/regression/posixsem/Makefile
@@ -2,8 +2,7 @@
PROG= posixsem
SRCS= posixsem.c test.c
-DPADD= ${LIBKVM}
-LDADD= -lkvm
+LIBADD= kvm
MAN=
WARNS?= 3
diff --git a/tools/regression/priv/Makefile b/tools/regression/priv/Makefile
index a1fbcc6..32a4a74 100644
--- a/tools/regression/priv/Makefile
+++ b/tools/regression/priv/Makefile
@@ -48,8 +48,7 @@ SRCS= main.c \
MAN=
WARNS?= 3
-DPADD+= ${LIBIPSEC}
-LDADD+= -lipsec
+LIBADD+= ipsec
.if ${MK_INET6_SUPPORT} != "no"
CFLAGS+= -DINET6
diff --git a/tools/regression/pthread/cv_cancel1/Makefile b/tools/regression/pthread/cv_cancel1/Makefile
index bedca56..be2ffaa 100644
--- a/tools/regression/pthread/cv_cancel1/Makefile
+++ b/tools/regression/pthread/cv_cancel1/Makefile
@@ -2,7 +2,6 @@
PROG= cv_cancel1
MAN=
-DPADD= ${LIBPTHREAD}
-LDADD= -lpthread
+LIBADD= pthread
.include <bsd.prog.mk>
diff --git a/tools/regression/pthread/mutex_isowned_np/Makefile b/tools/regression/pthread/mutex_isowned_np/Makefile
index f7a8984..8827053 100644
--- a/tools/regression/pthread/mutex_isowned_np/Makefile
+++ b/tools/regression/pthread/mutex_isowned_np/Makefile
@@ -2,7 +2,6 @@
PROG= mutex_isowned_np
MAN=
-DPADD= ${LIBPTHREAD}
-LDADD= -lpthread
+LIBADD= pthread
.include <bsd.prog.mk>
diff --git a/tools/regression/rpcsec_gss/Makefile b/tools/regression/rpcsec_gss/Makefile
index 5db4b79..bea9d9c 100644
--- a/tools/regression/rpcsec_gss/Makefile
+++ b/tools/regression/rpcsec_gss/Makefile
@@ -3,8 +3,7 @@
PROG= rpctest
MAN=
WARNS?= 6
-DPADD= ${LIBRPCSEC_GSS}
-LDADD= -lrpcsec_gss
+LIBADD= rpcsec_gss
DEBUG_FLAGS= -g -O0
.include <bsd.prog.mk>
diff --git a/tools/regression/sockets/sendfile/Makefile b/tools/regression/sockets/sendfile/Makefile
index 9d6f185..6e9c1ab 100644
--- a/tools/regression/sockets/sendfile/Makefile
+++ b/tools/regression/sockets/sendfile/Makefile
@@ -5,7 +5,6 @@
PROG= sendfile
MAN=
WARNS?= 6
-DPADD= ${LIBMD}
-LDADD= -lmd
+LIBADD= md
.include <bsd.prog.mk>
diff --git a/tools/regression/tls/ttls2/Makefile b/tools/regression/tls/ttls2/Makefile
index 643040f..cbebbe7 100644
--- a/tools/regression/tls/ttls2/Makefile
+++ b/tools/regression/tls/ttls2/Makefile
@@ -1,8 +1,7 @@
# $FreeBSD$
PROG= ttls2
-DPADD= ${LIBPTHREAD}
-LDADD= -lpthread
+LIBADD= pthread
MAN=
DEBUG_FLAGS= -g
diff --git a/tools/regression/tls/ttls4/Makefile b/tools/regression/tls/ttls4/Makefile
index 2d1e501..ab6ca6f 100644
--- a/tools/regression/tls/ttls4/Makefile
+++ b/tools/regression/tls/ttls4/Makefile
@@ -1,8 +1,7 @@
# $FreeBSD$
PROG= ttls4
-DPADD= ${LIBPTHREAD}
-LDADD= -lpthread
+LIBADD= pthread
MAN=
DEBUG_FLAGS= -g
diff --git a/tools/tools/ath/athratestats/Makefile b/tools/tools/ath/athratestats/Makefile
index 87cd0f8..938f0cb 100644
--- a/tools/tools/ath/athratestats/Makefile
+++ b/tools/tools/ath/athratestats/Makefile
@@ -7,7 +7,7 @@ PROG= athratestats
SRCS= main.c opt_ah.h ah_osdep.h
-LDADD+= -lcurses
+LIBADD+= curses
CLEANFILES+= opt_ah.h ah_osdep.h
diff --git a/tools/tools/atsectl/Makefile b/tools/tools/atsectl/Makefile
index 3f3a8c4..afe79a9 100644
--- a/tools/tools/atsectl/Makefile
+++ b/tools/tools/atsectl/Makefile
@@ -2,8 +2,7 @@
PROG= atsectl
-DPADD= ${LIBMD}
-LDADD= -lmd
+LIBADD= md
BINDIR?= /usr/sbin
diff --git a/tools/tools/ether_reflect/Makefile b/tools/tools/ether_reflect/Makefile
index 0d20f39..040a5bd 100644
--- a/tools/tools/ether_reflect/Makefile
+++ b/tools/tools/ether_reflect/Makefile
@@ -4,8 +4,7 @@
# A Makefile that builds both the ether_reflect program and its manual page.
PROG= ether_reflect
-DPADD= ${LIBPCAP}
-LDADD= -lpcap
+LIBADD= pcap
CFLAGS+=-DHAVE_SNPRINTF
.include <bsd.prog.mk>
diff --git a/tools/tools/ifpifa/Makefile b/tools/tools/ifpifa/Makefile
index 0c09ecc..d381792 100644
--- a/tools/tools/ifpifa/Makefile
+++ b/tools/tools/ifpifa/Makefile
@@ -4,7 +4,6 @@ PROG= ifpifa
MAN=
WARNS?=6
BINDIR?=/usr/local/bin
-DPADD=${LIBKVM}
-LDADD=-lkvm
+LIBADD=kvm
.include <bsd.prog.mk>
diff --git a/tools/tools/mctest/Makefile b/tools/tools/mctest/Makefile
index 6edaf89..dc583e5 100644
--- a/tools/tools/mctest/Makefile
+++ b/tools/tools/mctest/Makefile
@@ -1,7 +1,6 @@
# $FreeBSD$
PROG_CXX= mctest
-DPADD= ${LIBPTHREAD}
-LDADD= -lpthread
+LIBADD= pthread
.include <bsd.prog.mk>
diff --git a/tools/tools/nanobsd/defaults.sh b/tools/tools/nanobsd/defaults.sh
index 59a6a5d..067d306 100755
--- a/tools/tools/nanobsd/defaults.sh
+++ b/tools/tools/nanobsd/defaults.sh
@@ -164,7 +164,6 @@ NANO_SLICE_DATA=s4
# conflates the two, so architectures where TARGET != TARGET_ARCH and
# TARGET can't be guessed from TARGET_ARCH do not work. This defaults
# to the arch of the current machine.
-
NANO_ARCH=`uname -p`
# CPUTYPE defaults to "" which is the default when CPUTYPE isn't
@@ -177,9 +176,12 @@ NANO_CFGDIR=""
# Directory to populate /data from
NANO_DATADIR=""
-# src.conf to use when building the image. Defaults to /dev/null for the sake
-# of determinism.
-SRCCONF=${SRCCONF:=/dev/null}
+# We don't need SRCCONF or SRC_ENV_CONF. NanoBSD puts everything we
+# need for the build in files included with __MAKE_CONF. Override in your
+# config file if you really must. We set them unconditionally here, though
+# in case they are stray in the build environment
+SRCCONF=/dev/null
+SRC_ENV_CONF=/dev/null
#######################################################################
#
@@ -188,6 +190,46 @@ SRCCONF=${SRCCONF:=/dev/null}
#
#######################################################################
+# Export values into the shell. Must use { } instead of ( ) like
+# other functions to avoid a subshell.
+# We set __MAKE_CONF as a global since it is easier to get quoting
+# right for paths with spaces in them.
+make_export ( ) {
+ # Similar to export_var, except puts the data out to stdout
+ var=$1
+ eval val=\$$var
+ echo "Setting variable: $var=\"$val\""
+ export $1
+}
+
+nano_make_build_env ( ) {
+ __MAKE_CONF="${NANO_MAKE_CONF_BUILD}"
+ make_export __MAKE_CONF
+}
+
+nano_make_install_env ( ) {
+ __MAKE_CONF="${NANO_MAKE_CONF_INSTALL}"
+ make_export __MAKE_CONF
+}
+
+# Extra environment variables for kernel builds
+nano_make_kernel_env ( ) {
+ if [ -f ${NANO_KERNEL} ] ; then
+ KERNCONFDIR="$(realpath $(dirname ${NANO_KERNEL}))"
+ KERNCONF="$(basename ${NANO_KERNEL})"
+ make_export KERNCONFDIR
+ make_export KERNCONF
+ else
+ export KERNCONF="${NANO_KERNEL}"
+ make_export KERNCONF
+ fi
+}
+
+nano_global_make_env ( ) (
+ [ ! -z "${NANO_ARCH}" ] && echo TARGET_ARCH="${NANO_ARCH}" || true
+ [ ! -z "${NANO_CPUTYPE}" ] && echo TARGET_CPUTYPE="${NANO_CPUTYPE}" || true
+)
+
# rm doesn't know -x prior to FreeBSD 10, so cope with a variety of build
# hosts for now.
nano_rm ( ) {
@@ -198,15 +240,13 @@ nano_rm ( ) {
}
# run in the world chroot, errors fatal
-CR()
-{
- chroot ${NANO_WORLDDIR} /bin/sh -exc "$*"
+CR ( ) {
+ chroot "${NANO_WORLDDIR}" /bin/sh -exc "$*"
}
# run in the world chroot, errors not fatal
-CR0()
-{
- chroot ${NANO_WORLDDIR} /bin/sh -c "$*" || true
+CR0 ( ) {
+ chroot "${NANO_WORLDDIR}" /bin/sh -c "$*" || true
}
nano_cleanup ( ) (
@@ -231,19 +271,25 @@ make_conf_build ( ) (
mkdir -p ${MAKEOBJDIRPREFIX}
printenv > ${MAKEOBJDIRPREFIX}/_.env
- echo "${CONF_WORLD}" > ${NANO_MAKE_CONF_BUILD}
- echo "${CONF_BUILD}" >> ${NANO_MAKE_CONF_BUILD}
+ # Make sure we get all the global settings that NanoBSD wants
+ # in addition to the user's global settings
+ (
+ nano_global_make_env
+ echo "${CONF_WORLD}"
+ echo "${CONF_BUILD}"
+ ) > ${NANO_MAKE_CONF_BUILD}
)
build_world ( ) (
pprint 2 "run buildworld"
pprint 3 "log: ${MAKEOBJDIRPREFIX}/_.bw"
- cd ${NANO_SRC}
- env TARGET_ARCH=${NANO_ARCH} TARGET_CPUTYPE=${NANO_CPUTYPE} ${NANO_PMAKE} \
- SRCCONF=${SRCCONF} \
- __MAKE_CONF=${NANO_MAKE_CONF_BUILD} buildworld \
- > ${MAKEOBJDIRPREFIX}/_.bw 2>&1
+ (
+ nano_make_build_env
+ set -o xtrace
+ cd "${NANO_SRC}"
+ ${NANO_PMAKE} buildworld
+ ) > ${MAKEOBJDIRPREFIX}/_.bw 2>&1
)
build_kernel ( ) (
@@ -253,20 +299,16 @@ build_kernel ( ) (
pprint 3 "log: ${MAKEOBJDIRPREFIX}/_.bk"
(
- if [ -f ${NANO_KERNEL} ] ; then
- kernconfdir_arg="KERNCONFDIR='$(realpath $(dirname ${NANO_KERNEL}))'"
- kernconf=$(basename ${NANO_KERNEL})
- else
- kernconf=${NANO_KERNEL}
- fi
+ nano_make_build_env
+ nano_make_kernel_env
- cd ${NANO_SRC};
# Note: We intentionally build all modules, not only the ones in
# NANO_MODULES so the built world can be reused by multiple images.
- eval "TARGET_ARCH=${NANO_ARCH} ${NANO_PMAKE} buildkernel \
- SRCCONF='${SRCCONF}' \
- __MAKE_CONF='${NANO_MAKE_CONF_BUILD}' \
- ${kernconfdir_arg} KERNCONF=${kernconf}"
+ # Although MODULES_OVERRIDE can be defined in the kenrel config
+ # file to override this behavior. Just set NANO_MODULES=default.
+ set -o xtrace
+ cd "${NANO_SRC}"
+ ${NANO_PMAKE} buildkernel
) > ${MAKEOBJDIRPREFIX}/_.bk 2>&1
)
@@ -277,36 +319,45 @@ clean_world ( ) (
chflags -R noschg ${NANO_OBJ}
nano_rm -r ${NANO_OBJ}/
fi
- mkdir -p ${NANO_OBJ} ${NANO_WORLDDIR}
+ mkdir -p "${NANO_OBJ}" "${NANO_WORLDDIR}"
printenv > ${NANO_OBJ}/_.env
else
pprint 2 "Clean and create world directory (${NANO_WORLDDIR})"
- if ! nano_rm -rf ${NANO_WORLDDIR}/ > /dev/null 2>&1 ; then
- chflags -R noschg ${NANO_WORLDDIR}
- nano_rm -rf ${NANO_WORLDDIR}/
+ if ! nano_rm -rf "${NANO_WORLDDIR}/" > /dev/null 2>&1 ; then
+ chflags -R noschg "${NANO_WORLDDIR}"
+ nano_rm -rf "${NANO_WORLDDIR}/"
fi
- mkdir -p ${NANO_WORLDDIR}
+ mkdir -p "${NANO_WORLDDIR}"
fi
)
make_conf_install ( ) (
pprint 2 "Construct install make.conf ($NANO_MAKE_CONF_INSTALL)"
- echo "${CONF_WORLD}" > ${NANO_MAKE_CONF_INSTALL}
- echo "${CONF_INSTALL}" >> ${NANO_MAKE_CONF_INSTALL}
+ # Make sure we get all the global settings that NanoBSD wants
+ # in addition to the user's global settings
+ (
+ nano_global_make_env
+ echo "${CONF_WORLD}"
+ echo "${CONF_INSTALL}"
+ if [ ! -z "${NANO_NOPRIV_BUILD}" ]; then
+ echo NO_ROOT=t
+ echo METALOG=${NANO_METALOG}
+ fi
+ ) > ${NANO_MAKE_CONF_INSTALL}
)
install_world ( ) (
pprint 2 "installworld"
pprint 3 "log: ${NANO_OBJ}/_.iw"
- cd ${NANO_SRC}
- env TARGET_ARCH=${NANO_ARCH} TARGET_CPUTYPE=${NANO_CPUTYPE} \
- ${NANO_MAKE} SRCCONF=${SRCCONF} \
- __MAKE_CONF=${NANO_MAKE_CONF_INSTALL} installworld \
- DESTDIR=${NANO_WORLDDIR} \
- > ${NANO_OBJ}/_.iw 2>&1
- chflags -R noschg ${NANO_WORLDDIR}
+ (
+ nano_make_install_env
+ set -o xtrace
+ cd "${NANO_SRC}"
+ ${NANO_MAKE} installworld DESTDIR="${NANO_WORLDDIR}"
+ chflags -R noschg "${NANO_WORLDDIR}"
+ ) > ${NANO_OBJ}/_.iw 2>&1
)
install_etc ( ) (
@@ -314,15 +365,15 @@ install_etc ( ) (
pprint 2 "install /etc"
pprint 3 "log: ${NANO_OBJ}/_.etc"
- cd ${NANO_SRC}
- env TARGET_ARCH=${NANO_ARCH} TARGET_CPUTYPE=${NANO_CPUTYPE} \
- ${NANO_MAKE} SRCCONF=${SRCCONF} \
- __MAKE_CONF=${NANO_MAKE_CONF_INSTALL} distribution \
- DESTDIR=${NANO_WORLDDIR} \
- > ${NANO_OBJ}/_.etc 2>&1
+ (
+ nano_make_install_env
+ set -o xtrace
+ cd "${NANO_SRC}"
+ ${NANO_MAKE} distribution DESTDIR="${NANO_WORLDDIR}"
# make.conf doesn't get created by default, but some ports need it
# so they can spam it.
- cp /dev/null ${NANO_WORLDDIR}/etc/make.conf
+ cp /dev/null "${NANO_WORLDDIR}"/etc/make.conf
+ ) > ${NANO_OBJ}/_.etc 2>&1
)
install_kernel ( ) (
@@ -332,27 +383,19 @@ install_kernel ( ) (
pprint 3 "log: ${NANO_OBJ}/_.ik"
(
- if [ -f ${NANO_KERNEL} ] ; then
- kernconfdir_arg="KERNCONFDIR='$(realpath $(dirname ${NANO_KERNEL}))'"
- kernconf=$(basename ${NANO_KERNEL})
- else
- kernconf=${NANO_KERNEL}
- fi
- # Install all built modules if NANO_MODULES=default,
- # else install only listed modules (none if NANO_MODULES is empty).
+ nano_make_install_env
+ nano_make_kernel_env
+
if [ "${NANO_MODULES}" != "default" ]; then
- modules_override_arg="MODULES_OVERRIDE='${NANO_MODULES}'"
+ MODULES_OVERRIDE="${NANO_MODULES}"
+ make_export MODULES_OVERRIDE
fi
- cd ${NANO_SRC}
- eval "TARGET_ARCH=${NANO_ARCH} TARGET_CPUTYPE=${NANO_CPUTYPE} \
- ${NANO_MAKE} installkernel \
- DESTDIR='${NANO_WORLDDIR}' \
- SRCCONF='${SRCCONF}' \
- __MAKE_CONF='${NANO_MAKE_CONF_INSTALL}' \
- ${kernconfdir_arg} KERNCONF=${kernconf} \
- ${modules_override_arg}"
+ set -o xtrace
+ cd "${NANO_SRC}"
+ ${NANO_MAKE} installkernel DESTDIR="${NANO_WORLDDIR}"
+
) > ${NANO_OBJ}/_.ik 2>&1
)
@@ -360,15 +403,17 @@ native_xtools ( ) (
print 2 "Installing the optimized native build tools for cross env"
pprint 3 "log: ${NANO_OBJ}/_.native_xtools"
- cd ${NANO_SRC}
- env TARGET_ARCH=${NANO_ARCH} TARGET_CPUTYPE=${NANO_CPUTYPE} \
- ${NANO_MAKE} SRCCONF=${SRCCONF} \
- __MAKE_CONF=${NANO_MAKE_CONF_INSTALL} native-xtools \
- DESTDIR=${NANO_WORLDDIR} \
- > ${NANO_OBJ}/_.native_xtools 2>&1
+ (
+
+ nano_make_install_env
+ set -o xtrace
+ cd "${NANO_SRC}"
+ ${NANO_MAKE} native-xtools DESTDIR="${NANO_WORLDDIR}"
+
+ ) > ${NANO_OBJ}/_.native_xtools 2>&1
)
-run_customize() (
+run_customize ( ) (
pprint 2 "run customize scripts"
for c in $NANO_CUSTOMIZE
@@ -380,7 +425,7 @@ run_customize() (
done
)
-run_late_customize() (
+run_late_customize ( ) (
pprint 2 "run late customize scripts"
for c in $NANO_LATE_CUSTOMIZE
@@ -397,7 +442,7 @@ setup_nanobsd ( ) (
pprint 3 "log: ${NANO_OBJ}/_.dl"
(
- cd ${NANO_WORLDDIR}
+ cd "${NANO_WORLDDIR}"
# Move /usr/local/etc to /etc/local so that the /cfg stuff
# can stomp on it. Otherwise packages like ipsec-tools which
@@ -439,13 +484,15 @@ setup_nanobsd_etc ( ) (
pprint 2 "configure nanobsd /etc"
(
- cd ${NANO_WORLDDIR}
+ cd "${NANO_WORLDDIR}"
# create diskless marker file
touch etc/diskless
# Make root filesystem R/O by default
+ [ ! -z "${NANO_NOPRIV_BUILD}" ] && chmod 666 etc/defaults/rc.conf
echo "root_rw_mount=NO" >> etc/defaults/rc.conf
+ [ ! -z "${NANO_NOPRIV_BUILD}" ] && chmod 444 etc/defaults/rc.conf
# save config file for scripts
echo "NANO_DRIVE=${NANO_DRIVE}" > etc/nanobsd.conf
@@ -456,10 +503,10 @@ setup_nanobsd_etc ( ) (
)
)
-prune_usr() (
+prune_usr ( ) (
# Remove all empty directories in /usr
- find ${NANO_WORLDDIR}/usr -type d -depth -print |
+ find "${NANO_WORLDDIR}"/usr -type d -depth -print |
while read d
do
rmdir $d > /dev/null 2>&1 || true
@@ -478,7 +525,7 @@ newfs_part ( ) (
# Convenient spot to work around any umount issues that your build environment
# hits by overriding this method.
-nano_umount () (
+nano_umount ( ) (
umount ${1}
)
@@ -492,7 +539,7 @@ populate_slice ( ) (
newfs_part ${dev} ${mnt} ${lbl}
if [ -n "${dir}" -a -d "${dir}" ]; then
echo "Populating ${lbl} from ${dir}"
- cd ${dir}
+ cd "${dir}"
find . -print | grep -Ev '/(CVS|\.svn|\.hg|\.git)' | cpio -dumpv ${mnt}
fi
df -i ${mnt}
@@ -615,9 +662,9 @@ create_diskimage ( ) (
populate_slice /dev/${MD}${NANO_SLICE_ROOT}a ${NANO_WORLDDIR} ${MNT} "${NANO_SLICE_ROOT}a"
mount /dev/${MD}${NANO_SLICE_ROOT}a ${MNT}
echo "Generating mtree..."
- ( cd ${MNT} && mtree -c ) > ${NANO_OBJ}/_.mtree
- ( cd ${MNT} && du -k ) > ${NANO_OBJ}/_.du
- nano_umount ${MNT}
+ ( cd "${MNT}" && mtree -c ) > ${NANO_OBJ}/_.mtree
+ ( cd "${MNT}" && du -k ) > ${NANO_OBJ}/_.du
+ nano_umount "${MNT}"
if [ $NANO_IMAGES -gt 1 -a $NANO_INIT_IMG2 -gt 0 ] ; then
# Duplicate to second image (if present)
@@ -674,7 +721,7 @@ create_diskimage ( ) (
) > ${NANO_OBJ}/_.di 2>&1
)
-last_orders () (
+last_orders ( ) (
# Redefine this function with any last orders you may have
# after the build completed, for instance to copy the finished
# image to a more convenient place:
@@ -692,7 +739,7 @@ last_orders () (
# Common Flash device geometries
#
-FlashDevice () {
+FlashDevice ( ) {
if [ -d ${NANO_TOOLS} ] ; then
. ${NANO_TOOLS}/FlashDevice.sub
else
@@ -721,7 +768,7 @@ FlashDevice () {
# The generic-hdd device is preferred for flash devices larger than 1GB.
#
-UsbDevice () {
+UsbDevice ( ) {
a1=`echo $1 | tr '[:upper:]' '[:lower:]'`
case $a1 in
generic-fdd)
@@ -744,7 +791,7 @@ UsbDevice () {
#######################################################################
# Setup serial console
-cust_comconsole () (
+cust_comconsole ( ) (
# Enable getty on console
sed -i "" -e /tty[du]0/s/off/on/ ${NANO_WORLDDIR}/etc/ttys
@@ -758,7 +805,7 @@ cust_comconsole () (
#######################################################################
# Allow root login via ssh
-cust_allow_ssh_root () (
+cust_allow_ssh_root ( ) (
sed -i "" -e '/PermitRootLogin/s/.*/PermitRootLogin yes/' \
${NANO_WORLDDIR}/etc/ssh/sshd_config
)
@@ -766,15 +813,15 @@ cust_allow_ssh_root () (
#######################################################################
# Install the stuff under ./Files
-cust_install_files () (
- cd ${NANO_TOOLS}/Files
+cust_install_files ( ) (
+ cd "${NANO_TOOLS}/Files"
find . -print | grep -Ev '/(CVS|\.svn|\.hg|\.git)' | cpio -Ldumpv ${NANO_WORLDDIR}
)
#######################################################################
# Install packages from ${NANO_PACKAGE_DIR}
-cust_pkgng () (
+cust_pkgng ( ) (
# If the package directory doesn't exist, we're done.
if [ ! -d ${NANO_PACKAGE_DIR} ]; then
@@ -794,8 +841,8 @@ cust_pkgng () (
# Copy packages into chroot
mkdir -p ${NANO_WORLDDIR}/Pkg
(
- cd ${NANO_PACKAGE_DIR}
- find ${NANO_PACKAGE_LIST} -print |
+ cd "${NANO_PACKAGE_DIR}"
+ find "${NANO_PACKAGE_LIST}" -print |
cpio -Ldumpv ${NANO_WORLDDIR}/Pkg
)
@@ -842,7 +889,7 @@ cust_pkgng () (
# Convenience function:
# Register all args as customize function.
-customize_cmd () {
+customize_cmd ( ) {
NANO_CUSTOMIZE="$NANO_CUSTOMIZE $*"
}
@@ -851,7 +898,7 @@ customize_cmd () {
# Register all args as late customize function to run just before
# image creation.
-late_customize_cmd () {
+late_customize_cmd ( ) {
NANO_LATE_CUSTOMIZE="$NANO_LATE_CUSTOMIZE $*"
}
@@ -863,14 +910,14 @@ late_customize_cmd () {
# Progress Print
# Print $2 at level $1.
-pprint() (
+pprint ( ) (
if [ "$1" -le $PPLEVEL ]; then
runtime=$(( `date +%s` - $NANO_STARTTIME ))
printf "%s %.${1}s %s\n" "`date -u -r $runtime +%H:%M:%S`" "#####" "$2" 1>&3
fi
)
-usage () {
+usage ( ) {
(
echo "Usage: $0 [-bfiKknqvw] [-c config_file]"
echo " -b suppress builds (both kernel and world)"
@@ -891,7 +938,7 @@ usage () {
# Setup and Export Internal variables
#
-export_var() {
+export_var ( ) { # Don't wawnt a subshell
var=$1
# Lookup value of the variable.
eval val=\$$var
@@ -900,7 +947,8 @@ export_var() {
}
# Call this function to set defaults _after_ parsing options.
-set_defaults_and_export() {
+# dont want a subshell otherwise variable setting is thrown away.
+set_defaults_and_export ( ) {
test -n "${NANO_OBJ}" || NANO_OBJ=/usr/obj/nanobsd.${NANO_NAME}
test -n "${MAKEOBJDIRPREFIX}" || MAKEOBJDIRPREFIX=${NANO_OBJ}
test -n "${NANO_DISKIMGDIR}" || NANO_DISKIMGDIR=${NANO_OBJ}
@@ -909,11 +957,14 @@ set_defaults_and_export() {
NANO_MAKE_CONF_INSTALL=${NANO_OBJ}/make.conf.install
# Override user's NANO_DRIVE if they specified a NANO_LABEL
- [ ! -z "${NANO_LABEL}" ] && NANO_DRIVE="ufs/${NANO_LABEL}"
+ [ ! -z "${NANO_LABEL}" ] && NANO_DRIVE="ufs/${NANO_LABEL}" || true
# Set a default NANO_TOOLS to NANO_SRC/NANO_TOOLS if it exists.
[ ! -d "${NANO_TOOLS}" ] && [ -d "${NANO_SRC}/${NANO_TOOLS}" ] && \
- NANO_TOOLS="${NANO_SRC}/${NANO_TOOLS}"
+ NANO_TOOLS="${NANO_SRC}/${NANO_TOOLS}" || true
+
+ [ ! -z "${NANO_NOPRIV_BUILD}" ] && [ -z "${NANO_METALOG}" ] && \
+ NANO_METALOG=${NANO_OBJ}/_.metalog || true
NANO_STARTTIME=`date +%s`
pprint 3 "Exporting NanoBSD variables"
@@ -943,4 +994,8 @@ set_defaults_and_export() {
export_var NANO_BOOTLOADER
export_var NANO_LABEL
export_var NANO_MODULES
+ export_var NANO_NOPRIV_BUILD
+ export_var NANO_METALOG
+ export_var SRCCONF
+ export_var SRC_ENV_CONF
}
diff --git a/tools/tools/nanobsd/embedded/README b/tools/tools/nanobsd/embedded/README
new file mode 100644
index 0000000..7be7978
--- /dev/null
+++ b/tools/tools/nanobsd/embedded/README
@@ -0,0 +1,14 @@
+$FreeBSD$
+
+Example for creating many different builds (including different
+arch) from a common set of files, as well as building natively
+using qemu user space emulation.
+
+This creates a simple appliance that uses dnsmasq to serve DNS
+and DHCPd.
+
+This is a work in progress. Generally, to build this you should
+ cd tools/tools/nanobsd/embedded
+ sudo sh ../nanobsd.sh -c foo.cfg
+but do be careful if things are interrupted. There may still be
+bugs lurking that cause your entire FreeBSD tree to disappear.
diff --git a/tools/tools/nanobsd/embedded/beaglebone.cfg b/tools/tools/nanobsd/embedded/beaglebone.cfg
new file mode 100644
index 0000000..3f28feb
--- /dev/null
+++ b/tools/tools/nanobsd/embedded/beaglebone.cfg
@@ -0,0 +1,42 @@
+# $FreeBSD$
+
+#-
+# Copyright (c) 2015 Warner Losh. All Rights Reserved.
+# Copyright (c) 2010-2011 iXsystems, Inc., 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 iXsystems, Inc. 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.
+#
+# This file is heavily derived from both Sam Leffler's Avilia config,
+# as well as the BSDRP project's config file. Neither of these have
+# an explicit copyright/license statement, but are implicitly BSDL. This
+# example has been taken from the FreeNAS project and simplified to meet
+# the needs of the example.
+#
+
+NANO_ARCH=armv6
+NANO_KERNEL=BEAGLEBONE
+NANO_DRIVE=mmcsd0
+NANO_NAME=rpi2
+NANO_BOOT_PKG=u-boot-beaglebone
+NANO_CPUTYPE=cortex-a8
+
+. common # Pull in common definitions, keep last
diff --git a/tools/tools/nanobsd/embedded/common b/tools/tools/nanobsd/embedded/common
new file mode 100644
index 0000000..a4635f0
--- /dev/null
+++ b/tools/tools/nanobsd/embedded/common
@@ -0,0 +1,567 @@
+# $FreeBSD$
+
+#-
+# Copyright (c) 2015 Warner Losh. All Rights Reserved.
+# Copyright (c) 2010-2011 iXsystems, Inc., 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 iXsystems, Inc 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.
+#
+#
+# This file is heavily derived from both Sam Leffler's Avilia config,
+# as well as the BSDRP project's config file. Neither of these have
+# an explicit copyright/license statement, but are implicitly BSDL. This
+# example has been taken from the FreeNAS project (an early version) and
+# simplified to meet the needs of the example.
+#
+
+# NB: You want the other file as the command line arg :)
+
+# Missing in base:
+# o mkimg setting active partition
+# o mkimg starting at arbitrary offset (needed for A10, et al)
+# o mtools still needed becuase we have no makefs -t msdos
+# o nanobsd doesn't record changes to WORLDTEMP in customization
+# scripts yet, so we have kludge to pick up all files
+# o easy way for pkg to grab files from other repos and put that
+# data on the image
+# o Need to have some way to create / resize the s4 slice to do ping
+# pong bouncing between s3 and s4 for an arbitrary image. we can resize
+# one slice, not two
+# o hints in the uboot ports for how to create the image
+#
+# Missing here
+# o documentation for how to run the qemu images
+# o msdos mtools fallback
+# o special boot for !x86 !arm platforms
+# o qemu image for arm
+# o qemu image for aarch64
+# o qemu image for armv6/armv7
+# o easy support for different image / vm formats
+# o need to promote much of this to nanobsd.sh and friends
+# o uses old kludge to build image w/o ownership being right
+# for many files. Should move to mtree-dedup.awk.
+# o support for EFI images
+# o support for GPT partitioning
+#
+# Long Term
+# o common tooling for creating images for odd-ball platforms
+# o support for boot loaders other than uboot in the image
+# or via special insturctions
+# o No pony support. Sadly, you cannot have a pony.
+#
+
+if [ -z $NANO_NAME ]; then
+ echo "NANO_NAME not defined. Use foo.cfg instead."
+fi
+
+# Slice 1: FAT for ROM loading bootstrap
+# Slice 2: Config partition
+# Slice 3: FreeBSD partition (sized exactly)
+# Slice 4: FreeBSD partition (empty)
+# on first boot, we resize slice 3 & 4 to be 1/2 of what's
+# left over on the SD card after slice 1 and 2 are taken
+# off the top. We also resize the 'a' partion on first boot
+# to the size of the partition for the ping/pong upgrade.
+if [ -z "$EMBED_OMIT_FAT" ]; then
+ NANO_SLICE_FAT=s1
+ NANO_SLICE_CFG=s2
+ NANO_SLICE_ROOT=s3
+ NANO_SLICE_ALTROOT=s4
+else
+ NANO_SLICE_CFG=s1
+ NANO_SLICE_ROOT=s2
+ NANO_SLICE_ALTROOT=s3
+fi
+NANO_SLICE_DATA= # Not included
+
+NANO_SLICE_FAT_SIZE=32m
+NANO_SLICE_CFG_SIZE=32m
+
+NANO_RAM_ETCSIZE=8192
+NANO_RAM_TMPVARSIZE=8192
+NANO_IMAGES=2
+
+NANO_PMAKE="make -j $(sysctl -n hw.ncpu)"
+
+NANO_CFG_BASE=$(pwd)
+NANO_CFG_BASE=$(realpath ${NANO_CFG_BASE}/..)
+NANO_SRC=$(realpath ${NANO_CFG_BASE}/../../..)
+#### XXX share obj
+NANO_OBJ=${NANO_SRC}/../$NANO_NAME/obj
+# Where cust_pkg() finds packages to install
+#XXX: Is this the right place?
+#NANO_PORTS=$(realpath ${NANO_SRC}/../ports)
+NANO_PORTS=/usr/ports
+NANO_PACKAGE_DIR=${NANO_SRC}/${NANO_TOOLS}/Pkg
+NANO_INIT_IMG2=0
+NANO_NOPRIV_BUILD=t
+unset MAKEOBJDIRPREFIX
+
+# this to go into nanobsd.sh
+NANO_PORTS=${NANO_PORTS:-/usr/ports}
+
+mkdir -p ${NANO_OBJ}
+
+customize_cmd cust_allow_ssh_root
+
+add_etc_make_conf()
+{
+ touch ${NANO_WORLDDIR}/etc/make.conf
+}
+customize_cmd add_etc_make_conf
+
+cust_install_machine_files()
+{
+ echo "cd ${NANO_CFG_BASE}/Files"
+ cd ${NANO_CFG_BASE}/Files
+ find . -print | grep -Ev '/(CVS|\.svn|\.hg|\.git)' | cpio -dumpv ${NANO_WORLDDIR}
+}
+customize_cmd cust_install_files
+customize_cmd cust_install_machine_files
+
+buildenv()
+{
+ cd ${NANO_SRC}
+ env __MAKE_CONF=${NANO_MAKE_CONF_BUILD} DESTDIR=${NANO_WORLDDIR} make buildenv
+}
+
+NANO_MAKEFS="makefs -B big \
+ -o bsize=4096,fsize=512,density=8192,optimization=space"
+export NANO_MAKEFS
+
+# NB: leave c++ enabled so devd can be built
+CONF_BUILD="
+WITHOUT_ACPI=true
+WITHOUT_ATM=true
+WITHOUT_AUDIT=true
+WITHOUT_BIND_DNSSEC=true
+WITHOUT_BIND_ETC=true
+WITHOUT_BIND_LIBS_LWRES=true
+WITHOUT_BLUETOOTH=true
+WITHOUT_CALENDAR=true
+WITHOUT_CVS=true
+WITHOUT_DICT=true
+WITHOUT_EXAMPLES=true
+WITHOUT_FORTRAN=true
+WITHOUT_GAMES=true
+WITHOUT_GCOV=true
+WITHOUT_GPIB=true
+WITHOUT_HTML=true
+WITHOUT_I4B=true
+WITHOUT_IPFILTER=true
+WITHOUT_IPX=true
+WITHOUT_LIBKSE=true
+WITHOUT_LOCALES=true
+WITHOUT_LPR=true
+WITHOUT_MAN=true
+WITHOUT_NETCAT=true
+WITHOUT_NIS=true
+WITHOUT_NLS=true
+WITHOUT_NS_CACHING=true
+WITHOUT_OBJC=true
+WITHOUT_PROFILE=true
+WITHOUT_RCMDS=true
+WITHOUT_SENDMAIL=true
+WITHOUT_SHAREDOCS=true
+WITHOUT_SYSCONS=true
+WITHOUT_LIB32=true
+"
+CONF_INSTALL="$CONF_BUILD
+INSTALL_NODEBUG=t
+NOPORTDOCS=t
+NO_INSTALL_MANPAGES=t
+"
+# The following would help...
+# WITHOUT_TOOLCHAIN=true can't build ports
+# WITHOUT_INSTALLLIB=true libgcc.a
+#
+# from the build
+# WITHOUT_INFO=true makeinfo
+# WITHOUT_RCS=true
+PKG_ONLY_MAKE_CONF="
+WITHOUT_TOOLCHAIN=true
+WITHOUT_INSTALLLIB=true
+WITHOUT_INFO=true
+WITHOUT_RCS=true
+"
+
+NANO_PACKAGE_ONLY=1
+
+# install a package from a pre-built binary
+do_add_pkg ()
+{
+ # Need to create ${NANO_OBJ}/ports in this add_pkg_${port} function
+ set -x
+ mkdir -p ${NANO_OBJ}/ports/distfiles
+ mkdir -p ${NANO_OBJ}/ports/packages
+ mkdir -p ${NANO_WORLDDIR}/usr/ports/packages
+ mkdir -p ${NANO_WORLDDIR}/usr/ports/distfiles
+ mount -t nullfs -o noatime ${NANO_OBJ}/ports/packages \
+ ${NANO_WORLDDIR}/usr/ports/packages
+ mount -t nullfs -o noatime ${NANO_OBJ}/ports/distfiles \
+ ${NANO_WORLDDIR}/usr/ports/distfiles
+ CR env ASSUME_ALWAYS_YES=YES SIGNATURE_TYPE=none /usr/sbin/pkg add /usr/ports/packages/All/$1.txz
+ umount ${NANO_WORLDDIR}/usr/ports/distfiles
+ umount ${NANO_WORLDDIR}/usr/ports/packages
+ rmdir ${NANO_WORLDDIR}/usr/ports/packages
+ rmdir ${NANO_WORLDDIR}/usr/ports/distfiles
+ rmdir ${NANO_WORLDDIR}/usr/ports
+ set +x
+}
+
+# Build a port (with the side effect of creating a package)
+do_add_port ()
+{
+ local port_path
+ port_path=$1
+ shift
+ set -x
+ # Need to create ${NANO_OBJ}/ports in this add_port_${port} function
+ mkdir -p ${NANO_OBJ}/ports/distfiles
+ mkdir -p ${NANO_OBJ}/ports/packages
+ mkdir -p ${NANO_PORTS}/packages
+ mkdir -p ${NANO_PORTS}/distfiles
+ mkdir -p ${NANO_WORLDDIR}/usr/src
+ mkdir -p ${NANO_WORLDDIR}/usr/ports
+ mount -t nullfs -o noatime ${NANO_SRC} ${NANO_WORLDDIR}/usr/src
+ mount -t nullfs -o noatime ${NANO_PORTS} ${NANO_WORLDDIR}/usr/ports
+ mount -t nullfs -o noatime ${NANO_OBJ}/ports/packages \
+ ${NANO_WORLDDIR}/usr/ports/packages
+ mount -t nullfs -o noatime ${NANO_OBJ}/ports/distfiles \
+ ${NANO_WORLDDIR}/usr/ports/distfiles
+ mkdir -p ${NANO_WORLDDIR}/dev
+ mount -t devfs devfs ${NANO_WORLDDIR}/dev
+ mkdir -p ${NANO_WORLDDIR}/usr/workdir
+ cp /etc/resolv.conf ${NANO_WORLDDIR}/etc/resolv.conf
+ # OK, a little inefficient, but likely not enough to worry about.
+ CR ldconfig /lib /usr/lib /usr/local/lib
+ CR ldconfig -R
+ CR ldconfig -r
+# Improvement: Don't know why package-recursive don't works here
+ CR "env UNAME_p=${NANO_ARCH} TARGET=${NANO_ARCH} \
+ TARGET_ARCH=${NANO_ARCH} PORTSDIR=${NANO_PORTS} make \
+ __MAKE_CONF=${NANO_MAKE_CONF_BUILD} \
+ WRKDIRPREFIX=/usr/workdir -C /usr/ports/$port_path \
+ package-recursive BATCH=yes $* clean FORCE_PKG_REGISTER=t"
+ rm ${NANO_WORLDDIR}/etc/resolv.conf
+ rm -rf ${NANO_WORLDDIR}/usr/obj
+ rm -rf ${NANO_WORLDDIR}/usr/workdir
+ umount ${NANO_WORLDDIR}/dev
+ umount ${NANO_WORLDDIR}/usr/ports/packages
+ umount ${NANO_WORLDDIR}/usr/ports/distfiles
+ umount ${NANO_WORLDDIR}/usr/ports
+ umount ${NANO_WORLDDIR}/usr/src
+ set +x
+}
+
+# Need to check if this function works with cross-compiling architecture!!!!
+# Recursive complex fonction: Generate one function for each ports
+add_port () {
+ local port_path=$1
+ local port=`echo $1 | sed -e 's/\//_/'`
+ shift
+ # Check if package allready exist
+ # Need to:
+ # 1. check ARCH of this package!
+ # 2. Add a trap
+ cd ${NANO_PORTS}/${port_path}
+ PKG_NAME=`env PORTSDIR=${NANO_PORTS} make __MAKE_CONF=${NANO_MAKE_CONF_BUILD} package-name`
+ if [ -f ${NANO_OBJ}/ports/packages/All/${PKG_NAME}.txz ]; then
+ # Pkg file found: Generate add_pkg_NAME function
+ eval "
+ add_pkg_${port} () {
+ do_add_pkg ${PKG_NAME}
+ }
+ customize_cmd add_pkg_${port}
+ "
+ else
+ # No pkg file: Generate add_port_NAME function
+ eval "
+ add_port_${port} () {
+ do_add_port ${port_path} $*
+ }
+ customize_cmd add_port_${port}
+ "
+ NANO_PACKAGE_ONLY=0
+ fi
+}
+
+create_diskimage ( ) (
+ local extra
+
+ pprint 2 "build diskimage ${NANO_NAME}"
+ pprint 3 "log: ${NANO_OBJ}/_.di"
+
+ (
+ if [ ! -z ${NANO_NOPRIV_BUILD} ]; then
+ extra="-F ${NANO_OBJ}/_.metalog"
+ fi
+
+ for i in s1 s2 s3 s4 empty; do
+ rm -fr ${NANO_OBJ}/_.${i}*
+ done
+
+ if [ ! -z "${NANO_SLICE_FAT}" ]; then
+ echo Creating MSDOS partition for kernel
+ newfs_msdos -C ${NANO_SLICE_FAT_SIZE:-100m} -F 16 -L ${NANO_NAME} \
+ ${NANO_OBJ}/_.${NANO_SLICE_FAT}
+ fi
+ echo Creating main partition
+ sz=${NANO_SLICE_ROOT_SIZE:+-s ${NANO_SLICE_ROOT_SIZE}}
+ makefs ${extra} -B little $sz -t ffs ${NANO_OBJ}/_.${NANO_SLICE_ROOT}a "${NANO_WORLDDIR}"
+ if [ -z "${NANO_CFGDIR}" ]; then
+ echo "Faking cfg dir, it's empty"
+ NANO_CFGDIR=${NANO_OBJ}/_.empty
+ mkdir ${NANO_CFGDIR}
+ fi
+ echo Creating cfg parittion
+# XXX -F cfg-mtree
+ makefs -B little -t ffs -s ${NANO_SLICE_CFG_SIZE:-100m} \
+ ${NANO_OBJ}/_.${NANO_SLICE_CFG} "${NANO_CFGDIR}"
+ # data slice not supported since we need the part for FAT for
+ # booting
+ echo Slicing up the main partition into a full bsd part
+ mkimg -s bsd -p freebsd-ufs:=${NANO_OBJ}/_.${NANO_SLICE_ROOT}a \
+ -o ${NANO_OBJ}/_.${NANO_SLICE_ROOT}
+ echo Making the whole shooting match
+ if [ ! -z $NANO_SLICE_FAT ]; then
+ eval $NANO_SLICE_FAT=fat16b
+ fi
+ eval $NANO_SLICE_CFG=freebsd
+ eval $NANO_SLICE_ROOT=freebsd
+ if [ ! -z "${NANO_SLICE_FAT}" ]; then
+ mkimg -s mbr -p ${s1}:=${NANO_OBJ}/_.s1 \
+ -p ${s2}:=${NANO_OBJ}/_.s2 \
+ -p ${s3}:=${NANO_OBJ}/_.s3 \
+ -o ${NANO_OBJ}/_.disk.image.${NANO_NAME}
+ else
+ # s1 is cfg, s2 is /, not sure how to make that
+ # boot (marked as active) with mkimg yet
+ mkimg -s mbr -p ${s1}:=${NANO_OBJ}/_.s1 \
+ -p ${s2}:=${NANO_OBJ}/_.s2 \
+ -o ${NANO_OBJ}/_.disk.image.${NANO_NAME}
+ fi
+ ) > ${NANO_OBJ}/_.di 2>&1
+)
+
+die()
+{
+ echo "$*"
+ exit 1
+}
+
+# Automatically include the packaging port here so it is always first so it
+# builds the port and adds the package so we can add other packages.
+#XXX Not sure this works for cross build, so punting for the moment
+#add_port ports-mgmt/pkg
+#add_port security/sudo
+#add_port ftp/curl
+
+rp=$(realpath ${NANO_OBJ}/)
+__a=`mount | grep ${rp} | awk '{print length($3), $3;}' | sort -rn | awk '{$1=""; print;}'`
+if [ -n "$__a" ]; then
+ echo "unmounting $__a"
+ umount $__a
+fi
+
+NANO_BOOTLOADER="boot/boot0"
+
+if [ "$DEBUG" = 1 ]; then
+ DEBUG_BUILD="
+DEBUG_FLAGS= -g
+"
+else
+ DEBUG_INSTALL="
+INSTALL_NODEBUG= t
+"
+fi
+
+CONF_INSTALL="$CONF_BUILD
+${DEBUG_BUILD}
+"
+CONF_INSTALL="$CONF_INSTALL
+${DEBUG_INSTALL}
+"
+
+if [ "${NANO_PACKAGE_ONLY}" -eq 1 ]; then
+ CONF_INSTALL="${CONF_INSTALL}
+${PKG_ONLY_MAKE_CONF}
+"
+ echo "Automatically building a thin image with packages"
+else
+ echo "Automatically building a * * F A T * * image so we can build ports"
+fi
+
+VARS="MASTER_SITE_BACKUP MASTER_SITE_OVERRIDE PACKAGEROOT PACKAGESITE"
+
+for var in $VARS; do
+ val=$(eval echo "\$$var")
+ if [ -n "$val" ]; then
+ CONF_INSTALL="${CONF_INSTALL}
+$var=$val"
+ fi
+done
+
+hack_nsswitch_conf ( )
+{
+ # Remove all references to NIS in the nsswitch.conf file
+ # Not sure this is still needed, but FreeNAS has it...
+ sed -i.bak -es/nis/files/g ${NANO_WORLDDIR}/etc/nsswitch.conf
+ rm -f ${NANO_WORLDDIR}/etc/nsswitch.conf.bak
+}
+customize_cmd hack_nsswitch_conf
+
+save_build ( )
+{
+ VERSION_FILE=${NANO_WORLDDIR}/etc/version
+ if [ "${SVNREVISION}" = "${REVISION}" ]; then
+ echo "${NANO_NAME}" > "${VERSION_FILE}"
+ else
+ echo "${NANO_NAME} (${SVNREVISION})" > "${VERSION_FILE}"
+ fi
+}
+customize_cmd save_build
+
+remove_patch_divots ( )
+{
+ find ${NANO_WORLDDIR} -name \*.orig -or -name \*.rej -delete
+}
+customize_cmd remove_patch_divots
+
+shrink_md_fbsize()
+{
+ # We have a lot of little files on our memory disks. Let's decrease
+ # the block and frag size to fit more little files on them (this
+ # halves our space requirement by ~50% on /etc and /var on 8.x --
+ # and gives us more back on 9.x as the default block and frag size
+ # are 4 times larger).
+ sed -i '' -e 's,-S -i 4096,-S -i 4096 -b 4096 -f 512,' \
+ ${NANO_WORLDDIR}/etc/rc.initdiskless
+}
+customize_cmd shrink_md_fbsize
+
+if [ "${DEBUG}" = 1 ]; then
+
+unmute_console_logging()
+{
+ # /var is small. Don't fill it up with messages from console.log
+ # because it's a chatty log.
+ sed -i '' -e 's/#console.info/console.info/' \
+ "${NANO_WORLDDIR}/etc/syslog.conf"
+}
+customize_cmd unmute_console_logging
+
+fi
+
+product_custom()
+{
+ if [ -z ${NANO_NOPRIV_BUILD} ]; then
+ # Last second tweaks -- generally not needed
+ chown -R root:wheel ${NANO_WORLDDIR}/root
+ chmod 0755 ${NANO_WORLDDIR}/root/*
+ chmod 0755 ${NANO_WORLDDIR}/*
+ chown -R root:wheel ${NANO_WORLDDIR}/etc
+ chown -R root:wheel ${NANO_WORLDDIR}/boot
+ chown root:wheel ${NANO_WORLDDIR}/
+ chown root:wheel ${NANO_WORLDDIR}/usr
+ else
+ # Construct an mtree after our messing around with the tree
+ # Trim out all the uid / gid stuff, since for new files it
+ # is likely wrong, and for other files it doesn't matter.
+ mtree -p ${NANO_WORLDDIR} -c | \
+ mtree -C | \
+ sed -e 's/ uid=[0-9][0-9]* / /g;s/ gid=[0-9][0-9]* / /' \
+ > ${NANO_OBJ}/_.mtree.post
+
+ # Sort the metalog, and save the original. Sadly, this
+ # seems to expand the uname= and gname= to uid= and gid=
+ # which is lame and likely a bug in mtree. The man page
+ # is just vague enough to be infuriating as to the proper
+ # behavior. Happily, it removes all the // that can confound
+ # things.
+ mtree -C -S -f ${NANO_OBJ}/_.metalog > ${NANO_OBJ}/_.mtree.pre
+ mv ${NANO_OBJ}/_.metalog ${NANO_OBJ}/_.metalog.install
+
+ # mtree -f -f produces a comm-like output. The first column will
+ # be the files we deleted, so we ignore it. The second column is
+ # the same in both, so we pass it through. The third column is
+ # listed twice, so we ignore the second one. We also trim out
+ # the size, because size just doesn't matter as nanobsd and
+ # customizations often tweak files changing their size. We also
+ # add 'optional' to every file in case something slipped through
+ # that's gone from the tree, though maybe that's a real bug.
+ #
+ # To make matters worse, currently mtree in freebsd uses the
+ # old 'file' keyword rather than the newer type=file. Ditto
+ # dir and link. Also, nlinks is output, which is lame. And
+ # there's a bloatload of extra flags=none, which I remove too.
+ #
+ # Even worse is that all the uid / gid stuff is also tossed
+ # into the scrap heap. Hope they weren't important.
+ #
+ # And somewhere along the way, flags seem to have gone missing.
+ #
+ # Oh, and we have to add back in ./ to keep makefs happy.
+ #
+ # And then we have to sort the damn hing so directories come
+ # before subdirectories
+ #
+ # Note: For reasons unknown, all the directories are changing
+ # from 755 to 775, so that's why we ignore the second line.
+ # We also get repeats for all the files whose size changed.
+ # Perhaps we should filter those going into the pre/post files
+ # and not here.
+ mtree -f ${NANO_OBJ}/_.mtree.pre -f ${NANO_OBJ}/_.mtree.post | \
+ awk '
+ function frob_bogus_mtree_line(old) {
+ line = "./" old " gid=0 uid=0"
+ # XXX make this a damn function
+ sub(/^\.\/\./, ".", line);
+ sub(/ file /, " type=file ", line);
+ sub(/ dir /, " type=dir ", line);
+ sub(/ link /, " type=link ", line);
+ sub(/ size=[0-9][0-9]*/, "", line);
+ sub(/ nlinks=[0-9][0-9]*/, "", line);
+ sub(/ flags=none*/, "", line);
+ return line;
+ }
+ BEGIN {
+ x = 0;
+ FS="\t";
+ print "#mtree 2.0";
+ }
+ $1 != "" {}
+ $2 != "" {
+ print frob_bogus_mtree_line($2);
+ }
+ $3 != "" {
+ if (x == 0) {
+ print frob_bogus_mtree_line($3);
+ x = 1;
+ } else {
+ x = 0;
+ }
+ }
+ ' | sort > ${NANO_OBJ}/_.metalog
+ fi
+}
+late_customize_cmd product_custom
diff --git a/tools/tools/nanobsd/embedded/qemu-amd64.cfg b/tools/tools/nanobsd/embedded/qemu-amd64.cfg
new file mode 100644
index 0000000..5ca6837
--- /dev/null
+++ b/tools/tools/nanobsd/embedded/qemu-amd64.cfg
@@ -0,0 +1,42 @@
+# $FreeBSD$
+
+#-
+# Copyright (c) 2015 Warner Losh. All Rights Reserved.
+# Copyright (c) 2010-2011 iXsystems, Inc., 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 iXsystems, Inc. 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.
+#
+# This file is heavily derived from both Sam Leffler's Avilia config,
+# as well as the BSDRP project's config file. Neither of these have
+# an explicit copyright/license statement, but are implicitly BSDL. This
+# example has been taken from the FreeNAS project and simplified to meet
+# the needs of the example.
+#
+
+NANO_ARCH=amd64
+NANO_KERNEL=GENERIC
+NANO_DRIVE=ada0
+NANO_NAME=qemu-amd64
+
+export EMBED_OMIT_FAT=t
+
+. common # Pull in common definitions, keep last
diff --git a/tools/tools/nanobsd/embedded/qemu-i386.cfg b/tools/tools/nanobsd/embedded/qemu-i386.cfg
new file mode 100644
index 0000000..856f61f
--- /dev/null
+++ b/tools/tools/nanobsd/embedded/qemu-i386.cfg
@@ -0,0 +1,42 @@
+# $FreeBSD$
+
+#-
+# Copyright (c) 2015 Warner Losh. All Rights Reserved.
+# Copyright (c) 2010-2011 iXsystems, Inc., 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 iXsystems, Inc. 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.
+#
+# This file is heavily derived from both Sam Leffler's Avilia config,
+# as well as the BSDRP project's config file. Neither of these have
+# an explicit copyright/license statement, but are implicitly BSDL. This
+# example has been taken from the FreeNAS project and simplified to meet
+# the needs of the example.
+#
+
+NANO_ARCH=i386
+NANO_KERNEL=GENERIC
+NANO_DRIVE=ada0
+NANO_NAME=qemu-i386
+
+export EMBED_OMIT_FAT=t
+
+. common # Pull in common definitions, keep last
diff --git a/tools/tools/nanobsd/embedded/qemu-mips.cfg b/tools/tools/nanobsd/embedded/qemu-mips.cfg
new file mode 100644
index 0000000..9b9581d
--- /dev/null
+++ b/tools/tools/nanobsd/embedded/qemu-mips.cfg
@@ -0,0 +1,42 @@
+# $FreeBSD$
+
+#-
+# Copyright (c) 2015 Warner Losh. All Rights Reserved.
+# Copyright (c) 2010-2011 iXsystems, Inc., 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 iXsystems, Inc. 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.
+#
+# This file is heavily derived from both Sam Leffler's Avilia config,
+# as well as the BSDRP project's config file. Neither of these have
+# an explicit copyright/license statement, but are implicitly BSDL. This
+# example has been taken from the FreeNAS project and simplified to meet
+# the needs of the example.
+#
+
+NANO_ARCH=mips
+NANO_KERNEL=MALTA
+NANO_DRIVE=ada0
+NANO_NAME=qemu-mips
+
+export EMBED_OMIT_FAT=t
+
+. common # Pull in common definitions, keep last
diff --git a/tools/tools/nanobsd/embedded/qemu-mips64.cfg b/tools/tools/nanobsd/embedded/qemu-mips64.cfg
new file mode 100644
index 0000000..9ac22cd
--- /dev/null
+++ b/tools/tools/nanobsd/embedded/qemu-mips64.cfg
@@ -0,0 +1,42 @@
+# $FreeBSD$
+
+#-
+# Copyright (c) 2015 Warner Losh. All Rights Reserved.
+# Copyright (c) 2010-2011 iXsystems, Inc., 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 iXsystems, Inc. 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.
+#
+# This file is heavily derived from both Sam Leffler's Avilia config,
+# as well as the BSDRP project's config file. Neither of these have
+# an explicit copyright/license statement, but are implicitly BSDL. This
+# example has been taken from the FreeNAS project and simplified to meet
+# the needs of the example.
+#
+
+NANO_ARCH=mips
+NANO_KERNEL=MALTA64
+NANO_DRIVE=ada0
+NANO_NAME=qemu-mips64
+
+export EMBED_OMIT_FAT=t
+
+. common # Pull in common definitions, keep last
diff --git a/tools/tools/nanobsd/embedded/qemu-powerpc.cfg b/tools/tools/nanobsd/embedded/qemu-powerpc.cfg
new file mode 100644
index 0000000..8c588b1
--- /dev/null
+++ b/tools/tools/nanobsd/embedded/qemu-powerpc.cfg
@@ -0,0 +1,43 @@
+# $FreeBSD$
+
+#-
+# Copyright (c) 2015 Warner Losh. All Rights Reserved.
+# Copyright (c) 2010-2011 iXsystems, Inc., 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 iXsystems, Inc. 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.
+#
+# This file is heavily derived from both Sam Leffler's Avilia config,
+# as well as the BSDRP project's config file. Neither of these have
+# an explicit copyright/license statement, but are implicitly BSDL. This
+# example has been taken from the FreeNAS project and simplified to meet
+# the needs of the example.
+#
+
+# Open question: do we have one for MAC G4 and one for Book-E?
+NANO_ARCH=powerpc
+NANO_KERNEL=GENERIC
+NANO_DRIVE=ada0
+NANO_NAME=qemu-powerpc
+
+export EMBED_OMIT_FAT=t
+
+. common # Pull in common definitions, keep last
diff --git a/tools/tools/nanobsd/embedded/qemu-powerpc64.cfg b/tools/tools/nanobsd/embedded/qemu-powerpc64.cfg
new file mode 100644
index 0000000..1563472
--- /dev/null
+++ b/tools/tools/nanobsd/embedded/qemu-powerpc64.cfg
@@ -0,0 +1,42 @@
+# $FreeBSD$
+
+#-
+# Copyright (c) 2015 Warner Losh. All Rights Reserved.
+# Copyright (c) 2010-2011 iXsystems, Inc., 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 iXsystems, Inc. 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.
+#
+# This file is heavily derived from both Sam Leffler's Avilia config,
+# as well as the BSDRP project's config file. Neither of these have
+# an explicit copyright/license statement, but are implicitly BSDL. This
+# example has been taken from the FreeNAS project and simplified to meet
+# the needs of the example.
+#
+
+NANO_ARCH=powerpc64
+NANO_KERNEL=GENERIC64
+NANO_DRIVE=ada0
+NANO_NAME=qemu-powerpc64
+
+export EMBED_OMIT_FAT=t
+
+. common # Pull in common definitions, keep last
diff --git a/tools/tools/nanobsd/embedded/qemu-sparc64.cfg b/tools/tools/nanobsd/embedded/qemu-sparc64.cfg
new file mode 100644
index 0000000..656fcef
--- /dev/null
+++ b/tools/tools/nanobsd/embedded/qemu-sparc64.cfg
@@ -0,0 +1,42 @@
+# $FreeBSD$
+
+#-
+# Copyright (c) 2015 Warner Losh. All Rights Reserved.
+# Copyright (c) 2010-2011 iXsystems, Inc., 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 iXsystems, Inc. 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.
+#
+# This file is heavily derived from both Sam Leffler's Avilia config,
+# as well as the BSDRP project's config file. Neither of these have
+# an explicit copyright/license statement, but are implicitly BSDL. This
+# example has been taken from the FreeNAS project and simplified to meet
+# the needs of the example.
+#
+
+NANO_ARCH=sparc64
+NANO_KERNEL=GENERIC
+NANO_DRIVE=ada0
+NANO_NAME=qemu-sparc64
+
+export EMBED_OMIT_FAT=t
+
+. common # Pull in common definitions, keep last
diff --git a/tools/tools/nanobsd/embedded/rpi.cfg b/tools/tools/nanobsd/embedded/rpi.cfg
new file mode 100644
index 0000000..598de19
--- /dev/null
+++ b/tools/tools/nanobsd/embedded/rpi.cfg
@@ -0,0 +1,42 @@
+# $FreeBSD$
+
+#-
+# Copyright (c) 2015 Warner Losh. All Rights Reserved.
+# Copyright (c) 2010-2011 iXsystems, Inc., 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 iXsystems, Inc. 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.
+#
+# This file is heavily derived from both Sam Leffler's Avilia config,
+# as well as the BSDRP project's config file. Neither of these have
+# an explicit copyright/license statement, but are implicitly BSDL. This
+# example has been taken from the FreeNAS project and simplified to meet
+# the needs of the example.
+#
+
+NANO_ARCH=armv6
+NANO_KERNEL=RPI-B
+NANO_DRIVE=mmcsd0
+NANO_NAME=rpi-b
+NANO_BOOT_PKG=u-boot-rpi
+NANO_CPUTYPE=arm1176jzf-s
+
+. common # Pull in common definitions, keep last
diff --git a/tools/tools/nanobsd/embedded/rpi2.cfg b/tools/tools/nanobsd/embedded/rpi2.cfg
new file mode 100644
index 0000000..043874c
--- /dev/null
+++ b/tools/tools/nanobsd/embedded/rpi2.cfg
@@ -0,0 +1,42 @@
+# $FreeBSD$
+
+#-
+# Copyright (c) 2015 Warner Losh. All Rights Reserved.
+# Copyright (c) 2010-2011 iXsystems, Inc., 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 iXsystems, Inc. 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.
+#
+# This file is heavily derived from both Sam Leffler's Avilia config,
+# as well as the BSDRP project's config file. Neither of these have
+# an explicit copyright/license statement, but are implicitly BSDL. This
+# example has been taken from the FreeNAS project and simplified to meet
+# the needs of the example.
+#
+
+NANO_ARCH=armv6
+NANO_KERNEL=RPI2
+NANO_DRIVE=mmcsd0
+NANO_NAME=rpi2
+NANO_BOOT_PKG=u-boot-rpi2
+NANO_CPUTYPE=cortex-a7
+
+. common # Pull in common definitions, keep last
diff --git a/tools/tools/nanobsd/embedded/sam9260ek.cfg b/tools/tools/nanobsd/embedded/sam9260ek.cfg
new file mode 100644
index 0000000..fec892a
--- /dev/null
+++ b/tools/tools/nanobsd/embedded/sam9260ek.cfg
@@ -0,0 +1,41 @@
+# $FreeBSD$
+
+#-
+# Copyright (c) 2015 Warner Losh. All Rights Reserved.
+# Copyright (c) 2010-2011 iXsystems, Inc., 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 iXsystems, Inc. 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.
+#
+# This file is heavily derived from both Sam Leffler's Avilia config,
+# as well as the BSDRP project's config file. Neither of these have
+# an explicit copyright/license statement, but are implicitly BSDL. This
+# example has been taken from the FreeNAS project and simplified to meet
+# the needs of the example.
+#
+
+NANO_ARCH=arm
+NANO_KERNEL=SAM9260EK
+NANO_DRIVE=mmcsd0
+NANO_NAME=sam9260ek
+NANO_CPUTYPE=arm926ej-s
+
+. common # Pull in common definitions, keep last
diff --git a/tools/tools/nanobsd/embedded/sam9g20ek.cfg b/tools/tools/nanobsd/embedded/sam9g20ek.cfg
new file mode 100644
index 0000000..8fe67d4
--- /dev/null
+++ b/tools/tools/nanobsd/embedded/sam9g20ek.cfg
@@ -0,0 +1,41 @@
+# $FreeBSD$
+
+#-
+# Copyright (c) 2015 Warner Losh. All Rights Reserved.
+# Copyright (c) 2010-2011 iXsystems, Inc., 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 iXsystems, Inc. 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.
+#
+# This file is heavily derived from both Sam Leffler's Avilia config,
+# as well as the BSDRP project's config file. Neither of these have
+# an explicit copyright/license statement, but are implicitly BSDL. This
+# example has been taken from the FreeNAS project and simplified to meet
+# the needs of the example.
+#
+
+NANO_ARCH=arm
+NANO_KERNEL=SAM9G20EK
+NANO_DRIVE=mmcsd0
+NANO_NAME=sam9g20ek
+NANO_CPUTYPE=arm926ej-s
+
+. common # Pull in common definitions, keep last
diff --git a/tools/tools/nanobsd/mtree-dedup.awk b/tools/tools/nanobsd/mtree-dedup.awk
new file mode 100755
index 0000000..17aa5e2
--- /dev/null
+++ b/tools/tools/nanobsd/mtree-dedup.awk
@@ -0,0 +1,197 @@
+#!/usr/bin/awk -f
+
+#
+# Copyright (c) 2015 M. Warner Losh.
+# 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.
+#
+# $FreeBSD$
+#
+
+#
+# Takes a meta-log created by installworld and friends, plus
+# additions from NanoBSD to augment its build to communicate when
+# files move around after installworld / installkernel phase of
+# NanoBSD.
+#
+# All mtree lines from the metafile have a path, followed by
+# a number of keywords.
+#
+# This script recognizes the following new keywords
+#
+# unlink[=x] remove the path from the output.
+# copy_from=x create new entry for path copied from
+# the keywords from x.
+# move_from=x create new entry for path copied from
+# the keywords from x. Remove path from
+# the output.
+#
+# In addition, when path matches a previous entry, the
+# new entry and previous entry are merged.
+#
+# Special note: when uid and uname are both present,
+# uid is ignored. Ditto gid/gname.
+#
+# Also, the paths above have to match exactly, so X
+# should start with "./".
+#
+
+function die(str)
+{
+ print str > "/dev/stderr";
+ exit 1;
+}
+
+function kv(str)
+{
+ if (split(str, xxx, "=") == 2) {
+ kv_key = xxx[1];
+ kv_value = xxx[2];
+ } else {
+ kv_key = str;
+ kv_value = nv;
+ }
+}
+
+# Output the mtree for path based on the kvs.
+function mtree_from_kvs(path, kvs)
+{
+ lv = path " ";
+ for (k in kvs) {
+ if (kvs[k] == nv)
+ lv = lv k " ";
+ else
+ lv = lv k "=" kvs[k] " ";
+ }
+ return lv;
+}
+
+# Parse the mtree line into path + KVs. Use a sentinal value
+# for a bare keyword, which is extremely unlikely to be used
+# for real.
+function line2kv(kvs, str)
+{
+ delete kvs;
+
+ n = split(str, yyy, " ");
+ for (i = 2; i <= n; i++) {
+ s = yyy[i];
+ if (split(s, xxx, "=") == 2)
+ kvs[xxx[1]] = xxx[2];
+ else
+ kvs[s] = nv;
+ }
+}
+
+
+# old += new
+function merge_kvs(old, new)
+{
+ for (k in new) {
+ # uname / uid -- last one wins.
+ if (k == "uid" && "uname" in old)
+ delete old["uname"]
+ if (k == "uname" && "uid" in old)
+ delete old["uid"];
+ # gname / gid -- last one wins.
+ if (k == "gid" && "gname" in old)
+ delete old["gname"]
+ if (k == "gname" && "gid" in old)
+ delete old["gid"];
+ # Otherwise newest value wins
+ old[k] = new[k];
+ }
+}
+
+# Process the line we've read in, per the comments below
+function process_line(path, new)
+{
+ # Clear kvs
+ line2kv(new_kvs, new);
+
+ if ("unlink" in new_kvs) {
+ # A file removed
+ # Sanity check to see if tree[path] exists?
+ # Makes sure when foo/bar/baz exists and foo/bar
+ # unlinked, baz is gone (for all baz).
+ if (path !~ "^\./")
+ die("bad path in : " new);
+ delete tree[path]; # unlink
+ return;
+ # } else if (new_kvs["append_from"]) { # not implemented
+ } else if ("copy_from" in new_kvs) {
+ # A file copied from another location, preserve its
+ # attribute for new file.
+ # Also merge any new attributes from this line.
+ from = new_kvs["copy_from"];
+ if (from !~ "^\./")
+ die("bad path in : " new);
+ delete new_kvs["copy_from"];
+ line2kv(old_kvs, tree[from]); # old_kvs = kv's in entry
+ merge_kvs(old_kvs, new_kvs); # old_kvs += new_kvs
+ tree[path] = mtree_from_kvs(path, old_kvs);
+ } else if ("move_from" in new_kvs) {
+ # A file moved from another location, preserve its
+ # attribute for new file, and scrag old location
+ # Also merge any new attributes from this line.
+ from = new_kvs["move_from"];
+ if (from !~ "^\./")
+ die("bad path in : " new);
+ delete new_kvs["move_from"];
+ line2kv(old_kvs, tree[from]); # old_kvs = kv's in entry
+ merge_kvs(old_kvs, new_kvs); # old_kvs += new_kvs
+ tree[path] = mtree_from_kvs(path, old_kvs);
+ delete tree[from]; # unlink
+ } else if (tree[path]) { # Update existing entry with new line
+ line2kv(old_kvs, tree[path]); # old_kvs = kv's in entry
+ merge_kvs(old_kvs, new_kvs); # old_kvs += new_kvs
+ tree[path] = mtree_from_kvs(path, old_kvs);
+ } else { # Add entry plus defaults
+ delete old_kvs;
+ merge_kvs(old_kvs, defaults);
+ merge_kvs(old_kvs, new_kvs);
+ tree[path] = mtree_from_kvs(path, old_kvs);
+ }
+}
+
+BEGIN {
+ nv = "___NO__VALUE___";
+
+ while ((getline < "/dev/stdin") > 0) {
+ if ($1 == "/set") {
+ for (i = 2; i <= NF; i++) {
+ kv($i);
+ defaults[kv_key] = kv_value;
+ }
+ } else if ($1 == "/unset") {
+ for (i = 2; i <= NF; i++) {
+ kv($i);
+ delete defaults[kv_key];
+ }
+ } else
+ process_line($1, $0);
+ }
+
+ for (x in tree)
+ print tree[x];
+}
diff --git a/tools/tools/nanobsd/pcengines/ALIX_NFS b/tools/tools/nanobsd/pcengines/ALIX_NFS
index 6555ed5..ca7f57b 100644
--- a/tools/tools/nanobsd/pcengines/ALIX_NFS
+++ b/tools/tools/nanobsd/pcengines/ALIX_NFS
@@ -2,119 +2,8 @@
# $FreeBSD$
#
-cpu I586_CPU
-ident ALIX_DSK
-makeoptions DEBUG=-g
-options CPU_GEODE
-options SCHED_ULE
-options PREEMPTION
-options INET
-options INET6
-options FFS
-options SOFTUPDATES
-options UFS_ACL
-options UFS_DIRHASH
-options NFSCL # Network Filesystem Client
-options NFSLOCKD
-options MSDOSFS
-options CD9660
-options PROCFS
-options PSEUDOFS
-options GEOM_PART_GPT
-options GEOM_LABEL
-options COMPAT_43TTY
-options COMPAT_FREEBSD4 # Compatible with FreeBSD4
-options COMPAT_FREEBSD5 # Compatible with FreeBSD5
-options COMPAT_FREEBSD6 # Compatible with FreeBSD6
-options COMPAT_FREEBSD7 # Compatible with FreeBSD7
-options COMPAT_FREEBSD9 # Compatible with FreeBSD9
-options COMPAT_FREEBSD10 # Compatible with FreeBSD10
-options SCSI_DELAY=5000
-options SYSVSHM
-options SYSVMSG
-options SYSVSEM
-options P1003_1B_SEMAPHORES
-options _KPOSIX_PRIORITY_SCHEDULING
-options PRINTF_BUFR_SIZE=128
-device apic
-device pci
-device fdc
-device ata
-device atadisk
-device atapicd
-device atapist
-options ATA_STATIC_ID
-device scbus
-device da
-device sa
-device cd
-device pass
-device uart
-device em
-device miibus
-device vr
-device wlan
-options IEEE80211_DEBUG
-options IEEE80211_AMPDU_AGE
-options IEEE80211_SUPPORT_MESH
-device wlan_wep
-device wlan_ccmp
-device wlan_tkip
-device wlan_amrr
-device an
-device ath
-device ath_hal
-options AH_SUPPORT_AR5416
-device ath_rate_sample
-device wi
-device loop
-device random
-device ether
-device tun
-device pty
-device md
-device gif
-device firmware
-device bpf
-device uhci
-device ohci
-device ehci
-device usb
-device ulpt
-device umass
-device u3g
-device ubsa
-device uftdi
-
-options INCLUDE_CONFIG_FILE
-
-options ALTQ
-options ALTQ_CBQ
-options ALTQ_RED
-options ALTQ_RIO
-options ALTQ_HFSC
-options ALTQ_CDNR
-options ALTQ_PRIQ
-
-device pf
-device pflog
-device pfsync
-device carp
-device if_bridge
-
-options DEVICE_POLLING
-
-options NETGRAPH
-options NETGRAPH_BPF
-options NETGRAPH_ETHER
-options NETGRAPH_IFACE
-options NETGRAPH_PPP
-options NETGRAPH_PPPOE
-options NETGRAPH_PPTPGRE
-options NETGRAPH_MPPC_ENCRYPTION
-options NETGRAPH_SOCKET
-options NETGRAPH_KSOCKET
-options NETGRAPH_VJC
+include ALIX_DSK
+ident ALIX_NFS
options NFS_ROOT
options BOOTP
diff --git a/tools/tools/nanobsd/pcengines/common.conf b/tools/tools/nanobsd/pcengines/common.conf
index 40275dd..687fd74 100644
--- a/tools/tools/nanobsd/pcengines/common.conf
+++ b/tools/tools/nanobsd/pcengines/common.conf
@@ -13,9 +13,6 @@ NANO_RAM_TMPVARSIZE=40960
NANO_PMAKE="make -j 8"
NANO_MD_BACKING="swap"
-#NANO_MAKEFS="makefs \
-# -o bsize=4096,fsize=512,density=8192,optimization=space"
-#export NANO_MAKEFS
# Options to put in make.conf during buildworld only
CONF_BUILD='
@@ -26,7 +23,6 @@ CONF_INSTALL='
'
# Options to put in make.conf during both build- & installworld.
CONF_WORLD='
-#TARGET_ARCH=i386
CFLAGS=-O -pipe
WITHOUT_ACPI=
WITHOUT_TESTS=
diff --git a/tools/tools/ncpus/Makefile b/tools/tools/ncpus/Makefile
index 011f49e..b2683e1 100644
--- a/tools/tools/ncpus/Makefile
+++ b/tools/tools/ncpus/Makefile
@@ -9,7 +9,6 @@ SRCS+= biosmptable.c
BINDIR= /usr/local/bin
WARNS?= 6
-DPADD= ${LIBDEVINFO}
-LDADD= -ldevinfo
+LIBADD= devinfo
.include <bsd.prog.mk>
diff --git a/tools/tools/net80211/stumbler/Makefile b/tools/tools/net80211/stumbler/Makefile
index e7ea87c..e840be7 100644
--- a/tools/tools/net80211/stumbler/Makefile
+++ b/tools/tools/net80211/stumbler/Makefile
@@ -2,8 +2,7 @@
PROG= stumbler
BINDIR= /usr/local/bin
-DPADD= ${LIBPCAP} ${LIBNCURSESW}
-LDADD= -lpcap -lncursesw
+LIBADD= pcap ncursesw
CFLAGS=-g
MAN=
diff --git a/tools/tools/net80211/wesside/dics/Makefile b/tools/tools/net80211/wesside/dics/Makefile
index 4f368e3..96583cf 100644
--- a/tools/tools/net80211/wesside/dics/Makefile
+++ b/tools/tools/net80211/wesside/dics/Makefile
@@ -2,8 +2,7 @@
PROG= dics
BINDIR= /usr/local/bin
-DPADD= ${LIBZ}
-LDADD= -lz
+LIBADD= z
CFLAGS=-g
MAN=
diff --git a/tools/tools/net80211/wesside/udps/Makefile b/tools/tools/net80211/wesside/udps/Makefile
index caa2fc0..b4dd203 100644
--- a/tools/tools/net80211/wesside/udps/Makefile
+++ b/tools/tools/net80211/wesside/udps/Makefile
@@ -2,8 +2,7 @@
PROG= udps
BINDIR= /usr/local/bin
-DPADD= ${LIBZ}
-LDADD= -lz
+LIBADD= z
CFLAGS=-g
MAN=
diff --git a/tools/tools/net80211/wesside/wesside/Makefile b/tools/tools/net80211/wesside/wesside/Makefile
index 5c39407..65942e5 100644
--- a/tools/tools/net80211/wesside/wesside/Makefile
+++ b/tools/tools/net80211/wesside/wesside/Makefile
@@ -2,8 +2,7 @@
PROG= wesside
BINDIR= /usr/local/bin
-DPADD= ${LIBZ}
-LDADD= -lz
+LIBADD= z
CFLAGS=-g
MAN=
SRCS=wesside.c aircrack-ptw-lib.c
diff --git a/tools/tools/netrate/http/Makefile b/tools/tools/netrate/http/Makefile
index d501e61..bd144b5 100644
--- a/tools/tools/netrate/http/Makefile
+++ b/tools/tools/netrate/http/Makefile
@@ -3,7 +3,6 @@
PROG= http
MAN=
WARNS?= 3
-DPADD= ${LIBPTHREAD}
-LDADD= -lpthread
+LIBADD= pthread
.include <bsd.prog.mk>
diff --git a/tools/tools/netrate/httpd/Makefile b/tools/tools/netrate/httpd/Makefile
index 2318dae..6acbe64 100644
--- a/tools/tools/netrate/httpd/Makefile
+++ b/tools/tools/netrate/httpd/Makefile
@@ -3,7 +3,6 @@
PROG= httpd
MAN=
WARNS?= 3
-DPADD= ${LIBPTHREAD}
-LDADD= -lpthread
+LIBADD= pthread
.include <bsd.prog.mk>
diff --git a/tools/tools/netrate/juggle/Makefile b/tools/tools/netrate/juggle/Makefile
index 751bbb5..f7b7afd 100644
--- a/tools/tools/netrate/juggle/Makefile
+++ b/tools/tools/netrate/juggle/Makefile
@@ -3,7 +3,6 @@
PROG= juggle
MAN=
WARNS?= 3
-DPADD= ${LIBPTHREAD}
-LDADD= -lpthread
+LIBADD= pthread
.include <bsd.prog.mk>
diff --git a/tools/tools/tscdrift/Makefile b/tools/tools/tscdrift/Makefile
index 0b5c8ac..fad714d 100644
--- a/tools/tools/tscdrift/Makefile
+++ b/tools/tools/tscdrift/Makefile
@@ -4,7 +4,6 @@ PROG= tscdrift
MAN=
WARNS?= 6
-LDADD= -lpthread -lm
-DPADD= ${LIBPTHREAD} ${LIBM}
+LIBADD= pthread m
.include <bsd.prog.mk>
diff --git a/tools/tools/umastat/Makefile b/tools/tools/umastat/Makefile
index 8160936..92cd50e 100644
--- a/tools/tools/umastat/Makefile
+++ b/tools/tools/umastat/Makefile
@@ -4,7 +4,6 @@ PROG= umastat
MAN=
WARNS?= 3
-DPADD= ${LIBKVM}
-LDADD= -lkvm
+LIBADD= kvm
.include <bsd.prog.mk>
diff --git a/tools/tools/usbtest/Makefile b/tools/tools/usbtest/Makefile
index f9b16bc..b535f52 100644
--- a/tools/tools/usbtest/Makefile
+++ b/tools/tools/usbtest/Makefile
@@ -33,8 +33,7 @@ SRCS+= usb_modem_test.c
SRCS+= usb_control_ep_test.c
SYSDIR?= ${.CURDIR}/../../../sys
-DPADD+= ${LIBUSB}
-LDADD+= -lusb
+LIBADD+= usb
WARNS= 3
diff --git a/tools/tools/vimage/Makefile b/tools/tools/vimage/Makefile
index 76c7617..262e3c6 100644
--- a/tools/tools/vimage/Makefile
+++ b/tools/tools/vimage/Makefile
@@ -1,8 +1,7 @@
# $FreeBSD$
PROG= vimage
-LDADD= -ljail
-DPADD= ${LIBJAIL}
+LIBADD= jail
WARNS?= 2
CFLAGS+= -I../../../sys
diff --git a/tools/tools/zfsboottest/Makefile b/tools/tools/zfsboottest/Makefile
index 7362073..4b08a2d 100644
--- a/tools/tools/zfsboottest/Makefile
+++ b/tools/tools/zfsboottest/Makefile
@@ -17,7 +17,7 @@ CFLAGS= -O1 \
-fdiagnostics-show-option \
-W -Wextra -Wno-sign-compare -Wno-unused-parameter
CFLAGS+=-m32
-LDADD+= -lmd
+LIBADD+= md
.if ${MACHINE_CPUARCH} == "amd64"
beforedepend zfsboottest.o: machine
OpenPOWER on IntegriCloud