svn commit: r344309 - head/sys/teken

2019-02-19 Thread Ed Schouten
Author: ed
Date: Tue Feb 19 21:58:23 2019
New Revision: 344309
URL: https://svnweb.freebsd.org/changeset/base/344309

Log:
  Place an upper bound on the number of iterations for REP.
  
  Right now it's possible to invoke the REP escape sequence with a maximum
  of tens of millions of iterations. In practice, there is never any need
  to do this. Calling it more frequently than the number of cells in the
  terminal hardly makes any sense. By placing a limit on it, we can
  prevent users from exhausting resources in inside the terminal emulator.
  
  As support for this escape sequence is not present in any of the stable
  branches, there is no need to MFC.
  
  Reported by:  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=11255

Modified:
  head/sys/teken/teken_subr.h

Modified: head/sys/teken/teken_subr.h
==
--- head/sys/teken/teken_subr.h Tue Feb 19 21:49:48 2019(r344308)
+++ head/sys/teken/teken_subr.h Tue Feb 19 21:58:23 2019(r344309)
@@ -1337,8 +1337,11 @@ teken_subr_vertical_position_absolute(teken_t *t, unsi
 static void
 teken_subr_repeat_last_graphic_char(teken_t *t, unsigned int rpts)
 {
+   unsigned int max_repetitions;
 
+   max_repetitions = t->t_winsize.tp_row * t->t_winsize.tp_col;
+   if (rpts > max_repetitions)
+   rpts = max_repetitions;
for (; t->t_last != 0 && rpts > 0; rpts--)
teken_subr_regular_character(t, t->t_last);
 }
-
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r344308 - head/sys/teken

2019-02-19 Thread Ed Schouten
Author: ed
Date: Tue Feb 19 21:49:48 2019
New Revision: 344308
URL: https://svnweb.freebsd.org/changeset/base/344308

Log:
  Add missing __unused attributes to unused function arguments.
  
  This fixes the userspace build of libteken.

Modified:
  head/sys/teken/teken_subr.h

Modified: head/sys/teken/teken_subr.h
==
--- head/sys/teken/teken_subr.h Tue Feb 19 21:33:02 2019(r344307)
+++ head/sys/teken/teken_subr.h Tue Feb 19 21:49:48 2019(r344308)
@@ -372,7 +372,7 @@ teken_subr_cursor_up(teken_t *t, unsigned int nrows)
 }
 
 static void
