svn commit: r293406 - in projects/sendfile: bin/sh libexec/rtld-elf share/man/man4 sys/dev/ioat sys/kern tools/tools/nanobsd tools/tools/nanobsd/embedded

Gleb Smirnoff glebius at FreeBSD.org
Fri Jan 8 01:18:13 UTC 2016


Author: glebius
Date: Fri Jan  8 01:18:10 2016
New Revision: 293406
URL: https://svnweb.freebsd.org/changeset/base/293406

Log:
  Merge head r261119 through r293405.

Modified:
  projects/sendfile/bin/sh/expand.c
  projects/sendfile/bin/sh/options.c
  projects/sendfile/bin/sh/options.h
  projects/sendfile/bin/sh/var.c
  projects/sendfile/libexec/rtld-elf/rtld.c
  projects/sendfile/libexec/rtld-elf/rtld.h
  projects/sendfile/share/man/man4/ioat.4
  projects/sendfile/sys/dev/ioat/ioat.c
  projects/sendfile/sys/dev/ioat/ioat.h
  projects/sendfile/sys/kern/uipc_usrreq.c
  projects/sendfile/tools/tools/nanobsd/defaults.sh
  projects/sendfile/tools/tools/nanobsd/embedded/common
Directory Properties:
  projects/sendfile/   (props changed)
  projects/sendfile/share/   (props changed)
  projects/sendfile/share/man/man4/   (props changed)
  projects/sendfile/sys/   (props changed)

Modified: projects/sendfile/bin/sh/expand.c
==============================================================================
--- projects/sendfile/bin/sh/expand.c	Fri Jan  8 01:16:03 2016	(r293405)
+++ projects/sendfile/bin/sh/expand.c	Fri Jan  8 01:18:10 2016	(r293406)
@@ -951,8 +951,8 @@ varvalue(const char *name, int quoted, i
 	case '-':
 		p = buf;
 		for (i = 0 ; i < NSHORTOPTS ; i++) {
-			if (optlist[i].val)
-				*p++ = optlist[i].letter;
+			if (optval[i])
+				*p++ = optletter[i];
 		}
 		*p = '\0';
 		strtodest(buf, flag, subtype, quoted, dst);

Modified: projects/sendfile/bin/sh/options.c
==============================================================================
--- projects/sendfile/bin/sh/options.c	Fri Jan  8 01:16:03 2016	(r293405)
+++ projects/sendfile/bin/sh/options.c	Fri Jan  8 01:18:10 2016	(r293406)
@@ -91,7 +91,7 @@ procargs(int argc, char **argv)
 	if (argc > 0)
 		argptr++;
 	for (i = 0; i < NOPTS; i++)
-		optlist[i].val = 2;
+		optval[i] = 2;
 	privileged = (getuid() != geteuid() || getgid() != getegid());
 	options(1);
 	if (*argptr == NULL && minusc == NULL)
@@ -104,8 +104,8 @@ procargs(int argc, char **argv)
 	if (mflag == 2)
 		mflag = iflag;
 	for (i = 0; i < NOPTS; i++)
-		if (optlist[i].val == 2)
-			optlist[i].val = 0;
+		if (optval[i] == 2)
+			optval[i] = 0;
 	arg0 = argv[0];
 	if (sflag == 0 && minusc == NULL) {
 		scriptname = *argptr++;
@@ -250,26 +250,29 @@ static void
 minus_o(char *name, int val)
 {
 	int i;
+	const unsigned char *on;
+	size_t len;
 
 	if (name == NULL) {
 		if (val) {
 			/* "Pretty" output. */
 			out1str("Current option settings\n");
-			for (i = 0; i < NOPTS; i++)
-				out1fmt("%-16s%s\n", optlist[i].name,
-					optlist[i].val ? "on" : "off");
+			for (i = 0, on = optname; i < NOPTS; i++, on += *on + 1)
+				out1fmt("%-16.*s%s\n", *on, on + 1,
+					optval[i] ? "on" : "off");
 		} else {
 			/* Output suitable for re-input to shell. */
-			for (i = 0; i < NOPTS; i++)
-				out1fmt("%s %co %s%s",
+			for (i = 0, on = optname; i < NOPTS; i++, on += *on + 1)
+				out1fmt("%s %co %.*s%s",
 				    i % 6 == 0 ? "set" : "",
-				    optlist[i].val ? '-' : '+',
-				    optlist[i].name,
+				    optval[i] ? '-' : '+',
+				    *on, on + 1,
 				    i % 6 == 5 || i == NOPTS - 1 ? "\n" : "");
 		}
 	} else {
-		for (i = 0; i < NOPTS; i++)
-			if (equal(name, optlist[i].name)) {
+		len = strlen(name);
+		for (i = 0, on = optname; i < NOPTS; i++, on += *on + 1)
+			if (*on == len && memcmp(on + 1, name, len) == 0) {
 				setoptionbyindex(i, val);
 				return;
 			}
@@ -281,18 +284,18 @@ minus_o(char *name, int val)
 static void
 setoptionbyindex(int idx, int val)
 {
-	if (optlist[idx].letter == 'p' && !val && privileged) {
+	if (optletter[idx] == 'p' && !val && privileged) {
 		if (setgid(getgid()) == -1)
 			error("setgid");
 		if (setuid(getuid()) == -1)
 			error("setuid");
 	}
-	optlist[idx].val = val;
+	optval[idx] = val;
 	if (val) {
 		/* #%$ hack for ksh semantics */
-		if (optlist[idx].letter == 'V')
+		if (optletter[idx] == 'V')
 			Eflag = 0;
-		else if (optlist[idx].letter == 'E')
+		else if (optletter[idx] == 'E')
 			Vflag = 0;
 	}
 }
@@ -303,7 +306,7 @@ setoption(int flag, int val)
 	int i;
 
 	for (i = 0; i < NSHORTOPTS; i++)
-		if (optlist[i].letter == flag) {
+		if (optletter[i] == flag) {
 			setoptionbyindex(i, val);
 			return;
 		}

Modified: projects/sendfile/bin/sh/options.h
==============================================================================
--- projects/sendfile/bin/sh/options.h	Fri Jan  8 01:16:03 2016	(r293405)
+++ projects/sendfile/bin/sh/options.h	Fri Jan  8 01:18:10 2016	(r293406)
@@ -45,60 +45,57 @@ struct shparam {
 
 
 
-#define eflag optlist[0].val
-#define fflag optlist[1].val
-#define Iflag optlist[2].val
-#define iflag optlist[3].val
-#define mflag optlist[4].val
-#define nflag optlist[5].val
-#define sflag optlist[6].val
-#define xflag optlist[7].val
-#define vflag optlist[8].val
-#define Vflag optlist[9].val
-#define	Eflag optlist[10].val
-#define	Cflag optlist[11].val
-#define	aflag optlist[12].val
-#define	bflag optlist[13].val
-#define	uflag optlist[14].val
-#define	privileged optlist[15].val
-#define	Tflag optlist[16].val
-#define	Pflag optlist[17].val
-#define	hflag optlist[18].val
-#define	nologflag optlist[19].val
+#define eflag optval[0]
+#define fflag optval[1]
+#define Iflag optval[2]
+#define iflag optval[3]
+#define mflag optval[4]
+#define nflag optval[5]
+#define sflag optval[6]
+#define xflag optval[7]
+#define vflag optval[8]
+#define Vflag optval[9]
+#define	Eflag optval[10]
+#define	Cflag optval[11]
+#define	aflag optval[12]
+#define	bflag optval[13]
+#define	uflag optval[14]
+#define	privileged optval[15]
+#define	Tflag optval[16]
+#define	Pflag optval[17]
+#define	hflag optval[18]
+#define	nologflag optval[19]
 
 #define NSHORTOPTS	19
 #define NOPTS		20
 
-struct optent {
-	const char *name;
-	const char letter;
-	char val;
-};
-
-extern struct optent optlist[NOPTS];
+extern char optval[NOPTS];
+extern const char optletter[NSHORTOPTS];
 #ifdef DEFINE_OPTIONS
-struct optent optlist[NOPTS] = {
-	{ "errexit",	'e',	0 },
-	{ "noglob",	'f',	0 },
-	{ "ignoreeof",	'I',	0 },
-	{ "interactive",'i',	0 },
-	{ "monitor",	'm',	0 },
-	{ "noexec",	'n',	0 },
-	{ "stdin",	's',	0 },
-	{ "xtrace",	'x',	0 },
-	{ "verbose",	'v',	0 },
-	{ "vi",		'V',	0 },
-	{ "emacs",	'E',	0 },
-	{ "noclobber",	'C',	0 },
-	{ "allexport",	'a',	0 },
-	{ "notify",	'b',	0 },
-	{ "nounset",	'u',	0 },
-	{ "privileged",	'p',	0 },
-	{ "trapsasync",	'T',	0 },
-	{ "physical",	'P',	0 },
-	{ "trackall",	'h',	0 },
-	{ "nolog",	'\0',	0 },
-};
+char optval[NOPTS];
+const char optletter[NSHORTOPTS] = "efIimnsxvVECabupTPh";
+static const unsigned char optname[] =
+	"\007errexit"
+	"\006noglob"
+	"\011ignoreeof"
+	"\013interactive"
+	"\007monitor"
+	"\006noexec"
+	"\005stdin"
+	"\006xtrace"
+	"\007verbose"
+	"\002vi"
+	"\005emacs"
+	"\011noclobber"
+	"\011allexport"
+	"\006notify"
+	"\007nounset"
+	"\012privileged"
+	"\012trapsasync"
+	"\010physical"
+	"\010trackall"
+	"\005nolog"
+;
 #endif
 
 

Modified: projects/sendfile/bin/sh/var.c
==============================================================================
--- projects/sendfile/bin/sh/var.c	Fri Jan  8 01:16:03 2016	(r293405)
+++ projects/sendfile/bin/sh/var.c	Fri Jan  8 01:18:10 2016	(r293406)
@@ -754,8 +754,8 @@ mklocal(char *name)
 	INTOFF;
 	lvp = ckmalloc(sizeof (struct localvar));
 	if (name[0] == '-' && name[1] == '\0') {
-		lvp->text = ckmalloc(sizeof optlist);
-		memcpy(lvp->text, optlist, sizeof optlist);
+		lvp->text = ckmalloc(sizeof optval);
+		memcpy(lvp->text, optval, sizeof optval);
 		vp = NULL;
 	} else {
 		vp = find_var(name, &vpp, NULL);
@@ -797,7 +797,7 @@ poplocalvars(void)
 		localvars = lvp->next;
 		vp = lvp->vp;
 		if (vp == NULL) {	/* $- saved */
-			memcpy(optlist, lvp->text, sizeof optlist);
+			memcpy(optval, lvp->text, sizeof optval);
 			ckfree(lvp->text);
 			optschanged();
 		} else if ((lvp->flags & (VUNSET|VSTRFIXED)) == VUNSET) {

Modified: projects/sendfile/libexec/rtld-elf/rtld.c
==============================================================================
--- projects/sendfile/libexec/rtld-elf/rtld.c	Fri Jan  8 01:16:03 2016	(r293405)
+++ projects/sendfile/libexec/rtld-elf/rtld.c	Fri Jan  8 01:18:10 2016	(r293406)
@@ -1144,13 +1144,13 @@ digest_dynamic1(Obj_Entry *obj, int earl
 	 * is mapped read-only. DT_MIPS_RLD_MAP is used instead.
 	 */
 
+#ifndef __mips__
 	case DT_DEBUG:
-	    if (!obj->writable_dynamic)
-		break;
 	    if (!early)
 		dbg("Filling in DT_DEBUG entry");
 	    ((Elf_Dyn*)dynp)->d_un.d_ptr = (Elf_Addr) &r_debug;
 	    break;
+#endif
 
 	case DT_FLAGS:
 		if (dynp->d_un.d_val & DF_ORIGIN)
@@ -1331,8 +1331,6 @@ digest_phdr(const Elf_Phdr *phdr, int ph
 	    break;
 
 	case PT_DYNAMIC:
-	    if (ph->p_flags & PROT_WRITE)
-		obj->writable_dynamic = true;
 	    obj->dynamic = (const Elf_Dyn *)(ph->p_vaddr + obj->relocbase);
 	    break;
 

Modified: projects/sendfile/libexec/rtld-elf/rtld.h
==============================================================================
--- projects/sendfile/libexec/rtld-elf/rtld.h	Fri Jan  8 01:16:03 2016	(r293405)
+++ projects/sendfile/libexec/rtld-elf/rtld.h	Fri Jan  8 01:18:10 2016	(r293406)
@@ -264,7 +264,6 @@ typedef struct Struct_Obj_Entry {
     bool valid_hash_sysv : 1;	/* A valid System V hash hash tag is available */
     bool valid_hash_gnu : 1;	/* A valid GNU hash tag is available */
     bool dlopened : 1;		/* dlopen()-ed (vs. load statically) */
-    bool writable_dynamic : 1;	/* PT_DYNAMIC is writable */
 
     struct link_map linkmap;	/* For GDB and dlinfo() */
     Objlist dldags;		/* Object belongs to these dlopened DAGs (%) */

Modified: projects/sendfile/share/man/man4/ioat.4
==============================================================================
--- projects/sendfile/share/man/man4/ioat.4	Fri Jan  8 01:16:03 2016	(r293405)
+++ projects/sendfile/share/man/man4/ioat.4	Fri Jan  8 01:18:10 2016	(r293406)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd January 5, 2016
+.Dd January 7, 2016
 .Dt IOAT 4
 .Os
 .Sh NAME
@@ -73,6 +73,8 @@ In
 .Fn ioat_get_max_coalesce_period "bus_dmaengine_t dmaengine"
 .Ft void
 .Fn ioat_acquire "bus_dmaengine_t dmaengine"
+.Ft int
+.Fn ioat_acquire_reserve "bus_dmaengine_t dmaengine" "uint32_t n" "int mflags"
 .Ft void
 .Fn ioat_release "bus_dmaengine_t dmaengine"
 .Ft struct bus_dmadesc *
@@ -178,6 +180,14 @@ When the user wants to offload a copy, t
 the
 .Ar bus_dmaengine_t
 object for exclusive access to enqueue operations on that channel.
+Optionally, the user can reserve space by using
+.Fn ioat_acquire_reserve
+instead.
+If
+.Fn ioat_acquire_reserve
+succeeds, there is guaranteed to be room for
+.Fa N
+new operations in the internal ring buffer.
 Then, they will submit one or more operations using
 .Fn ioat_blockfill ,
 .Fn ioat_copy ,

Modified: projects/sendfile/sys/dev/ioat/ioat.c
==============================================================================
--- projects/sendfile/sys/dev/ioat/ioat.c	Fri Jan  8 01:16:03 2016	(r293405)
+++ projects/sendfile/sys/dev/ioat/ioat.c	Fri Jan  8 01:18:10 2016	(r293406)
@@ -789,6 +789,21 @@ ioat_acquire(bus_dmaengine_t dmaengine)
 	CTR0(KTR_IOAT, __func__);
 }
 
+int
+ioat_acquire_reserve(bus_dmaengine_t dmaengine, unsigned n, int mflags)
+{
+	struct ioat_softc *ioat;
+	int error;
+
+	ioat = to_ioat_softc(dmaengine);
+	ioat_acquire(dmaengine);
+
+	error = ioat_reserve_space(ioat, n, mflags);
+	if (error != 0)
+		ioat_release(dmaengine);
+	return (error);
+}
+
 void
 ioat_release(bus_dmaengine_t dmaengine)
 {

Modified: projects/sendfile/sys/dev/ioat/ioat.h
==============================================================================
--- projects/sendfile/sys/dev/ioat/ioat.h	Fri Jan  8 01:16:03 2016	(r293405)
+++ projects/sendfile/sys/dev/ioat/ioat.h	Fri Jan  8 01:18:10 2016	(r293406)
@@ -96,13 +96,26 @@ uint16_t ioat_get_max_coalesce_period(bu
 
 /*
  * Acquire must be called before issuing an operation to perform. Release is
- * called after. Multiple operations can be issued within the context of one
+ * called after.  Multiple operations can be issued within the context of one
  * acquire and release
  */
 void ioat_acquire(bus_dmaengine_t dmaengine);
 void ioat_release(bus_dmaengine_t dmaengine);
 
 /*
+ * Acquire_reserve can be called to ensure there is room for N descriptors.  If
+ * it succeeds, the next N valid operations will successfully enqueue.
+ *
+ * It may fail with:
+ *   - ENXIO if the channel is in an errored state, or the driver is being
+ *     unloaded
+ *   - EAGAIN if mflags included M_NOWAIT
+ *
+ * On failure, the caller does not hold the dmaengine.
+ */
+int ioat_acquire_reserve(bus_dmaengine_t dmaengine, unsigned n, int mflags);
+
+/*
  * Issue a blockfill operation.  The 64-bit pattern 'fillpattern' is written to
  * 'len' physically contiguous bytes at 'dst'.
  *

Modified: projects/sendfile/sys/kern/uipc_usrreq.c
==============================================================================
--- projects/sendfile/sys/kern/uipc_usrreq.c	Fri Jan  8 01:16:03 2016	(r293405)
+++ projects/sendfile/sys/kern/uipc_usrreq.c	Fri Jan  8 01:18:10 2016	(r293406)
@@ -981,7 +981,7 @@ uipc_send(struct socket *so, int flags, 
 				    control))
 					control = NULL;
 			} else
-				sbappend_locked(&so2->so_rcv, m);
+				sbappendstream_locked(&so2->so_rcv, m, flags);
 			break;
 
 		case SOCK_SEQPACKET: {

Modified: projects/sendfile/tools/tools/nanobsd/defaults.sh
==============================================================================
--- projects/sendfile/tools/tools/nanobsd/defaults.sh	Fri Jan  8 01:16:03 2016	(r293405)
+++ projects/sendfile/tools/tools/nanobsd/defaults.sh	Fri Jan  8 01:18:10 2016	(r293406)
@@ -500,10 +500,9 @@ fixup_before_diskimage ( ) (
 	if [ -n "${NANO_METALOG}" ]; then
 		pprint 2 "Fixing metalog"
 		cp ${NANO_METALOG} ${NANO_METALOG}.pre
-		(echo "/set uname=${NANO_DEF_UNAME} gname=${NANO_DEF_GNAME}" &&
-			cat ${NANO_METALOG}.pre) | \
-		    ${NANO_TOOLS}/mtree-dedup.awk | \
-		    sed -e 's/ size=[0-9][0-9]*//' | sort > ${NANO_METALOG}
+		echo "/set uname=${NANO_DEF_UNAME} gname=${NANO_DEF_GNAME}" > ${NANO_METALOG}
+		cat ${NANO_METALOG}.pre | ${NANO_TOOLS}/mtree-dedup.awk | \
+		    sed -e 's/ size=[0-9][0-9]*//' | sort >> ${NANO_METALOG}
 	fi	
 )
 

Modified: projects/sendfile/tools/tools/nanobsd/embedded/common
==============================================================================
--- projects/sendfile/tools/tools/nanobsd/embedded/common	Fri Jan  8 01:16:03 2016	(r293405)
+++ projects/sendfile/tools/tools/nanobsd/embedded/common	Fri Jan  8 01:18:10 2016	(r293406)
@@ -449,6 +449,28 @@ typical_embedded ( ) (
 )
 customize_cmd typical_embedded
 
+fix_pkg ( ) (
+	chdir ${NANO_WORLDDIR}
+	mkdir -p pkg
+	mkdir -p pkg/db
+	mkdir -p pkg/cache
+	mkdir -p pkg/tmp		# Needed for pkg bootstrap
+	mkdir -p usr/local/etc		# Will get moved to local/etc
+	(
+	echo 'PKG_DBDIR = "/pkg/db"'
+	echo 'PKG_CACHEDIR = "/pkg/cache"'
+	echo 'DEFAULT_ALWAYS_YES = "yes"'
+	echo 'ASSUME_ALWAYS_YES = "yes"'
+	) >> usr/local/etc/pkg.conf
+	[ -z ${NANO_NOPRIV_BUILD} ] || (
+	echo "./pkg type=dir uname=root gname=wheel mode=0755"
+	echo "./pkg/cache type=dir uname=root gname=wheel mode=0755"
+	echo "./pkg/db type=dir uname=root gname=wheel mode=0755"
+	echo "./pkg/tmp type=dir uname=root gname=wheel mode=0755"
+	) >> ${NANO_METALOG}
+)
+customize_cmd fix_pkg
+
 save_build ( ) (
 	VERSION_FILE=${NANO_WORLDDIR}/etc/version
 	if [ "${SVNREVISION}" = "${REVISION}" ]; then


More information about the svn-src-projects mailing list