-teken_subr_set_cursor_style(teken_t *t, unsigned int style)
+teken_subr_set_cursor_style(teken_t *t __unused, unsigned int style __unused)
 {
 
/* TODO */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r340231 - head/sys/kern

2018-11-07 Thread Ed Schouten
Op wo 7 nov. 2018 om 19:32 schreef John Baldwin :
> Modified: head/sys/kern/imgact_elf.c
> ==
> --- head/sys/kern/imgact_elf.c  Wed Nov  7 18:29:54 2018(r340230)
> +++ head/sys/kern/imgact_elf.c  Wed Nov  7 18:32:02 2018(r340231)
> @@ -120,7 +120,8 @@ SYSCTL_INT(_debug, OID_AUTO, __elfN(legacy_coredump),
>
>  int __elfN(nxstack) =
>  #if defined(__amd64__) || defined(__powerpc64__) /* both 64 and 32 bit */ || 
> \
> -(defined(__arm__) && __ARM_ARCH >= 7) || defined(__aarch64__)
> +(defined(__arm__) && __ARM_ARCH >= 7) || defined(__aarch64__) || \
> +defined(__riscv)
> 1;
>  #else
> 0;

Are we getting to the point that it might make sense to invert this
logic, i.e., just list the architectures that require executable
stacks?


-- 
Ed Schouten 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r339468 - in head/sys: kern sys

2018-10-20 Thread Ed Schouten
Op za 20 okt. 2018 om 21:59 schreef Conrad Meyer :
> > Can kdb_active, tp == NULL and panicstr != NULL even occur in this
> > case? tty_info() can only get called in non-degenerate cases, right?
>
> I think you are correct, but I did not want to investigate to confirm.
> This was just the direct, conservative conversion of ttyprintf ->
> putchar.  The checks can *probably* be removed.

If they can, then certain other parts of this change can be reverted
as well (e.g., the addition of cnputsn).

-- 
Ed Schouten 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r339468 - in head/sys: kern sys

2018-10-20 Thread Ed Schouten
Hi there,

Op za 20 okt. 2018 om 20:31 schreef Conrad Meyer :
> +static int
> +sbuf_tty_drain(void *a, const char *d, int len)
> +{
> +   struct tty *tp;
> +   int rc;
> +
> +   tp = a;
> +
> +   if (kdb_active) {
> +   cnputsn(d, len);
> +   return (len);
> +   }
> +   if (tp != NULL && panicstr == NULL) {
> +   rc = tty_putstrn(tp, d, len);
> +   if (rc != 0)
> +   return (-ENXIO);
> +   return (len);
> +   }
> +   return (-ENXIO);
> +}

Disclaimer: Long time since I did a lot with the TTY code.

Can kdb_active, tp == NULL and panicstr != NULL even occur in this
case? tty_info() can only get called in non-degenerate cases, right?

-- 
Ed Schouten 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r336086 - head/usr.sbin/newsyslog

2018-07-08 Thread Ed Schouten
Author: ed
Date: Sun Jul  8 10:08:24 2018
New Revision: 336086
URL: https://svnweb.freebsd.org/changeset/base/336086

Log:
  Use the FQDN in the newsyslog log message when RFC 5424 is enabled.
  
  The RFC 5424 spec mentions that logging FQDNs over short hostnames is
  preferred. Alter this code, so that the hostname doesn't get truncated
  on startup. Keep track of the length of the short hostname, so that
  fprintf() can do the truncation where necessary.
  
  MFC after:1 month

Modified:
  head/usr.sbin/newsyslog/newsyslog.c

Modified: head/usr.sbin/newsyslog/newsyslog.c
==
--- head/usr.sbin/newsyslog/newsyslog.c Sun Jul  8 07:42:58 2018
(r336085)
+++ head/usr.sbin/newsyslog/newsyslog.c Sun Jul  8 10:08:24 2018
(r336086)
@@ -271,6 +271,7 @@ static char daytime[DAYTIME_LEN];/* The current time i
 static char daytime_rfc5424[DAYTIME_RFC5424_LEN];
 
 static char hostname[MAXHOSTNAMELEN]; /* hostname */
+static size_t hostname_shortlen;
 
 static const char *path_syslogpid = _PATH_SYSLOGPID;
 
@@ -657,11 +658,8 @@ parse_args(int argc, char **argv)
 
/* Let's get our hostname */
(void)gethostname(hostname, sizeof(hostname));
+   hostname_shortlen = strcspn(hostname, ".");
 
-   /* Truncate domain */
-   if ((p = strchr(hostname, '.')) != NULL)
-   *p = '\0';
-
/* Parse command line options. */
while ((ch = getopt(argc, argv, "a:d:f:nrst:vCD:FNPR:S:")) != -1)
switch (ch) {
@@ -2349,14 +2347,20 @@ log_trim(const char *logname, const struct conf_entry 
}
} else {
if (log_ent->firstcreate)
-   fprintf(f, "%s %s newsyslog[%d]: logfile first 
created%s\n",
-   daytime, hostname, getpid(), xtra);
+   fprintf(f,
+   "%s %.*s newsyslog[%d]: logfile first created%s\n",
+   daytime, (int)hostname_shortlen, hostname, getpid(),
+   xtra);
else if (log_ent->r_reason != NULL)
-   fprintf(f, "%s %s newsyslog[%d]: logfile turned 
over%s%s\n",
-   daytime, hostname, getpid(), log_ent->r_reason, 
xtra);
+   fprintf(f,
+   "%s %.*s newsyslog[%d]: logfile turned over%s%s\n",
+   daytime, (int)hostname_shortlen, hostname, getpid(),
+   log_ent->r_reason, xtra);
else
-   fprintf(f, "%s %s newsyslog[%d]: logfile turned 
over%s\n",
-   daytime, hostname, getpid(), xtra);
+   fprintf(f,
+   "%s %.*s newsyslog[%d]: logfile turned over%s\n",
+   daytime, (int)hostname_shortlen, hostname, getpid(),
+   xtra);
}
if (fclose(f) == EOF)
err(1, "log_trim: fclose");
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r336060 - head/usr.sbin/syslogd

2018-07-07 Thread Ed Schouten
Author: ed
Date: Sat Jul  7 11:53:39 2018
New Revision: 336060
URL: https://svnweb.freebsd.org/changeset/base/336060

Log:
  Allow the use of slashes in process names of RFC 3164 formatted messages.
  
  Tools such as Postfix use slashes in process names for hierarchy
  (postfix/qmgr). By allowing these slashes, syslogd is able to extract
  the process name and process ID nicely, so that they can be stored in
  RFC 5424 message fields.
  
  MFC after:1 week

Modified:
  head/usr.sbin/syslogd/syslogd.c

Modified: head/usr.sbin/syslogd/syslogd.c
==
--- head/usr.sbin/syslogd/syslogd.c Sat Jul  7 11:39:20 2018
(r336059)
+++ head/usr.sbin/syslogd/syslogd.c Sat Jul  7 11:53:39 2018
(r336060)
@@ -1120,7 +1120,7 @@ parsemsg_rfc3164_app_name_procid(char **msg, const cha
"abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"0123456789"
-   "_-");
+   "_-/");
if (app_name_length == 0)
goto bad;
m += app_name_length;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r335862 - head/usr.sbin/syslogd

2018-07-02 Thread Ed Schouten
Author: ed
Date: Mon Jul  2 11:02:27 2018
New Revision: 335862
URL: https://svnweb.freebsd.org/changeset/base/335862

Log:
  Document that syslogd -v has no effect when RFC 5424 mode is enabled.
  
  The variable it sets, LogFacPri, is only used in the RFC 3164 formatting
  codepath.
  
  PR:   229457
  Reported by:  Andre Albsmeier
  MFC after:1 week

Modified:
  head/usr.sbin/syslogd/syslogd.8

Modified: head/usr.sbin/syslogd/syslogd.8
==
--- head/usr.sbin/syslogd/syslogd.8 Mon Jul  2 10:57:22 2018
(r335861)
+++ head/usr.sbin/syslogd/syslogd.8 Mon Jul  2 11:02:27 2018
(r335862)
@@ -28,7 +28,7 @@
 .\" @(#)syslogd.8  8.1 (Berkeley) 6/6/93
 .\" $FreeBSD$
 .\"
-.Dd April 15, 2018
+.Dd July 2, 2018
 .Dt SYSLOGD 8
 .Os
 .Sh NAME
@@ -348,6 +348,10 @@ logged with each locally-written message.
 If specified more than once,
 the names of the facility and priority are logged with each locally-written
 message.
+.Pp
+This option only affects the formatting of RFC 3164 messages.
+Messages formatted according to RFC 5424 always include a
+facility/priority number.
 .El
 .Pp
 The
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r335861 - head/usr.sbin/syslogd

2018-07-02 Thread Ed Schouten
Author: ed
Date: Mon Jul  2 10:57:22 2018
New Revision: 335861
URL: https://svnweb.freebsd.org/changeset/base/335861

Log:
  Restore the order in which RFC 3164 messages with fac/pri are formatted.
  
  The refactoring of the syslogd code to format messages using iovecs
  slightly altered the output of syslogd by placing the facility/priority
  after the hostname, as opposed to printing it right before. This change
  reverts the behaviour to be consistent with how it was before.
  
  PR:   229457
  Reported by:  Andre Albsmeier
  MFC after:1 week

Modified:
  head/usr.sbin/syslogd/syslogd.c

Modified: head/usr.sbin/syslogd/syslogd.c
==
--- head/usr.sbin/syslogd/syslogd.c Mon Jul  2 09:14:00 2018
(r335860)
+++ head/usr.sbin/syslogd/syslogd.c Mon Jul  2 10:57:22 2018
(r335861)
@@ -1873,8 +1873,6 @@ fprintlog_rfc3164(struct filed *f, const char *hostnam
/* Message written to files. */
iovlist_append(, timebuf);
iovlist_append(, " ");
-   iovlist_append(, hostname);
-   iovlist_append(, " ");
 
if (LogFacPri) {
iovlist_append(, "<");
@@ -1918,6 +1916,9 @@ fprintlog_rfc3164(struct filed *f, const char *hostnam
 
iovlist_append(, "> ");
}
+
+   iovlist_append(, hostname);
+   iovlist_append(, " ");
break;
}
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r335765 - head/sys/sys

2018-06-28 Thread Ed Schouten
2018-06-28 21:09 GMT+02:00 Conrad Meyer :
> I think the right initializer is something like:
>
> *(kevp_) = (struct kevent) {
> ...
> .ext = {
>   [0] = 0,
>   [1] = 0,
> ...
> },
> };

The nice thing about using an inline function is that you can get rid
of the compound literal:

static __inline void
EV_SET(struct kevent *kevp, ...)
{
struct kevent kev = {
// initializer goes here.
};
*kevp = kev;
}

This should even work with C89 compilers, assuming 
provides some smartness for __inline.

-- 
Ed Schouten 
Nuxi, 's-Hertogenbosch, the Netherlands
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r335765 - head/sys/sys

2018-06-28 Thread Ed Schouten
Hi David,

2018-06-28 19:01 GMT+02:00 David Bright :
> +#define EV_SET(kevp_, a, b, c, d, e, f) do {   \

Some time ago I also looked into this and realised that it may even be
possible to do something like this:

static __inline void
EV_SET(...)
{
}

/* Compatibility for code that tests #ifdef EV_SET. */
#define EV_SET EV_SET

This has the advantage that you get pretty neat error messages in case
you get the typing of arguments wrong, as if you're just calling a
function incorrectly. The EV_SET() macro is never used in contexts
that require constant values.

-- 
Ed Schouten 
Nuxi, 's-Hertogenbosch, the Netherlands
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r333590 - head/share/man/man9

2018-06-25 Thread Ed Schouten
Hi Andriy, Matthew,

2018-06-24 23:36 GMT+02:00 Andriy Gapon :
> Perhaps a little application of google can help.
> [keywords: epoch based reclamation]

Based on the man page, it wasn't clear that this refers to a generally
accepted construct or something that is specific to FreeBSD. Any
objections if I were to extend the man page as follows?

Index: epoch.9
===
--- epoch.9 (revision 335613)
+++ epoch.9 (working copy)
@@ -39,7 +39,7 @@
 .Nm epoch_wait ,
 .Nm epoch_call ,
 .Nm in_epoch ,
-.Nd kernel epoch based reclamation
+.Nd kernel Epoch Based Reclamation (EBR)
 .Sh SYNOPSIS
 .In sys/param.h
 .In sys/proc.h
@@ -191,3 +191,10 @@
 .Xr sleep 9 ,
 .Xr sx 9 ,
 .Xr timeout 9
+.Rs
+.%A K. Fraser
+.%T Practical lock-freedom
+.%D February 2004
+.%P 79-81
+.%U https://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-579.pdf
+.Re

-- 
Ed Schouten 
Nuxi, 's-Hertogenbosch, the Netherlands
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r335613 - head/share/man/man9

2018-06-25 Thread Ed Schouten
Author: ed
Date: Mon Jun 25 06:57:10 2018
New Revision: 335613
URL: https://svnweb.freebsd.org/changeset/base/335613

Log:
  Fix spelling of "reclamation".

Modified:
  head/share/man/man9/epoch.9

Modified: head/share/man/man9/epoch.9
==
--- head/share/man/man9/epoch.9 Mon Jun 25 01:29:54 2018(r335612)
+++ head/share/man/man9/epoch.9 Mon Jun 25 06:57:10 2018(r335613)
@@ -26,7 +26,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd June 21, 2018
+.Dd June 25, 2018
 .Dt EPOCH 9
 .Os
 .Sh NAME
@@ -39,7 +39,7 @@
 .Nm epoch_wait ,
 .Nm epoch_call ,
 .Nm in_epoch ,
-.Nd kernel epoch based reclaimation
+.Nd kernel epoch based reclamation
 .Sh SYNOPSIS
 .In sys/param.h
 .In sys/proc.h
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r333590 - head/share/man/man9

2018-06-24 Thread Ed Schouten
Hi Matt,

2018-05-17 9:06 GMT+02:00 Ed Schouten :
> Hi Matt,
>
> 2018-05-14 1:16 GMT+02:00 Matt Macy :
>> +Epochs do not have any lock ordering issues. Entering and leaving
>
> It looks like the man page is missing some newlines between sentences.
>
> Quick question: How does this work relate to RCU
> (https://en.wikipedia.org/wiki/Read-copy-update)? If there is any
> relation, should we mention it in the documentation?

I never got a response to this. Any thoughts?

-- 
Ed Schouten 
Nuxi, 's-Hertogenbosch, the Netherlands
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r335565 - head/usr.sbin/syslogd

2018-06-22 Thread Ed Schouten
Author: ed
Date: Fri Jun 22 20:53:39 2018
New Revision: 335565
URL: https://svnweb.freebsd.org/changeset/base/335565

Log:
  Still parse messages that don't contain an RFC 3164 timestamp.
  
  The changes made in r326573 required that messages always start with an
  RFC 3164 timestamp. It looks like certain devices, but also certain
  logging libraries (Python 3's "logging" package) simply don't generate
  RFC 3164 formatted messages containing a timestamp.
  
  Make timestamps optional again. When the timestamp is missing, also
  assume that the message contains no hostname. The first word of the
  message likely already belongs to the message payload.
  
  PR:   229236
  Reported by:  Michael Grimm & Marek Zarychta
  Reviewed by:  glebius (cursory)
  MFC after:1 week

Modified:
  head/usr.sbin/syslogd/syslogd.c

Modified: head/usr.sbin/syslogd/syslogd.c
==
--- head/usr.sbin/syslogd/syslogd.c Fri Jun 22 20:45:40 2018
(r335564)
+++ head/usr.sbin/syslogd/syslogd.c Fri Jun 22 20:53:39 2018
(r335565)
@@ -1172,68 +1172,70 @@ parsemsg_rfc3164(const char *from, int pri, char *msg)
size_t i, msglen;
char line[MAXLINE + 1];
 
-   /* Parse the timestamp provided by the remote side. */
-   if (strptime(msg, RFC3164_DATEFMT, _parsed) !=
-   msg + RFC3164_DATELEN || msg[RFC3164_DATELEN] != ' ') {
-   dprintf("Failed to parse TIMESTAMP from %s: %s\n", from, msg);
-   return;
-   }
-   msg += RFC3164_DATELEN + 1;
+   /*
+* Parse the TIMESTAMP provided by the remote side. If none is
+* found, assume this is not an RFC 3164 formatted message,
+* only containing a TAG and a MSG.
+*/
+   timestamp = NULL;
+   if (strptime(msg, RFC3164_DATEFMT, _parsed) ==
+   msg + RFC3164_DATELEN && msg[RFC3164_DATELEN] == ' ') {
+   msg += RFC3164_DATELEN + 1;
+   if (!RemoteAddDate) {
+   struct tm tm_now;
+   time_t t_now;
+   int year;
 
-   if (!RemoteAddDate) {
-   struct tm tm_now;
-   time_t t_now;
-   int year;
+   /*
+* As the timestamp does not contain the year
+* number, daylight saving time information, nor
+* a time zone, attempt to infer it. Due to
+* clock skews, the timestamp may even be part
+* of the next year. Use the last year for which
+* the timestamp is at most one week in the
+* future.
+*
+* This loop can only run for at most three
+* iterations before terminating.
+*/
+   t_now = time(NULL);
+   localtime_r(_now, _now);
+   for (year = tm_now.tm_year + 1;; --year) {
+   assert(year >= tm_now.tm_year - 1);
+   timestamp_remote.tm = tm_parsed;
+   timestamp_remote.tm.tm_year = year;
+   timestamp_remote.tm.tm_isdst = -1;
+   timestamp_remote.usec = 0;
+   if (mktime(_remote.tm) <
+   t_now + 7 * 24 * 60 * 60)
+   break;
+   }
+   timestamp = _remote;
+   }
 
/*
-* As the timestamp does not contain the year number,
-* daylight saving time information, nor a time zone,
-* attempt to infer it. Due to clock skews, the
-* timestamp may even be part of the next year. Use the
-* last year for which the timestamp is at most one week
-* in the future.
-*
-* This loop can only run for at most three iterations
-* before terminating.
+* A single space character MUST also follow the HOSTNAME field.
 */
-   t_now = time(NULL);
-   localtime_r(_now, _now);
-   for (year = tm_now.tm_year + 1;; --year) {
-   assert(year >= tm_now.tm_year - 1);
-   timestamp_remote.tm = tm_parsed;
-   timestamp_remote.tm.tm_year = year;
-   timestamp_remote.tm.tm_isdst = -1;
-   timestamp_remote.usec = 0;
-   if (mktime(_remote.tm) <
-   t_now + 7 * 24 * 60 * 60)
+   msglen = strlen(msg);
+   for (i = 0; i < MIN(MAXHOSTNAMELEN, msglen); i++) {
+   if (msg[i] == ' ') {
+   

svn commit: r335314 - head/usr.sbin/syslogd

2018-06-18 Thread Ed Schouten
Author: ed
Date: Mon Jun 18 06:01:28 2018
New Revision: 335314
URL: https://svnweb.freebsd.org/changeset/base/335314

Log:
  Fix bad logic in iovlist_truncate().
  
  To conform to RFC 5426, this function is intended to truncate messages
  if they exceed the message size limits. Unfortunately, the amount of
  space was computed the wrong way around, causing messages to be
  truncated entirely.
  
  Reported by:  Michael Grimm on stable@
  MFC after:3 days

Modified:
  head/usr.sbin/syslogd/syslogd.c

Modified: head/usr.sbin/syslogd/syslogd.c
==
--- head/usr.sbin/syslogd/syslogd.c Mon Jun 18 04:58:48 2018
(r335313)
+++ head/usr.sbin/syslogd/syslogd.c Mon Jun 18 06:01:28 2018
(r335314)
@@ -1613,8 +1613,8 @@ iovlist_truncate(struct iovlist *il, size_t size)
struct iovec *last;
size_t diff;
 
-   while (size > il->totalsize) {
-   diff = size - il->totalsize;
+   while (il->totalsize > size) {
+   diff = il->totalsize - size;
last = >iov[il->iovcnt - 1];
if (diff >= last->iov_len) {
/* Remove the last iovec entirely. */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r333995 - head/sys/teken

2018-05-22 Thread Ed Schouten
Hi Bruce,

2018-05-22 3:18 GMT+02:00 Bruce Evans <b...@optusnet.com.au>:
> DECSCUSR is a verbose yet cryptic abbreviation which is not even expanded
> its name.  It is the only abbreviation longer than 7 characters.  This
> messes up the souce formatting.

Yeah, it's a bit silly, but that's simply how it's called:

https://vt100.net/docs/vt510-rm/DECSCUSR.html

I think the state machine generator doesn't mind if we added an extra
tab between all other entries to get it to line up again. Maybe that
does push us over 80 columns, though...

-- 
Ed Schouten <e...@nuxi.nl>
Nuxi, 's-Hertogenbosch, the Netherlands
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r333925 - head/sys/teken

2018-05-20 Thread Ed Schouten
Hi Jean-Sébastien,

2018-05-20 16:21 GMT+02:00 Jean-Sébastien Pédron <dumbb...@freebsd.org>:
> Modified: head/sys/teken/sequences
> ==
> --- head/sys/teken/sequencesSun May 20 06:14:12 2018(r333924)
> +++ head/sys/teken/sequencesSun May 20 14:21:20 2018(r333925)
> @@ -48,6 +48,7 @@ CUF   Cursor Forward  ^[ [ a
>   n
>  CUPCursor Position ^[ [ H  n n
>  CUPCursor Position ^[ [ f  n n
>  CUUCursor Up   ^[ [ A  n
> +CS Cursor style^[ [ SP q   r
>  DA1Primary Device Attributes   ^[ [ c  r
>  DA2Secondary Device Attributes ^[ [ > cr
>  DC Delete character^[ [ P  n

So far I've been trying to be quite consistent in the naming here,
using the exact phrasing that is used elsewhere. Could you please use
"DECSCUSR" and "Set Cursor Style" here, just like on this page?
https://vt100.net/docs/vt510-rm/DECSCUSR.html

Thanks,
-- 
Ed Schouten <e...@nuxi.nl>
Nuxi, 's-Hertogenbosch, the Netherlands
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r333590 - head/share/man/man9

2018-05-17 Thread Ed Schouten
Hi Matt,

2018-05-14 1:16 GMT+02:00 Matt Macy <mm...@freebsd.org>:
> +Epochs do not have any lock ordering issues. Entering and leaving

It looks like the man page is missing some newlines between sentences.

Quick question: How does this work relate to RCU
(https://en.wikipedia.org/wiki/Read-copy-update)? If there is any
relation, should we mention it in the documentation?

-- 
Ed Schouten <e...@nuxi.nl>
Nuxi, 's-Hertogenbosch, the Netherlands
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r332511 - head/usr.sbin/syslogd

2018-04-15 Thread Ed Schouten
Author: ed
Date: Sun Apr 15 08:44:26 2018
New Revision: 332511
URL: https://svnweb.freebsd.org/changeset/base/332511

Log:
  Use proper alphabetic sorting of options.

Modified:
  head/usr.sbin/syslogd/syslogd.8

Modified: head/usr.sbin/syslogd/syslogd.8
==
--- head/usr.sbin/syslogd/syslogd.8 Sun Apr 15 08:34:16 2018
(r332510)
+++ head/usr.sbin/syslogd/syslogd.8 Sun Apr 15 08:44:26 2018
(r332511)
@@ -28,7 +28,7 @@
 .\" @(#)syslogd.8  8.1 (Berkeley) 6/6/93
 .\" $FreeBSD$
 .\"
-.Dd April 9, 2018
+.Dd April 15, 2018
 .Dt SYSLOGD 8
 .Os
 .Sh NAME
@@ -243,20 +243,6 @@ Usually the
 .Dq kern
 facility is reserved for messages read directly from
 .Pa /dev/klog .
-.It Fl O Ar format
-Select the output format of generated log messages.
-The values
-.Ar bsd
-and
-.Ar rfc3164
-are used to generate RFC 3164 log messages.
-The values
-.Ar syslog
-and
-.Ar rfc5424
-are used to generate RFC 5424 log messages,
-having RFC 3339 timestamps with microsecond precision.
-The default is to generate RFC 3164 log messages.
 .It Fl m Ar mark_interval
 Select the number of minutes between
 .Dq mark
@@ -274,6 +260,20 @@ This option inherits
 .Fl s .
 .It Fl n
 Disable DNS query for every request.
+.It Fl O Ar format
+Select the output format of generated log messages.
+The values
+.Ar bsd
+and
+.Ar rfc3164
+are used to generate RFC 3164 log messages.
+The values
+.Ar syslog
+and
+.Ar rfc5424
+are used to generate RFC 5424 log messages,
+having RFC 3339 timestamps with microsecond precision.
+The default is to generate RFC 3164 log messages.
 .It Fl o
 Prefix kernel messages with the full kernel boot file as determined by
 .Xr getbootfile 3 .
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r332510 - in head: usr.bin/wall usr.sbin/syslogd

2018-04-15 Thread Ed Schouten
Author: ed
Date: Sun Apr 15 08:34:16 2018
New Revision: 332510
URL: https://svnweb.freebsd.org/changeset/base/332510

Log:
  Add RFC 5424 syslog message output to syslogd.
  
  - Move all of the code responsible for transmitting log messages into a
separate function, fprintlog_write().
  - Instead of manually modifying a list of iovecs, add a structure
iovlist with some helper functions.
  - Alter the F_FORW (UDP message forwarding) case to also use iovecs like
the other cases. Use sendmsg() instead of sendto().
  - In the case of F_FORW, truncate the message to a size dependent on the
address family (AF_INET, AF_INET6), as proposed by RFC 5426.
  - Move all traditional message formatting into fprintlog_bsd(). Get rid
of some of the string copying and snprintf()'ing. Simply emit more
iovecs to get the job done.
  - Increase ttymsg()'s limit of 7 iovecs to 32. Add a definition for this
limit, so it can be reused by iovlist.
  - Add fprintlog_rfc5424() to emit RFC 5424 formatted log entries.
  - Add a "-O" command line option to enable RFC 5424 formatting. It would
have been nicer if we supported "-o rfc5424", just like on NetBSD.
Unfortunately, the "-o" flag is already used for a different purpose
on FreeBSD.
  - Don't truncate hostnames in the RFC 5424 case, as suggested by that
specific RFC.
  
  For people interested in using this, this feature can be enabled by
  adding the following line to /etc/rc.conf:
  
syslogd_flags="-s -O rfc5424"
  
  Differential Revision:https://reviews.freebsd.org/D15011

Modified:
  head/usr.bin/wall/ttymsg.c
  head/usr.bin/wall/ttymsg.h
  head/usr.sbin/syslogd/syslogd.8
  head/usr.sbin/syslogd/syslogd.c

Modified: head/usr.bin/wall/ttymsg.c
==
--- head/usr.bin/wall/ttymsg.c  Sat Apr 14 22:14:18 2018(r332509)
+++ head/usr.bin/wall/ttymsg.c  Sun Apr 15 08:34:16 2018(r332510)
@@ -61,7 +61,7 @@ static const char sccsid[] = "@(#)ttymsg.c8.2 (Berkel
 const char *
 ttymsg(struct iovec *iov, int iovcnt, const char *line, int tmout)
 {
-   struct iovec localiov[7];
+   struct iovec localiov[TTYMSG_IOV_MAX];
ssize_t left, wret;
int cnt, fd;
char device[MAXNAMLEN] = _PATH_DEV;

Modified: head/usr.bin/wall/ttymsg.h
==
--- head/usr.bin/wall/ttymsg.h  Sat Apr 14 22:14:18 2018(r332509)
+++ head/usr.bin/wall/ttymsg.h  Sun Apr 15 08:34:16 2018(r332510)
@@ -1,3 +1,5 @@
 /* $FreeBSD$ */
 
+#defineTTYMSG_IOV_MAX  32
+
 const char *ttymsg(struct iovec *, int, const char *, int);

Modified: head/usr.sbin/syslogd/syslogd.8
==
--- head/usr.sbin/syslogd/syslogd.8 Sat Apr 14 22:14:18 2018
(r332509)
+++ head/usr.sbin/syslogd/syslogd.8 Sun Apr 15 08:34:16 2018
(r332510)
@@ -28,7 +28,7 @@
 .\" @(#)syslogd.8  8.1 (Berkeley) 6/6/93
 .\" $FreeBSD$
 .\"
-.Dd November 28, 2017
+.Dd April 9, 2018
 .Dt SYSLOGD 8
 .Os
 .Sh NAME
@@ -42,6 +42,7 @@
 .Op Fl f Ar config_file
 .Op Fl l Oo Ar mode Ns \&: Oc Ns Ar path
 .Op Fl m Ar mark_interval
+.Op Fl O Ar format
 .Op Fl P Ar pid_file
 .Op Fl p Ar log_socket
 .Op Fl S Ar logpriv_socket
@@ -242,6 +243,20 @@ Usually the
 .Dq kern
 facility is reserved for messages read directly from
 .Pa /dev/klog .
+.It Fl O Ar format
+Select the output format of generated log messages.
+The values
+.Ar bsd
+and
+.Ar rfc3164
+are used to generate RFC 3164 log messages.
+The values
+.Ar syslog
+and
+.Ar rfc5424
+are used to generate RFC 5424 log messages,
+having RFC 3339 timestamps with microsecond precision.
+The default is to generate RFC 3164 log messages.
 .It Fl m Ar mark_interval
 Select the number of minutes between
 .Dq mark

Modified: head/usr.sbin/syslogd/syslogd.c
==
--- head/usr.sbin/syslogd/syslogd.c Sat Apr 14 22:14:18 2018
(r332509)
+++ head/usr.sbin/syslogd/syslogd.c Sun Apr 15 08:34:16 2018
(r332510)
@@ -136,6 +136,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -367,9 +368,12 @@ static int KeepKernFac;/* Keep remotely logged kernel
 static int needdofsync = 0; /* Are any file(s) waiting to be fsynced? */
 static struct pidfh *pfh;
 static int sigpipe[2]; /* Pipe to catch a signal during select(). */
+static boolRFC3164OutputFormat = true; /* Use legacy format by default. */
 
 static volatile sig_atomic_t MarkSet, WantDie, WantInitialize, WantReapchild;
 
+struct iovlist;
+
 static int allowaddr(char *);
 static int addfile(struct filed *);
 static int addpeer(struct peer *);
@@ -386,6 +390,7 @@ static void dofsync(void);
 static voiddomark(int);
 static voidfprintlog_first(struct 

svn commit: r332165 - head/usr.sbin/syslogd

2018-04-07 Thread Ed Schouten
Author: ed
Date: Sat Apr  7 09:03:51 2018
New Revision: 332165
URL: https://svnweb.freebsd.org/changeset/base/332165

Log:
  Fix enough warnings that we can build syslogd on all targets at WARNS=6.
  
  This also fixes the build on MIPS.
  
  Reported by:  cy (MIPS build failure)

Modified:
  head/usr.sbin/syslogd/Makefile
  head/usr.sbin/syslogd/syslogd.c

Modified: head/usr.sbin/syslogd/Makefile
==
--- head/usr.sbin/syslogd/Makefile  Sat Apr  7 03:51:19 2018
(r332164)
+++ head/usr.sbin/syslogd/Makefile  Sat Apr  7 09:03:51 2018
(r332165)
@@ -11,8 +11,6 @@ SRCS= syslogd.c ttymsg.c
 
 LIBADD=util
 
-WARNS?= 3
-
 .if ${MK_INET_SUPPORT} != "no"
 CFLAGS+= -DINET
 .endif

Modified: head/usr.sbin/syslogd/syslogd.c
==
--- head/usr.sbin/syslogd/syslogd.c Sat Apr  7 03:51:19 2018
(r332164)
+++ head/usr.sbin/syslogd/syslogd.c Sat Apr  7 09:03:51 2018
(r332165)
@@ -581,7 +581,7 @@ main(int argc, char *argv[])
else if (ch == 'p') {
mode = DEFFILEMODE;
pflag = 1;
-   } else if (ch == 'S') {
+   } else {
mode = S_IRUSR | S_IWUSR;
Sflag = 1;
}
@@ -931,7 +931,7 @@ static void
 parsemsg_rfc5424(const char *from, int pri, char *msg)
 {
const struct logtime *timestamp;
-   struct logtime timestamp_remote = { 0 };
+   struct logtime timestamp_remote;
const char *omsg, *hostname, *app_name, *procid, *msgid,
*structured_data;
char line[MAXLINE + 1];
@@ -971,6 +971,7 @@ parsemsg_rfc5424(const char *from, int pri, char *msg)
dest = v;   \
 } while (0)
/* Date and time. */
+   memset(_remote, 0, sizeof(timestamp_remote));
PARSE_NUMBER(timestamp_remote.tm.tm_year, 4, 0, );
timestamp_remote.tm.tm_year -= 1900;
PARSE_CHAR("TIMESTAMP", '-');
@@ -1151,7 +1152,7 @@ parsemsg_rfc3164(const char *from, int pri, char *msg)
 {
struct tm tm_parsed;
const struct logtime *timestamp;
-   struct logtime timestamp_remote = { 0 };
+   struct logtime timestamp_remote;
const char *app_name, *procid;
size_t i, msglen;
char line[MAXLINE + 1];
@@ -1187,6 +1188,7 @@ parsemsg_rfc3164(const char *from, int pri, char *msg)
timestamp_remote.tm = tm_parsed;
timestamp_remote.tm.tm_year = year;
timestamp_remote.tm.tm_isdst = -1;
+   timestamp_remote.usec = 0;
if (mktime(_remote.tm) <
t_now + 7 * 24 * 60 * 60)
break;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r332118 - head/usr.sbin/syslogd

2018-04-06 Thread Ed Schouten
Author: ed
Date: Fri Apr  6 17:16:50 2018
New Revision: 332118
URL: https://svnweb.freebsd.org/changeset/base/332118

Log:
  Push RFC 5424 message format from logmsg() into fprintlog().
  
  Now that all of parsemsg() parses both RFC 3164 and 5424 messages and
  hands them to logmsg(), alter the latter to properly forward all RFC
  5424 message attributes to fprintlog(). While there, make some minor
  cleanups to this code:
  
  - Instead of extending the existing code that compares hostnames and
message bodies for deduplication, print all of the relevant message
fields into a single string that we can compare ('saved').
  
  - No longer let the behaviour of fprintflog() depend on whether
'msg == NULL' to print repetition messages, Simply decompose this
function into fprintlog_first() and fprintlog_successive(). This
makes the interpretation of function arguments less magical and also
allows us to get consistent behaviour across RFC 3164 and 5424 when
adding support for the RFC 5424 output format.
  
  - As RFC 5424 syslog messages have a dedicated application name field,
alter the repetition messages to be printed on behalf of syslogd on
the current system. Change these messages to use the local hostname,
so that it's obvious which syslogd instance detected the repetition.
Remove f_prevhost, as it has now become unnecessary.
  
  - Remove a useless strdup(). Deconsting the message string is safe in
this specific case.

Modified:
  head/usr.sbin/syslogd/syslogd.c

Modified: head/usr.sbin/syslogd/syslogd.c
==
--- head/usr.sbin/syslogd/syslogd.c Fri Apr  6 17:06:22 2018
(r332117)
+++ head/usr.sbin/syslogd/syslogd.c Fri Apr  6 17:16:50 2018
(r332118)
@@ -252,7 +252,6 @@ struct filed {
 #definefu_pipe_pid f_un.f_pipe.f_pid
charf_prevline[MAXSVLINE];  /* last message logged */
struct logtime f_lasttime;  /* time of last occurrence */
-   charf_prevhost[MAXHOSTNAMELEN]; /* host from which recd. */
int f_prevpri;  /* pri of f_prevline */
size_t  f_prevlen;  /* length of f_prevline */
int f_prevcount;/* repetition cnt of prevline */
@@ -385,7 +384,9 @@ static void die(int) __dead2;
 static voiddodie(int);
 static voiddofsync(void);
 static voiddomark(int);
-static voidfprintlog(struct filed *, int, const char *);
+static voidfprintlog_first(struct filed *, const char *, const char *,
+const char *, const char *, const char *, const char *, int);
+static voidfprintlog_successive(struct filed *, int);
 static voidinit(int);
 static voidlogerror(const char *);
 static voidlogmsg(int, const struct logtime *, const char *, const char *,
@@ -1411,19 +1412,19 @@ skip_message(const char *name, const char *spec, int c
  * STRUCTURED-DATA fields are thus discarded for the time being.
  */
 static void
-logmsg(int pri, const struct logtime *timestamp, const char *from,
-const char *app_name, const char *procid, const char *msgid __unused,
-const char *structured_data __unused, const char *msg, int flags)
+logmsg(int pri, const struct logtime *timestamp, const char *hostname,
+const char *app_name, const char *procid, const char *msgid,
+const char *structured_data, const char *msg, int flags)
 {
struct timeval tv;
struct logtime timestamp_now;
struct filed *f;
-   size_t msglen;
+   size_t savedlen;
int fac, prilev;
-   char buf[MAXLINE+1];
+   char saved[MAXSVLINE];
 
dprintf("logmsg: pri %o, flags %x, from %s, msg %s\n",
-   pri, flags, from, msg);
+   pri, flags, hostname, msg);
 
(void)gettimeofday(, NULL);
now = tv.tv_sec;
@@ -1445,18 +1446,6 @@ logmsg(int pri, const struct logtime *timestamp, const
 
prilev = LOG_PRI(pri);
 
-   /* Prepend the application name to the message if provided. */
-   if (app_name != NULL) {
-   if (procid != NULL)
-   msglen = snprintf(buf, sizeof(buf), "%s[%s]: %s",
-   app_name, procid, msg);
-   else
-   msglen = snprintf(buf, sizeof(buf), "%s: %s",
-   app_name, msg);
-   msg = buf;
-   } else
-   msglen = strlen(msg);
-
/* log the message to the particular outputs */
if (!Initialized) {
f = 
@@ -1468,12 +1457,27 @@ logmsg(int pri, const struct logtime *timestamp, const
 
if (f->f_file >= 0) {
f->f_lasttime = *timestamp;
-   fprintlog(f, flags, msg);
+   fprintlog_first(f, hostname, app_name, procid, msgid,
+   structured_data, msg, flags);
 

svn commit: r332111 - head/usr.sbin/syslogd

2018-04-06 Thread Ed Schouten
Author: ed
Date: Fri Apr  6 16:26:46 2018
New Revision: 332111
URL: https://svnweb.freebsd.org/changeset/base/332111

Log:
  Remove some places where error messages are prefixed with "syslogd".
  
  Due to using RFC 5424, the application name is stored in a dedicated
  field. It can simply be passed as an argument to logmsg() now.

Modified:
  head/usr.sbin/syslogd/syslogd.c

Modified: head/usr.sbin/syslogd/syslogd.c
==
--- head/usr.sbin/syslogd/syslogd.c Fri Apr  6 16:24:03 2018
(r332110)
+++ head/usr.sbin/syslogd/syslogd.c Fri Apr  6 16:26:46 2018
(r332111)
@@ -1991,7 +1991,7 @@ domark(int signo __unused)
  * Print syslogd errors some place.
  */
 static void
-logerror(const char *type)
+logerror(const char *msg)
 {
char buf[512];
static int recursed = 0;
@@ -2000,15 +2000,15 @@ logerror(const char *type)
if (recursed)
return;
recursed++;
-   if (errno)
-   (void)snprintf(buf,
-   sizeof buf, "syslogd: %s: %s", type, strerror(errno));
-   else
-   (void)snprintf(buf, sizeof buf, "syslogd: %s", type);
+   if (errno != 0) {
+   (void)snprintf(buf, sizeof(buf), "%s: %s", msg,
+   strerror(errno));
+   msg = buf;
+   }
errno = 0;
dprintf("%s\n", buf);
-   logmsg(LOG_SYSLOG|LOG_ERR, NULL, LocalHostName, NULL, NULL, NULL,
-   NULL, buf, 0);
+   logmsg(LOG_SYSLOG|LOG_ERR, NULL, LocalHostName, "syslogd", NULL, NULL,
+   NULL, msg, 0);
recursed--;
 }
 
@@ -2355,18 +2355,18 @@ init(int signo)
}
}
 
-   logmsg(LOG_SYSLOG|LOG_INFO, NULL, LocalHostName, NULL, NULL, NULL,
-   NULL, "syslogd: restart", 0);
+   logmsg(LOG_SYSLOG | LOG_INFO, NULL, LocalHostName, "syslogd", NULL,
+   NULL, NULL, "restart", 0);
dprintf("syslogd: restarted\n");
/*
 * Log a change in hostname, but only on a restart.
 */
if (signo != 0 && strcmp(oldLocalHostName, LocalHostName) != 0) {
(void)snprintf(hostMsg, sizeof(hostMsg),
-   "syslogd: hostname changed, \"%s\" to \"%s\"",
+   "hostname changed, \"%s\" to \"%s\"",
oldLocalHostName, LocalHostName);
-   logmsg(LOG_SYSLOG|LOG_INFO, NULL, LocalHostName, NULL, NULL,
-   NULL, NULL, hostMsg, 0);
+   logmsg(LOG_SYSLOG | LOG_INFO, NULL, LocalHostName, "syslogd",
+   NULL, NULL, NULL, hostMsg, 0);
dprintf("%s\n", hostMsg);
}
/*
@@ -2375,9 +2375,9 @@ init(int signo)
 */
if (signo == 0 && !use_bootfile) {
(void)snprintf(bootfileMsg, sizeof(bootfileMsg),
-   "syslogd: kernel boot file is %s", bootfile);
-   logmsg(LOG_KERN|LOG_INFO, NULL, LocalHostName, NULL, NULL,
-   NULL, NULL, bootfileMsg, 0);
+   "kernel boot file is %s", bootfile);
+   logmsg(LOG_KERN | LOG_INFO, NULL, LocalHostName, "syslogd",
+   NULL, NULL, NULL, bootfileMsg, 0);
dprintf("%s\n", bootfileMsg);
}
 }
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r332110 - head/usr.sbin/syslogd

2018-04-06 Thread Ed Schouten
Author: ed
Date: Fri Apr  6 16:24:03 2018
New Revision: 332110
URL: https://svnweb.freebsd.org/changeset/base/332110

Log:
  Properly respect the passed in hostname for RFC 5424 messages.
  
  Only override the hostname in case none is provided or when remote
  hostnames should be ignored.

Modified:
  head/usr.sbin/syslogd/syslogd.c

Modified: head/usr.sbin/syslogd/syslogd.c
==
--- head/usr.sbin/syslogd/syslogd.c Fri Apr  6 16:22:14 2018
(r332109)
+++ head/usr.sbin/syslogd/syslogd.c Fri Apr  6 16:24:03 2018
(r332110)
@@ -1028,6 +1028,8 @@ parsemsg_rfc5424(const char *from, int pri, char *msg)
msg[-1] = '\0'; \
}
PARSE_STRING("HOSTNAME", hostname);
+   if (hostname == NULL || !RemoteHostname)
+   hostname = from;
PARSE_STRING("APP-NAME", app_name);
PARSE_STRING("PROCID", procid);
PARSE_STRING("MSGID", msgid);
@@ -1079,7 +1081,7 @@ parsemsg_rfc5424(const char *from, int pri, char *msg)
 #undef IF_NOT_NILVALUE
 
parsemsg_remove_unsafe_characters(msg, line, sizeof(line));
-   logmsg(pri, timestamp, from, app_name, procid, msgid,
+   logmsg(pri, timestamp, hostname, app_name, procid, msgid,
structured_data, line, 0);
 }
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r332100 - in head: . lib/libc/gen sys/sys

2018-04-06 Thread Ed Schouten
Author: ed
Date: Fri Apr  6 13:00:45 2018
New Revision: 332100
URL: https://svnweb.freebsd.org/changeset/base/332100

Log:
  Let syslog(3) use RFC 5424.
  
  With r332099 changing syslogd(8) to parse RFC 5424 formatted syslog
  messages, go ahead and also change the syslog(3) libc function to
  generate them. Compared to RFC 3164, RFC 5424 has various advantages,
  such as sub-second precision for log entry timestamps.
  
  As this change could have adverse effects when not updating syslogd(8)
  or using a different system logging daemon, add a notice to UPDATING and
  increase __FreeBSD_version.
  
  Differential Revision:https://reviews.freebsd.org/D14926

Modified:
  head/UPDATING
  head/lib/libc/gen/syslog.3
  head/lib/libc/gen/syslog.c
  head/sys/sys/param.h

Modified: head/UPDATING
==
--- head/UPDATING   Fri Apr  6 12:57:01 2018(r332099)
+++ head/UPDATING   Fri Apr  6 13:00:45 2018(r332100)
@@ -51,6 +51,45 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 12.x IS SLOW:
 
 ** SPECIAL WARNING: **
 
+20180406:
+   In addition to supporting RFC 3164 formatted messages, the
+   syslogd(8) service is now capable of parsing RFC 5424 formatted
+   log messages. The main benefit of using RFC 5424 is that clients
+   may now send log messages with timestamps containing year numbers,
+   microseconds and time zone offsets.
+
+   Similarly, the syslog(3) C library function has been altered to
+   send RFC 5424 formatted messages to the local system logging
+   daemon. On systems using syslogd(8), this change should have no
+   negative impact, as long as syslogd(8) and the C library are
+   updated at the same time. On systems using a different system
+   logging daemon, it may be necessary to make configuration
+   adjustments, depending on the software used.
+
+   When using syslog-ng, add the 'syslog-protocol' flag to local
+   input sources to enable parsing of RFC 5424 formatted messages:
+
+   source src {
+   unix-dgram("/var/run/log" flags(syslog-protocol));
+   }
+
+   When using rsyslog, disable the 'SysSock.UseSpecialParser' option
+   of the 'imuxsock' module to let messages be processed by the
+   regular RFC 3164/5424 parsing pipeline:
+
+   module(load="imuxsock" SysSock.UseSpecialParser="off")
+
+   Do note that these changes only affect communication between local
+   applications and syslogd(8). The format that syslogd(8) uses to
+   store messages on disk or forward messages to other systems
+   remains unchanged. syslogd(8) still uses RFC 3164 for these
+   purposes. Options to customize this behaviour will be added in the
+   future. Utilities that process log files stored in /var/log are
+   thus expected to continue to function as before.
+
+   __FreeBSD_version has been incremented to 1200061 to denote this
+   change.
+
 20180328:
Support for token ring networks has been removed. If you
have "device token" in your kernel config you should remove

Modified: head/lib/libc/gen/syslog.3
==
--- head/lib/libc/gen/syslog.3  Fri Apr  6 12:57:01 2018(r332099)
+++ head/lib/libc/gen/syslog.3  Fri Apr  6 13:00:45 2018(r332100)
@@ -28,7 +28,7 @@
 .\" @(#)syslog.3   8.1 (Berkeley) 6/4/93
 .\" $FreeBSD$
 .\"
-.Dd November 5, 2017
+.Dd April 6, 2018
 .Dt SYSLOG 3
 .Os
 .Sh NAME
@@ -156,6 +156,9 @@ Write the message to standard error output as well to 
 .It Dv LOG_PID
 Log the process id with each message: useful for identifying
 instantiations of daemons.
+On
+.Fx ,
+this option is enabled by default.
 .El
 .Pp
 The

Modified: head/lib/libc/gen/syslog.c
==
--- head/lib/libc/gen/syslog.c  Fri Apr  6 12:57:01 2018(r332099)
+++ head/lib/libc/gen/syslog.c  Fri Apr  6 13:00:45 2018(r332100)
@@ -36,9 +36,10 @@ static char sccsid[] = "@(#)syslog.c 8.5 (Berkeley) 4/
 __FBSDID("$FreeBSD$");
 
 #include "namespace.h"
-#include 
+#include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -134,11 +135,13 @@ syslog(int pri, const char *fmt, ...)
 static void
 vsyslog1(int pri, const char *fmt, va_list ap)
 {
-   int cnt;
+   struct timeval now;
+   struct tm tm;
char ch, *p;
-   time_t now;
-   int fd, saved_errno;
-   char *stdp, tbuf[2048], fmt_cpy[1024], timbuf[26], errstr[64];
+   long tz_offset;
+   int cnt, fd, saved_errno;
+   char hostname[MAXHOSTNAMELEN], *stdp, tbuf[2048], fmt_cpy[1024],
+   errstr[64], tz_sign;
FILE *fp, *fmt_fp;
struct bufcookie tbuf_cookie;
struct bufcookie fmt_cookie;
@@ -168,24 

svn commit: r332099 - head/usr.sbin/syslogd

2018-04-06 Thread Ed Schouten
Author: ed
Date: Fri Apr  6 12:57:01 2018
New Revision: 332099
URL: https://svnweb.freebsd.org/changeset/base/332099

Log:
  Add RFC 5424 syslog message parsing to syslogd.
  
  Syslogd currently uses the RFC 3164 format for its log messages.One
  limitation of RFC 3164 is that it cannot be used to log entries with
  sub-second precision timestamps. One of our users has expressed a desire
  for doing this for doing some basic performance measurements.
  
  This change attempts to make a first cut at switching to RFC 5424 based
  logging. The first step is to alter syslogd's input path to properly
  parse such messages. It alters the logmsg() prototype to match the
  fields of RFC 5424. The parsemsg() function is extended to parse both
  RFC 3164 and 5424 messages and call into logmsg() accordingly.
  
  Additional changes include:
  
  - Introducing proper parsing of timestamps, so that they can be printed
in any desired output format. This means we need to infer the year and
timezone for RFC 3164 timestamps.
  - Removing ISKERNEL. This can now be realised by simply providing an
APP-NAME (== "kernel").
  - Extending RFC 3164 parsing to trim off the TAG prefix and using that
to derive APP-NAME and PROCID.
  - Increase MAXLINE. RFC 5424 mentions we should support 2k messages.
  
  Differential Revision:https://reviews.freebsd.org/D14926

Modified:
  head/usr.sbin/syslogd/syslogd.c

Modified: head/usr.sbin/syslogd/syslogd.c
==
--- head/usr.sbin/syslogd/syslogd.c Fri Apr  6 12:39:47 2018
(r332098)
+++ head/usr.sbin/syslogd/syslogd.c Fri Apr  6 12:57:01 2018
(r332099)
@@ -28,6 +28,33 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2018 Prodrive Technologies, https://prodrive-technologies.com/
+ * Author: Ed Schouten <e...@freebsd.org>
+ *
+ * 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.
+ */
 
 #ifndef lint
 static const char copyright[] =
@@ -71,8 +98,7 @@ __FBSDID("$FreeBSD$");
  */
 
 /* Maximum number of characters in time of last occurrence */
-#defineMAXDATELEN  16
-#defineMAXLINE 1024/* maximum line length */
+#defineMAXLINE 2048/* maximum line length */
 #defineMAXSVLINE   MAXLINE /* maximum saved line length */
 #defineDEFUPRI (LOG_USER|LOG_NOTICE)
 #defineDEFSPRI (LOG_KERN|LOG_CRIT)
@@ -97,8 +123,8 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #endif
-#include 
 
+#include 
 #include 
 #include 
 #include 
@@ -107,6 +133,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -174,8 +201,17 @@ static STAILQ_HEAD(, socklist) shead = STAILQ_HEAD_INI
 #defineIGN_CONS0x001   /* don't print on console */
 #defineSYNC_FILE   0x002   /* do fsync on file after printing */
 #defineMARK0x008   /* this message is a mark */
-#defineISKERNEL0x010   /* kernel generated message */
 
+/* Timestamps of log entries. */
+struct logtime {
+   struct tm   tm;
+   suseconds_t usec;
+};
+
+/* Traditional syslog timestamp format. */
+#defineRFC3164_DATELEN 15
+#defineRFC3164_DATEFMT "%b %e %H:%M:%S"
+
 /*
  * This structure represents the files that will have log
  * copies printed.
@@ -215,10 +251,10 @@ struct filed {
 #definefu_pipe_pname   f_un.f_pipe.f_pname
 #definefu_pipe_pid f_un.f_pipe.f_pid

Re: svn commit: r329882 - in head/sys: conf kern sys vm

2018-03-02 Thread Ed Schouten
Hi Jeff,

2018-02-23 23:51 GMT+01:00 Jeff Roberson <j...@freebsd.org>:
>   Add a generic Proportional Integral Derivative (PID) controller algorithm 
> and
>   use it to regulate page daemon output.

That looks pretty nifty. Looking at the code, it exposes metrics
through sysctl. Be sure to give prometheus_sysctl_exporter(8) a try if
you ever want to graph the characteristics of the controller!

-- 
Ed Schouten <e...@nuxi.nl>
Nuxi, 's-Hertogenbosch, the Netherlands
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r328492 - head/contrib/opie/libopie

2018-01-27 Thread Ed Schouten
2018-01-27 23:31 GMT+01:00 Dimitry Andric <d...@freebsd.org>:
> On 27 Jan 2018, at 23:20, Ed Schouten <e...@nuxi.nl> wrote:
>>
>> 2018-01-27 23:16 GMT+01:00 Pedro F. Giffuni <p...@freebsd.org>:
>>>char host[sizeof(utmp.ut_host) + 1];
>>>insecure = 1;
>>>
>>> -   strncpy(host, utmp.ut_host, sizeof(utmp.ut_host));
>>> -   host[sizeof(utmp.ut_host)] = 0;
>>> +   strncpy(host, utmp.ut_host, sizeof(host));
>>
>> Wait... This may access utmp.ut_host one byte past the end and no
>> longer guarantees that host is null-terminated, right?
>
> No, strncpy "copies at most len characters from src into dst".

Substituting 'len', 'src' and 'dst' gives me:

strncpy "copies at most 'sizeof(utmp.ut_host) + 1' characters from
'utmp.ut_host' into 'host'".

As 'utmp.ut_host' is not guaranteed to be null-terminated by POSIX*,
it can actually end up in the situation where it copies
'sizeof(utmp.ut_host) + 1' characters, which may leave 'host'
unterminated.

-- 
Ed Schouten <e...@nuxi.nl>
Nuxi, 's-Hertogenbosch, the Netherlands
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r328492 - head/contrib/opie/libopie

2018-01-27 Thread Ed Schouten
Hi Pedro,

2018-01-27 23:16 GMT+01:00 Pedro F. Giffuni <p...@freebsd.org>:
> char host[sizeof(utmp.ut_host) + 1];
> insecure = 1;
>
> -   strncpy(host, utmp.ut_host, sizeof(utmp.ut_host));
> -   host[sizeof(utmp.ut_host)] = 0;
> +   strncpy(host, utmp.ut_host, sizeof(host));

Wait... This may access utmp.ut_host one byte past the end and no
longer guarantees that host is null-terminated, right?

-- 
Ed Schouten <e...@nuxi.nl>
Nuxi, 's-Hertogenbosch, the Netherlands
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r328430 - head/sbin/devd

2018-01-25 Thread Ed Schouten
2018-01-26 5:52 GMT+01:00 Warner Losh <i...@bsdimp.com>:
> Everything needs a virtual destructor...  Please back that part of this
> out...

If you're concerned about inheritance, what about adding the 'final'
keyword to the class?

http://en.cppreference.com/w/cpp/language/final

Eitan:

static void usage(void) __dead2;

This should be spelled:

[[noreturn]] static void usage();

-- 
Ed Schouten <e...@nuxi.nl>
Nuxi, 's-Hertogenbosch, the Netherlands
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r327684 - in head/sys/compat: cloudabi32 cloudabi64

2018-01-08 Thread Ed Schouten
Hi Andrew,

2018-01-08 8:37 GMT+01:00 Andrew Turner <and...@fubar.geek.nz>:
> Won’t this lead to a NULL pointer dereference on overflow? mallocarray can 
> return NULL even with M_WAITOK.

Yes, it will, but an overflow shouldn't happen in the first place.
ri_data_len is compared with UIO_MAXIOV a few lines above. Even if an
overflow would happen, this would cause a kernel panic due to a NULL
pointer dereference later on, which is likely easier to debug than
some piece of code that overruns a buffer.

In this case, mallocarray() is preferred, because it makes it more
obvious that we're allocating a buffer that is accessed as an array,
as opposed to single structure.

-- 
Ed Schouten <e...@nuxi.nl>
Nuxi, 's-Hertogenbosch, the Netherlands
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r327684 - in head/sys/compat: cloudabi32 cloudabi64

2018-01-07 Thread Ed Schouten
Author: ed
Date: Sun Jan  7 22:38:45 2018
New Revision: 327684
URL: https://svnweb.freebsd.org/changeset/base/327684

Log:
  Use mallocarray(9) in CloudABI kernel code where possible.
  
  Submitted by: pfg@

Modified:
  head/sys/compat/cloudabi32/cloudabi32_sock.c
  head/sys/compat/cloudabi64/cloudabi64_sock.c

Modified: head/sys/compat/cloudabi32/cloudabi32_sock.c
==
--- head/sys/compat/cloudabi32/cloudabi32_sock.cSun Jan  7 22:21:07 
2018(r327683)
+++ head/sys/compat/cloudabi32/cloudabi32_sock.cSun Jan  7 22:38:45 
2018(r327684)
@@ -60,7 +60,7 @@ cloudabi32_sys_sock_recv(struct thread *td,
/* Convert iovecs to native format. */
if (ri.ri_data_len > UIO_MAXIOV)
return (EINVAL);
-   iov = malloc(ri.ri_data_len * sizeof(struct iovec),
+   iov = mallocarray(ri.ri_data_len, sizeof(struct iovec),
M_SOCKET, M_WAITOK);
user_iov = TO_PTR(ri.ri_data);
for (i = 0; i < ri.ri_data_len; i++) {
@@ -104,7 +104,7 @@ cloudabi32_sys_sock_send(struct thread *td,
/* Convert iovecs to native format. */
if (si.si_data_len > UIO_MAXIOV)
return (EINVAL);
-   iov = malloc(si.si_data_len * sizeof(struct iovec),
+   iov = mallocarray(si.si_data_len, sizeof(struct iovec),
M_SOCKET, M_WAITOK);
user_iov = TO_PTR(si.si_data);
for (i = 0; i < si.si_data_len; i++) {

Modified: head/sys/compat/cloudabi64/cloudabi64_sock.c
==
--- head/sys/compat/cloudabi64/cloudabi64_sock.cSun Jan  7 22:21:07 
2018(r327683)
+++ head/sys/compat/cloudabi64/cloudabi64_sock.cSun Jan  7 22:38:45 
2018(r327684)
@@ -60,7 +60,7 @@ cloudabi64_sys_sock_recv(struct thread *td,
/* Convert iovecs to native format. */
if (ri.ri_data_len > UIO_MAXIOV)
return (EINVAL);
-   iov = malloc(ri.ri_data_len * sizeof(struct iovec),
+   iov = mallocarray(ri.ri_data_len, sizeof(struct iovec),
M_SOCKET, M_WAITOK);
user_iov = TO_PTR(ri.ri_data);
for (i = 0; i < ri.ri_data_len; i++) {
@@ -104,7 +104,7 @@ cloudabi64_sys_sock_send(struct thread *td,
/* Convert iovecs to native format. */
if (si.si_data_len > UIO_MAXIOV)
return (EINVAL);
-   iov = malloc(si.si_data_len * sizeof(struct iovec),
+   iov = mallocarray(si.si_data_len, sizeof(struct iovec),
M_SOCKET, M_WAITOK);
user_iov = TO_PTR(si.si_data);
for (i = 0; i < si.si_data_len; i++) {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r327560 - in head/sys/compat: cloudabi cloudabi32 cloudabi64

2018-01-04 Thread Ed Schouten
Author: ed
Date: Thu Jan  4 21:57:37 2018
New Revision: 327560
URL: https://svnweb.freebsd.org/changeset/base/327560

Log:
  Allow timed waits with relative timeouts on locks and condvars.
  
  Even though pthreads doesn't support this, there are various alternative
  APIs that use this. For example, uv_cond_timedwait() accepts a relative
  timeout. So does Rust's std::sync::Condvar::wait_timeout().
  
  Though I personally think that relative timeouts are bad (due to
  imprecision for repeated operations), it does seem that people want
  this. Extend the existing futex functions to keep track of whether an
  absolute timeout is used in a boolean flag.
  
  MFC after:1 month

Modified:
  head/sys/compat/cloudabi/cloudabi_futex.c
  head/sys/compat/cloudabi/cloudabi_util.h
  head/sys/compat/cloudabi32/cloudabi32_poll.c
  head/sys/compat/cloudabi64/cloudabi64_poll.c

Modified: head/sys/compat/cloudabi/cloudabi_futex.c
==
--- head/sys/compat/cloudabi/cloudabi_futex.c   Thu Jan  4 20:05:47 2018
(r327559)
+++ head/sys/compat/cloudabi/cloudabi_futex.c   Thu Jan  4 21:57:37 2018
(r327560)
@@ -197,7 +197,7 @@ static void futex_queue_requeue(struct futex_queue *, 
 unsigned int);
 static int futex_queue_sleep(struct futex_queue *, struct futex_lock *,
 struct futex_waiter *, struct thread *, cloudabi_clockid_t,
-cloudabi_timestamp_t, cloudabi_timestamp_t);
+cloudabi_timestamp_t, cloudabi_timestamp_t, bool);
 static cloudabi_tid_t futex_queue_tid_best(const struct futex_queue *);
 static void futex_queue_wake_up_all(struct futex_queue *);
 static void futex_queue_wake_up_best(struct futex_queue *);
@@ -427,7 +427,7 @@ futex_lock_lookup_locked(struct futex_address *fa)
 static int
 futex_lock_rdlock(struct futex_lock *fl, struct thread *td,
 cloudabi_lock_t *lock, cloudabi_clockid_t clock_id,
-cloudabi_timestamp_t timeout, cloudabi_timestamp_t precision)
+cloudabi_timestamp_t timeout, cloudabi_timestamp_t precision, bool abstime)
 {
struct futex_waiter fw;
int error;
@@ -438,7 +438,7 @@ futex_lock_rdlock(struct futex_lock *fl, struct thread
KASSERT(fl->fl_owner != LOCK_UNMANAGED,
("Attempted to sleep on an unmanaged lock"));
error = futex_queue_sleep(>fl_readers, fl, , td,
-   clock_id, timeout, precision);
+   clock_id, timeout, precision, abstime);
KASSERT((error == 0) == fw.fw_locked,
("Should have locked write lock on success"));
KASSERT(futex_queue_count(_donated) == 0,
@@ -707,7 +707,7 @@ futex_lock_wake_up_next(struct futex_lock *fl, cloudab
 static int
 futex_lock_wrlock(struct futex_lock *fl, struct thread *td,
 cloudabi_lock_t *lock, cloudabi_clockid_t clock_id,
-cloudabi_timestamp_t timeout, cloudabi_timestamp_t precision,
+cloudabi_timestamp_t timeout, cloudabi_timestamp_t precision, bool abstime,
 struct futex_queue *donated)
 {
struct futex_waiter fw;
@@ -735,7 +735,7 @@ futex_lock_wrlock(struct futex_lock *fl, struct thread
KASSERT(fl->fl_owner != LOCK_UNMANAGED,
("Attempted to sleep on an unmanaged lock"));
error = futex_queue_sleep(>fl_writers, fl, , td,
-   clock_id, timeout, precision);
+   clock_id, timeout, precision, abstime);
KASSERT((error == 0) == fw.fw_locked,
("Should have locked write lock on success"));
KASSERT(futex_queue_count(_donated) == 0,
@@ -789,16 +789,18 @@ futex_queue_convert_timestamp_relative(cloudabi_timest
 static int
 futex_queue_convert_timestamp(struct thread *td, cloudabi_clockid_t clock_id,
 cloudabi_timestamp_t timeout, cloudabi_timestamp_t precision,
-sbintime_t *sbttimeout, sbintime_t *sbtprecision)
+sbintime_t *sbttimeout, sbintime_t *sbtprecision, bool abstime)
 {
cloudabi_timestamp_t now;
int error;
 
-   /* Make the time relative. */
-   error = cloudabi_clock_time_get(td, clock_id, );
-   if (error != 0)
-   return (error);
-   timeout = timeout < now ? 0 : timeout - now;
+   if (abstime) {
+   /* Make the time relative. */
+   error = cloudabi_clock_time_get(td, clock_id, );
+   if (error != 0)
+   return (error);
+   timeout = timeout < now ? 0 : timeout - now;
+   }
 
*sbttimeout = futex_queue_convert_timestamp_relative(timeout);
*sbtprecision = futex_queue_convert_timestamp_relative(precision);
@@ -808,7 +810,7 @@ futex_queue_convert_timestamp(struct thread *td, cloud
 static int
 futex_queue_sleep(struct futex_queue *fq, struct futex_lock *fl,
 struct futex_waiter *fw, struct thread *td, cloudabi_clockid_t clock_id,
-cloudabi_timestamp_t timeout, cloudabi_timestamp_t 

svn commit: r327057 - head/usr.bin/truss

2017-12-21 Thread Ed Schouten
Author: ed
Date: Thu Dec 21 09:21:40 2017
New Revision: 327057
URL: https://svnweb.freebsd.org/changeset/base/327057

Log:
  Make truss work for CloudABI executables on i386.
  
  The system call convention is different from i386 binaries running on
  FreeBSD/amd64, but this is not noticeable by executables. On
  FreeBSD/amd64, the vDSO already does padding of arguments and return
  values to 64-bit values. On i386, it does not, meaning that system call
  return values are simply stored in registers.

Added:
  head/usr.bin/truss/i386-cloudabi32.c
 - copied, changed from r327055, head/usr.bin/truss/amd64-cloudabi32.c
Modified:
  head/usr.bin/truss/Makefile

Modified: head/usr.bin/truss/Makefile
==
--- head/usr.bin/truss/Makefile Thu Dec 21 09:17:48 2017(r327056)
+++ head/usr.bin/truss/Makefile Thu Dec 21 09:21:40 2017(r327057)
@@ -18,6 +18,7 @@ ABIS+=cloudabi64
 .endif
 .if ${MACHINE_CPUARCH} == "i386"
 ABIS+= i386-linux
+ABIS+= cloudabi32
 .endif
 .if ${MACHINE_CPUARCH} == "amd64"
 ABIS+= amd64-linux

Copied and modified: head/usr.bin/truss/i386-cloudabi32.c (from r327055, 
head/usr.bin/truss/amd64-cloudabi32.c)
==
--- head/usr.bin/truss/amd64-cloudabi32.c   Thu Dec 21 04:23:00 2017
(r327055, copy source)
+++ head/usr.bin/truss/i386-cloudabi32.cThu Dec 21 09:21:40 2017
(r327057)
@@ -38,7 +38,7 @@ __FBSDID("$FreeBSD$");
 #include "truss.h"
 
 static int
-amd64_cloudabi32_fetch_args(struct trussinfo *trussinfo, unsigned int narg)
+i386_cloudabi32_fetch_args(struct trussinfo *trussinfo, unsigned int narg)
 {
struct current_syscall *cs;
struct ptrace_io_desc iorequest;
@@ -46,7 +46,7 @@ amd64_cloudabi32_fetch_args(struct trussinfo *trussinf
lwpid_t tid;
 
if (narg > 0) {
-   /* Fetch registers, containing the address of the arguments. */
+   /* Fetch registers, containing the stack pointer. */
tid = trussinfo->curthread->tid;
if (ptrace(PT_GETREGS, tid, (caddr_t), 0) == -1) {
fprintf(trussinfo->outfile,
@@ -54,10 +54,10 @@ amd64_cloudabi32_fetch_args(struct trussinfo *trussinf
return (-1);
}
 
-   /* Fetch arguments. They are already padded to 64 bits. */
+   /* Fetch arguments. */
cs = >curthread->cs;
iorequest.piod_op = PIOD_READ_D;
-   iorequest.piod_offs = (void *)regs.r_rcx;
+   iorequest.piod_offs = (void **)regs.r_esp + 1;
iorequest.piod_addr = cs->args;
iorequest.piod_len = sizeof(cs->args[0]) * narg;
if (ptrace(PT_IO, tid, (caddr_t), 0) == -1 ||
@@ -68,45 +68,31 @@ amd64_cloudabi32_fetch_args(struct trussinfo *trussinf
 }
 
 static int
-amd64_cloudabi32_fetch_retval(struct trussinfo *trussinfo, long *retval,
+i386_cloudabi32_fetch_retval(struct trussinfo *trussinfo, long *retval,
 int *errorp)
 {
-   struct ptrace_io_desc iorequest;
struct reg regs;
lwpid_t tid;
 
-   /* Fetch registers, containing the address of the return values. */
tid = trussinfo->curthread->tid;
if (ptrace(PT_GETREGS, tid, (caddr_t), 0) == -1) {
fprintf(trussinfo->outfile, "-- CANNOT READ REGISTERS --\n");
return (-1);
}
 
-   if (regs.r_rax == 0) {
-   /* System call succeeded. Fetch return values. */
-   iorequest.piod_op = PIOD_READ_D;
-   iorequest.piod_offs = (void *)regs.r_rcx;
-   iorequest.piod_addr = retval;
-   iorequest.piod_len = sizeof(retval[0]) * 2;
-   if (ptrace(PT_IO, tid, (caddr_t), 0) == -1 ||
-   iorequest.piod_len == 0)
-   return (-1);
-   *errorp = 0;
-   } else {
-   /* System call failed. Set error. */
-   retval[0] = regs.r_rax;
-   *errorp = 1;
-   }
+   retval[0] = regs.r_eax;
+   retval[1] = regs.r_edx;
+   *errorp = (regs.r_eflags & PSL_C) != 0;
return (0);
 }
 
-static struct procabi amd64_cloudabi32 = {
+static struct procabi i386_cloudabi32 = {
"CloudABI ELF32",
SYSDECODE_ABI_CLOUDABI32,
-   amd64_cloudabi32_fetch_args,
-   amd64_cloudabi32_fetch_retval,
-   STAILQ_HEAD_INITIALIZER(amd64_cloudabi32.extra_syscalls),
+   i386_cloudabi32_fetch_args,
+   i386_cloudabi32_fetch_retval,
+   STAILQ_HEAD_INITIALIZER(i386_cloudabi32.extra_syscalls),
{ NULL }
 };
 
-PROCABI(amd64_cloudabi32);
+PROCABI(i386_cloudabi32);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any 

svn commit: r327022 - head/usr.bin/truss

2017-12-20 Thread Ed Schouten
Author: ed
Date: Wed Dec 20 13:13:10 2017
New Revision: 327022
URL: https://svnweb.freebsd.org/changeset/base/327022

Log:
  Make truss(8) work for 32-bit CloudABI executables on ARM64.
  
  This change effectively merges the existing 64-bit support for ARM64
  with the 32-on-64-bit support for AMD64.

Added:
  head/usr.bin/truss/aarch64-cloudabi32.c
 - copied, changed from r327021, head/usr.bin/truss/aarch64-cloudabi64.c
Modified:
  head/usr.bin/truss/Makefile

Modified: head/usr.bin/truss/Makefile
==
--- head/usr.bin/truss/Makefile Wed Dec 20 07:55:47 2017(r327021)
+++ head/usr.bin/truss/Makefile Wed Dec 20 13:13:10 2017(r327022)
@@ -13,6 +13,7 @@ ABIS+=freebsd
 # Each ABI is expected to have an ABI.c, MACHINE_ARCH-ABI.c or
 # MACHINE_CPUARCH-ABI.c file that will be used to map the syscall arguments.
 .if ${MACHINE_ARCH} == "aarch64"
+ABIS+= cloudabi32
 ABIS+= cloudabi64
 .endif
 .if ${MACHINE_CPUARCH} == "i386"

Copied and modified: head/usr.bin/truss/aarch64-cloudabi32.c (from r327021, 
head/usr.bin/truss/aarch64-cloudabi64.c)
==
--- head/usr.bin/truss/aarch64-cloudabi64.c Wed Dec 20 07:55:47 2017
(r327021, copy source)
+++ head/usr.bin/truss/aarch64-cloudabi32.c Wed Dec 20 13:13:10 2017
(r327022)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2015 Nuxi, https://nuxi.nl/
+ * Copyright (c) 2015-2017 Nuxi, https://nuxi.nl/
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -38,51 +38,75 @@ __FBSDID("$FreeBSD$");
 #include "truss.h"
 
 static int
-aarch64_cloudabi64_fetch_args(struct trussinfo *trussinfo, unsigned int narg)
+aarch64_cloudabi32_fetch_args(struct trussinfo *trussinfo, unsigned int narg)
 {
struct current_syscall *cs;
+   struct ptrace_io_desc iorequest;
struct reg regs;
lwpid_t tid;
-   unsigned int i;
 
-   tid = trussinfo->curthread->tid;
-   if (ptrace(PT_GETREGS, tid, (caddr_t), 0) == -1) {
-   fprintf(trussinfo->outfile, "-- CANNOT READ REGISTERS --\n");
-   return (-1);
-   }
+   if (narg > 0) {
+   /* Fetch registers, containing the address of the arguments. */
+   tid = trussinfo->curthread->tid;
+   if (ptrace(PT_GETREGS, tid, (caddr_t), 0) == -1) {
+   fprintf(trussinfo->outfile,
+   "-- CANNOT READ REGISTERS --\n");
+   return (-1);
+   }
 
-   cs = >curthread->cs;
-   for (i = 0; i < narg && i < 8; i++)
-   cs->args[i] = regs.x[i];
+   /* Fetch arguments. They are already padded to 64 bits. */
+   cs = >curthread->cs;
+   iorequest.piod_op = PIOD_READ_D;
+   iorequest.piod_offs = (void *)regs.x[2];
+   iorequest.piod_addr = cs->args;
+   iorequest.piod_len = sizeof(cs->args[0]) * narg;
+   if (ptrace(PT_IO, tid, (caddr_t), 0) == -1 ||
+   iorequest.piod_len == 0)
+   return (-1);
+   }
return (0);
 }
 
 static int
-aarch64_cloudabi64_fetch_retval(struct trussinfo *trussinfo, long *retval,
+aarch64_cloudabi32_fetch_retval(struct trussinfo *trussinfo, long *retval,
 int *errorp)
 {
+   struct ptrace_io_desc iorequest;
struct reg regs;
lwpid_t tid;
 
+   /* Fetch registers, containing the address of the return values. */
tid = trussinfo->curthread->tid;
if (ptrace(PT_GETREGS, tid, (caddr_t), 0) == -1) {
fprintf(trussinfo->outfile, "-- CANNOT READ REGISTERS --\n");
return (-1);
}
 
-   retval[0] = regs.x[0];
-   retval[1] = regs.x[1];
-   *errorp = (regs.spsr & PSR_C) != 0;
+   if ((regs.spsr & PSR_C) == 0) {
+   /* System call succeeded. Fetch return values. */
+   iorequest.piod_op = PIOD_READ_D;
+   iorequest.piod_offs = (void *)regs.x[2];
+   iorequest.piod_addr = retval;
+   iorequest.piod_len = sizeof(retval[0]) * 2;
+   if (ptrace(PT_IO, tid, (caddr_t), 0) == -1 ||
+   iorequest.piod_len == 0)
+   return (-1);
+   *errorp = 0;
+   } else {
+   /* System call failed. Set error. */
+   retval[0] = regs.x[0];
+   *errorp = 1;
+   }
return (0);
 }
 
-static struct procabi aarch64_cloudabi64 = {
-   "CloudABI ELF64",
-   SYSDECODE_ABI_CLOUDABI64,
-   aarch64_cloudabi64_fetch_args,
-   aarch64_cloudabi64_fetch_retval,
-   STAILQ_HEAD_INITIALIZER(aarch64_cloudabi64.extra_syscalls),
+static struct procabi aarch64_cloudabi32 = {
+   "CloudABI ELF32",
+ 

svn commit: r326911 - head/usr.bin/truss

2017-12-16 Thread Ed Schouten
Author: ed
Date: Sat Dec 16 19:40:28 2017
New Revision: 326911
URL: https://svnweb.freebsd.org/changeset/base/326911

Log:
  Make truss(8) work for i686-unknown-cloudabi binaries on FreeBSD/amd64.
  
  This change copies the existing amd64_cloudabi64.c to amd64_cloudabi32.c
  and reimplements the functions for fetching system call arguments and
  return values to use the same scheme as used by the vDSO that is used
  when running cloudabi32 executables.
  
  As arguments are automatically padded to 64-bit words by the vDSO in
  userspace, we can copy the arguments directly into the array used by
  truss(8) internally.
  
  Reviewed by:  jhb
  Differential Revision:https://reviews.freebsd.org/D13516

Added:
  head/usr.bin/truss/amd64-cloudabi32.c
 - copied, changed from r326896, head/usr.bin/truss/amd64-cloudabi64.c
Modified:
  head/usr.bin/truss/Makefile

Modified: head/usr.bin/truss/Makefile
==
--- head/usr.bin/truss/Makefile Sat Dec 16 19:37:55 2017(r326910)
+++ head/usr.bin/truss/Makefile Sat Dec 16 19:40:28 2017(r326911)
@@ -22,6 +22,7 @@ ABIS+=i386-linux
 ABIS+= amd64-linux
 ABIS+= amd64-linux32
 ABIS+= freebsd32
+ABIS+= cloudabi32
 ABIS+= cloudabi64
 .endif
 .if ${MACHINE_ARCH} == "powerpc64"

Copied and modified: head/usr.bin/truss/amd64-cloudabi32.c (from r326896, 
head/usr.bin/truss/amd64-cloudabi64.c)
==
--- head/usr.bin/truss/amd64-cloudabi64.c   Sat Dec 16 12:23:59 2017
(r326896, copy source)
+++ head/usr.bin/truss/amd64-cloudabi32.c   Sat Dec 16 19:40:28 2017
(r326911)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2015 Nuxi, https://nuxi.nl/
+ * Copyright (c) 2015-2017 Nuxi, https://nuxi.nl/
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -38,60 +38,75 @@ __FBSDID("$FreeBSD$");
 #include "truss.h"
 
 static int
-amd64_cloudabi64_fetch_args(struct trussinfo *trussinfo, unsigned int narg)
+amd64_cloudabi32_fetch_args(struct trussinfo *trussinfo, unsigned int narg)
 {
struct current_syscall *cs;
+   struct ptrace_io_desc iorequest;
struct reg regs;
lwpid_t tid;
 
-   tid = trussinfo->curthread->tid;
-   if (ptrace(PT_GETREGS, tid, (caddr_t), 0) == -1) {
-   fprintf(trussinfo->outfile, "-- CANNOT READ REGISTERS --\n");
-   return (-1);
-   }
+   if (narg > 0) {
+   /* Fetch registers, containing the address of the arguments. */
+   tid = trussinfo->curthread->tid;
+   if (ptrace(PT_GETREGS, tid, (caddr_t), 0) == -1) {
+   fprintf(trussinfo->outfile,
+   "-- CANNOT READ REGISTERS --\n");
+   return (-1);
+   }
 
-   cs = >curthread->cs;
-   if (narg >= 1)
-   cs->args[0] = regs.r_rdi;
-   if (narg >= 2)
-   cs->args[1] = regs.r_rsi;
-   if (narg >= 3)
-   cs->args[2] = regs.r_rdx;
-   if (narg >= 4)
-   cs->args[3] = regs.r_rcx;
-   if (narg >= 5)
-   cs->args[4] = regs.r_r8;
-   if (narg >= 6)
-   cs->args[5] = regs.r_r9;
+   /* Fetch arguments. They are already padded to 64 bits. */
+   cs = >curthread->cs;
+   iorequest.piod_op = PIOD_READ_D;
+   iorequest.piod_offs = (void *)regs.r_rcx;
+   iorequest.piod_addr = cs->args;
+   iorequest.piod_len = sizeof(cs->args[0]) * narg;
+   if (ptrace(PT_IO, tid, (caddr_t), 0) == -1 ||
+   iorequest.piod_len == 0)
+   return (-1);
+   }
return (0);
 }
 
 static int
-amd64_cloudabi64_fetch_retval(struct trussinfo *trussinfo, long *retval,
+amd64_cloudabi32_fetch_retval(struct trussinfo *trussinfo, long *retval,
 int *errorp)
 {
+   struct ptrace_io_desc iorequest;
struct reg regs;
lwpid_t tid;
 
+   /* Fetch registers, containing the address of the return values. */
tid = trussinfo->curthread->tid;
if (ptrace(PT_GETREGS, tid, (caddr_t), 0) == -1) {
fprintf(trussinfo->outfile, "-- CANNOT READ REGISTERS --\n");
return (-1);
}
 
-   retval[0] = regs.r_rax;
-   retval[1] = regs.r_rdx;
-   *errorp = (regs.r_rflags & PSL_C) != 0;
+   if (regs.r_rax == 0) {
+   /* System call succeeded. Fetch return values. */
+   iorequest.piod_op = PIOD_READ_D;
+   iorequest.piod_offs = (void *)regs.r_rcx;
+   iorequest.piod_addr = retval;
+   iorequest.piod_len = sizeof(retval[0]) * 2;
+   if (ptrace(PT_IO, tid, (caddr_t), 0) == -1 ||
+   

svn commit: r326910 - head/lib/libsysdecode

2017-12-16 Thread Ed Schouten
Author: ed
Date: Sat Dec 16 19:37:55 2017
New Revision: 326910
URL: https://svnweb.freebsd.org/changeset/base/326910

Log:
  libsysdecode: Add a new ABI type, SYSDECODE_ABI_CLOUDABI32.
  
  In order to let truss(8) support tracing of 32-bit CloudABI
  applications, we need to add a new ABI type to libsysdecode. We can
  reuse the existing errno mapping table. Also link in the cloudabi32
  system call table to translate system call names.
  
  While there, remove all of the architecture ifdefs. There are not
  needed, as the CloudABI data types and system call tables build fine on
  any architecture. Building this unconditionally will make it easier to
  do tracing for different compat modes, emulation, etc.
  
  Reviewed by:  jhb
  Differential Revision:https://reviews.freebsd.org/D13516

Modified:
  head/lib/libsysdecode/errno.c
  head/lib/libsysdecode/syscallnames.c
  head/lib/libsysdecode/sysdecode.3
  head/lib/libsysdecode/sysdecode.h

Modified: head/lib/libsysdecode/errno.c
==
--- head/lib/libsysdecode/errno.c   Sat Dec 16 18:06:30 2017
(r326909)
+++ head/lib/libsysdecode/errno.c   Sat Dec 16 19:37:55 2017
(r326910)
@@ -58,7 +58,6 @@ static int bsd_to_linux_errno[ELAST + 1] = {
 };
 #endif
 
-#if defined(__aarch64__) || defined(__amd64__)
 #include 
 
 static const int cloudabi_errno_table[] = {
@@ -139,7 +138,6 @@ static const int cloudabi_errno_table[] = {
[CLOUDABI_EXDEV]= EXDEV,
[CLOUDABI_ENOTCAPABLE]  = ENOTCAPABLE,
 };
-#endif
 
 int
 sysdecode_abi_to_freebsd_errno(enum sysdecode_abi abi, int error)
@@ -165,13 +163,12 @@ sysdecode_abi_to_freebsd_errno(enum sysdecode_abi abi,
break;
}
 #endif
-#if defined(__aarch64__) || defined(__amd64__)
+   case SYSDECODE_ABI_CLOUDABI32:
case SYSDECODE_ABI_CLOUDABI64:
if (error >= 0 &&
(unsigned int)error < nitems(cloudabi_errno_table))
return (cloudabi_errno_table[error]);
break;
-#endif
default:
break;
}
@@ -193,7 +190,7 @@ sysdecode_freebsd_to_abi_errno(enum sysdecode_abi abi,
return (bsd_to_linux_errno[error]);
break;
 #endif
-#if defined(__aarch64__) || defined(__amd64__)
+   case SYSDECODE_ABI_CLOUDABI32:
case SYSDECODE_ABI_CLOUDABI64: {
unsigned int i;
 
@@ -203,7 +200,6 @@ sysdecode_freebsd_to_abi_errno(enum sysdecode_abi abi,
}
break;
}
-#endif
default:
break;
}

Modified: head/lib/libsysdecode/syscallnames.c
==
--- head/lib/libsysdecode/syscallnames.cSat Dec 16 18:06:30 2017
(r326909)
+++ head/lib/libsysdecode/syscallnames.cSat Dec 16 19:37:55 2017
(r326910)
@@ -63,10 +63,10 @@ static
 #include 
 #endif
 
-#if defined(__amd64__) || defined(__aarch64__)
 static
+#include 
+static
 #include 
-#endif
 
 const char *
 sysdecode_syscallname(enum sysdecode_abi abi, unsigned int code)
@@ -95,12 +95,14 @@ sysdecode_syscallname(enum sysdecode_abi abi, unsigned
return (linux32_syscallnames[code]);
break;
 #endif
-#if defined(__amd64__) || defined(__aarch64__)
+   case SYSDECODE_ABI_CLOUDABI32:
+   if (code < nitems(cloudabi32_syscallnames))
+   return (cloudabi32_syscallnames[code]);
+   break;
case SYSDECODE_ABI_CLOUDABI64:
if (code < nitems(cloudabi64_syscallnames))
return (cloudabi64_syscallnames[code]);
break;
-#endif
default:
break;
}

Modified: head/lib/libsysdecode/sysdecode.3
==
--- head/lib/libsysdecode/sysdecode.3   Sat Dec 16 18:06:30 2017
(r326909)
+++ head/lib/libsysdecode/sysdecode.3   Sat Dec 16 19:37:55 2017
(r326910)
@@ -25,7 +25,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd November 24, 2017
+.Dd December 16, 2017
 .Dt SYSDECODE 3
 .Os
 .Sh NAME
@@ -61,9 +61,12 @@ Supported on amd64 and i386.
 .It Li SYSDECODE_ABI_LINUX32
 32-bit Linux binaries.
 Supported on amd64.
+.It Li SYSDECODE_ABI_CLOUDABI32
+32-bit CloudABI binaries.
+Supported on all platforms.
 .It Li SYSDECODE_ABI_CLOUDABI64
 64-bit CloudABI binaries.
-Supported on aarch64 and amd64.
+Supported on all platforms.
 .It Li SYSDECODE_ABI_UNKNOWN
 A placeholder for use when the ABI is not known.
 .El

Modified: head/lib/libsysdecode/sysdecode.h
==
--- head/lib/libsysdecode/sysdecode.h   Sat Dec 16 18:06:30 2017
(r326909)
+++ head/lib/libsysdecode/sysdecode.h   Sat Dec 16 19:37:55 2017
(r326910)
@@ -35,7 

svn commit: r326719 - in head: . include lib/libc/gen

2017-12-08 Thread Ed Schouten
Author: ed
Date: Fri Dec  8 22:06:18 2017
New Revision: 326719
URL: https://svnweb.freebsd.org/changeset/base/326719

Log:
  Remove basename_r(3).
  
  Now that the POSIX working group is going to require that basename(3)
  and dirname(3) are thread-safe in future revisions of the standard,
  there is even less of a need to provide basename_r(3). Remove this
  function to prevent people from writing code that only builds on
  FreeBSD and Bionic.
  
  Removing this function seems to break exactly one port: sbruno@'s
  qemu-user-static. I will send him a pull request on GitHub in a bit.
  __FreeBSD_version will not be bumped, as any value from 2017 can be used
  to test for the presence of a thread-safe basename(3)/dirname(3).
  
  PR:   https://bugs.freebsd.org/224016

Modified:
  head/ObsoleteFiles.inc
  head/include/libgen.h
  head/lib/libc/gen/Makefile.inc
  head/lib/libc/gen/Symbol.map
  head/lib/libc/gen/basename_compat.c

Modified: head/ObsoleteFiles.inc
==
--- head/ObsoleteFiles.inc  Fri Dec  8 21:59:50 2017(r326718)
+++ head/ObsoleteFiles.inc  Fri Dec  8 22:06:18 2017(r326719)
@@ -38,6 +38,8 @@
 #   xargs -n1 | sort | uniq -d;
 # done
 
+# 20171208: Remove basename_r(3)
+OLD_FILES+=usr/share/man/man3/basename_r.3.gz
 # 20171204: Move fdformat man page from volume 1 to volume 8.
 OLD_FILES+=usr/share/man/man1/fdformat.1.gz
 # 20171203: libproc version bump

Modified: head/include/libgen.h
==
--- head/include/libgen.h   Fri Dec  8 21:59:50 2017(r326718)
+++ head/include/libgen.h   Fri Dec  8 22:06:18 2017(r326719)
@@ -37,7 +37,6 @@
 
 __BEGIN_DECLS
 char   *basename(char *);
-char   *basename_r(const char *, char *);
 char   *dirname(char *);
 __END_DECLS
 

Modified: head/lib/libc/gen/Makefile.inc
==
--- head/lib/libc/gen/Makefile.inc  Fri Dec  8 21:59:50 2017
(r326718)
+++ head/lib/libc/gen/Makefile.inc  Fri Dec  8 22:06:18 2017
(r326719)
@@ -312,7 +312,6 @@ MLINKS+=arc4random.3 arc4random_addrandom.3 \
arc4random.3 arc4random_stir.3 \
arc4random.3 arc4random_buf.3 \
arc4random.3 arc4random_uniform.3
-MLINKS+=basename.3 basename_r.3
 MLINKS+=ctermid.3 ctermid_r.3
 MLINKS+=devname.3 devname_r.3
 MLINKS+=devname.3 fdevname.3

Modified: head/lib/libc/gen/Symbol.map
==
--- head/lib/libc/gen/Symbol.mapFri Dec  8 21:59:50 2017
(r326718)
+++ head/lib/libc/gen/Symbol.mapFri Dec  8 22:06:18 2017
(r326719)
@@ -332,7 +332,6 @@ FBSD_1.1 {
 };
 
 FBSD_1.2 {
-   basename_r;
cfmakesane;
endutxent;
getpagesizes;

Modified: head/lib/libc/gen/basename_compat.c
==
--- head/lib/libc/gen/basename_compat.c Fri Dec  8 21:59:50 2017
(r326718)
+++ head/lib/libc/gen/basename_compat.c Fri Dec  8 22:06:18 2017
(r326719)
@@ -26,7 +26,7 @@ __FBSDID("$FreeBSD$");
 #include 
 
 char *
-basename_r(const char *path, char *bname)
+__freebsd11_basename_r(const char *path, char *bname)
 {
const char *endp, *startp;
size_t len;
@@ -75,7 +75,8 @@ __freebsd11_basename(char *path)
if (bname == NULL)
return (NULL);
}
-   return (basename_r(path, bname));
+   return (__freebsd11_basename_r(path, bname));
 }
 
+__sym_compat(basename_r, __freebsd11_basename_r, FBSD_1.2);
 __sym_compat(basename, __freebsd11_basename, FBSD_1.0);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r326558 - in head: . usr.sbin/fdformat

2017-12-05 Thread Ed Schouten
2017-12-05 6:02 GMT+01:00 Cy Schubert <c...@freebsd.org>:
> +OLD_FILES+=usr/share/man/man8/fdformat.1.gz

s/man8/man1/, right? :-)

-- 
Ed Schouten <e...@nuxi.nl>
Nuxi, 's-Hertogenbosch, the Netherlands
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r326518 - head/contrib/mdocml

2017-12-04 Thread Ed Schouten
2017-12-04 10:57 GMT+01:00 Baptiste Daroussin <b...@freebsd.org>:
> I just have one thing to say here: why? seriously why? :)

It's just a branching thing. The 2013 and 2016 editions are the same
as the 2008 standard, but have fixes for some of the errata. Think of
the 2008 standard being "POSIX 7.0" and the 2013 and 2016 editions
being 7.1 and 7.2, respectively.

In the meantime, the POSIX folks are working on the 8th version of the
standard. This is where some of the larger changes/additions may be
done.

-- 
Ed Schouten <e...@nuxi.nl>
Nuxi, 's-Hertogenbosch, the Netherlands
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r326518 - head/contrib/mdocml

2017-12-04 Thread Ed Schouten
2017-12-04 10:48 GMT+01:00 Baptiste Daroussin <b...@freebsd.org>:
> Log:
>   Add Posix 2013 référence for manpages

I'm not sure that's correct. As far as I know, it's called "IEEE Std
1003.1-2008, 2013 Edition".

The top of this page is a bit ambiguous about it:
http://pubs.opengroup.org/onlinepubs/9699919799.2013edition/
But look at the top of the 2016 edition instead:
http://pubs.opengroup.org/onlinepubs/9699919799.2016edition/

-- 
Ed Schouten <e...@nuxi.nl>
Nuxi, 's-Hertogenbosch, the Netherlands
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r326501 - head/sys/arm64/conf

2017-12-03 Thread Ed Schouten
Author: ed
Date: Sun Dec  3 19:26:14 2017
New Revision: 326501
URL: https://svnweb.freebsd.org/changeset/base/326501

Log:
  Make COMPAT_FREEBSD32 part of GENERIC on arm64.
  
  The cloudabi32.ko kernel modules can only be loaded on AMD64 and ARM64
  by kernels built with COMPAT_FREEBSD32. Even though COMPAT_FREEBSD32
  does not support the execution of native FreeBSD executables, do add it
  to GENERIC, to make cloudabi32.ko usable.
  
  According to size(1), this makes the kernel image approximately 0.7%
  larger.
  
  Reviewed by:  andrew, imp, emaste
  Differential Revision:https://reviews.freebsd.org/D13311

Modified:
  head/sys/arm64/conf/GENERIC

Modified: head/sys/arm64/conf/GENERIC
==
--- head/sys/arm64/conf/GENERIC Sun Dec  3 18:35:07 2017(r326500)
+++ head/sys/arm64/conf/GENERIC Sun Dec  3 19:26:14 2017(r326501)
@@ -52,6 +52,7 @@ options   PSEUDOFS# Pseudo-filesystem 
framework
 optionsGEOM_PART_GPT   # GUID Partition Tables.
 optionsGEOM_RAID   # Soft RAID functionality.
 optionsGEOM_LABEL  # Provides labelization
+optionsCOMPAT_FREEBSD32# Incomplete, but used by cloudabi32.ko.
 optionsCOMPAT_FREEBSD11# Compatible with FreeBSD11
 optionsSCSI_DELAY=5000 # Delay (in ms) before probing SCSI
 optionsKTRACE  # ktrace(1) support
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r326423 - head/lib/libproc/tests

2017-12-01 Thread Ed Schouten
Author: ed
Date: Fri Dec  1 10:25:52 2017
New Revision: 326423
URL: https://svnweb.freebsd.org/changeset/base/326423

Log:
  Eliminate the last user of basename_r() in the base system.
  
  In this case it's fairly easy to make use of basename().

Modified:
  head/lib/libproc/tests/proc_test.c

Modified: head/lib/libproc/tests/proc_test.c
==
--- head/lib/libproc/tests/proc_test.c  Fri Dec  1 09:59:42 2017
(r326422)
+++ head/lib/libproc/tests/proc_test.c  Fri Dec  1 10:25:52 2017
(r326423)
@@ -105,7 +105,7 @@ static void
 verify_bkpt(struct proc_handle *phdl, GElf_Sym *sym, const char *symname,
 const char *mapname)
 {
-   char mapbname[MAXPATHLEN], *name;
+   char *name, *mapname_copy, *mapbname;
GElf_Sym tsym;
prmap_t *map;
size_t namesz;
@@ -147,9 +147,11 @@ verify_bkpt(struct proc_handle *phdl, GElf_Sym *sym, c
map = proc_addr2map(phdl, addr);
ATF_REQUIRE_MSG(map != NULL, "failed to look up map for address 0x%lx",
addr);
-   basename_r(map->pr_mapname, mapbname);
+   mapname_copy = strdup(map->pr_mapname);
+   mapbname = basename(mapname_copy);
ATF_REQUIRE_EQ_MSG(strcmp(mapname, mapbname), 0,
"expected map name '%s' doesn't match '%s'", mapname, mapbname);
+   free(mapname_copy);
 }
 
 ATF_TC(map_alias_name2map);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r326420 - head/share/man/man4

2017-12-01 Thread Ed Schouten
Author: ed
Date: Fri Dec  1 05:57:05 2017
New Revision: 326420
URL: https://svnweb.freebsd.org/changeset/base/326420

Log:
  Add an mlink for cloudabi32(4).
  
  We already provide this for cloudabi64(4), so not adding it for
  cloudabi32(4) is fairly inconsistent.
  
  MFC after:1 week

Modified:
  head/share/man/man4/Makefile

Modified: head/share/man/man4/Makefile
==
--- head/share/man/man4/MakefileFri Dec  1 03:22:40 2017
(r326419)
+++ head/share/man/man4/MakefileFri Dec  1 05:57:05 2017
(r326420)
@@ -605,7 +605,8 @@ MLINKS+=${_bxe.4} ${_if_bxe.4}
 MLINKS+=cas.4 if_cas.4
 MLINKS+=cdce.4 if_cdce.4
 MLINKS+=cfi.4 cfid.4
-MLINKS+=cloudabi.4 cloudabi64.4
+MLINKS+=cloudabi.4 cloudabi32.4 \
+   cloudabi.4 cloudabi64.4
 MLINKS+=crypto.4 cryptodev.4
 MLINKS+=cue.4 if_cue.4
 MLINKS+=cxgb.4 if_cxgb.4
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r326406 - in head: share/man/man4 sys/arm64/cloudabi32 sys/conf sys/modules

2017-11-30 Thread Ed Schouten
Author: ed
Date: Thu Nov 30 17:58:48 2017
New Revision: 326406
URL: https://svnweb.freebsd.org/changeset/base/326406

Log:
  Port cloudabi32.ko to FreeBSD/arm64.
  
  This change adds an implementation of a sysent for running CloudABI
  armv6 and armv7 binaries on FreeBSD/arm64. It is a somewhat literal copy
  of the armv6 version, except that it's been patched up to use the proper
  registers.
  
  Just like for cloudabi32.ko on FreeBSD/amd64, we make use of a vDSO that
  automatically pads system call parameters to 64-bit value. These are
  stored in a buffer on the stack, meaning we need to use copyin() and
  copyout() unconditionally.

Added:
  head/sys/arm64/cloudabi32/
 - copied from r326229, head/sys/arm/cloudabi32/
Modified:
  head/share/man/man4/cloudabi.4
  head/sys/arm64/cloudabi32/cloudabi32_sysvec.c
  head/sys/conf/files.arm64
  head/sys/modules/Makefile

Modified: head/share/man/man4/cloudabi.4
==
--- head/share/man/man4/cloudabi.4  Thu Nov 30 15:58:38 2017
(r326405)
+++ head/share/man/man4/cloudabi.4  Thu Nov 30 17:58:48 2017
(r326406)
@@ -1,4 +1,4 @@
-.\" Copyright (c) 2015-2016 Nuxi, https://nuxi.nl/
+.\" Copyright (c) 2015-2017 Nuxi, https://nuxi.nl/
 .\"
 .\" Redistribution and use in source and binary forms, with or without
 .\" modification, are permitted provided that the following conditions
@@ -22,7 +22,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\" $FreeBSD$
-.Dd September 22, 2016
+.Dd November 30, 2017
 .Dt CLOUDABI 4
 .Os
 .Sh NAME
@@ -84,7 +84,7 @@ module can be loaded on any architecture supported by
 .Fx ,
 the
 .Nm cloudabi32
-module is only available on amd64, armv6 and i386.
+module is only available on amd64, arm64, armv6, armv7 and i386.
 The same holds for the
 .Nm cloudabi64
 module,

Modified: head/sys/arm64/cloudabi32/cloudabi32_sysvec.c
==
--- head/sys/arm/cloudabi32/cloudabi32_sysvec.c Sun Nov 26 14:53:56 2017
(r326229)
+++ head/sys/arm64/cloudabi32/cloudabi32_sysvec.c   Thu Nov 30 17:58:48 
2017(r326406)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2015-2016 Nuxi, https://nuxi.nl/
+ * Copyright (c) 2015-2017 Nuxi, https://nuxi.nl/
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -53,16 +53,13 @@ cloudabi32_proc_setregs(struct thread *td, struct imag
 {
struct trapframe *regs;
 
-   exec_setregs(td, imgp, stack);
-
-   /*
-* The stack now contains a pointer to the TCB and the auxiliary
-* vector. Let r0 point to the auxiliary vector, and set
-* tpidrurw to the TCB.
-*/
regs = td->td_frame;
-   regs->tf_r0 =
+   memset(regs, 0, sizeof(*regs));
+   regs->tf_x[0] =
stack + roundup(sizeof(cloudabi32_tcb_t), sizeof(register_t));
+   regs->tf_x[13] = STACKALIGN(stack);
+   regs->tf_elr = imgp->entry_addr;
+   regs->tf_spsr |= PSR_AARCH32;
(void)cpu_set_user_tls(td, TO_PTR(stack));
 }
 
@@ -77,27 +74,30 @@ cloudabi32_fetch_syscall_args(struct thread *td)
sa = >td_sa;
 
/* Obtain system call number. */
-   sa->code = frame->tf_r12;
+   sa->code = frame->tf_x[0];
if (sa->code >= CLOUDABI32_SYS_MAXSYSCALL)
return (ENOSYS);
sa->callp = _sysent[sa->code];
sa->narg = sa->callp->sy_narg;
 
-   /* Fetch system call arguments from registers and the stack. */
-   sa->args[0] = frame->tf_r0;
-   sa->args[1] = frame->tf_r1;
-   sa->args[2] = frame->tf_r2;
-   sa->args[3] = frame->tf_r3;
-   if (sa->narg > 4) {
-   error = copyin((void *)td->td_frame->tf_usr_sp, >args[4],
-   (sa->narg - 4) * sizeof(register_t));
-   if (error != 0)
-   return (error);
-   }
+   /*
+* Fetch system call arguments.
+*
+* The vDSO has already made sure that the arguments are
+* eight-byte aligned. Pointers and size_t parameters are
+* zero-extended. This makes it possible to copy in the
+* arguments directly. As long as the call doesn't use 32-bit
+* data structures, we can just invoke the same system call
+* implementation used by 64-bit processes.
+*/
+   error = copyin((void *)frame->tf_x[2], sa->args,
+   sa->narg * sizeof(sa->args[0]));
+   if (error != 0)
+   return (error);
 
/* Default system call return values. */
td->td_retval[0] = 0;
-   td->td_retval[1] = frame->tf_r1;
+   td->td_retval[1] = 0;
return (0);
 }
 
@@ -108,20 +108,32 @@ cloudabi32_set_syscall_retval(struct thread *td, int e
 
switch (error) {
case 0:
-   /* System call succeeded. */
-   frame->tf_r0 = td->td_retval[0];
-   

Re: svn commit: r326385 - head/usr.bin/pr

2017-11-30 Thread Ed Schouten
2017-11-30 8:08 GMT+01:00 Eitan Adler <ead...@freebsd.org>:
>   Permitted by https://www.freebsd.org/copyright/license.html
> [...]
>   * Copyright (c) 1991 Keith Muller.

Isn't it the case that this only allows us to remove this clause from
code that has the university as the sole copyright holder? In this
case we should also ask Keith Muller, right...?

-- 
Ed Schouten <e...@nuxi.nl>
Nuxi, 's-Hertogenbosch, the Netherlands
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r326230 - in head/sys/arm64: arm64 include

2017-11-26 Thread Ed Schouten
Author: ed
Date: Sun Nov 26 14:56:23 2017
New Revision: 326230
URL: https://svnweb.freebsd.org/changeset/base/326230

Log:
  Add a Saved Process Status Register bit for AArch32 execution mode.
  
  The documentation on the Saved Process Status Register (SPSR) is a bit
  weird; the M[4] bit is documented separately from M[3:0]. The M[4] bit
  can be toggled to switch to 32-bit execution mode. This functionality is
  orthogonal to M[3:0].
  
  Change the definition of PSR_M_MASK to no longer include M[4]. Add a new
  definition, PSR_AARCH32 that can be used to toggle 32-bit independently.
  This bit will be used by the cloudabi32 code to force execution of
  userspace code in 32-bit mode.
  
  Reviewed by:  andrew
  Differential Revision:https://reviews.freebsd.org/D13148

Modified:
  head/sys/arm64/arm64/machdep.c
  head/sys/arm64/include/armreg.h

Modified: head/sys/arm64/arm64/machdep.c
==
--- head/sys/arm64/arm64/machdep.c  Sun Nov 26 14:53:56 2017
(r326229)
+++ head/sys/arm64/arm64/machdep.c  Sun Nov 26 14:56:23 2017
(r326230)
@@ -405,7 +405,7 @@ set_mcontext(struct thread *td, mcontext_t *mcp)
 
spsr = mcp->mc_gpregs.gp_spsr;
if ((spsr & PSR_M_MASK) != PSR_M_EL0t ||
-   (spsr & (PSR_F | PSR_I | PSR_A | PSR_D)) != 0)
+   (spsr & (PSR_AARCH32 | PSR_F | PSR_I | PSR_A | PSR_D)) != 0)
return (EINVAL); 
 
memcpy(tf->tf_x, mcp->mc_gpregs.gp_x, sizeof(tf->tf_x));

Modified: head/sys/arm64/include/armreg.h
==
--- head/sys/arm64/include/armreg.h Sun Nov 26 14:53:56 2017
(r326229)
+++ head/sys/arm64/include/armreg.h Sun Nov 26 14:56:23 2017
(r326230)
@@ -549,7 +549,6 @@
 /* SPSR_EL1 */
 /*
  * When the exception is taken in AArch64:
- * M[4]   is 0 for AArch64 mode
  * M[3:2] is the exception level
  * M[1]   is unused
  * M[0]   is the SP select:
@@ -561,8 +560,9 @@
 #definePSR_M_EL1h  0x0005
 #definePSR_M_EL2t  0x0008
 #definePSR_M_EL2h  0x0009
-#definePSR_M_MASK  0x001f
+#definePSR_M_MASK  0x000f
 
+#definePSR_AARCH32 0x0010
 #definePSR_F   0x0040
 #definePSR_I   0x0080
 #definePSR_A   0x0100
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r326229 - in head/sys: arm/cloudabi32 arm64/cloudabi64

2017-11-26 Thread Ed Schouten
Author: ed
Date: Sun Nov 26 14:53:56 2017
New Revision: 326229
URL: https://svnweb.freebsd.org/changeset/base/326229

Log:
  Correct some more places where TO_PTR() should be used.
  
  These were missed in r326228.
  
  MFC after:2 weeks

Modified:
  head/sys/arm/cloudabi32/cloudabi32_sysvec.c
  head/sys/arm64/cloudabi64/cloudabi64_sysvec.c

Modified: head/sys/arm/cloudabi32/cloudabi32_sysvec.c
==
--- head/sys/arm/cloudabi32/cloudabi32_sysvec.c Sun Nov 26 14:45:56 2017
(r326228)
+++ head/sys/arm/cloudabi32/cloudabi32_sysvec.c Sun Nov 26 14:53:56 2017
(r326229)
@@ -165,7 +165,7 @@ cloudabi32_thread_setregs(struct thread *td,
frame->tf_r1 = attr->argument;
 
/* Set up TLS. */
-   return (cpu_set_user_tls(td, (void *)tcb));
+   return (cpu_set_user_tls(td, TO_PTR(tcb)));
 }
 
 static struct sysentvec cloudabi32_elf_sysvec = {

Modified: head/sys/arm64/cloudabi64/cloudabi64_sysvec.c
==
--- head/sys/arm64/cloudabi64/cloudabi64_sysvec.c   Sun Nov 26 14:45:56 
2017(r326228)
+++ head/sys/arm64/cloudabi64/cloudabi64_sysvec.c   Sun Nov 26 14:53:56 
2017(r326229)
@@ -157,7 +157,7 @@ cloudabi64_thread_setregs(struct thread *td,
frame->tf_x[1] = attr->argument;
 
/* Set up TLS. */
-   return (cpu_set_user_tls(td, (void *)tcb));
+   return (cpu_set_user_tls(td, TO_PTR(tcb)));
 }
 
 static struct sysentvec cloudabi64_elf_sysvec = {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r326228 - in head/sys: amd64/cloudabi32 amd64/cloudabi64 arm/cloudabi32 arm64/cloudabi64 i386/cloudabi32

2017-11-26 Thread Ed Schouten
Author: ed
Date: Sun Nov 26 14:45:56 2017
New Revision: 326228
URL: https://svnweb.freebsd.org/changeset/base/326228

Log:
  Use TO_PTR() to convert integers to pointers.
  
  For FreeBSD/arm64's cloudabi32 support, I'm going to need a TO_PTR() in
  this place. Also use it for all of the other source files, so that the
  difference remains as minimal as possible.
  
  MFC after:2 weeks

Modified:
  head/sys/amd64/cloudabi32/cloudabi32_sysvec.c
  head/sys/amd64/cloudabi64/cloudabi64_sysvec.c
  head/sys/arm/cloudabi32/cloudabi32_sysvec.c
  head/sys/arm64/cloudabi64/cloudabi64_sysvec.c
  head/sys/i386/cloudabi32/cloudabi32_sysvec.c

Modified: head/sys/amd64/cloudabi32/cloudabi32_sysvec.c
==
--- head/sys/amd64/cloudabi32/cloudabi32_sysvec.c   Sun Nov 26 14:28:27 
2017(r326227)
+++ head/sys/amd64/cloudabi32/cloudabi32_sysvec.c   Sun Nov 26 14:45:56 
2017(r326228)
@@ -86,7 +86,7 @@ cloudabi32_proc_setregs(struct thread *td, struct imag
 {
 
ia32_setregs(td, imgp, stack);
-   (void)cpu_set_user_tls(td, (void *)stack);
+   (void)cpu_set_user_tls(td, TO_PTR(stack));
 }
 
 static int

Modified: head/sys/amd64/cloudabi64/cloudabi64_sysvec.c
==
--- head/sys/amd64/cloudabi64/cloudabi64_sysvec.c   Sun Nov 26 14:28:27 
2017(r326227)
+++ head/sys/amd64/cloudabi64/cloudabi64_sysvec.c   Sun Nov 26 14:45:56 
2017(r326228)
@@ -83,7 +83,7 @@ cloudabi64_proc_setregs(struct thread *td, struct imag
regs = td->td_frame;
regs->tf_rdi = stack + sizeof(register_t) +
roundup(sizeof(cloudabi64_tcb_t), sizeof(register_t));
-   (void)cpu_set_user_tls(td, (void *)stack);
+   (void)cpu_set_user_tls(td, TO_PTR(stack));
 }
 
 static int
@@ -188,7 +188,7 @@ cloudabi64_thread_setregs(struct thread *td,
frame->tf_rdi = td->td_tid;
frame->tf_rsi = attr->argument;
 
-   return (cpu_set_user_tls(td, (void *)tcbptr));
+   return (cpu_set_user_tls(td, TO_PTR(tcbptr)));
 }
 
 static struct sysentvec cloudabi64_elf_sysvec = {

Modified: head/sys/arm/cloudabi32/cloudabi32_sysvec.c
==
--- head/sys/arm/cloudabi32/cloudabi32_sysvec.c Sun Nov 26 14:28:27 2017
(r326227)
+++ head/sys/arm/cloudabi32/cloudabi32_sysvec.c Sun Nov 26 14:45:56 2017
(r326228)
@@ -63,7 +63,7 @@ cloudabi32_proc_setregs(struct thread *td, struct imag
regs = td->td_frame;
regs->tf_r0 =
stack + roundup(sizeof(cloudabi32_tcb_t), sizeof(register_t));
-   (void)cpu_set_user_tls(td, (void *)stack);
+   (void)cpu_set_user_tls(td, TO_PTR(stack));
 }
 
 static int

Modified: head/sys/arm64/cloudabi64/cloudabi64_sysvec.c
==
--- head/sys/arm64/cloudabi64/cloudabi64_sysvec.c   Sun Nov 26 14:28:27 
2017(r326227)
+++ head/sys/arm64/cloudabi64/cloudabi64_sysvec.c   Sun Nov 26 14:45:56 
2017(r326228)
@@ -63,7 +63,7 @@ cloudabi64_proc_setregs(struct thread *td, struct imag
regs = td->td_frame;
regs->tf_x[0] =
stack + roundup(sizeof(cloudabi64_tcb_t), sizeof(register_t));
-   (void)cpu_set_user_tls(td, (void *)stack);
+   (void)cpu_set_user_tls(td, TO_PTR(stack));
 }
 
 static int

Modified: head/sys/i386/cloudabi32/cloudabi32_sysvec.c
==
--- head/sys/i386/cloudabi32/cloudabi32_sysvec.cSun Nov 26 14:28:27 
2017(r326227)
+++ head/sys/i386/cloudabi32/cloudabi32_sysvec.cSun Nov 26 14:45:56 
2017(r326228)
@@ -81,7 +81,7 @@ cloudabi32_proc_setregs(struct thread *td, struct imag
 {
 
exec_setregs(td, imgp, stack);
-   (void)cpu_set_user_tls(td, (void *)stack);
+   (void)cpu_set_user_tls(td, TO_PTR(stack));
 }
 
 static int
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r326227 - in head/sys/arm64: arm64 include

2017-11-26 Thread Ed Schouten
Author: ed
Date: Sun Nov 26 14:28:27 2017
New Revision: 326227
URL: https://svnweb.freebsd.org/changeset/base/326227

Log:
  Make 32-bit system calls end up in svc_handler().
  
  The nice thing about ARM64 is that it's pretty elegant to install
  separate trap/exception handlers for 32-bit and 64-bit processes. That
  said, for all other architectures (e.g., i386 on amd64) we always let
  32-bit counterparts go through the regular system call codepath. Let's
  do the same on ARM64.
  
  Reviewed by:  andrew
  Differential Revision:https://reviews.freebsd.org/D13146

Modified:
  head/sys/arm64/arm64/exception.S
  head/sys/arm64/arm64/trap.c
  head/sys/arm64/include/armreg.h

Modified: head/sys/arm64/arm64/exception.S
==
--- head/sys/arm64/arm64/exception.SSun Nov 26 10:02:43 2017
(r326226)
+++ head/sys/arm64/arm64/exception.SSun Nov 26 14:28:27 2017
(r326227)
@@ -219,8 +219,8 @@ exception_vectors:
vempty  /* FIQ 64-bit EL0 */
vector el0_error/* Error 64-bit EL0 */
 
-   vempty  /* Synchronous 32-bit EL0 */
-   vempty  /* IRQ 32-bit EL0 */
+   vector el0_sync /* Synchronous 32-bit EL0 */
+   vector el0_irq  /* IRQ 32-bit EL0 */
vempty  /* FIQ 32-bit EL0 */
-   vempty  /* Error 32-bit EL0 */
+   vector el0_error/* Error 32-bit EL0 */
 

Modified: head/sys/arm64/arm64/trap.c
==
--- head/sys/arm64/arm64/trap.c Sun Nov 26 10:02:43 2017(r326226)
+++ head/sys/arm64/arm64/trap.c Sun Nov 26 14:28:27 2017(r326227)
@@ -381,7 +381,8 @@ do_el0_sync(struct thread *td, struct trapframe *frame
panic("VFP exception in userland");
 #endif
break;
-   case EXCP_SVC:
+   case EXCP_SVC32:
+   case EXCP_SVC64:
svc_handler(td, frame);
break;
case EXCP_INSN_ABORT_L:

Modified: head/sys/arm64/include/armreg.h
==
--- head/sys/arm64/include/armreg.h Sun Nov 26 10:02:43 2017
(r326226)
+++ head/sys/arm64/include/armreg.h Sun Nov 26 14:28:27 2017
(r326227)
@@ -123,7 +123,8 @@
 #define EXCP_UNKNOWN   0x00/* Unkwn exception */
 #define EXCP_FP_SIMD   0x07/* VFP/SIMD trap */
 #define EXCP_ILL_STATE 0x0e/* Illegal execution state */
-#define EXCP_SVC   0x15/* SVC trap */
+#define EXCP_SVC32 0x11/* SVC trap for AArch32 */
+#define EXCP_SVC64 0x15/* SVC trap for AArch64 */
 #define EXCP_MSR   0x18/* MSR/MRS trap */
 #define EXCP_INSN_ABORT_L  0x20/* Instruction abort, from 
lower EL */
 #define EXCP_INSN_ABORT0x21/* Instruction abort, from same 
EL */ 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r326167 - head/sys/modules/cloudabi32

2017-11-24 Thread Ed Schouten
Author: ed
Date: Fri Nov 24 14:02:32 2017
New Revision: 326167
URL: https://svnweb.freebsd.org/changeset/base/326167

Log:
  Pick the right vDSO file/linker flags when building cloudabi32.ko on ARM64.
  
  The recently imported cloudabi_vdso_armv6_on_64bit.S should be the vDSO
  for 32-bit processes when being run on FreeBSD/arm64. This vDSO ensures
  that all system call arguments are padded to 64 bits, so that they can
  be used by the kernel to call into most of the native implementations
  directly.

Modified:
  head/sys/modules/cloudabi32/Makefile

Modified: head/sys/modules/cloudabi32/Makefile
==
--- head/sys/modules/cloudabi32/MakefileFri Nov 24 13:51:59 2017
(r326166)
+++ head/sys/modules/cloudabi32/MakefileFri Nov 24 14:02:32 2017
(r326167)
@@ -14,7 +14,11 @@ SRCS=cloudabi32_fd.c cloudabi32_module.c cloudabi32_p
 OBJS=  cloudabi32_vdso_blob.o
 CLEANFILES=cloudabi32_vdso.o
 
-.if ${MACHINE_CPUARCH} == "amd64"
+.if ${MACHINE_CPUARCH} == "aarch64"
+VDSO_SRCS=${SYSDIR}/contrib/cloudabi/cloudabi_vdso_armv6_on_64bit.S
+OUTPUT_TARGET=elf64-littleaarch64
+BINARY_ARCHITECTURE=aarch64
+.elif ${MACHINE_CPUARCH} == "amd64"
 VDSO_SRCS=${SYSDIR}/contrib/cloudabi/cloudabi_vdso_i686_on_64bit.S
 OUTPUT_TARGET=elf64-x86-64-freebsd
 BINARY_ARCHITECTURE=i386
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r326166 - head/sys/arm64/arm64

2017-11-24 Thread Ed Schouten
Author: ed
Date: Fri Nov 24 13:51:59 2017
New Revision: 326166
URL: https://svnweb.freebsd.org/changeset/base/326166

Log:
  Set CP15BEN in SCTLR to make memory barriers work in 32-bit mode.
  
  Binaries generated by Clang for ARMv6 may contain these instructions:
  
MCR p15, 0, , c7, c10, 5
  
  These instructions are deprecated as of ARMv7, which is why modern
  processors have a way of toggling support for them. On FreeBSD/arm64 we
  currently disable support for these instructions, meaning that if 32-bit
  executables with these instructions are run, they would crash with
  SIGILL. This is likely not what we want.
  
  Reviewed by:  andrew
  Differential Revision:https://reviews.freebsd.org/D13145

Modified:
  head/sys/arm64/arm64/locore.S

Modified: head/sys/arm64/arm64/locore.S
==
--- head/sys/arm64/arm64/locore.S   Fri Nov 24 13:50:53 2017
(r326165)
+++ head/sys/arm64/arm64/locore.S   Fri Nov 24 13:51:59 2017
(r326166)
@@ -628,11 +628,12 @@ sctlr_set:
/* Bits to set */
.quad (SCTLR_LSMAOE | SCTLR_nTLSMD | SCTLR_UCI | SCTLR_SPAN | \
SCTLR_nTWE | SCTLR_nTWI | SCTLR_UCT | SCTLR_DZE | \
-   SCTLR_I | SCTLR_SED | SCTLR_SA0 | SCTLR_SA | SCTLR_C | SCTLR_M)
+   SCTLR_I | SCTLR_SED | SCTLR_SA0 | SCTLR_SA | SCTLR_C | \
+   SCTLR_M | SCTLR_CP15BEN)
 sctlr_clear:
/* Bits to clear */
.quad (SCTLR_EE | SCTLR_EOE | SCTLR_IESB | SCTLR_WXN | SCTLR_UMA | \
-   SCTLR_ITD | SCTLR_THEE | SCTLR_CP15BEN | SCTLR_A)
+   SCTLR_ITD | SCTLR_THEE | SCTLR_A)
 
.globl abort
 abort:
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r326165 - in head/sys: arm64/arm64 arm64/include conf sys

2017-11-24 Thread Ed Schouten
Author: ed
Date: Fri Nov 24 13:50:53 2017
New Revision: 326165
URL: https://svnweb.freebsd.org/changeset/base/326165

Log:
  Add rudimentary support for building FreeBSD/arm64 with COMPAT_FREEBSD32.
  
  Right now I'm using two Raspberry Pi's (2 and 3) to test CloudABI
  support for armv6, armv7 and aarch64. It would be nice if I could
  restrict this to just a single instance when testing smaller changes.
  This is why I'd like to get COMPAT_CLOUDABI32 to work on arm64.
  
  As COMPAT_CLOUDABI32 depends on COMPAT_FREEBSD32, at least for the ELF
  loading, this change adds all of the bits necessary to at least build a
  kernel with COMPAT_FREEBSD32. All of the machine dependent system calls
  are still stubbed out, for the reason that implementations for these are
  only useful if actual support for running FreeBSD binaries is added.
  This is outside the scope of this work.
  
  Reviewed by:  andrew
  Differential Revision:https://reviews.freebsd.org/D13144

Added:
  head/sys/arm64/arm64/elf32_machdep.c   (contents, props changed)
  head/sys/arm64/arm64/freebsd32_machdep.c   (contents, props changed)
Modified:
  head/sys/arm64/arm64/machdep.c
  head/sys/arm64/include/elf.h
  head/sys/arm64/include/param.h
  head/sys/arm64/include/proc.h
  head/sys/arm64/include/reg.h
  head/sys/arm64/include/vdso.h
  head/sys/conf/files.arm64
  head/sys/conf/options.arm64
  head/sys/sys/sysctl.h

Added: head/sys/arm64/arm64/elf32_machdep.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/arm64/arm64/elf32_machdep.cFri Nov 24 13:50:53 2017
(r326165)
@@ -0,0 +1,38 @@
+/*-
+ * Copyright (c) 2017 Nuxi, https://nuxi.nl/
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#define__ELF_WORD_SIZE 32
+#include 
+
+void
+elf32_dump_thread(struct thread *td __unused, void *dst __unused,
+size_t *off __unused)
+{
+
+}

Added: head/sys/arm64/arm64/freebsd32_machdep.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/arm64/arm64/freebsd32_machdep.cFri Nov 24 13:50:53 2017
(r326165)
@@ -0,0 +1,70 @@
+/*-
+ * Copyright (c) 2017 Nuxi, https://nuxi.nl/
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+

svn commit: r326145 - in head/sys: amd64/amd64 amd64/ia32 amd64/linux32 arm/cloudabi32 arm64/arm64 arm64/cloudabi64 compat/linux i386/i386 kern powerpc/powerpc riscv/riscv sparc64/sparc64

2017-11-23 Thread Ed Schouten
Author: ed
Date: Fri Nov 24 07:35:08 2017
New Revision: 326145
URL: https://svnweb.freebsd.org/changeset/base/326145

Log:
  Don't let cpu_set_syscall_retval() clobber exec_setregs().
  
  Upon successful completion, the execve() system call invokes
  exec_setregs() to initialize the registers of the initial thread of the
  newly executed process. What is weird is that when execve() returns, it
  still goes through the normal system call return path, clobbering the
  registers with the system call's return value (td->td_retval).
  
  Though this doesn't seem to be problematic for x86 most of the times (as
  the value of eax/rax doesn't matter upon startup), this can be pretty
  frustrating for architectures where function argument and return
  registers overlap (e.g., ARM). On these systems, exec_setregs() also
  needs to initialize td_retval.
  
  Even worse are architectures where cpu_set_syscall_retval() sets
  registers to values not derived from td_retval. On these architectures,
  there is no way cpu_set_syscall_retval() can set registers to the way it
  wants them to be upon the start of execution.
  
  To get rid of this madness, let sys_execve() return EJUSTRETURN. This
  will cause cpu_set_syscall_retval() to leave registers intact. This
  makes process execution easier to understand. It also eliminates the
  difference between execution of the initial process and successive ones.
  The initial call to sys_execve() is not performed through a system call
  context.
  
  Reviewed by:  kib, jhibbits
  Differential Revision:https://reviews.freebsd.org/D13180

Modified:
  head/sys/amd64/amd64/machdep.c
  head/sys/amd64/ia32/ia32_signal.c
  head/sys/amd64/linux32/linux32_sysvec.c
  head/sys/arm/cloudabi32/cloudabi32_sysvec.c
  head/sys/arm64/arm64/machdep.c
  head/sys/arm64/cloudabi64/cloudabi64_sysvec.c
  head/sys/compat/linux/linux_emul.c
  head/sys/i386/i386/machdep.c
  head/sys/kern/init_main.c
  head/sys/kern/kern_exec.c
  head/sys/powerpc/powerpc/exec_machdep.c
  head/sys/riscv/riscv/machdep.c
  head/sys/sparc64/sparc64/machdep.c

Modified: head/sys/amd64/amd64/machdep.c
==
--- head/sys/amd64/amd64/machdep.c  Fri Nov 24 05:01:00 2017
(r326144)
+++ head/sys/amd64/amd64/machdep.c  Fri Nov 24 07:35:08 2017
(r326145)
@@ -604,7 +604,6 @@ exec_setregs(struct thread *td, struct image_params *i
regs->tf_fs = _ufssel;
regs->tf_gs = _ugssel;
regs->tf_flags = TF_HASSEGS;
-   td->td_retval[1] = 0;
 
/*
 * Reset the hardware debug registers if they were in use.

Modified: head/sys/amd64/ia32/ia32_signal.c
==
--- head/sys/amd64/ia32/ia32_signal.c   Fri Nov 24 05:01:00 2017
(r326144)
+++ head/sys/amd64/ia32/ia32_signal.c   Fri Nov 24 07:35:08 2017
(r326145)
@@ -967,5 +967,4 @@ ia32_setregs(struct thread *td, struct image_params *i
 
/* Return via doreti so that we can change to a different %cs */
set_pcb_flags(pcb, PCB_32BIT | PCB_FULL_IRET);
-   td->td_retval[1] = 0;
 }

Modified: head/sys/amd64/linux32/linux32_sysvec.c
==
--- head/sys/amd64/linux32/linux32_sysvec.c Fri Nov 24 05:01:00 2017
(r326144)
+++ head/sys/amd64/linux32/linux32_sysvec.c Fri Nov 24 07:35:08 2017
(r326145)
@@ -832,7 +832,6 @@ exec_linux_setregs(struct thread *td, struct image_par
 
/* Do full restore on return so that we can change to a different %cs */
set_pcb_flags(pcb, PCB_32BIT | PCB_FULL_IRET);
-   td->td_retval[1] = 0;
 }
 
 /*

Modified: head/sys/arm/cloudabi32/cloudabi32_sysvec.c
==
--- head/sys/arm/cloudabi32/cloudabi32_sysvec.c Fri Nov 24 05:01:00 2017
(r326144)
+++ head/sys/arm/cloudabi32/cloudabi32_sysvec.c Fri Nov 24 07:35:08 2017
(r326145)
@@ -61,7 +61,7 @@ cloudabi32_proc_setregs(struct thread *td, struct imag
 * tpidrurw to the TCB.
 */
regs = td->td_frame;
-   regs->tf_r0 = td->td_retval[0] =
+   regs->tf_r0 =
stack + roundup(sizeof(cloudabi32_tcb_t), sizeof(register_t));
(void)cpu_set_user_tls(td, (void *)stack);
 }

Modified: head/sys/arm64/arm64/machdep.c
==
--- head/sys/arm64/arm64/machdep.c  Fri Nov 24 05:01:00 2017
(r326144)
+++ head/sys/arm64/arm64/machdep.c  Fri Nov 24 07:35:08 2017
(r326145)
@@ -311,12 +311,7 @@ exec_setregs(struct thread *td, struct image_params *i
 
memset(tf, 0, sizeof(struct trapframe));
 
-   /*
-* We need to set x0 for init as it doesn't call
-* cpu_set_syscall_retval to copy the value. We also
-* need to set td_retval for the cases where 

svn commit: r326075 - head/sys/contrib/cloudabi

2017-11-21 Thread Ed Schouten
Author: ed
Date: Tue Nov 21 20:46:21 2017
New Revision: 326075
URL: https://svnweb.freebsd.org/changeset/base/326075

Log:
  Import the latest CloudABI definitions, v0.18.
  
  In addition to some small style fixes to the ARMv6 vDSO, this release
  includes a new vDSO that can be used for the execution of ARMv6/ARMv7
  code on 64-bit platforms.
  
  Just like for i686 on x86-64, this new vDSO is responsible for padding
  arguments and return values to 64-bit values, so that the kernel can
  easily forward system calls to the native system calls.
  
  Obtained from:https://github.com/NuxiNL/cloudabi

Added:
  head/sys/contrib/cloudabi/cloudabi_vdso_armv6_on_64bit.S   (contents, props 
changed)
Modified:
  head/sys/contrib/cloudabi/cloudabi_vdso_armv6.S

Modified: head/sys/contrib/cloudabi/cloudabi_vdso_armv6.S
==
--- head/sys/contrib/cloudabi/cloudabi_vdso_armv6.S Tue Nov 21 20:31:54 
2017(r326074)
+++ head/sys/contrib/cloudabi/cloudabi_vdso_armv6.S Tue Nov 21 20:46:21 
2017(r326075)
@@ -39,9 +39,9 @@ ENTRY(cloudabi_sys_clock_res_get)
   mov ip, #0
   swi 0
   ldrcc r2, [sp, #-4]
-  strcc r0, [r2, 0]
-  strcc r1, [r2, 4]
-  movcc r0, $0
+  strcc r0, [r2, #0]
+  strcc r1, [r2, #4]
+  movcc r0, #0
   bx lr
 END(cloudabi_sys_clock_res_get)
 
@@ -49,9 +49,9 @@ ENTRY(cloudabi_sys_clock_time_get)
   mov ip, #1
   swi 0
   ldrcc r2, [sp, #0]
-  strcc r0, [r2, 0]
-  strcc r1, [r2, 4]
-  movcc r0, $0
+  strcc r0, [r2, #0]
+  strcc r1, [r2, #4]
+  movcc r0, #0
   bx lr
 END(cloudabi_sys_clock_time_get)
 
@@ -73,7 +73,7 @@ ENTRY(cloudabi_sys_fd_create1)
   swi 0
   ldrcc r2, [sp, #-4]
   strcc r0, [r2]
-  movcc r0, $0
+  movcc r0, #0
   bx lr
 END(cloudabi_sys_fd_create1)
 
@@ -86,7 +86,7 @@ ENTRY(cloudabi_sys_fd_create2)
   ldrcc r3, [sp, #-8]
   strcc r0, [r2]
   strcc r1, [r3]
-  movcc r0, $0
+  movcc r0, #0
   bx lr
 END(cloudabi_sys_fd_create2)
 
@@ -102,7 +102,7 @@ ENTRY(cloudabi_sys_fd_dup)
   swi 0
   ldrcc r2, [sp, #-4]
   strcc r0, [r2]
-  movcc r0, $0
+  movcc r0, #0
   bx lr
 END(cloudabi_sys_fd_dup)
 
@@ -111,7 +111,7 @@ ENTRY(cloudabi_sys_fd_pread)
   swi 0
   ldrcc r2, [sp, #8]
   strcc r0, [r2]
-  movcc r0, $0
+  movcc r0, #0
   bx lr
 END(cloudabi_sys_fd_pread)
 
@@ -120,7 +120,7 @@ ENTRY(cloudabi_sys_fd_pwrite)
   swi 0
   ldrcc r2, [sp, #8]
   strcc r0, [r2]
-  movcc r0, $0
+  movcc r0, #0
   bx lr
 END(cloudabi_sys_fd_pwrite)
 
@@ -130,7 +130,7 @@ ENTRY(cloudabi_sys_fd_read)
   swi 0
   ldrcc r2, [sp, #-4]
   strcc r0, [r2]
-  movcc r0, $0
+  movcc r0, #0
   bx lr
 END(cloudabi_sys_fd_read)
 
@@ -144,9 +144,9 @@ ENTRY(cloudabi_sys_fd_seek)
   mov ip, #12
   swi 0
   ldrcc r2, [sp, #4]
-  strcc r0, [r2, 0]
-  strcc r1, [r2, 4]
-  movcc r0, $0
+  strcc r0, [r2, #0]
+  strcc r1, [r2, #4]
+  movcc r0, #0
   bx lr
 END(cloudabi_sys_fd_seek)
 
@@ -174,7 +174,7 @@ ENTRY(cloudabi_sys_fd_write)
   swi 0
   ldrcc r2, [sp, #-4]
   strcc r0, [r2]
-  movcc r0, $0
+  movcc r0, #0
   bx lr
 END(cloudabi_sys_fd_write)
 
@@ -207,7 +207,7 @@ ENTRY(cloudabi_sys_file_open)
   swi 0
   ldrcc r2, [sp, #8]
   strcc r0, [r2]
-  movcc r0, $0
+  movcc r0, #0
   bx lr
 END(cloudabi_sys_file_open)
 
@@ -216,7 +216,7 @@ ENTRY(cloudabi_sys_file_readdir)
   swi 0
   ldrcc r2, [sp, #8]
   strcc r0, [r2]
-  movcc r0, $0
+  movcc r0, #0
   bx lr
 END(cloudabi_sys_file_readdir)
 
@@ -225,7 +225,7 @@ ENTRY(cloudabi_sys_file_readlink)
   swi 0
   ldrcc r2, [sp, #4]
   strcc r0, [r2]
-  movcc r0, $0
+  movcc r0, #0
   bx lr
 END(cloudabi_sys_file_readlink)
 
@@ -288,7 +288,7 @@ ENTRY(cloudabi_sys_mem_map)
   swi 0
   ldrcc r2, [sp, #16]
   strcc r0, [r2]
-  movcc r0, $0
+  movcc r0, #0
   bx lr
 END(cloudabi_sys_mem_map)
 
@@ -316,7 +316,7 @@ ENTRY(cloudabi_sys_poll)
   swi 0
   ldrcc r2, [sp, #-4]
   strcc r0, [r2]
-  movcc r0, $0
+  movcc r0, #0
   bx lr
 END(cloudabi_sys_poll)
 
@@ -340,7 +340,7 @@ ENTRY(cloudabi_sys_proc_fork)
   ldrcc r3, [sp, #-8]
   strcc r0, [r2]
   strcc r1, [r3]
-  movcc r0, $0
+  movcc r0, #0
   bx lr
 END(cloudabi_sys_proc_fork)
 
@@ -380,7 +380,7 @@ ENTRY(cloudabi_sys_thread_create)
   swi 0
   ldrcc r2, [sp, #-4]
   strcc r0, [r2]
-  movcc r0, $0
+  movcc r0, #0
   bx lr
 END(cloudabi_sys_thread_create)
 

Added: head/sys/contrib/cloudabi/cloudabi_vdso_armv6_on_64bit.S
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/contrib/cloudabi/cloudabi_vdso_armv6_on_64bit.STue Nov 21 
20:46:21 2017(r326075)
@@ -0,0 +1,732 @@
+// Copyright (c) 2016 Nuxi (https://nuxi.nl/) and contributors.
+//
+// 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.
+// 

svn commit: r325555 - in head/sys: compat/cloudabi32 compat/cloudabi64 contrib/cloudabi

2017-11-08 Thread Ed Schouten
Author: ed
Date: Wed Nov  8 14:21:52 2017
New Revision: 32
URL: https://svnweb.freebsd.org/changeset/base/32

Log:
  Upgrade to CloudABI v0.17.
  
  Compared to the previous version, v0.16, there are a couple of minor
  changes:
  
  - CLOUDABI_AT_PID: Process identifiers for CloudABI processes.
  
Initially, BSD process identifiers weren't exposed inside the runtime,
due to them being pretty much useless inside of a cluster computing
environment. When jobs are scheduled across systems, the BSD process
number doesn't act as an identifier. Even on individual systems they
may recycle relatively quickly.
  
With this change, the kernel will now generate a UUIDv4 when executing
a process. These UUIDs can be obtained within the process using
program_getpid(). Right now, FreeBSD will not attempt to store this
value. This should of course happen at some point in time, so that it
may be printed by administration tools.
  
  - Removal of some unused structure members for polling.
  
With the polling framework being simplified/redesigned, it turns out
some of the structure fields were not used by the C library. We can
remove these to keep things nice and tidy.
  
  Obtained from:https://github.com/NuxiNL/cloudabi

Modified:
  head/sys/compat/cloudabi32/cloudabi32_module.c
  head/sys/compat/cloudabi32/cloudabi32_poll.c
  head/sys/compat/cloudabi32/cloudabi32_proto.h
  head/sys/compat/cloudabi32/cloudabi32_systrace_args.c
  head/sys/compat/cloudabi64/cloudabi64_module.c
  head/sys/compat/cloudabi64/cloudabi64_poll.c
  head/sys/compat/cloudabi64/cloudabi64_proto.h
  head/sys/compat/cloudabi64/cloudabi64_systrace_args.c
  head/sys/contrib/cloudabi/cloudabi32_types.h
  head/sys/contrib/cloudabi/cloudabi64_types.h
  head/sys/contrib/cloudabi/cloudabi_types_common.h
  head/sys/contrib/cloudabi/syscalls32.master
  head/sys/contrib/cloudabi/syscalls64.master

Modified: head/sys/compat/cloudabi32/cloudabi32_module.c
==
--- head/sys/compat/cloudabi32/cloudabi32_module.c  Wed Nov  8 13:06:41 
2017(r325554)
+++ head/sys/compat/cloudabi32/cloudabi32_module.c  Wed Nov  8 14:21:52 
2017(r32)
@@ -63,10 +63,10 @@ cloudabi32_copyout_strings(struct image_params *imgp)
 int
 cloudabi32_fixup(register_t **stack_base, struct image_params *imgp)
 {
-   char canarybuf[64];
+   char canarybuf[64], pidbuf[16];
Elf32_Auxargs *args;
struct thread *td;
-   void *argdata, *canary;
+   void *argdata, *canary, *pid;
size_t argdatalen;
int error;
 
@@ -79,8 +79,9 @@ cloudabi32_fixup(register_t **stack_base, struct image
td = curthread;
td->td_proc->p_osrel = __FreeBSD_version;
 
-   /* Store canary for stack smashing protection. */
argdata = *stack_base;
+
+   /* Store canary for stack smashing protection. */
arc4rand(canarybuf, sizeof(canarybuf), 0);
*stack_base -= howmany(sizeof(canarybuf), sizeof(register_t));
canary = *stack_base;
@@ -89,6 +90,20 @@ cloudabi32_fixup(register_t **stack_base, struct image
return (error);
 
/*
+* Generate a random UUID that identifies the process. Right now
+* we don't store this UUID in the kernel. Ideally, it should be
+* exposed through ps(1).
+*/
+   arc4rand(pidbuf, sizeof(pidbuf), 0);
+   pidbuf[6] = (pidbuf[6] & 0x0f) | 0x40;
+   pidbuf[8] = (pidbuf[8] & 0x3f) | 0x80;
+   *stack_base -= howmany(sizeof(pidbuf), sizeof(register_t));
+   pid = *stack_base;
+   error = copyout(pidbuf, pid, sizeof(pidbuf));
+   if (error != 0)
+   return (error);
+
+   /*
 * Compute length of program arguments. As the argument data is
 * binary safe, we had to add a trailing null byte in
 * exec_copyin_data_fds(). Undo this by reducing the length.
@@ -111,9 +126,10 @@ cloudabi32_fixup(register_t **stack_base, struct image
VAL(CLOUDABI_AT_PAGESZ, args->pagesz),
PTR(CLOUDABI_AT_PHDR, args->phdr),
VAL(CLOUDABI_AT_PHNUM, args->phnum),
-   VAL(CLOUDABI_AT_TID, td->td_tid),
+   PTR(CLOUDABI_AT_PID, pid),
PTR(CLOUDABI_AT_SYSINFO_EHDR,
imgp->proc->p_sysent->sv_shared_page_base),
+   VAL(CLOUDABI_AT_TID, td->td_tid),
 #undef VAL
 #undef PTR
{ .a_type = CLOUDABI_AT_NULL },

Modified: head/sys/compat/cloudabi32/cloudabi32_poll.c
==
--- head/sys/compat/cloudabi32/cloudabi32_poll.cWed Nov  8 13:06:41 
2017(r325554)
+++ head/sys/compat/cloudabi32/cloudabi32_poll.cWed Nov  8 14:21:52 
2017(r32)
@@ -78,7 +78,7 @@ convert_signal(int sig)
 
 struct cloudabi32_kevent_args {
const 

svn commit: r324727 - in head: sys/compat/cloudabi sys/compat/cloudabi32 sys/compat/cloudabi64 sys/contrib/cloudabi usr.bin/truss

2017-10-18 Thread Ed Schouten
Author: ed
Date: Wed Oct 18 19:22:53 2017
New Revision: 324727
URL: https://svnweb.freebsd.org/changeset/base/324727

Log:
  Import the latest CloudABI definitions, version 0.16.
  
  The most important change in this release is the removal of the
  poll_fd() system call; CloudABI's equivalent of kevent(). Though I think
  that kqueue is a lot saner than many of its alternatives, our
  experience is that emulating this system call on other systems
  accurately isn't easy. It has become a complex API, even though I'm not
  convinced this complexity is needed. This is why we've decided to take a
  different approach, by looking one layer up.
  
  We're currently adding an event loop to CloudABI's C library that is API
  compatible with libuv (except when incompatible with Capsicum).
  Initially, this event loop will be built on top of plain inefficient
  poll() calls. Only after this is finished, we'll work our way backwards
  and design a new set of system calls to optimize it.
  
  Interesting challenges will include integrating asynchronous I/O into
  such a system call API. libuv currently doesn't aio(4) on Linux/BSD, due
  to it being unreliable and having undesired semantics.
  
  Obtained from:https://github.com/NuxiNL/cloudabi

Modified:
  head/sys/compat/cloudabi/cloudabi_fd.c
  head/sys/compat/cloudabi32/cloudabi32_poll.c
  head/sys/compat/cloudabi32/cloudabi32_proto.h
  head/sys/compat/cloudabi32/cloudabi32_syscall.h
  head/sys/compat/cloudabi32/cloudabi32_syscalls.c
  head/sys/compat/cloudabi32/cloudabi32_sysent.c
  head/sys/compat/cloudabi32/cloudabi32_systrace_args.c
  head/sys/compat/cloudabi64/cloudabi64_poll.c
  head/sys/compat/cloudabi64/cloudabi64_proto.h
  head/sys/compat/cloudabi64/cloudabi64_syscall.h
  head/sys/compat/cloudabi64/cloudabi64_syscalls.c
  head/sys/compat/cloudabi64/cloudabi64_sysent.c
  head/sys/compat/cloudabi64/cloudabi64_systrace_args.c
  head/sys/contrib/cloudabi/cloudabi32_types.h
  head/sys/contrib/cloudabi/cloudabi64_types.h
  head/sys/contrib/cloudabi/cloudabi_types_common.h
  head/sys/contrib/cloudabi/cloudabi_vdso_aarch64.S
  head/sys/contrib/cloudabi/cloudabi_vdso_armv6.S
  head/sys/contrib/cloudabi/cloudabi_vdso_i686.S
  head/sys/contrib/cloudabi/cloudabi_vdso_i686_on_64bit.S
  head/sys/contrib/cloudabi/cloudabi_vdso_x86_64.S
  head/sys/contrib/cloudabi/syscalls32.master
  head/sys/contrib/cloudabi/syscalls64.master
  head/usr.bin/truss/syscalls.c

Modified: head/sys/compat/cloudabi/cloudabi_fd.c
==
--- head/sys/compat/cloudabi/cloudabi_fd.c  Wed Oct 18 18:59:35 2017
(r324726)
+++ head/sys/compat/cloudabi/cloudabi_fd.c  Wed Oct 18 19:22:53 2017
(r324727)
@@ -73,9 +73,7 @@ __FBSDID("$FreeBSD$");
MAPPING(CLOUDABI_RIGHT_MEM_MAP, CAP_MMAP)   \
MAPPING(CLOUDABI_RIGHT_MEM_MAP_EXEC, CAP_MMAP_X)\
MAPPING(CLOUDABI_RIGHT_POLL_FD_READWRITE, CAP_EVENT)\
-   MAPPING(CLOUDABI_RIGHT_POLL_MODIFY, CAP_KQUEUE_CHANGE)  \
MAPPING(CLOUDABI_RIGHT_POLL_PROC_TERMINATE, CAP_EVENT)  \
-   MAPPING(CLOUDABI_RIGHT_POLL_WAIT, CAP_KQUEUE_EVENT) \
MAPPING(CLOUDABI_RIGHT_PROC_EXEC, CAP_FEXECVE)  \
MAPPING(CLOUDABI_RIGHT_SOCK_SHUTDOWN, CAP_SHUTDOWN) \
 
@@ -93,9 +91,6 @@ cloudabi_sys_fd_create1(struct thread *td,
struct filecaps fcaps = {};
 
switch (uap->type) {
-   case CLOUDABI_FILETYPE_POLL:
-   cap_rights_init(_rights, CAP_FSTAT, CAP_KQUEUE);
-   return (kern_kqueue(td, 0, ));
case CLOUDABI_FILETYPE_SHARED_MEMORY:
cap_rights_init(_rights, CAP_FSTAT, CAP_FTRUNCATE,
CAP_MMAP_RWX);
@@ -201,8 +196,6 @@ cloudabi_convert_filetype(const struct file *fp)
switch (fp->f_type) {
case DTYPE_FIFO:
return (CLOUDABI_FILETYPE_SOCKET_STREAM);
-   case DTYPE_KQUEUE:
-   return (CLOUDABI_FILETYPE_POLL);
case DTYPE_PIPE:
return (CLOUDABI_FILETYPE_SOCKET_STREAM);
case DTYPE_PROCDESC:
@@ -315,10 +308,6 @@ cloudabi_remove_conflicting_rights(cloudabi_filetype_t
CLOUDABI_RIGHT_MEM_MAP_EXEC |
CLOUDABI_RIGHT_POLL_FD_READWRITE |
CLOUDABI_RIGHT_PROC_EXEC;
-   break;
-   case CLOUDABI_FILETYPE_POLL:
-   *base &= ~CLOUDABI_RIGHT_FILE_ADVISE;
-   *inheriting = 0;
break;
case CLOUDABI_FILETYPE_PROCESS:
*base &= ~(CLOUDABI_RIGHT_FILE_ADVISE |

Modified: head/sys/compat/cloudabi32/cloudabi32_poll.c
==
--- head/sys/compat/cloudabi32/cloudabi32_poll.cWed Oct 18 18:59:35 
2017(r324726)
+++ head/sys/compat/cloudabi32/cloudabi32_poll.cWed Oct 18 19:22:53 
2017 

Re: svn commit: r324065 - head/sys/dev/qlxgbe

2017-09-27 Thread Ed Schouten
2017-09-27 19:46 GMT+02:00 David C Somayajulu <davi...@freebsd.org>:
> +   *(hw_tx_cntxt->tx_cons) = 0;

In this case the parentheses are superfluous, right? -> has a higher
precedence than *.

-- 
Ed Schouten <e...@nuxi.nl>
Nuxi, 's-Hertogenbosch, the Netherlands
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r323177 - in head: sys/compat/cloudabi sys/contrib/cloudabi usr.bin/truss

2017-09-16 Thread Ed Schouten
Hi Jilles,

2017-09-15 12:58 GMT+01:00 Jilles Tjoelker <jil...@stack.nl>:
> Although this is correct from a functionality point of view (S_IFIFO and
> S_IFSOCK are probably expected to be different in a POSIX context, but
> this is unlikely to break anything that is not already broken), it is a
> partial reversal of previous changes to FreeBSD that created separate
> implementations for pipes (first unnamed pipes in 1996, later fifos in
> 2012 r232055). The main reason for these changes was performance.
>
> Unfortunately, I do not have concrete benchmarks in the CloudABI
> context.

That is important to keep in mind indeed. Thanks for pointing this out!

When I discussed this with some of the other folks working on
CloudABI, we came to the conclusion that this (potential) loss of
performance is acceptable in the nearby future. If it would really
affect us negatively, it should in theory be possible to reimplement
our streaming sockets and pipes with something as simple and fast as
FreeBSD's pipes, but still support file descriptor passing, etc.

-- 
Ed Schouten <e...@nuxi.nl>
Nuxi, 's-Hertogenbosch, the Netherlands
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r323177 - in head: sys/compat/cloudabi sys/contrib/cloudabi usr.bin/truss

2017-09-05 Thread Ed Schouten
Author: ed
Date: Tue Sep  5 07:46:45 2017
New Revision: 323177
URL: https://svnweb.freebsd.org/changeset/base/323177

Log:
  Merge pipes and socket pairs.
  
  Now that CloudABI's sockets API has been changed to be addressless and
  only connected socket instances are used (e.g., socket pairs), they have
  become fairly similar to pipes. The only differences on CloudABI is that
  socket pairs additionally support shutdown(), send() and recv().
  
  To simplify the ABI, we've therefore decided to remove pipes as a
  separate file descriptor type and just let pipe() return a socket pair
  of type SOCK_STREAM. S_ISFIFO() and S_ISSOCK() are now defined
  identically.

Modified:
  head/sys/compat/cloudabi/cloudabi_fd.c
  head/sys/compat/cloudabi/cloudabi_file.c
  head/sys/contrib/cloudabi/cloudabi_types_common.h
  head/usr.bin/truss/syscalls.c

Modified: head/sys/compat/cloudabi/cloudabi_fd.c
==
--- head/sys/compat/cloudabi/cloudabi_fd.c  Tue Sep  5 06:20:02 2017
(r323176)
+++ head/sys/compat/cloudabi/cloudabi_fd.c  Tue Sep  5 07:46:45 2017
(r323177)
@@ -56,7 +56,6 @@ __FBSDID("$FreeBSD$");
MAPPING(CLOUDABI_RIGHT_FILE_ALLOCATE, CAP_WRITE)\
MAPPING(CLOUDABI_RIGHT_FILE_CREATE_DIRECTORY, CAP_MKDIRAT)  \
MAPPING(CLOUDABI_RIGHT_FILE_CREATE_FILE, CAP_CREATE)\
-   MAPPING(CLOUDABI_RIGHT_FILE_CREATE_FIFO, CAP_MKFIFOAT)  \
MAPPING(CLOUDABI_RIGHT_FILE_LINK_SOURCE, CAP_LINKAT_SOURCE) \
MAPPING(CLOUDABI_RIGHT_FILE_LINK_TARGET, CAP_LINKAT_TARGET) \
MAPPING(CLOUDABI_RIGHT_FILE_OPEN, CAP_LOOKUP)   \
@@ -110,34 +109,21 @@ int
 cloudabi_sys_fd_create2(struct thread *td,
 struct cloudabi_sys_fd_create2_args *uap)
 {
-   struct filecaps fcaps1 = {}, fcaps2 = {};
int fds[2];
-   int error;
+   int error, type;
 
switch (uap->type) {
-   case CLOUDABI_FILETYPE_FIFO:
-   /*
-* CloudABI pipes are unidirectional. Restrict rights on
-* the pipe to simulate this.
-*/
-   cap_rights_init(_rights, CAP_EVENT, CAP_FCNTL,
-   CAP_FSTAT, CAP_READ);
-   fcaps1.fc_fcntls = CAP_FCNTL_SETFL;
-   cap_rights_init(_rights, CAP_EVENT, CAP_FCNTL,
-   CAP_FSTAT, CAP_WRITE);
-   fcaps2.fc_fcntls = CAP_FCNTL_SETFL;
-   error = kern_pipe(td, fds, 0, , );
-   break;
case CLOUDABI_FILETYPE_SOCKET_DGRAM:
-   error = kern_socketpair(td, AF_UNIX, SOCK_DGRAM, 0, fds);
+   type = SOCK_DGRAM;
break;
case CLOUDABI_FILETYPE_SOCKET_STREAM:
-   error = kern_socketpair(td, AF_UNIX, SOCK_STREAM, 0, fds);
+   type = SOCK_STREAM;
break;
default:
return (EINVAL);
}
 
+   error = kern_socketpair(td, AF_UNIX, type, 0, fds);
if (error == 0) {
td->td_retval[0] = fds[0];
td->td_retval[1] = fds[1];
@@ -214,11 +200,11 @@ cloudabi_convert_filetype(const struct file *fp)
 
switch (fp->f_type) {
case DTYPE_FIFO:
-   return (CLOUDABI_FILETYPE_FIFO);
+   return (CLOUDABI_FILETYPE_SOCKET_STREAM);
case DTYPE_KQUEUE:
return (CLOUDABI_FILETYPE_POLL);
case DTYPE_PIPE:
-   return (CLOUDABI_FILETYPE_FIFO);
+   return (CLOUDABI_FILETYPE_SOCKET_STREAM);
case DTYPE_PROCDESC:
return (CLOUDABI_FILETYPE_PROCESS);
case DTYPE_SHM:
@@ -243,7 +229,7 @@ cloudabi_convert_filetype(const struct file *fp)
case VDIR:
return (CLOUDABI_FILETYPE_DIRECTORY);
case VFIFO:
-   return (CLOUDABI_FILETYPE_FIFO);
+   return (CLOUDABI_FILETYPE_SOCKET_STREAM);
case VLNK:
return (CLOUDABI_FILETYPE_SYMBOLIC_LINK);
case VREG:
@@ -286,7 +272,6 @@ cloudabi_remove_conflicting_rights(cloudabi_filetype_t
CLOUDABI_RIGHT_FD_SYNC | CLOUDABI_RIGHT_FILE_ADVISE |
CLOUDABI_RIGHT_FILE_CREATE_DIRECTORY |
CLOUDABI_RIGHT_FILE_CREATE_FILE |
-   CLOUDABI_RIGHT_FILE_CREATE_FIFO |
CLOUDABI_RIGHT_FILE_LINK_SOURCE |
CLOUDABI_RIGHT_FILE_LINK_TARGET |
CLOUDABI_RIGHT_FILE_OPEN |
@@ -312,7 +297,6 @@ cloudabi_remove_conflicting_rights(cloudabi_filetype_t
CLOUDABI_RIGHT_FILE_ALLOCATE |
CLOUDABI_RIGHT_FILE_CREATE_DIRECTORY |
CLOUDABI_RIGHT_FILE_CREATE_FILE |
-   CLOUDABI_RIGHT_FILE_CREATE_FIFO |
CLOUDABI_RIGHT_FILE_LINK_SOURCE |

svn commit: r323015 - in head: sys/compat/cloudabi sys/compat/cloudabi32 sys/compat/cloudabi64 sys/contrib/cloudabi usr.bin/truss

2017-08-30 Thread Ed Schouten
Author: ed
Date: Wed Aug 30 07:30:06 2017
New Revision: 323015
URL: https://svnweb.freebsd.org/changeset/base/323015

Log:
  Complete the CloudABI networking refactoring.
  
  Now that all of the packaged software has been adjusted to either use
  Flower (https://github.com/NuxiNL/flower) for making incoming/outgoing
  network connections or can have connections injected, there is no longer
  need to keep accept() around. It is now a lot easier to write networked
  services that are address family independent, dual-stack, testable, etc.
  
  Remove all of the bits related to accept(), but also to
  getsockopt(SO_ACCEPTCONN).

Modified:
  head/sys/compat/cloudabi/cloudabi_fd.c
  head/sys/compat/cloudabi/cloudabi_sock.c
  head/sys/compat/cloudabi32/cloudabi32_proto.h
  head/sys/compat/cloudabi32/cloudabi32_syscall.h
  head/sys/compat/cloudabi32/cloudabi32_syscalls.c
  head/sys/compat/cloudabi32/cloudabi32_sysent.c
  head/sys/compat/cloudabi32/cloudabi32_systrace_args.c
  head/sys/compat/cloudabi64/cloudabi64_proto.h
  head/sys/compat/cloudabi64/cloudabi64_syscall.h
  head/sys/compat/cloudabi64/cloudabi64_syscalls.c
  head/sys/compat/cloudabi64/cloudabi64_sysent.c
  head/sys/compat/cloudabi64/cloudabi64_systrace_args.c
  head/sys/contrib/cloudabi/cloudabi_types_common.h
  head/sys/contrib/cloudabi/cloudabi_vdso_aarch64.S
  head/sys/contrib/cloudabi/cloudabi_vdso_armv6.S
  head/sys/contrib/cloudabi/cloudabi_vdso_i686.S
  head/sys/contrib/cloudabi/cloudabi_vdso_i686_on_64bit.S
  head/sys/contrib/cloudabi/cloudabi_vdso_x86_64.S
  head/sys/contrib/cloudabi/syscalls32.master
  head/sys/contrib/cloudabi/syscalls64.master
  head/usr.bin/truss/syscalls.c

Modified: head/sys/compat/cloudabi/cloudabi_fd.c
==
--- head/sys/compat/cloudabi/cloudabi_fd.c  Wed Aug 30 07:05:29 2017
(r323014)
+++ head/sys/compat/cloudabi/cloudabi_fd.c  Wed Aug 30 07:30:06 2017
(r323015)
@@ -78,10 +78,7 @@ __FBSDID("$FreeBSD$");
MAPPING(CLOUDABI_RIGHT_POLL_PROC_TERMINATE, CAP_EVENT)  \
MAPPING(CLOUDABI_RIGHT_POLL_WAIT, CAP_KQUEUE_EVENT) \
MAPPING(CLOUDABI_RIGHT_PROC_EXEC, CAP_FEXECVE)  \
-   MAPPING(CLOUDABI_RIGHT_SOCK_ACCEPT, CAP_ACCEPT) \
MAPPING(CLOUDABI_RIGHT_SOCK_SHUTDOWN, CAP_SHUTDOWN) \
-   MAPPING(CLOUDABI_RIGHT_SOCK_STAT_GET, CAP_GETPEERNAME,  \
-   CAP_GETSOCKNAME, CAP_GETSOCKOPT)
 
 int
 cloudabi_sys_fd_close(struct thread *td, struct cloudabi_sys_fd_close_args 
*uap)
@@ -386,9 +383,7 @@ cloudabi_remove_conflicting_rights(cloudabi_filetype_t
CLOUDABI_RIGHT_FD_WRITE |
CLOUDABI_RIGHT_FILE_STAT_FGET |
CLOUDABI_RIGHT_POLL_FD_READWRITE |
-   CLOUDABI_RIGHT_SOCK_ACCEPT |
-   CLOUDABI_RIGHT_SOCK_SHUTDOWN |
-   CLOUDABI_RIGHT_SOCK_STAT_GET;
+   CLOUDABI_RIGHT_SOCK_SHUTDOWN;
break;
default:
*inheriting = 0;

Modified: head/sys/compat/cloudabi/cloudabi_sock.c
==
--- head/sys/compat/cloudabi/cloudabi_sock.cWed Aug 30 07:05:29 2017
(r323014)
+++ head/sys/compat/cloudabi/cloudabi_sock.cWed Aug 30 07:30:06 2017
(r323015)
@@ -49,14 +49,6 @@ __FBSDID("$FreeBSD$");
 #include 
 
 int
-cloudabi_sys_sock_accept(struct thread *td,
-struct cloudabi_sys_sock_accept_args *uap)
-{
-
-   return (kern_accept(td, uap->sock, NULL, NULL, NULL));
-}
-
-int
 cloudabi_sys_sock_shutdown(struct thread *td,
 struct cloudabi_sys_sock_shutdown_args *uap)
 {
@@ -77,37 +69,6 @@ cloudabi_sys_sock_shutdown(struct thread *td,
}
 
return (kern_shutdown(td, uap->sock, how));
-}
-
-int
-cloudabi_sys_sock_stat_get(struct thread *td,
-struct cloudabi_sys_sock_stat_get_args *uap)
-{
-   cloudabi_sockstat_t ss = {};
-   cap_rights_t rights;
-   struct file *fp;
-   struct socket *so;
-   int error;
-
-   error = getsock_cap(td, uap->sock, cap_rights_init(,
-   CAP_GETSOCKOPT, CAP_GETPEERNAME, CAP_GETSOCKNAME), , NULL, NULL);
-   if (error != 0)
-   return (error);
-   so = fp->f_data;
-
-   /* Set ss_error. */
-   SOCK_LOCK(so);
-   ss.ss_error = cloudabi_convert_errno(so->so_error);
-   if ((uap->flags & CLOUDABI_SOCKSTAT_CLEAR_ERROR) != 0)
-   so->so_error = 0;
-   SOCK_UNLOCK(so);
-
-   /* Set ss_state. */
-   if ((so->so_options & SO_ACCEPTCONN) != 0)
-   ss.ss_state |= CLOUDABI_SOCKSTATE_ACCEPTCONN;
-
-   fdrop(fp, td);
-   return (copyout(, uap->buf, sizeof(ss)));
 }
 
 int

Modified: head/sys/compat/cloudabi32/cloudabi32_proto.h
==
--- head/sys/compat/cloudabi32/cloudabi32_proto.h

Re: svn commit: r322875 - head/sys/dev/nvme

2017-08-28 Thread Ed Schouten
2017-08-28 11:02 GMT+02:00 Mark Millard <mar...@dsl-only.net>:
> Based on the same main.cc as before . . .
>
> g++7 -std=c++98 main.cc
> g++7 -Wpedantic -std=c++98 main.cc
> g++7 -std=c++03 main.cc
> g++7 -Wpedantic -std=c++03 main.cc
>
> no longer complain (so no error, no
> warning).

Perfect! I've committed this change as r322965. Thanks for testing!


-- 
Ed Schouten <e...@nuxi.nl>
Nuxi, 's-Hertogenbosch, the Netherlands
KvK-nr.: 62051717
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r322965 - head/sys/sys

2017-08-28 Thread Ed Schouten
Author: ed
Date: Mon Aug 28 09:35:17 2017
New Revision: 322965
URL: https://svnweb.freebsd.org/changeset/base/322965

Log:
  Make _Static_assert() work with GCC in older C++ standards.
  
  GCC only activates C11 keywords in C mode, not C++ mode. This means
  that when targeting an older C++ standard, we cannot fall back to using
  _Static_assert(). In this case, do define _Static_assert() as a macro
  that uses a typedef'ed array.
  
  Discussed in: r322875 commit thread
  Reported by:  Mark MIllard
  MFC after:1 month

Modified:
  head/sys/sys/cdefs.h

Modified: head/sys/sys/cdefs.h
==
--- head/sys/sys/cdefs.hMon Aug 28 07:50:54 2017(r322964)
+++ head/sys/sys/cdefs.hMon Aug 28 09:35:17 2017(r322965)
@@ -294,7 +294,7 @@
 #if (defined(__cplusplus) && __cplusplus >= 201103L) || \
 __has_extension(cxx_static_assert)
 #define_Static_assert(x, y)static_assert(x, y)
-#elif __GNUC_PREREQ__(4,6)
+#elif __GNUC_PREREQ__(4,6) && !defined(__cplusplus)
 /* Nothing, gcc 4.6 and higher has _Static_assert built-in */
 #elif defined(__COUNTER__)
 #define_Static_assert(x, y)__Static_assert(x, __COUNTER__)
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r322875 - head/sys/dev/nvme

2017-08-28 Thread Ed Schouten
Mark,

2017-08-25 14:53 GMT+02:00 Ed Schouten <e...@nuxi.nl>:
> 2017-08-25 9:46 GMT+02:00 Mark Millard <mar...@dsl-only.net>:
>> It appears that at least 11.1-STABLE -r322807 does not handle
>> -std=c++98 styles of use of _Static_assert for g++7 in that
>> g++7 reports an error:
>
> Maybe we need to do something like this?
>
> Index: sys/sys/cdefs.h
> ===
> --- sys/sys/cdefs.h (revision 322887)
> +++ sys/sys/cdefs.h (working copy)
> @@ -294,7 +294,7 @@
>  #if (defined(__cplusplus) && __cplusplus >= 201103L) || \
>  __has_extension(cxx_static_assert)
>  #define _Static_assert(x, y) static_assert(x, y)
> -#elif __GNUC_PREREQ__(4,6)
> +#elif __GNUC_PREREQ__(4,6) && !defined(__cplusplus)
>  /* Nothing, gcc 4.6 and higher has _Static_assert built-in */
>  #elif defined(__COUNTER__)
>  #define _Static_assert(x, y) __Static_assert(x, __COUNTER__)

Could you let me know whether this patch fixes the build for you? If
so, I'll commit it!

-- 
Ed Schouten <e...@nuxi.nl>
Nuxi, 's-Hertogenbosch, the Netherlands
KvK-nr.: 62051717
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r322942 - head/sys/kern

2017-08-27 Thread Ed Schouten
Hi Conrad,

[ Context: I don't understand anything about CPU topologies! ]

2017-08-27 7:14 GMT+02:00 Conrad Meyer <c...@freebsd.org>:
> +   while (top->cg_children == 1) {
> +   top = >cg_child[0];
> +   top->cg_parent = NULL;
> +   }

This only removes layers from the top if they only have a single
child. Question: is it possible/likely to have CPU topologies where
one of the middle layers only has one child? If so, would it make
sense to use tree traversal here to do the flattening?

-- 
Ed Schouten <e...@nuxi.nl>
Nuxi, 's-Hertogenbosch, the Netherlands
KvK-nr.: 62051717
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r322875 - head/sys/dev/nvme

2017-08-25 Thread Ed Schouten
2017-08-25 9:46 GMT+02:00 Mark Millard <mar...@dsl-only.net>:
> It appears that at least 11.1-STABLE -r322807 does not handle
> -std=c++98 styles of use of _Static_assert for g++7 in that
> g++7 reports an error:

Maybe we need to do something like this?

Index: sys/sys/cdefs.h
===
--- sys/sys/cdefs.h (revision 322887)
+++ sys/sys/cdefs.h (working copy)
@@ -294,7 +294,7 @@
 #if (defined(__cplusplus) && __cplusplus >= 201103L) || \
 __has_extension(cxx_static_assert)
 #define _Static_assert(x, y) static_assert(x, y)
-#elif __GNUC_PREREQ__(4,6)
+#elif __GNUC_PREREQ__(4,6) && !defined(__cplusplus)
 /* Nothing, gcc 4.6 and higher has _Static_assert built-in */
 #elif defined(__COUNTER__)
 #define _Static_assert(x, y) __Static_assert(x, __COUNTER__)


-- 
Ed Schouten <e...@nuxi.nl>
Nuxi, 's-Hertogenbosch, the Netherlands
KvK-nr.: 62051717
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r322888 - head/usr.bin/calendar/calendars

2017-08-25 Thread Ed Schouten
Author: ed
Date: Fri Aug 25 12:28:34 2017
New Revision: 322888
URL: https://svnweb.freebsd.org/changeset/base/322888

Log:
  Make entries for the United States more consistent.
  
  MFC after:1 week

Modified:
  head/usr.bin/calendar/calendars/calendar.freebsd

Modified: head/usr.bin/calendar/calendars/calendar.freebsd
==
--- head/usr.bin/calendar/calendars/calendar.freebsdFri Aug 25 12:16:03 
2017(r322887)
+++ head/usr.bin/calendar/calendars/calendar.freebsdFri Aug 25 12:28:34 
2017(r322888)
@@ -224,7 +224,7 @@
 06/04  Johannes Jost Meixner  born in Wiesbaden, Germany, 
1987
 06/06  Sergei Kolobov  born in Karpinsk, Russian 
Federation, 1972
 06/06  Ryan Libby  born in Kirkland, Washington, United 
States, 1985
-06/06  Alan Eldridge  died in Denver, Colorado, 2003
+06/06  Alan Eldridge  died in Denver, Colorado, United 
States, 2003
 06/07  Jimmy Olgeni  born in Milano, Italy, 1976
 06/07  Benjamin Close  born in Adelaide, Australia, 1978
 06/07  Roger Pau Monne  born in Reus, Catalunya, Spain, 
1986
@@ -436,7 +436,7 @@
 12/18  Semen Ustimenko  born in Novosibirsk, Russian 
Federation, 1979
 12/19  Stephen Hurd  born in Estevan, Saskatchewan, Canada, 
1975
 12/19  Emmanuel Vadot  born in Decines-Charpieu, France, 1983
-12/20  Sean Bruno  born in Monterey, California, USA, 1974
+12/20  Sean Bruno  born in Monterey, California, United 
States, 1974
 12/21  Rong-En Fan  born in Taipei, Taiwan, Republic of 
China, 1982
 12/22  Alan L. Cox  born in Warren, Ohio, United States, 1964
 12/22  Maxim Sobolev  born in Dnepropetrovsk, Ukraine, 
1976
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r322885 - in head: sys/compat/cloudabi sys/compat/cloudabi32 sys/compat/cloudabi64 sys/contrib/cloudabi usr.bin/truss

2017-08-25 Thread Ed Schouten
Author: ed
Date: Fri Aug 25 11:01:39 2017
New Revision: 322885
URL: https://svnweb.freebsd.org/changeset/base/322885

Log:
  Sync CloudABI compatibility against the latest upstream version (v0.13).
  
  With Flower (CloudABI's network connection daemon) becoming more
  complete, there is no longer any need for creating any unconnected
  sockets. Socket pairs in combination with file descriptor passing is all
  that is necessary, as that is what is used by Flower to pass network
  connections from the public internet to listening processes.
  
  Remove all of the kernel bits that were used to implement socket(),
  listen(), bindat() and connectat(). In principle, accept() and
  SO_ACCEPTCONN may also be removed, but there are still some consumers
  left.
  
  Obtained from:https://github.com/NuxiNL/cloudabi
  MFC after:1 month

Modified:
  head/sys/compat/cloudabi/cloudabi_fd.c
  head/sys/compat/cloudabi/cloudabi_sock.c
  head/sys/compat/cloudabi32/cloudabi32_proto.h
  head/sys/compat/cloudabi32/cloudabi32_syscall.h
  head/sys/compat/cloudabi32/cloudabi32_syscalls.c
  head/sys/compat/cloudabi32/cloudabi32_sysent.c
  head/sys/compat/cloudabi32/cloudabi32_systrace_args.c
  head/sys/compat/cloudabi64/cloudabi64_proto.h
  head/sys/compat/cloudabi64/cloudabi64_syscall.h
  head/sys/compat/cloudabi64/cloudabi64_syscalls.c
  head/sys/compat/cloudabi64/cloudabi64_sysent.c
  head/sys/compat/cloudabi64/cloudabi64_systrace_args.c
  head/sys/contrib/cloudabi/cloudabi_types_common.h
  head/sys/contrib/cloudabi/cloudabi_vdso_aarch64.S
  head/sys/contrib/cloudabi/cloudabi_vdso_armv6.S
  head/sys/contrib/cloudabi/cloudabi_vdso_i686.S
  head/sys/contrib/cloudabi/cloudabi_vdso_i686_on_64bit.S
  head/sys/contrib/cloudabi/cloudabi_vdso_x86_64.S
  head/sys/contrib/cloudabi/syscalls32.master
  head/sys/contrib/cloudabi/syscalls64.master
  head/usr.bin/truss/syscalls.c

Modified: head/sys/compat/cloudabi/cloudabi_fd.c
==
--- head/sys/compat/cloudabi/cloudabi_fd.c  Fri Aug 25 10:57:17 2017
(r322884)
+++ head/sys/compat/cloudabi/cloudabi_fd.c  Fri Aug 25 11:01:39 2017
(r322885)
@@ -79,11 +79,6 @@ __FBSDID("$FreeBSD$");
MAPPING(CLOUDABI_RIGHT_POLL_WAIT, CAP_KQUEUE_EVENT) \
MAPPING(CLOUDABI_RIGHT_PROC_EXEC, CAP_FEXECVE)  \
MAPPING(CLOUDABI_RIGHT_SOCK_ACCEPT, CAP_ACCEPT) \
-   MAPPING(CLOUDABI_RIGHT_SOCK_BIND_DIRECTORY, CAP_BINDAT) \
-   MAPPING(CLOUDABI_RIGHT_SOCK_BIND_SOCKET, CAP_BIND)  \
-   MAPPING(CLOUDABI_RIGHT_SOCK_CONNECT_DIRECTORY, CAP_CONNECTAT)   \
-   MAPPING(CLOUDABI_RIGHT_SOCK_CONNECT_SOCKET, CAP_CONNECT)\
-   MAPPING(CLOUDABI_RIGHT_SOCK_LISTEN, CAP_LISTEN) \
MAPPING(CLOUDABI_RIGHT_SOCK_SHUTDOWN, CAP_SHUTDOWN) \
MAPPING(CLOUDABI_RIGHT_SOCK_STAT_GET, CAP_GETPEERNAME,  \
CAP_GETSOCKNAME, CAP_GETSOCKOPT)
@@ -109,10 +104,6 @@ cloudabi_sys_fd_create1(struct thread *td,
cap_rights_init(_rights, CAP_FSTAT, CAP_FTRUNCATE,
CAP_MMAP_RWX);
return (kern_shm_open(td, SHM_ANON, O_RDWR, 0, ));
-   case CLOUDABI_FILETYPE_SOCKET_DGRAM:
-   return (kern_socket(td, AF_UNIX, SOCK_DGRAM, 0));
-   case CLOUDABI_FILETYPE_SOCKET_STREAM:
-   return (kern_socket(td, AF_UNIX, SOCK_STREAM, 0));
default:
return (EINVAL);
}
@@ -312,9 +303,7 @@ cloudabi_remove_conflicting_rights(cloudabi_filetype_t
CLOUDABI_RIGHT_FILE_STAT_PUT_TIMES |
CLOUDABI_RIGHT_FILE_SYMLINK |
CLOUDABI_RIGHT_FILE_UNLINK |
-   CLOUDABI_RIGHT_POLL_FD_READWRITE |
-   CLOUDABI_RIGHT_SOCK_BIND_DIRECTORY |
-   CLOUDABI_RIGHT_SOCK_CONNECT_DIRECTORY;
+   CLOUDABI_RIGHT_POLL_FD_READWRITE;
*inheriting &= CLOUDABI_RIGHT_FD_DATASYNC |
CLOUDABI_RIGHT_FD_READ |
CLOUDABI_RIGHT_FD_SEEK |
@@ -344,9 +333,7 @@ cloudabi_remove_conflicting_rights(cloudabi_filetype_t
CLOUDABI_RIGHT_MEM_MAP |
CLOUDABI_RIGHT_MEM_MAP_EXEC |
CLOUDABI_RIGHT_POLL_FD_READWRITE |
-   CLOUDABI_RIGHT_PROC_EXEC |
-   CLOUDABI_RIGHT_SOCK_BIND_DIRECTORY |
-   CLOUDABI_RIGHT_SOCK_CONNECT_DIRECTORY;
+   CLOUDABI_RIGHT_PROC_EXEC;
break;
case CLOUDABI_FILETYPE_FIFO:
*base &= CLOUDABI_RIGHT_FD_READ |
@@ -400,9 +387,6 @@ cloudabi_remove_conflicting_rights(cloudabi_filetype_t
CLOUDABI_RIGHT_FILE_STAT_FGET |
CLOUDABI_RIGHT_POLL_FD_READWRITE |
CLOUDABI_RIGHT_SOCK_ACCEPT |
-   CLOUDABI_RIGHT_SOCK_BIND_SOCKET |
-   

Re: svn commit: r322875 - head/sys/dev/nvme

2017-08-25 Thread Ed Schouten
2017-08-25 8:32 GMT+02:00 Mark Millard <mar...@dsl-only.net>:
>> # g++49 main.cc
>> main.cc:2:15: error: expected constructor, destructor, or type conversion 
>> before '(' token
>>  _Static_assert(1,"Test");

Yeah, that's because GCC is such a pain in the neck compiler that it
doesn't want to expose these C11 keywords when building C++, even
though they are in the reserved namespace (_[A-Z]). GCC would be
permitted to expose these and still comply to standards. Doing so
would make things so much easier for operating system implementors,
like us. Clang does get it right, in my opinion.

We should just extend  to define _Static_assert() when
using GCC in C++ mode (if we're not doing so already).

-- 
Ed Schouten <e...@nuxi.nl>
Nuxi, 's-Hertogenbosch, the Netherlands
KvK-nr.: 62051717
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r321969 - in head/sys/boot: arm/at91/libat91 arm/ixp425/boot2 i386/boot2

2017-08-03 Thread Ed Schouten
2017-08-03 7:27 GMT+02:00 Ngie Cooper <n...@freebsd.org>:
> Modified: head/sys/boot/arm/at91/libat91/printf.c
> ==
> --- head/sys/boot/arm/at91/libat91/printf.c Thu Aug  3 03:45:48 2017  
>   (r321968)
> +++ head/sys/boot/arm/at91/libat91/printf.c Thu Aug  3 05:27:05 2017  
>   (r321969)
> @@ -20,12 +20,13 @@
>  #include 
>  #include "lib.h"
>
> -void
> +int
>  printf(const char *fmt,...)
>  {
> va_list ap;
> const char *hex = "0123456789abcdef";
> char buf[10];
> +   const char *fmt_orig = fmt;
> char *s;
> unsigned u;
> int c;
> @@ -66,5 +67,5 @@ printf(const char *fmt,...)
> }
> va_end(ap);
>
> -   return;
> +   return (int)(fmt - fmt_orig);
>  }

This makes printf() return the number of characters from the format
processed, right? This is different from libc's printf(), which
returns the number of characters printed.

-- 
Ed Schouten <e...@nuxi.nl>
Nuxi, 's-Hertogenbosch, the Netherlands
KvK-nr.: 62051717
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r321924 - head/sys/amd64/cloudabi64

2017-08-02 Thread Ed Schouten
Author: ed
Date: Wed Aug  2 13:08:10 2017
New Revision: 321924
URL: https://svnweb.freebsd.org/changeset/base/321924

Log:
  Keep top page on CloudABI to work around AMD Ryzen stability issues.
  
  Similar to r321899, reduce sv_maxuser by one page inside of CloudABI.
  This ensures that the stack, the vDSO and any allocations cannot touch
  the top page of user virtual memory.
  
  Considering that CloudABI userspace is completely oblivious to virtual
  memory layout, don't bother making this conditional based on the CPU of
  the running system.
  
  Reviewed by:  kib, truckman
  Differential Revision:https://reviews.freebsd.org/D11808

Modified:
  head/sys/amd64/cloudabi64/cloudabi64_sysvec.c

Modified: head/sys/amd64/cloudabi64/cloudabi64_sysvec.c
==
--- head/sys/amd64/cloudabi64/cloudabi64_sysvec.c   Wed Aug  2 12:31:03 
2017(r321923)
+++ head/sys/amd64/cloudabi64/cloudabi64_sysvec.c   Wed Aug  2 13:08:10 
2017(r321924)
@@ -199,7 +199,8 @@ static struct sysentvec cloudabi64_elf_sysvec = {
.sv_coredump= elf64_coredump,
.sv_pagesize= PAGE_SIZE,
.sv_minuser = VM_MIN_ADDRESS,
-   .sv_maxuser = VM_MAXUSER_ADDRESS,
+   /* Keep top page reserved to work around AMD Ryzen stability issues. */
+   .sv_maxuser = VM_MAXUSER_ADDRESS - PAGE_SIZE,
.sv_stackprot   = VM_PROT_READ | VM_PROT_WRITE,
.sv_copyout_strings = cloudabi64_copyout_strings,
.sv_setregs = cloudabi64_proc_setregs,
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r321678 - head/usr.sbin/prometheus_sysctl_exporter

2017-07-29 Thread Ed Schouten
Author: ed
Date: Sat Jul 29 08:35:07 2017
New Revision: 321678
URL: https://svnweb.freebsd.org/changeset/base/321678

Log:
  Be a bit more liberal about sysctl naming.
  
  On the systems on which I tested this exporter, I never ran into metrics
  that were named in such a way that they couldn't be exported to
  Prometheus metrics directly. Now it turns out that on systems with NUMA,
  the sysctl tree contains metrics named dev.${driver}.${index}.%domain.
  For these metrics, the % in the name is problematic, as Prometheus
  doesn't allow this symbol to be used.
  
  Remove the assertions that were originally put in place to prevent the
  exporter from generating malformed output and add code to deal with it
  accordingly. For metric names, convert any unsupported character to an
  underscore. For label values, perform string escaping.
  
  PR:   https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=221035
  Reported by:  lifanov@

Modified:
  head/usr.sbin/prometheus_sysctl_exporter/prometheus_sysctl_exporter.c

Modified: head/usr.sbin/prometheus_sysctl_exporter/prometheus_sysctl_exporter.c
==
--- head/usr.sbin/prometheus_sysctl_exporter/prometheus_sysctl_exporter.c   
Sat Jul 29 08:24:51 2017(r321677)
+++ head/usr.sbin/prometheus_sysctl_exporter/prometheus_sysctl_exporter.c   
Sat Jul 29 08:35:07 2017(r321678)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2016 Nuxi, https://nuxi.nl/
+ * Copyright (c) 2016-2017 Nuxi, https://nuxi.nl/
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -384,11 +385,12 @@ oidname_print(const struct oidname *on, const struct o
label = on->labels;
for (i = 0; i < on->oid.len; ++i) {
if (*label == '\0') {
-   assert(name[strspn(name,
-   "abcdefghijklmnopqrstuvwxyz"
-   "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-   "0123456789_")] == '\0');
-   fprintf(fp, "_%s", name);
+   fputc('_', fp);
+   while (*name != '\0') {
+   /* Map unsupported characters to underscores. */
+   fputc(isalnum(*name) ? *name : '_', fp);
+   ++name;
+   }
}
name += strlen(name) + 1;
label += strlen(label) + 1;
@@ -404,15 +406,18 @@ oidname_print(const struct oidname *on, const struct o
separator = '{';
for (i = 0; i < on->oid.len; ++i) {
if (*label != '\0') {
-   assert(name[strspn(name,
-   "abcdefghijklmnopqrstuvwxyz"
-   "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-   "0123456789_-")] == '\0');
assert(label[strspn(label,
"abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"0123456789_")] == '\0');
-   fprintf(fp, "%c%s=\"%s\"", separator, label, name);
+   fprintf(fp, "%c%s=\"", separator, label);
+   while (*name != '\0') {
+   /* Escape backslashes and double quotes. */
+   if (*name == '\\' || *name == '"')
+   fputc('\\', fp);
+   fputc(*name++, fp);
+   }
+   fputc('"', fp);
separator = ',';
}
name += strlen(name) + 1;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r321514 - in head: sys/compat/cloudabi sys/compat/cloudabi32 sys/compat/cloudabi64 sys/contrib/cloudabi usr.bin/truss

2017-07-26 Thread Ed Schouten
Author: ed
Date: Wed Jul 26 06:57:15 2017
New Revision: 321514
URL: https://svnweb.freebsd.org/changeset/base/321514

Log:
  Upgrade to the latest sources generated from the CloudABI specification.
  
  The CloudABI specification has had some minor changes over the last half
  year. No substantial features have been added, but some features that
  are deemed unnecessary in retrospect have been removed:
  
  - mlock()/munlock():
  
These calls tend to be used for two different purposes: real-time
support and handling of sensitive (cryptographic) material that
shouldn't end up in swap. The former use case is out of scope for
CloudABI. The latter may also be handled by encrypting swap.
  
Removing this has the advantage that we no longer need to worry about
having resource limits put in place.
  
  - SOCK_SEQPACKET:
  
Support for SOCK_SEQPACKET is rather inconsistent across various
operating systems. Some operating systems supported by CloudABI (e.g.,
macOS) don't support it at all. Considering that they are rarely used,
remove support for the time being.
  
  - getsockname(), getpeername(), etc.:
  
A shortcoming of the sockets API is that it doesn't allow you to
create socket(pair)s, having fake socket addresses associated with
them. This makes it harder to test applications or transparently
forward (proxy) connections to them.
  
With CloudABI, we're slowly moving networking connectivity into a
separate daemon called Flower. In addition to passing around socket
file descriptors, this daemon provides address information in the form
of arbitrary string labels. There is thus no longer any need for
requesting socket address information from the kernel itself.
  
  This change also updates consumers of the generated code accordingly.
  Even though system calls end up getting renumbered, this won't cause any
  problems in practice. CloudABI programs always call into the kernel
  through a kernel-supplied vDSO that has the numbers updated as well.
  
  Obtained from:https://github.com/NuxiNL/cloudabi

Modified:
  head/sys/compat/cloudabi/cloudabi_fd.c
  head/sys/compat/cloudabi/cloudabi_mem.c
  head/sys/compat/cloudabi/cloudabi_sock.c
  head/sys/compat/cloudabi/cloudabi_util.h
  head/sys/compat/cloudabi32/cloudabi32_proto.h
  head/sys/compat/cloudabi32/cloudabi32_sock.c
  head/sys/compat/cloudabi32/cloudabi32_syscall.h
  head/sys/compat/cloudabi32/cloudabi32_syscalls.c
  head/sys/compat/cloudabi32/cloudabi32_sysent.c
  head/sys/compat/cloudabi32/cloudabi32_systrace_args.c
  head/sys/compat/cloudabi64/cloudabi64_proto.h
  head/sys/compat/cloudabi64/cloudabi64_sock.c
  head/sys/compat/cloudabi64/cloudabi64_syscall.h
  head/sys/compat/cloudabi64/cloudabi64_syscalls.c
  head/sys/compat/cloudabi64/cloudabi64_sysent.c
  head/sys/compat/cloudabi64/cloudabi64_systrace_args.c
  head/sys/contrib/cloudabi/cloudabi32_types.h
  head/sys/contrib/cloudabi/cloudabi64_types.h
  head/sys/contrib/cloudabi/cloudabi_types_common.h
  head/sys/contrib/cloudabi/cloudabi_vdso_aarch64.S
  head/sys/contrib/cloudabi/cloudabi_vdso_armv6.S
  head/sys/contrib/cloudabi/cloudabi_vdso_i686.S
  head/sys/contrib/cloudabi/cloudabi_vdso_i686_on_64bit.S
  head/sys/contrib/cloudabi/cloudabi_vdso_x86_64.S
  head/sys/contrib/cloudabi/syscalls32.master
  head/sys/contrib/cloudabi/syscalls64.master
  head/usr.bin/truss/syscalls.c

Modified: head/sys/compat/cloudabi/cloudabi_fd.c
==
--- head/sys/compat/cloudabi/cloudabi_fd.c  Wed Jul 26 06:52:45 2017
(r321513)
+++ head/sys/compat/cloudabi/cloudabi_fd.c  Wed Jul 26 06:57:15 2017
(r321514)
@@ -111,8 +111,6 @@ cloudabi_sys_fd_create1(struct thread *td,
return (kern_shm_open(td, SHM_ANON, O_RDWR, 0, ));
case CLOUDABI_FILETYPE_SOCKET_DGRAM:
return (kern_socket(td, AF_UNIX, SOCK_DGRAM, 0));
-   case CLOUDABI_FILETYPE_SOCKET_SEQPACKET:
-   return (kern_socket(td, AF_UNIX, SOCK_SEQPACKET, 0));
case CLOUDABI_FILETYPE_SOCKET_STREAM:
return (kern_socket(td, AF_UNIX, SOCK_STREAM, 0));
default:
@@ -145,9 +143,6 @@ cloudabi_sys_fd_create2(struct thread *td,
case CLOUDABI_FILETYPE_SOCKET_DGRAM:
error = kern_socketpair(td, AF_UNIX, SOCK_DGRAM, 0, fds);
break;
-   case CLOUDABI_FILETYPE_SOCKET_SEQPACKET:
-   error = kern_socketpair(td, AF_UNIX, SOCK_SEQPACKET, 0, fds);
-   break;
case CLOUDABI_FILETYPE_SOCKET_STREAM:
error = kern_socketpair(td, AF_UNIX, SOCK_STREAM, 0, fds);
break;
@@ -245,8 +240,6 @@ cloudabi_convert_filetype(const struct file *fp)
switch (so->so_type) {
case SOCK_DGRAM:
return (CLOUDABI_FILETYPE_SOCKET_DGRAM);
-   case SOCK_SEQPACKET:
-   

Re: svn commit: r320595 - in head/sys: amd64/linux amd64/linux32 i386/linux

2017-07-03 Thread Ed Schouten
Hi there,

2017-07-03 12:24 GMT+02:00 Dmitry Chagin <dcha...@freebsd.org>:
> +   .compat_3_brand = "Linux",

I suspect that you can safely remove this line. It's only intended to
match a field in ELF headers that is/was BSD specific.

-- 
Ed Schouten <e...@nuxi.nl>
Nuxi, 's-Hertogenbosch, the Netherlands
KvK-nr.: 62051717
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r320240 - head/include

2017-06-27 Thread Ed Schouten
2017-06-27 13:17 GMT+02:00 Jan Beich <jbe...@freebsd.org>:
> False alarm. Sorry.

No problem. Thanks for bringing it to my attention, regardless! \o/

-- 
Ed Schouten <e...@nuxi.nl>
Nuxi, 's-Hertogenbosch, the Netherlands
KvK-nr.: 62051717
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r320240 - head/include

2017-06-27 Thread Ed Schouten
2017-06-27 7:02 GMT+02:00 Jan Beich <jbe...@freebsd.org>:
> max_align_t is now exposed even without -std=c11.

Which is now consistent with the rest of the C library, as this is
also the case for other C11 features, like 's quick_exit().

> thus regressing some ports e.g.,
>
> [...]
>
> https://lists.freebsd.org/pipermail/freebsd-pkg-fallout/Week-of-Mon-20170626/493679.html

Would there be an easy way for me to extract a list of ports that are affected?

-- 
Ed Schouten <e...@nuxi.nl>
Nuxi, 's-Hertogenbosch, the Netherlands
KvK-nr.: 62051717
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r320360 - head/usr.bin/resizewin

2017-06-26 Thread Ed Schouten
2017-06-26 15:14 GMT+02:00 Edward Tomasz Napierala <tr...@freebsd.org>:
> +   /* Disable echo, drain the input, and flush the output */
> if (tcgetattr(fd, ) == -1)
> exit(1);

> +   if (tcsetattr(fd, TCSAFLUSH, ) == -1)
> exit(1);

Would it make sense to print diagnostics here?

-- 
Ed Schouten <e...@nuxi.nl>
Nuxi, 's-Hertogenbosch, the Netherlands
KvK-nr.: 62051717
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r320240 - head/include

2017-06-22 Thread Ed Schouten
Author: ed
Date: Thu Jun 22 18:39:52 2017
New Revision: 320240
URL: https://svnweb.freebsd.org/changeset/base/320240

Log:
  Use __ISO_C_VISIBLE, as opposed to testing __STDC_VERSION__.
  
  FreeBSD's C library uses __STDC_VERSION__ to determine whether the
  compiler provides language features specific to a certain version of the
  C standard. __ISO_C_VISIBLE is used to specify which library features
  need to be exposed.
  
  max_align_t currently uses __STDC_VERSION__, even though it should be
  using __ISO_C_VISIBLE to remain consistent with the rest of the headers
  in include/.
  
  Reviewed by:  dim
  MFC after:1 month
  Differential Revision:https://reviews.freebsd.org/D11303

Modified:
  head/include/stddef.h

Modified: head/include/stddef.h
==
--- head/include/stddef.h   Thu Jun 22 17:10:34 2017(r320239)
+++ head/include/stddef.h   Thu Jun 22 18:39:52 2017(r320240)
@@ -62,7 +62,7 @@ typedef   ___wchar_t  wchar_t;
 #endif
 #endif
 
-#if __STDC_VERSION__ >= 201112L || __cplusplus >= 201103L
+#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
 #ifndef __CLANG_MAX_ALIGN_T_DEFINED
 typedef__max_align_t   max_align_t;
 #define __CLANG_MAX_ALIGN_T_DEFINED
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r319897 - head/usr.bin/yes

2017-06-13 Thread Ed Schouten
2017-06-13 14:35 GMT+02:00 Pietro Cerutti <g...@freebsd.org>:
> +   while (write(STDOUT_FILENO, exp, explen) > 0)
> +   ;

How does this deal with partial writes?

-- 
Ed Schouten <e...@nuxi.nl>
Nuxi, 's-Hertogenbosch, the Netherlands
KvK-nr.: 62051717
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r303033 - head/share/man/man7

2017-05-04 Thread Ed Schouten
Hi Ed,

2016-07-19 19:46 GMT+02:00 Ed Maste <ema...@freebsd.org>:
> +.It arm Ta soft Ta soft, double precision
...
> +.It mipsTa soft Ta identical to double

I was wondering, what's the difference between two ways of phrasing
it? If long double is double precision, it's identical to double,
right?

> +.It Dv BYTE_ORDER Ta Either Dv BIG_ENDIAN or Dv LITTLE_ENDIAN .
> +.Dv PDP11_ENDIAN is not used on FreeBSD.

Would it make more sense to describe GCC/Clang's officially documented
endianness macros here?

__BYTE_ORDER__
__ORDER_LITTLE_ENDIAN__
__ORDER_BIG_ENDIAN__
__ORDER_PDP_ENDIAN__

-- 
Ed Schouten <e...@nuxi.nl>
Nuxi, 's-Hertogenbosch, the Netherlands
KvK-nr.: 62051717
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r316825 - head/sys/netpfil/ipfw

2017-04-14 Thread Ed Schouten
Hi there,

2017-04-14 13:41 GMT+02:00 Andrey V. Elsukov <a...@freebsd.org>:
> -   memcpy(>k, >addr6.sin6_addr, sizeof(struct 
> in6_addr));
> +   memcpy(>k.addr6, >addr6.sin6_addr,
> +   sizeof(struct in6_addr));

In this case the code could be abbreviated by simply using assignment, right?

tent->k.addr6 = xn->addr6.sin6_addr;

-- 
Ed Schouten <e...@nuxi.nl>
Nuxi, 's-Hertogenbosch, the Netherlands
KvK-nr.: 62051717
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r315892 - head/sys/compat/cloudabi

2017-03-24 Thread Ed Schouten
Author: ed
Date: Fri Mar 24 07:09:33 2017
New Revision: 315892
URL: https://svnweb.freebsd.org/changeset/base/315892

Log:
  Include  to obtain the memcpy() prototype.
  
  I got a report of this source file not building on Raspberry Pi. It's
  interesting that this only fails for that target and not for others.
  Again, that's no reason not to include the right headers.
  
  PR:   217969
  Reported by:  Johannes Jost Meixner
  MFC after:1 week

Modified:
  head/sys/compat/cloudabi/cloudabi_clock.c

Modified: head/sys/compat/cloudabi/cloudabi_clock.c
==
--- head/sys/compat/cloudabi/cloudabi_clock.c   Fri Mar 24 07:03:26 2017
(r315891)
+++ head/sys/compat/cloudabi/cloudabi_clock.c   Fri Mar 24 07:09:33 2017
(r315892)
@@ -29,6 +29,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r315861 - in head/sys: amd64/cloudabi32 amd64/cloudabi64 arm/cloudabi32 arm64/cloudabi64 i386/cloudabi32

2017-03-23 Thread Ed Schouten
Author: ed
Date: Thu Mar 23 14:12:21 2017
New Revision: 315861
URL: https://svnweb.freebsd.org/changeset/base/315861

Log:
  Stop providing the compat_3_brand.
  
  As of r315860, the ELF image activator works fine for CloudABI without it.
  
  Reviewed by:  kib
  MFC after:2 weeks

Modified:
  head/sys/amd64/cloudabi32/cloudabi32_sysvec.c
  head/sys/amd64/cloudabi64/cloudabi64_sysvec.c
  head/sys/arm/cloudabi32/cloudabi32_sysvec.c
  head/sys/arm64/cloudabi64/cloudabi64_sysvec.c
  head/sys/i386/cloudabi32/cloudabi32_sysvec.c

Modified: head/sys/amd64/cloudabi32/cloudabi32_sysvec.c
==
--- head/sys/amd64/cloudabi32/cloudabi32_sysvec.c   Thu Mar 23 14:09:45 
2017(r315860)
+++ head/sys/amd64/cloudabi32/cloudabi32_sysvec.c   Thu Mar 23 14:12:21 
2017(r315861)
@@ -227,6 +227,5 @@ Elf32_Brandinfo cloudabi32_brand = {
.brand  = ELFOSABI_CLOUDABI,
.machine= EM_386,
.sysvec = _elf_sysvec,
-   .compat_3_brand = "CloudABI",
.flags  = BI_BRAND_ONLY_STATIC,
 };

Modified: head/sys/amd64/cloudabi64/cloudabi64_sysvec.c
==
--- head/sys/amd64/cloudabi64/cloudabi64_sysvec.c   Thu Mar 23 14:09:45 
2017(r315860)
+++ head/sys/amd64/cloudabi64/cloudabi64_sysvec.c   Thu Mar 23 14:12:21 
2017(r315861)
@@ -213,5 +213,4 @@ Elf64_Brandinfo cloudabi64_brand = {
.machine= EM_X86_64,
.sysvec = _elf_sysvec,
.flags  = BI_CAN_EXEC_DYN | BI_BRAND_ONLY_STATIC,
-   .compat_3_brand = "CloudABI",
 };

Modified: head/sys/arm/cloudabi32/cloudabi32_sysvec.c
==
--- head/sys/arm/cloudabi32/cloudabi32_sysvec.c Thu Mar 23 14:09:45 2017
(r315860)
+++ head/sys/arm/cloudabi32/cloudabi32_sysvec.c Thu Mar 23 14:12:21 2017
(r315861)
@@ -189,6 +189,5 @@ Elf32_Brandinfo cloudabi32_brand = {
.brand  = ELFOSABI_CLOUDABI,
.machine= EM_ARM,
.sysvec = _elf_sysvec,
-   .compat_3_brand = "CloudABI",
.flags  = BI_BRAND_ONLY_STATIC,
 };

Modified: head/sys/arm64/cloudabi64/cloudabi64_sysvec.c
==
--- head/sys/arm64/cloudabi64/cloudabi64_sysvec.c   Thu Mar 23 14:09:45 
2017(r315860)
+++ head/sys/arm64/cloudabi64/cloudabi64_sysvec.c   Thu Mar 23 14:12:21 
2017(r315861)
@@ -182,5 +182,4 @@ Elf64_Brandinfo cloudabi64_brand = {
.machine= EM_AARCH64,
.sysvec = _elf_sysvec,
.flags  = BI_CAN_EXEC_DYN | BI_BRAND_ONLY_STATIC,
-   .compat_3_brand = "CloudABI",
 };

Modified: head/sys/i386/cloudabi32/cloudabi32_sysvec.c
==
--- head/sys/i386/cloudabi32/cloudabi32_sysvec.cThu Mar 23 14:09:45 
2017(r315860)
+++ head/sys/i386/cloudabi32/cloudabi32_sysvec.cThu Mar 23 14:12:21 
2017(r315861)
@@ -200,6 +200,5 @@ Elf32_Brandinfo cloudabi32_brand = {
.brand  = ELFOSABI_CLOUDABI,
.machine= EM_386,
.sysvec = _elf_sysvec,
-   .compat_3_brand = "CloudABI",
.flags  = BI_BRAND_ONLY_STATIC,
 };
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r315860 - head/sys/kern

2017-03-23 Thread Ed Schouten
Author: ed
Date: Thu Mar 23 14:09:45 2017
New Revision: 315860
URL: https://svnweb.freebsd.org/changeset/base/315860

Log:
  Don't require the presence of the compat_3_brand.
  
  The existing ELF image activator requires the brandinfo to provide such
  a string unconditionally, even if the executable format in question
  doesn't use this type of branding. Skip matching when it's a null
  pointer.
  
  Reviewed by:  kib
  MFC after:2 weeks

Modified:
  head/sys/kern/imgact_elf.c

Modified: head/sys/kern/imgact_elf.c
==
--- head/sys/kern/imgact_elf.c  Thu Mar 23 13:28:16 2017(r315859)
+++ head/sys/kern/imgact_elf.c  Thu Mar 23 14:09:45 2017(r315860)
@@ -312,8 +312,9 @@ __elfN(get_brandinfo)(struct image_param
continue;
if (hdr->e_machine == bi->machine &&
(hdr->e_ident[EI_OSABI] == bi->brand ||
+   (bi->compat_3_brand != NULL &&
strcmp((const char *)>e_ident[OLD_EI_BRAND],
-   bi->compat_3_brand) == 0)) {
+   bi->compat_3_brand) == 0))) {
/* Looks good, but give brand a chance to veto */
if (!bi->header_supported ||
bi->header_supported(imgp)) {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r315701 - in head/sys: amd64/cloudabi32 amd64/cloudabi64 arm/cloudabi32 arm64/cloudabi64 i386/cloudabi32

2017-03-23 Thread Ed Schouten
Hi Kostik,

2017-03-23 0:00 GMT+01:00 Konstantin Belousov <kostik...@gmail.com>:
> On Wed, Mar 22, 2017 at 03:16:24PM +0100, Ed Schouten wrote:
>> Similarly, I seem to remember CloudABI's brandinfos set compat_3_brand
>> for a similar reason: it seems to be required by imgact_elf.c. Would
>> we also want to change that?
>
> Could you please try this ?

Thanks! I just gave the patch a try, but the comparison added to
imgact_elf.c now causes the brandinfo to be skipped entirely. Attached
is a patch that does work for me.

-- 
Ed Schouten <e...@nuxi.nl>
Nuxi, 's-Hertogenbosch, the Netherlands
KvK-nr.: 62051717
Index: sys/amd64/cloudabi32/cloudabi32_sysvec.c
===
--- sys/amd64/cloudabi32/cloudabi32_sysvec.c(revision 315828)
+++ sys/amd64/cloudabi32/cloudabi32_sysvec.c(working copy)
@@ -227,6 +227,5 @@
.brand  = ELFOSABI_CLOUDABI,
.machine= EM_386,
.sysvec = _elf_sysvec,
-   .compat_3_brand = "CloudABI",
.flags  = BI_BRAND_ONLY_STATIC,
 };
Index: sys/amd64/cloudabi64/cloudabi64_sysvec.c
===
--- sys/amd64/cloudabi64/cloudabi64_sysvec.c(revision 315828)
+++ sys/amd64/cloudabi64/cloudabi64_sysvec.c(working copy)
@@ -213,5 +213,4 @@
.machine= EM_X86_64,
.sysvec = _elf_sysvec,
.flags  = BI_CAN_EXEC_DYN | BI_BRAND_ONLY_STATIC,
-   .compat_3_brand = "CloudABI",
 };
Index: sys/arm/cloudabi32/cloudabi32_sysvec.c
===
--- sys/arm/cloudabi32/cloudabi32_sysvec.c  (revision 315828)
+++ sys/arm/cloudabi32/cloudabi32_sysvec.c  (working copy)
@@ -189,6 +189,5 @@
.brand  = ELFOSABI_CLOUDABI,
.machine= EM_ARM,
.sysvec = _elf_sysvec,
-   .compat_3_brand = "CloudABI",
.flags  = BI_BRAND_ONLY_STATIC,
 };
Index: sys/arm64/cloudabi64/cloudabi64_sysvec.c
===
--- sys/arm64/cloudabi64/cloudabi64_sysvec.c(revision 315828)
+++ sys/arm64/cloudabi64/cloudabi64_sysvec.c(working copy)
@@ -182,5 +182,4 @@
.machine= EM_AARCH64,
.sysvec = _elf_sysvec,
.flags  = BI_CAN_EXEC_DYN | BI_BRAND_ONLY_STATIC,
-   .compat_3_brand = "CloudABI",
 };
Index: sys/i386/cloudabi32/cloudabi32_sysvec.c
===
--- sys/i386/cloudabi32/cloudabi32_sysvec.c (revision 315828)
+++ sys/i386/cloudabi32/cloudabi32_sysvec.c (working copy)
@@ -200,6 +200,5 @@
.brand  = ELFOSABI_CLOUDABI,
.machine= EM_386,
.sysvec = _elf_sysvec,
-   .compat_3_brand = "CloudABI",
.flags  = BI_BRAND_ONLY_STATIC,
 };
Index: sys/kern/imgact_elf.c
===
--- sys/kern/imgact_elf.c   (revision 315828)
+++ sys/kern/imgact_elf.c   (working copy)
@@ -312,8 +312,9 @@
continue;
if (hdr->e_machine == bi->machine &&
(hdr->e_ident[EI_OSABI] == bi->brand ||
+   (bi->compat_3_brand != NULL &&
strcmp((const char *)>e_ident[OLD_EI_BRAND],
-   bi->compat_3_brand) == 0)) {
+   bi->compat_3_brand) == 0))) {
/* Looks good, but give brand a chance to veto */
if (!bi->header_supported ||
bi->header_supported(imgp)) {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

svn commit: r315736 - in head/sys/compat: cloudabi cloudabi32 cloudabi64

2017-03-22 Thread Ed Schouten
Author: ed
Date: Wed Mar 22 19:20:39 2017
New Revision: 315736
URL: https://svnweb.freebsd.org/changeset/base/315736

Log:
  Make file descriptor passing for CloudABI's recvmsg() work.
  
  Similar to the change for sendmsg(), create a pointer size independent
  implementation of recvmsg() and let cloudabi32 and cloudabi64 call into
  it. In case userspace requests one or more file descriptors, call
  kern_recvit() in such a way that we get the control message headers in
  an mbuf. Iterate over all of the headers and copy the file descriptors
  to userspace.

Modified:
  head/sys/compat/cloudabi/cloudabi_sock.c
  head/sys/compat/cloudabi/cloudabi_util.h
  head/sys/compat/cloudabi32/cloudabi32_sock.c
  head/sys/compat/cloudabi64/cloudabi64_sock.c

Modified: head/sys/compat/cloudabi/cloudabi_sock.c
==
--- head/sys/compat/cloudabi/cloudabi_sock.cWed Mar 22 19:18:47 2017
(r315735)
+++ head/sys/compat/cloudabi/cloudabi_sock.cWed Mar 22 19:20:39 2017
(r315736)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2015 Nuxi, https://nuxi.nl/
+ * Copyright (c) 2015-2017 Nuxi, https://nuxi.nl/
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -50,7 +50,7 @@ __FBSDID("$FreeBSD$");
 #include 
 
 /* Converts FreeBSD's struct sockaddr to CloudABI's cloudabi_sockaddr_t. */
-void
+static void
 cloudabi_convert_sockaddr(const struct sockaddr *sa, socklen_t sal,
 cloudabi_sockaddr_t *rsa)
 {
@@ -247,6 +247,81 @@ cloudabi_sys_sock_stat_get(struct thread
 }
 
 int
+cloudabi_sock_recv(struct thread *td, cloudabi_fd_t fd, struct iovec *data,
+size_t datalen, cloudabi_fd_t *fds, size_t fdslen,
+cloudabi_msgflags_t flags, size_t *rdatalen, size_t *rfdslen,
+cloudabi_sockaddr_t *peername, cloudabi_msgflags_t *rflags)
+{
+   struct sockaddr_storage ss;
+   struct msghdr hdr = {
+   .msg_name = ,
+   .msg_namelen = sizeof(ss),
+   .msg_iov = data,
+   .msg_iovlen = datalen,
+   };
+   struct mbuf *control;
+   int error;
+
+   /* Convert flags. */
+   if (flags & CLOUDABI_MSG_PEEK)
+   hdr.msg_flags |= MSG_PEEK;
+   if (flags & CLOUDABI_MSG_WAITALL)
+   hdr.msg_flags |= MSG_WAITALL;
+
+   control = NULL;
+   error = kern_recvit(td, fd, , UIO_SYSSPACE,
+   fdslen > 0 ?  : NULL);
+   if (error != 0)
+   return (error);
+
+   /* Convert return values. */
+   *rdatalen = td->td_retval[0];
+   td->td_retval[0] = 0;
+   *rfdslen = 0;
+   cloudabi_convert_sockaddr((struct sockaddr *),
+   MIN(hdr.msg_namelen, sizeof(ss)), peername);
+   *rflags = 0;
+   if (hdr.msg_flags & MSG_EOR)
+   *rflags |= CLOUDABI_MSG_EOR;
+   if (hdr.msg_flags & MSG_TRUNC)
+   *rflags |= CLOUDABI_MSG_TRUNC;
+
+   /* Extract file descriptors from SCM_RIGHTS messages. */
+   if (control != NULL) {
+   struct cmsghdr *chdr;
+
+   hdr.msg_control = mtod(control, void *);
+   hdr.msg_controllen = control->m_len;
+   for (chdr = CMSG_FIRSTHDR(); chdr != NULL;
+   chdr = CMSG_NXTHDR(, chdr)) {
+   if (chdr->cmsg_level == SOL_SOCKET &&
+   chdr->cmsg_type == SCM_RIGHTS) {
+   size_t nfds;
+
+   nfds = (chdr->cmsg_len - CMSG_LEN(0)) /
+   sizeof(int);
+   if (nfds > fdslen) {
+   /* Unable to store file descriptors. */
+   nfds = fdslen;
+   *rflags |= CLOUDABI_MSG_CTRUNC;
+   }
+   error = copyout(CMSG_DATA(chdr), fds,
+   nfds * sizeof(int));
+   if (error != 0) {
+   m_free(control);
+   return (error);
+   }
+   fds += nfds;
+   fdslen -= nfds;
+   *rfdslen += nfds;
+   }
+   }
+   m_free(control);
+   }
+   return (0);
+}
+
+int
 cloudabi_sock_send(struct thread *td, cloudabi_fd_t fd, struct iovec *data,
 size_t datalen, const cloudabi_fd_t *fds, size_t fdslen,
 cloudabi_msgflags_t flags, size_t *rdatalen)

Modified: head/sys/compat/cloudabi/cloudabi_util.h
==
--- head/sys/compat/cloudabi/cloudabi_util.hWed Mar 22 19:18:47 2017
(r315735)
+++ head/sys/compat/cloudabi/cloudabi_util.hWed Mar 22 

svn commit: r315732 - head/sys/sys

2017-03-22 Thread Ed Schouten
Author: ed
Date: Wed Mar 22 18:45:13 2017
New Revision: 315732
URL: https://svnweb.freebsd.org/changeset/base/315732

Log:
  Add forward declaration for struct vnode.
  
  The coredump() function provided by this header file has struct vnode *
  as an argument.
  
  MFC after:1 week

Modified:
  head/sys/sys/imgact_elf.h

Modified: head/sys/sys/imgact_elf.h
==
--- head/sys/sys/imgact_elf.h   Wed Mar 22 18:35:48 2017(r315731)
+++ head/sys/sys/imgact_elf.h   Wed Mar 22 18:45:13 2017(r315732)
@@ -39,6 +39,7 @@
 
 struct image_params;
 struct thread;
+struct vnode;
 
 /*
  * Structure used to pass information from the loader to the
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r315701 - in head/sys: amd64/cloudabi32 amd64/cloudabi64 arm/cloudabi32 arm64/cloudabi64 i386/cloudabi32

2017-03-22 Thread Ed Schouten
Hi Kostik,

2017-03-22 10:02 GMT+01:00 Konstantin Belousov <kostik...@gmail.com>:
> On Wed, Mar 22, 2017 at 07:05:27AM +, Ed Schouten wrote:
>> Author: ed
>> Date: Wed Mar 22 07:05:27 2017
>> New Revision: 315701
>> URL: https://svnweb.freebsd.org/changeset/base/315701
>>
>> Log:
>>   Set the interpreter path to /nonexistent.
>>
>>   CloudABI executables are statically linked and don't have an
>>   interpreter. Setting the interpreter path to NULL used to work
>>   previously, but r314851 introduced code that checks the string
>>   unconditionally. Running CloudABI executables now causes a null pointer
>>   dereference.
> You could have just reported that the revision breaks cloudabi.

Even though that revision made things crash for me, prior versions of
imgact_elf.c also dereferenced interp_path in several places, which I
interpreted as CloudABI not being a good citizen.

>>   Looking at the rest of imgact_elf.c, it seems various other codepaths
>>   already leaned on the fact that the interpreter path is set. Let's just
>>   go ahead and pick an obviously incorrect interpreter path to appease
>>   imgact_elf.c.
>
> I believe that we should move in the reverse direction, in particular,
> best would be to allow brand to specify that only a statically linked
> binaries can be handled by it.  My reasoning is coming from a desire
> to make brand matching as exact as possible, after dealing with the
> bugs due to too vague matching.

I agree. Sounds perfect!

Similarly, I seem to remember CloudABI's brandinfos set compat_3_brand
for a similar reason: it seems to be required by imgact_elf.c. Would
we also want to change that?

> Could you test the following ?  It supposedly fixes the NULL issue, and
> adds the flag marking brands as only allowing static (really PT_INTERP-less)
> binaries.

I've just given it a try. It works perfectly for me. Thanks!

-- 
Ed Schouten <e...@nuxi.nl>
Nuxi, 's-Hertogenbosch, the Netherlands
KvK-nr.: 62051717
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r315701 - in head/sys: amd64/cloudabi32 amd64/cloudabi64 arm/cloudabi32 arm64/cloudabi64 i386/cloudabi32

2017-03-22 Thread Ed Schouten
Author: ed
Date: Wed Mar 22 07:05:27 2017
New Revision: 315701
URL: https://svnweb.freebsd.org/changeset/base/315701

Log:
  Set the interpreter path to /nonexistent.
  
  CloudABI executables are statically linked and don't have an
  interpreter. Setting the interpreter path to NULL used to work
  previously, but r314851 introduced code that checks the string
  unconditionally. Running CloudABI executables now causes a null pointer
  dereference.
  
  Looking at the rest of imgact_elf.c, it seems various other codepaths
  already leaned on the fact that the interpreter path is set. Let's just
  go ahead and pick an obviously incorrect interpreter path to appease
  imgact_elf.c.
  
  MFC after:1 week

Modified:
  head/sys/amd64/cloudabi32/cloudabi32_sysvec.c
  head/sys/amd64/cloudabi64/cloudabi64_sysvec.c
  head/sys/arm/cloudabi32/cloudabi32_sysvec.c
  head/sys/arm64/cloudabi64/cloudabi64_sysvec.c
  head/sys/i386/cloudabi32/cloudabi32_sysvec.c

Modified: head/sys/amd64/cloudabi32/cloudabi32_sysvec.c
==
--- head/sys/amd64/cloudabi32/cloudabi32_sysvec.c   Wed Mar 22 06:43:10 
2017(r315700)
+++ head/sys/amd64/cloudabi32/cloudabi32_sysvec.c   Wed Mar 22 07:05:27 
2017(r315701)
@@ -228,4 +228,5 @@ Elf32_Brandinfo cloudabi32_brand = {
.machine= EM_386,
.sysvec = _elf_sysvec,
.compat_3_brand = "CloudABI",
+   .interp_path= "/nonexistent",
 };

Modified: head/sys/amd64/cloudabi64/cloudabi64_sysvec.c
==
--- head/sys/amd64/cloudabi64/cloudabi64_sysvec.c   Wed Mar 22 06:43:10 
2017(r315700)
+++ head/sys/amd64/cloudabi64/cloudabi64_sysvec.c   Wed Mar 22 07:05:27 
2017(r315701)
@@ -214,4 +214,5 @@ Elf64_Brandinfo cloudabi64_brand = {
.sysvec = _elf_sysvec,
.flags  = BI_CAN_EXEC_DYN,
.compat_3_brand = "CloudABI",
+   .interp_path= "/nonexistent",
 };

Modified: head/sys/arm/cloudabi32/cloudabi32_sysvec.c
==
--- head/sys/arm/cloudabi32/cloudabi32_sysvec.c Wed Mar 22 06:43:10 2017
(r315700)
+++ head/sys/arm/cloudabi32/cloudabi32_sysvec.c Wed Mar 22 07:05:27 2017
(r315701)
@@ -190,4 +190,5 @@ Elf32_Brandinfo cloudabi32_brand = {
.machine= EM_ARM,
.sysvec = _elf_sysvec,
.compat_3_brand = "CloudABI",
+   .interp_path= "/nonexistent",
 };

Modified: head/sys/arm64/cloudabi64/cloudabi64_sysvec.c
==
--- head/sys/arm64/cloudabi64/cloudabi64_sysvec.c   Wed Mar 22 06:43:10 
2017(r315700)
+++ head/sys/arm64/cloudabi64/cloudabi64_sysvec.c   Wed Mar 22 07:05:27 
2017(r315701)
@@ -183,4 +183,5 @@ Elf64_Brandinfo cloudabi64_brand = {
.sysvec = _elf_sysvec,
.flags  = BI_CAN_EXEC_DYN,
.compat_3_brand = "CloudABI",
+   .interp_path= "/nonexistent",
 };

Modified: head/sys/i386/cloudabi32/cloudabi32_sysvec.c
==
--- head/sys/i386/cloudabi32/cloudabi32_sysvec.cWed Mar 22 06:43:10 
2017(r315700)
+++ head/sys/i386/cloudabi32/cloudabi32_sysvec.cWed Mar 22 07:05:27 
2017(r315701)
@@ -201,4 +201,5 @@ Elf32_Brandinfo cloudabi32_brand = {
.machine= EM_386,
.sysvec = _elf_sysvec,
.compat_3_brand = "CloudABI",
+   .interp_path= "/nonexistent",
 };
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r315700 - in head/sys/compat: cloudabi cloudabi32 cloudabi64

2017-03-22 Thread Ed Schouten
Author: ed
Date: Wed Mar 22 06:43:10 2017
New Revision: 315700
URL: https://svnweb.freebsd.org/changeset/base/315700

Log:
  Make file descriptor passing work for CloudABI's sendmsg().
  
  Reduce the potential amount of code duplication between cloudabi32 and
  cloudabi64 by creating a cloudabi_sock_recv() utility function. The
  cloudabi32 and cloudabi64 modules will then only contain code to convert
  the iovecs to the native pointer size.
  
  In cloudabi_sock_recv(), we can now construct an SCM_RIGHTS cmsghdr in
  an mbuf and pass that on to kern_sendit().

Modified:
  head/sys/compat/cloudabi/cloudabi_sock.c
  head/sys/compat/cloudabi/cloudabi_util.h
  head/sys/compat/cloudabi32/cloudabi32_sock.c
  head/sys/compat/cloudabi64/cloudabi64_sock.c

Modified: head/sys/compat/cloudabi/cloudabi_sock.c
==
--- head/sys/compat/cloudabi/cloudabi_sock.cWed Mar 22 05:27:20 2017
(r315699)
+++ head/sys/compat/cloudabi/cloudabi_sock.cWed Mar 22 06:43:10 2017
(r315700)
@@ -30,7 +30,9 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -243,3 +245,51 @@ cloudabi_sys_sock_stat_get(struct thread
fdrop(fp, td);
return (copyout(, uap->buf, sizeof(ss)));
 }
+
+int
+cloudabi_sock_send(struct thread *td, cloudabi_fd_t fd, struct iovec *data,
+size_t datalen, const cloudabi_fd_t *fds, size_t fdslen,
+cloudabi_msgflags_t flags, size_t *rdatalen)
+{
+   struct msghdr hdr = {
+   .msg_iov = data,
+   .msg_iovlen = datalen,
+   };
+   struct mbuf *control;
+   int error, mflags;
+
+   /* Convert flags. */
+   mflags = MSG_NOSIGNAL;
+   if (flags & CLOUDABI_MSG_EOR)
+   mflags |= MSG_EOR;
+
+   /* Convert file descriptor array to an SCM_RIGHTS message. */
+   if (fdslen > MCLBYTES || CMSG_SPACE(fdslen * sizeof(int)) > MCLBYTES) {
+   return (EINVAL);
+   } else if (fdslen > 0) {
+   struct cmsghdr *chdr;
+
+   control = m_get2(CMSG_SPACE(fdslen * sizeof(int)),
+   M_WAITOK, MT_CONTROL, 0);
+   control->m_len = CMSG_SPACE(fdslen * sizeof(int));
+
+   chdr = mtod(control, struct cmsghdr *);
+   chdr->cmsg_len = CMSG_LEN(fdslen * sizeof(int));
+   chdr->cmsg_level = SOL_SOCKET;
+   chdr->cmsg_type = SCM_RIGHTS;
+   error = copyin(fds, CMSG_DATA(chdr), fdslen * sizeof(int));
+   if (error != 0) {
+   m_free(control);
+   return (error);
+   }
+   } else {
+   control = NULL;
+   }
+
+   error = kern_sendit(td, fd, , mflags, control, UIO_USERSPACE);
+   if (error != 0)
+   return (error);
+   *rdatalen = td->td_retval[0];
+   td->td_retval[0] = 0;
+   return (0);
+}

Modified: head/sys/compat/cloudabi/cloudabi_util.h
==
--- head/sys/compat/cloudabi/cloudabi_util.hWed Mar 22 05:27:20 2017
(r315699)
+++ head/sys/compat/cloudabi/cloudabi_util.hWed Mar 22 06:43:10 2017
(r315700)
@@ -77,6 +77,10 @@ int cloudabi_futex_lock_wrlock(struct th
 cloudabi_scope_t, cloudabi_clockid_t, cloudabi_timestamp_t,
 cloudabi_timestamp_t);
 
+/* Socket operations. */
+int cloudabi_sock_send(struct thread *, cloudabi_fd_t, struct iovec *, size_t,
+const cloudabi_fd_t *, size_t, cloudabi_msgflags_t, size_t *);
+
 /* vDSO setup and teardown. */
 void cloudabi_vdso_init(struct sysentvec *, char *, char *);
 void cloudabi_vdso_destroy(struct sysentvec *);

Modified: head/sys/compat/cloudabi32/cloudabi32_sock.c
==
--- head/sys/compat/cloudabi32/cloudabi32_sock.cWed Mar 22 05:27:20 
2017(r315699)
+++ head/sys/compat/cloudabi32/cloudabi32_sock.cWed Mar 22 06:43:10 
2017(r315700)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2015 Nuxi, https://nuxi.nl/
+ * Copyright (c) 2015-2017 Nuxi, https://nuxi.nl/
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -105,44 +105,37 @@ cloudabi32_sys_sock_send(struct thread *
cloudabi32_send_in_t si;
cloudabi32_send_out_t so = {};
cloudabi32_ciovec_t iovobj;
-   struct msghdr msghdr = {};
+   struct iovec *iov;
const cloudabi32_ciovec_t *user_iov;
-   size_t i;
-   int error, flags;
+   size_t datalen, i;
+   int error;
 
error = copyin(uap->in, , sizeof(si));
if (error != 0)
return (error);
 
-   /* Convert results in cloudabi_send_in_t to struct msghdr. */
+   /* Convert iovecs to native format. */
if (si.si_data_len 

Re: svn commit: r314685 - head/bin/ps

2017-03-05 Thread Ed Schouten
Hi Conrad,

2017-03-05 0:08 GMT+01:00 Conrad Meyer <c...@freebsd.org>:
>> - If something is a TTY, then our implementation of the TTY layer
>> guarantees that TIOCGWINSZ always works.
>
> Do you know if it did in 1990 too?  It's hard to tell why Marc@ made
> this change way back then.  I wasn't sure so I left it alone.

I can't tell. :-)

>> - If we're only interested in testing stdout whether it's a TTY, I
>> think it makes little sense to check TIOCGWINSZ on stdin, stderr.
>>
>> I think there would therefore be very little harm to use something like this:
>>
>> | if ((cols = getenv("COLUMNS")) != NULL && *cols != '\0')
>> | termwidth = atoi(cols);
>> | else if ((ioctl(STDOUT_FILENO, TIOCGWINSZ, (char *)) ==
>> -1 && ws.ws_row == 0)
>
> Shouldn't this remain || ws.ws_row == 0?

Err, yes. ||, not &&.

-- 
Ed Schouten <e...@nuxi.nl>
Nuxi, 's-Hertogenbosch, the Netherlands
KvK-nr.: 62051717
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r314685 - head/bin/ps

2017-03-04 Thread Ed Schouten
Hi Conrad,

2017-03-04 23:38 GMT+01:00 Conrad Meyer <c...@freebsd.org>:
> Log:
>   ps(1): Only detect terminal width if stdout is a tty

Nice!

> Modified: head/bin/ps/ps.c
> ==
> --- head/bin/ps/ps.cSat Mar  4 22:23:59 2017(r314684)
> +++ head/bin/ps/ps.cSat Mar  4 22:38:10 2017(r314685)
> @@ -194,6 +194,8 @@ main(int argc, char *argv[])
>
> if ((cols = getenv("COLUMNS")) != NULL && *cols != '\0')
> termwidth = atoi(cols);
> +   else if (!isatty(STDOUT_FILENO))
> +   termwidth = UNLIMITED;
> else if ((ioctl(STDOUT_FILENO, TIOCGWINSZ, (char *)) == -1 &&
>  ioctl(STDERR_FILENO, TIOCGWINSZ, (char *)) == -1 &&
>  ioctl(STDIN_FILENO,  TIOCGWINSZ, (char *)) == -1) ||
>

I think you can actually go ahead and simplify this a bit:

- If something is a TTY, then our implementation of the TTY layer
guarantees that TIOCGWINSZ always works.
- If we're only interested in testing stdout whether it's a TTY, I
think it makes little sense to check TIOCGWINSZ on stdin, stderr.

I think there would therefore be very little harm to use something like this:

| if ((cols = getenv("COLUMNS")) != NULL && *cols != '\0')
| termwidth = atoi(cols);
| else if ((ioctl(STDOUT_FILENO, TIOCGWINSZ, (char *)) ==
-1 && ws.ws_row == 0)
| termwidth = UNLIMITED;
|else
|termwidth = ws.ws_col - 1;

-- 
Ed Schouten <e...@nuxi.nl>
Nuxi, 's-Hertogenbosch, the Netherlands
KvK-nr.: 62051717
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r313801 - head/lib/libc/sys

2017-02-15 Thread Ed Schouten
Author: ed
Date: Thu Feb 16 06:52:53 2017
New Revision: 313801
URL: https://svnweb.freebsd.org/changeset/base/313801

Log:
  Remove unnecessary #includes from the kqueue(2) man page.
  
  Now that  can be included on its own, adjust the manual
  page accordingly. Remove both unnecessary #include statements from the
  synopsis and the example code.
  
  While there, also add a note to the BUGS section to mention that
  previous versions of this header file still depend on .
  
  Reviewed by:  ngie, vangyzen
  Differential Revision:https://reviews.freebsd.org/D9605

Modified:
  head/lib/libc/sys/kqueue.2

Modified: head/lib/libc/sys/kqueue.2
==
--- head/lib/libc/sys/kqueue.2  Thu Feb 16 06:36:16 2017(r313800)
+++ head/lib/libc/sys/kqueue.2  Thu Feb 16 06:52:53 2017(r313801)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd May 3, 2016
+.Dd February 15, 2017
 .Dt KQUEUE 2
 .Os
 .Sh NAME
@@ -34,9 +34,7 @@
 .Sh LIBRARY
 .Lb libc
 .Sh SYNOPSIS
-.In sys/types.h
 .In sys/event.h
-.In sys/time.h
 .Ft int
 .Fn kqueue "void"
 .Ft int
@@ -633,15 +631,12 @@ If the time limit expires, then
 returns 0.
 .Sh EXAMPLES
 .Bd -literal -compact
-#include 
 #include 
-#include 
 #include 
 #include 
 #include 
 #include 
 #include 
-#include 
 
 int
 main(int argc, char **argv)
@@ -769,3 +764,9 @@ The
 .Fa timeout
 value is limited to 24 hours; longer timeouts will be silently
 reinterpreted as 24 hours.
+.Pp
+Previous versions of
+.In sys/event.h
+fail to parse without including
+.In sys/types.h
+manually.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r313704 - head/sys/sys

2017-02-13 Thread Ed Schouten
Hi there,

2017-02-13 20:53 GMT+01:00 Ngie Cooper <yaneurab...@gmail.com>:
> Thanks! Should kqueue(2)/kevent(2) be updated?

I'm really not sure what's best here. On one hand the header no longer
depends on , but the man page does refer to types and
identifiers that are no longer declared by simply including this
header.

Maybe it's best to leave it there, so that it's more likely for people
to write code that also builds with previous versions of this header?

-- 
Ed Schouten <e...@nuxi.nl>
Nuxi, 's-Hertogenbosch, the Netherlands
KvK-nr.: 62051717
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r313704 - head/sys/sys

2017-02-13 Thread Ed Schouten
Author: ed
Date: Mon Feb 13 19:00:09 2017
New Revision: 313704
URL: https://svnweb.freebsd.org/changeset/base/313704

Log:
  Make  work on its own.
  
  Right now this header file doesn't want to build when included on its
  own, as it depends on some integer types that are only declared
  internally. Switch it over to use  and the __*
  counterparts.

Modified:
  head/sys/sys/event.h

Modified: head/sys/sys/event.h
==
--- head/sys/sys/event.hMon Feb 13 18:52:26 2017(r313703)
+++ head/sys/sys/event.hMon Feb 13 19:00:09 2017(r313704)
@@ -29,7 +29,8 @@
 #ifndef _SYS_EVENT_H_
 #define _SYS_EVENT_H_
 
-#include  
+#include 
+#include 
 
 #define EVFILT_READ(-1)
 #define EVFILT_WRITE   (-2)
@@ -57,11 +58,11 @@
 } while(0)
 
 struct kevent {
-   uintptr_t   ident;  /* identifier for this event */
+   __uintptr_t ident;  /* identifier for this event */
short   filter; /* filter for event */
-   u_short flags;
-   u_int   fflags;
-   intptr_tdata;
+   unsigned short  flags;
+   unsigned intfflags;
+   __intptr_t  data;
void*udata; /* opaque user data identifier */
 };
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r313329 - in head: bin/ed secure/usr.bin secure/usr.bin/bdes usr.bin usr.bin/enigma

2017-02-06 Thread Ed Schouten
Hi Allan,

2017-02-06 9:27 GMT+01:00 Allan Jude <allanj...@freebsd.org>:
>   The use of DES for anything is discouraged, especially with a static IV of 0

Not entirely related to this, but still...

Do we want to go ahead and also remove DES support from crypt(3)?
Compared to the other crypt formats, the DES implementation seems
fairly large, uses global state, etc.

I can send out a change for code review if people {like,don't object to} this.

-- 
Ed Schouten <e...@nuxi.nl>
Nuxi, 's-Hertogenbosch, the Netherlands
KvK-nr.: 62051717
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r313322 - in head/sys: conf dev/iwm modules/iwm

2017-02-05 Thread Ed Schouten
Hi Adrian,

2017-02-06 6:27 GMT+01:00 Adrian Chadd <adr...@freebsd.org>:
> Modified: head/sys/conf/files
> ==
> --- head/sys/conf/files Mon Feb  6 05:27:05 2017(r313321)
> +++ head/sys/conf/files Mon Feb  6 05:27:07 2017(r313322)
> @@ -1882,6 +1882,7 @@ dev/iwm/if_iwm.c  optional iwm
>  dev/iwm/if_iwm_binding.c   optional iwm
>  dev/iwm/if_iwm_led.c   optional iwm
>  dev/iwm/if_iwm_mac_ctxt.c  optional iwm
> +dev/netif/iwm/if_iwm_notif_wait.c  optional iwm
>  dev/iwm/if_iwm_pcie_trans.coptional iwm
>  dev/iwm/if_iwm_phy_ctxt.c  optional iwm
>  dev/iwm/if_iwm_phy_db.coptional iwm

What's with the 'netif' part in the source file's name? The actual
source file doesn't use it.

-- 
Ed Schouten <e...@nuxi.nl>
Nuxi, 's-Hertogenbosch, the Netherlands
KvK-nr.: 62051717
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r312355 - in head/sys: amd64/cloudabi32 amd64/cloudabi64 arm/cloudabi32 arm64/cloudabi64 compat/cloudabi compat/cloudabi32 compat/cloudabi64 i386/cloudabi32

2017-01-17 Thread Ed Schouten
Author: ed
Date: Tue Jan 17 22:05:52 2017
New Revision: 312355
URL: https://svnweb.freebsd.org/changeset/base/312355

Log:
  Catch up with changes to structure member names.
  
  Pointer/length pairs are now always named ${name} and ${name}_len.

Modified:
  head/sys/amd64/cloudabi32/cloudabi32_sysvec.c
  head/sys/amd64/cloudabi64/cloudabi64_sysvec.c
  head/sys/arm/cloudabi32/cloudabi32_sysvec.c
  head/sys/arm64/cloudabi64/cloudabi64_sysvec.c
  head/sys/compat/cloudabi/cloudabi_file.c
  head/sys/compat/cloudabi/cloudabi_mem.c
  head/sys/compat/cloudabi/cloudabi_proc.c
  head/sys/compat/cloudabi/cloudabi_random.c
  head/sys/compat/cloudabi/cloudabi_sock.c
  head/sys/compat/cloudabi32/cloudabi32_fd.c
  head/sys/compat/cloudabi32/cloudabi32_poll.c
  head/sys/compat/cloudabi32/cloudabi32_sock.c
  head/sys/compat/cloudabi32/cloudabi32_thread.c
  head/sys/compat/cloudabi64/cloudabi64_fd.c
  head/sys/compat/cloudabi64/cloudabi64_poll.c
  head/sys/compat/cloudabi64/cloudabi64_sock.c
  head/sys/compat/cloudabi64/cloudabi64_thread.c
  head/sys/i386/cloudabi32/cloudabi32_sysvec.c

Modified: head/sys/amd64/cloudabi32/cloudabi32_sysvec.c
==
--- head/sys/amd64/cloudabi32/cloudabi32_sysvec.c   Tue Jan 17 22:05:01 
2017(r312354)
+++ head/sys/amd64/cloudabi32/cloudabi32_sysvec.c   Tue Jan 17 22:05:52 
2017(r312355)
@@ -181,7 +181,7 @@ cloudabi32_thread_setregs(struct thread 
 
/* Perform standard register initialization. */
stack.ss_sp = TO_PTR(attr->stack);
-   stack.ss_size = attr->stack_size - sizeof(args);
+   stack.ss_size = attr->stack_len - sizeof(args);
cpu_set_upcall(td, TO_PTR(attr->entry_point), NULL, );
 
/*

Modified: head/sys/amd64/cloudabi64/cloudabi64_sysvec.c
==
--- head/sys/amd64/cloudabi64/cloudabi64_sysvec.c   Tue Jan 17 22:05:01 
2017(r312354)
+++ head/sys/amd64/cloudabi64/cloudabi64_sysvec.c   Tue Jan 17 22:05:52 
2017(r312355)
@@ -164,7 +164,7 @@ cloudabi64_thread_setregs(struct thread 
 * from the top of the stack to store a single element array,
 * containing a pointer to the TCB. %fs base will point to this.
 */
-   tcbptr = rounddown(attr->stack + attr->stack_size - sizeof(tcbptr),
+   tcbptr = rounddown(attr->stack + attr->stack_len - sizeof(tcbptr),
_Alignof(tcbptr));
error = copyout(, (void *)tcbptr, sizeof(tcb));
if (error != 0)

Modified: head/sys/arm/cloudabi32/cloudabi32_sysvec.c
==
--- head/sys/arm/cloudabi32/cloudabi32_sysvec.c Tue Jan 17 22:05:01 2017
(r312354)
+++ head/sys/arm/cloudabi32/cloudabi32_sysvec.c Tue Jan 17 22:05:52 2017
(r312355)
@@ -148,7 +148,7 @@ cloudabi32_thread_setregs(struct thread 
 
/* Perform standard register initialization. */
stack.ss_sp = TO_PTR(attr->stack);
-   stack.ss_size = attr->stack_size;
+   stack.ss_size = attr->stack_len;
cpu_set_upcall(td, TO_PTR(attr->entry_point), NULL, );
 
/*

Modified: head/sys/arm64/cloudabi64/cloudabi64_sysvec.c
==
--- head/sys/arm64/cloudabi64/cloudabi64_sysvec.c   Tue Jan 17 22:05:01 
2017(r312354)
+++ head/sys/arm64/cloudabi64/cloudabi64_sysvec.c   Tue Jan 17 22:05:52 
2017(r312355)
@@ -140,7 +140,7 @@ cloudabi64_thread_setregs(struct thread 
 
/* Perform standard register initialization. */
stack.ss_sp = TO_PTR(attr->stack);
-   stack.ss_size = attr->stack_size;
+   stack.ss_size = attr->stack_len;
cpu_set_upcall(td, TO_PTR(attr->entry_point), NULL, );
 
/*

Modified: head/sys/compat/cloudabi/cloudabi_file.c
==
--- head/sys/compat/cloudabi/cloudabi_file.cTue Jan 17 22:05:01 2017
(r312354)
+++ head/sys/compat/cloudabi/cloudabi_file.cTue Jan 17 22:05:52 2017
(r312355)
@@ -146,7 +146,7 @@ cloudabi_sys_file_create(struct thread *
char *path;
int error;
 
-   error = copyin_path(uap->path, uap->pathlen, );
+   error = copyin_path(uap->path, uap->path_len, );
if (error != 0)
return (error);
 
@@ -177,10 +177,10 @@ cloudabi_sys_file_link(struct thread *td
char *path1, *path2;
int error;
 
-   error = copyin_path(uap->path1, uap->path1len, );
+   error = copyin_path(uap->path1, uap->path1_len, );
if (error != 0)
return (error);
-   error = copyin_path(uap->path2, uap->path2len, );
+   error = copyin_path(uap->path2, uap->path2_len, );
if (error != 0) {
cloudabi_freestr(path1);
return (error);
@@ -261,7 +261,7 @@ 

svn commit: r312354 - in head/sys/compat: cloudabi32 cloudabi64

2017-01-17 Thread Ed Schouten
Author: ed
Date: Tue Jan 17 22:05:01 2017
New Revision: 312354
URL: https://svnweb.freebsd.org/changeset/base/312354

Log:
  Regenerate sources based on the system call tables.

Modified:
  head/sys/compat/cloudabi32/cloudabi32_proto.h
  head/sys/compat/cloudabi32/cloudabi32_syscall.h
  head/sys/compat/cloudabi32/cloudabi32_syscalls.c
  head/sys/compat/cloudabi32/cloudabi32_sysent.c
  head/sys/compat/cloudabi32/cloudabi32_systrace_args.c
  head/sys/compat/cloudabi64/cloudabi64_proto.h
  head/sys/compat/cloudabi64/cloudabi64_syscall.h
  head/sys/compat/cloudabi64/cloudabi64_syscalls.c
  head/sys/compat/cloudabi64/cloudabi64_sysent.c
  head/sys/compat/cloudabi64/cloudabi64_systrace_args.c

Modified: head/sys/compat/cloudabi32/cloudabi32_proto.h
==
--- head/sys/compat/cloudabi32/cloudabi32_proto.h   Tue Jan 17 22:03:08 
2017(r312353)
+++ head/sys/compat/cloudabi32/cloudabi32_proto.h   Tue Jan 17 22:05:01 
2017(r312354)
@@ -3,7 +3,7 @@
  *
  * DO NOT EDIT-- this file is automatically generated.
  * $FreeBSD$
- * created from FreeBSD: head/sys/contrib/cloudabi/syscalls32.master 304563 
2016-08-21 15:56:19Z ed 
+ * created from FreeBSD: head/sys/contrib/cloudabi/syscalls32.master 312353 
2017-01-17 22:03:08Z ed
  */
 
 #ifndef _CLOUDABI32_SYSPROTO_H_
@@ -63,20 +63,20 @@ struct cloudabi_sys_fd_dup_args {
 };
 struct cloudabi32_sys_fd_pread_args {
char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char 
fd_r_[PADR_(cloudabi_fd_t)];
-   char iov_l_[PADL_(const cloudabi32_iovec_t *)]; const 
cloudabi32_iovec_t * iov; char iov_r_[PADR_(const cloudabi32_iovec_t *)];
-   char iovcnt_l_[PADL_(size_t)]; size_t iovcnt; char 
iovcnt_r_[PADR_(size_t)];
+   char iovs_l_[PADL_(const cloudabi32_iovec_t *)]; const 
cloudabi32_iovec_t * iovs; char iovs_r_[PADR_(const cloudabi32_iovec_t *)];
+   char iovs_len_l_[PADL_(size_t)]; size_t iovs_len; char 
iovs_len_r_[PADR_(size_t)];
char offset_l_[PADL_(cloudabi_filesize_t)]; cloudabi_filesize_t offset; 
char offset_r_[PADR_(cloudabi_filesize_t)];
 };
 struct cloudabi32_sys_fd_pwrite_args {
char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char 
fd_r_[PADR_(cloudabi_fd_t)];
-   char iov_l_[PADL_(const cloudabi32_ciovec_t *)]; const 
cloudabi32_ciovec_t * iov; char iov_r_[PADR_(const cloudabi32_ciovec_t *)];
-   char iovcnt_l_[PADL_(size_t)]; size_t iovcnt; char 
iovcnt_r_[PADR_(size_t)];
+   char iovs_l_[PADL_(const cloudabi32_ciovec_t *)]; const 
cloudabi32_ciovec_t * iovs; char iovs_r_[PADR_(const cloudabi32_ciovec_t *)];
+   char iovs_len_l_[PADL_(size_t)]; size_t iovs_len; char 
iovs_len_r_[PADR_(size_t)];
char offset_l_[PADL_(cloudabi_filesize_t)]; cloudabi_filesize_t offset; 
char offset_r_[PADR_(cloudabi_filesize_t)];
 };
 struct cloudabi32_sys_fd_read_args {
char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char 
fd_r_[PADR_(cloudabi_fd_t)];
-   char iov_l_[PADL_(const cloudabi32_iovec_t *)]; const 
cloudabi32_iovec_t * iov; char iov_r_[PADR_(const cloudabi32_iovec_t *)];
-   char iovcnt_l_[PADL_(size_t)]; size_t iovcnt; char 
iovcnt_r_[PADR_(size_t)];
+   char iovs_l_[PADL_(const cloudabi32_iovec_t *)]; const 
cloudabi32_iovec_t * iovs; char iovs_r_[PADR_(const cloudabi32_iovec_t *)];
+   char iovs_len_l_[PADL_(size_t)]; size_t iovs_len; char 
iovs_len_r_[PADR_(size_t)];
 };
 struct cloudabi_sys_fd_replace_args {
char from_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t from; char 
from_r_[PADR_(cloudabi_fd_t)];
@@ -101,8 +101,8 @@ struct cloudabi_sys_fd_sync_args {
 };
 struct cloudabi32_sys_fd_write_args {
char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char 
fd_r_[PADR_(cloudabi_fd_t)];
-   char iov_l_[PADL_(const cloudabi32_ciovec_t *)]; const 
cloudabi32_ciovec_t * iov; char iov_r_[PADR_(const cloudabi32_ciovec_t *)];
-   char iovcnt_l_[PADL_(size_t)]; size_t iovcnt; char 
iovcnt_r_[PADR_(size_t)];
+   char iovs_l_[PADL_(const cloudabi32_ciovec_t *)]; const 
cloudabi32_ciovec_t * iovs; char iovs_r_[PADR_(const cloudabi32_ciovec_t *)];
+   char iovs_len_l_[PADL_(size_t)]; size_t iovs_len; char 
iovs_len_r_[PADR_(size_t)];
 };
 struct cloudabi_sys_file_advise_args {
char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char 
fd_r_[PADR_(cloudabi_fd_t)];
@@ -118,44 +118,44 @@ struct cloudabi_sys_file_allocate_args {
 struct cloudabi_sys_file_create_args {
char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char 
fd_r_[PADR_(cloudabi_fd_t)];
char path_l_[PADL_(const char *)]; const char * path; char 
path_r_[PADR_(const char *)];
-   char pathlen_l_[PADL_(size_t)]; size_t pathlen; char 
pathlen_r_[PADR_(size_t)];
+   char path_len_l_[PADL_(size_t)]; size_t path_len; char 
path_len_r_[PADR_(size_t)];
char type_l_[PADL_(cloudabi_filetype_t)]; cloudabi_filetype_t type; 
char type_r_[PADR_(cloudabi_filetype_t)];
 };
 struct 

  1   2   3   4   5   6   7   8   9   10   >