Re: ipmi(4) - Support ipmitool IOCTL etc.

2015-09-21 Thread Masao Uebayashi
I've added a patch to sysutils/ipmitool; apply it and rebuild.

https://github.com/uebayasi/openbsd-ipmi/blob/ipmi19/ipmitool.patch

On Fri, Sep 18, 2015 at 05:48:52PM +0900, Masao Uebayashi wrote:
> I've prepared a set of patches to make OpenBSD's ipmi(4) work with ipmitool
> via /dev/ipmi*, following what FreeBSD did.  I'd like to hear feedback from
> developers and users.
> 
>   https://github.com/uebayasi/openbsd-ipmi
> 
> I'm also looking for someone whose machine supports BT (block transfer)
> interface.  I believe the BT support is broken.  Need testers to fix it.



Clarify error/warning reporting in style(9)

2015-09-21 Thread Michael McConville
Could also say "Use the err(3) and warn(3) family of functions." That's
what the err(3) man page intro refers to it as.

Index: share/man/man9/style.9
===
RCS file: /cvs/src/share/man/man9/style.9,v
retrieving revision 1.59
diff -u -p -r1.59 style.9
--- share/man/man9/style.9  23 Jan 2015 13:02:49 -  1.59
+++ share/man/man9/style.9  22 Sep 2015 02:36:46 -
@@ -522,10 +522,10 @@ Routines returning
 should not have their return values cast to any pointer type.
 .Pp
 Use
-.Xr err 3
-or
+.Xr err 3 ,
 .Xr warn 3 ,
-don't roll your own!
+or one of their variants.
+Don't roll your own!
 .Bd -literal -offset indent
 if ((four = malloc(sizeof(struct foo))) == NULL)
err(1, NULL);



poll magic for pflogd

2015-09-21 Thread Ted Unangst
I think this will help pflogd sleep better at night...

My understanding of the pcap/bpf timeout is that it will always wait that
long, even if packets are received, so that you don't get one read() per
packet. But using this timeout doesn't mean wait forever until you get
something.

We can put a "long" poll() in front of pcap to wait until there are packets
(maybe never if you aren't using pf logging), and then let the timeout work
it's magic.


Index: pflogd.c
===
RCS file: /cvs/src/sbin/pflogd/pflogd.c,v
retrieving revision 1.51
diff -u -p -r1.51 pflogd.c
--- pflogd.c7 Feb 2015 02:09:13 -   1.51
+++ pflogd.c22 Sep 2015 00:08:16 -
@@ -35,6 +35,8 @@
 #include 
 #include 
 #include 
+
+#include 
 #include 
 #include 
 #include 
@@ -575,6 +577,7 @@ main(int argc, char **argv)
int ch, np, ret, Xflag = 0;
pcap_handler phandler = dump_packet;
const char *errstr = NULL;
+   struct pollfd pfd;
 
ret = 0;
 
@@ -685,9 +688,16 @@ main(int argc, char **argv)
} else if (Xflag)
return (0);
 
+   pfd.fd = pcap_get_selectable_fd(hpcap);
+   pfd.events = POLLIN;
while (1) {
-   np = pcap_dispatch(hpcap, PCAP_NUM_PKTS,
-   phandler, (u_char *)dpcap);
+   np = 0;
+   if (poll(&pfd, 1, INFTIM) == 1) {
+   np = pcap_dispatch(hpcap, PCAP_NUM_PKTS,
+   phandler, (u_char *)dpcap);
+   } else if (pfd.revents & (POLLERR|POLLHUP)) {
+   np = -1;
+   }
if (np < 0) {
if (!if_exists(interface)) {
logmsg(LOG_NOTICE, "interface %s went away",



Re: ports.7: tweak wording + punctuation

2015-09-21 Thread Ingo Schwarze
Hi Michael,

Michael Reed wrote on Mon, Sep 21, 2015 at 04:42:02PM -0400:

> Index: src/share/man/man7/ports.7
> ===
> RCS file: /cvs/src/share/man/man7/ports.7,v
> retrieving revision 1.103
> diff -u -p -r1.103 ports.7
> --- src/share/man/man7/ports.724 Aug 2015 12:57:14 -  1.103
> +++ src/share/man/man7/ports.721 Sep 2015 20:40:20 -
> @@ -140,8 +140,7 @@ apply.
>  .Sh TARGETS
>  Individual ports are controlled through a few documented targets.
>  Some of these targets work recursively through subdirectories, so that
> -someone can, for example, install all of the net
> -ports.
> +someone can, for example, install all of the net ports.
>  .Pp
>  The variable
>  .Ev SKIPDIR

Gratuitious, nothing is wrong here.  Re-wrapping can be done when
changing the text anyway, but i don't see the point in losing
history when there is no real change.

> @@ -429,7 +428,8 @@ This shows up as undefined references in
>  is no choice but to proceed the old way: deinstall the offending package
>  and everything built on top of it, build and install new packages.
>  .Sh BULK PACKAGE BUILDING
> -Building any significant number of packages from the ports tree should use
> +Building any significant number of packages from the ports tree should be 
> done
> +with
>  .Xr dpb 1 ,
>  a tool located inside the ports tree proper
>  .Po

Both versions look fine to me, no need to change.
Ceteris paribus, short and active is often better.

> @@ -439,7 +439,7 @@ normally as
>  In particular, it can take advantage of machine clusters (same architecture
>  and same installation), and of multi-core machines.
>  .Pp
> -A few remarks may save a lot of time
> +A few remarks may save a lot of time:
>  .Bl -bullet
>  .It
>  The default limits in
> @@ -451,7 +451,7 @@ For instance, a lot of C++-based ports w
>  .Ar datasize
>  over 1G.
>  .It
> -cluster builds should have shared
> +Cluster builds should have shared
>  .Ev PORTSDIR
>  and local
>  .Ev WRKOBJDIR .
> @@ -461,10 +461,10 @@ partitions mounted
>  .Sq noatime,async
>  will help.
>  .It
> -as far as possible, the log directory should be local to the machine running
> +As far as possible, the log directory should be local to the machine running
>  .Xr dpb 1 .
>  .It
> -a full bulk will fetch over 20G of distfiles, create over 17G of packages.
> +A full bulk will fetch over 20G of distfiles and create over 17G of packages.
>  The largest work directories are about 10G each.
>  .It
>  Take notice of
> @@ -634,7 +634,7 @@ Location of the ports tree
>  .Pa /usr/ports ) .
>  .It Ev DISTDIR
>  Where to find/put distfiles, normally
> -.Pa ${PORTSDIR}/distfiles
> +.Pa ${PORTSDIR}/distfiles .
>  .It Ev PACKAGE_REPOSITORY
>  Used only for the
>  .Cm package

Committed these four chunks.

Thanks,
  Ingo



Re: ports.7: Ar -> Va

2015-09-21 Thread Ingo Schwarze
Hi Michael,

Michael Reed wrote on Mon, Sep 21, 2015 at 04:50:07PM -0400:

> The variables below take arguments, but are not arguments themselves.
> Given that, change the markup accordingly.

Committed, thanks.
  Ingo


> Index: src/share/man/man7/ports.7
> ===
> RCS file: /cvs/src/share/man/man7/ports.7,v
> retrieving revision 1.103
> diff -u -p -r1.103 ports.7
> --- src/share/man/man7/ports.724 Aug 2015 12:57:14 -  1.103
> +++ src/share/man/man7/ports.721 Sep 2015 20:44:42 -
> @@ -445,10 +445,10 @@ A few remarks may save a lot of time
>  The default limits in
>  .Xr login.conf 5
>  are inappropriate for bulk builds.
> -.Ar maxproc , openfiles , datasize
> +.Va maxproc , openfiles , datasize
>  should be cranked way up, especially for parallel builds.
>  For instance, a lot of C++-based ports will require a
> -.Ar datasize
> +.Va datasize
>  over 1G.
>  .It
>  cluster builds should have shared
> 



ports.7: Ar -> Va

2015-09-21 Thread Michael Reed
Hi all,

The variables below take arguments, but are not arguments themselves.
Given that, change the markup accordingly.

Regards,
Michael



Index: src/share/man/man7/ports.7
===
RCS file: /cvs/src/share/man/man7/ports.7,v
retrieving revision 1.103
diff -u -p -r1.103 ports.7
--- src/share/man/man7/ports.7  24 Aug 2015 12:57:14 -  1.103
+++ src/share/man/man7/ports.7  21 Sep 2015 20:44:42 -
@@ -445,10 +445,10 @@ A few remarks may save a lot of time
 The default limits in
 .Xr login.conf 5
 are inappropriate for bulk builds.
-.Ar maxproc , openfiles , datasize
+.Va maxproc , openfiles , datasize
 should be cranked way up, especially for parallel builds.
 For instance, a lot of C++-based ports will require a
-.Ar datasize
+.Va datasize
 over 1G.
 .It
 cluster builds should have shared



ports.7: tweak wording + punctuation

2015-09-21 Thread Michael Reed
Hi,

I found the wording in ports.7 awkward in a few places,
which this patch aims to fix.  Besides that, there's
a few small punctuation changes.

I've tried to only touch low-hanging fruit to avoid any
bikeshedding, but if you think any change is too subjective
just let me know.

Regards,
Michael



Index: src/share/man/man7/ports.7
===
RCS file: /cvs/src/share/man/man7/ports.7,v
retrieving revision 1.103
diff -u -p -r1.103 ports.7
--- src/share/man/man7/ports.7  24 Aug 2015 12:57:14 -  1.103
+++ src/share/man/man7/ports.7  21 Sep 2015 20:40:20 -
@@ -140,8 +140,7 @@ apply.
 .Sh TARGETS
 Individual ports are controlled through a few documented targets.
 Some of these targets work recursively through subdirectories, so that
-someone can, for example, install all of the net
-ports.
+someone can, for example, install all of the net ports.
 .Pp
 The variable
 .Ev SKIPDIR
@@ -429,7 +428,8 @@ This shows up as undefined references in
 is no choice but to proceed the old way: deinstall the offending package
 and everything built on top of it, build and install new packages.
 .Sh BULK PACKAGE BUILDING
-Building any significant number of packages from the ports tree should use
+Building any significant number of packages from the ports tree should be done
+with
 .Xr dpb 1 ,
 a tool located inside the ports tree proper
 .Po
@@ -439,7 +439,7 @@ normally as
 In particular, it can take advantage of machine clusters (same architecture
 and same installation), and of multi-core machines.
 .Pp
-A few remarks may save a lot of time
+A few remarks may save a lot of time:
 .Bl -bullet
 .It
 The default limits in
@@ -451,7 +451,7 @@ For instance, a lot of C++-based ports w
 .Ar datasize
 over 1G.
 .It
-cluster builds should have shared
+Cluster builds should have shared
 .Ev PORTSDIR
 and local
 .Ev WRKOBJDIR .
@@ -461,10 +461,10 @@ partitions mounted
 .Sq noatime,async
 will help.
 .It
-as far as possible, the log directory should be local to the machine running
+As far as possible, the log directory should be local to the machine running
 .Xr dpb 1 .
 .It
-a full bulk will fetch over 20G of distfiles, create over 17G of packages.
+A full bulk will fetch over 20G of distfiles and create over 17G of packages.
 The largest work directories are about 10G each.
 .It
 Take notice of
@@ -634,7 +634,7 @@ Location of the ports tree
 .Pa /usr/ports ) .
 .It Ev DISTDIR
 Where to find/put distfiles, normally
-.Pa ${PORTSDIR}/distfiles
+.Pa ${PORTSDIR}/distfiles .
 .It Ev PACKAGE_REPOSITORY
 Used only for the
 .Cm package



Re: lighter sleep

2015-09-21 Thread Philip Guenther
On Mon, Sep 21, 2015 at 8:37 AM,   wrote:
...
> I don't want error messages or any feedback produced by the machine and
> the operating system in any other language than English in C locale,
> even if my locale is set to native (non-English).

You know that you can set LC_MESSAGES to a different value than LANG,
so you can control them independently?  Perhaps you want
LC_MESSAGES=en_US.UTF-8 LANG=ru.UTF-8
...and those that want localized messages can still have them.




Philip Guenther



Re: lighter sleep

2015-09-21 Thread lists
On Mon, 21 Sep 2015 16:53:12 +0200
Alexandre Ratchov  wrote:

> On Mon, Sep 21, 2015 at 02:29:03PM +, Christian Weisgerber wrote:
> > On 2015-09-21, Stefan Sperling  wrote:
> > 
> > > The function that parses funny numbers is iswdigit() which gets a wchar_t.
> > > But sleep(1) doesn't need that.
> > 
> > The sole somewhat realistic use of i18n in sleep(1) is the decimal
> > separator, so you could do
> > 
> > $ sleep 1,5
> > 
> > in an appropriate locale.  Of course the current code doesn't support
> > that.
> 
> IMO commands syntax should be considered as "computer language" and
> shouldn't depend on the locale.
> 
> In base commands, locale is only meaningful to generate strings
> that won't be parsed by the machine, like text of error messages.
> 
> 

Здравствуйте,

Localised error messages in Russian:

$ humppa
ksh: humppa: не найдено

$ кто humppa
кто: humpa: Команда не найдена.

No really, even native speakers do not want 'misfortunate' translations
and the ambiguity this adds: what the hell were they thinking 'losting
it into transition'...

I don't want error messages or any feedback produced by the machine and
the operating system in any other language than English in C locale,
even if my locale is set to native (non-English).

So, probably you can save the trouble wrapping around such
functionality and consider test of error messages also "computer
language" suitable for (easy) machine parsing.

Another one of those popcorn threads (sorry I'll not post again here
just could not resist to add a non native speaker's opinion about
butchered 'transversion').

С уважением,
Антон



Re: lighter sleep

2015-09-21 Thread Stefan Sperling
On Mon, Sep 21, 2015 at 01:25:04PM -0400, Ted Unangst wrote:
> Stefan Sperling wrote:
> > 
> > Just remove the setlocale() call to leave sleep(1) in the default "C" 
> > locale.
> 
> here's a diff that does that. you're right, there's no need to rewrite ctype
> if it hasn't been altered.  I also checked that there are no calls to err()
> or strerror() or whatever, and so there's no need to load localized klingon
> error messages or whatever else setlocale does.

ok stsp@

> 
> 
> Index: sleep.c
> ===
> RCS file: /cvs/src/bin/sleep/sleep.c,v
> retrieving revision 1.20
> diff -u -p -r1.20 sleep.c
> --- sleep.c   21 Nov 2013 15:54:46 -  1.20
> +++ sleep.c   21 Sep 2015 17:21:17 -
> @@ -32,7 +32,6 @@
>  
>  #include 
>  #include 
> -#include 
>  #include 
>  #include 
>  #include 
> @@ -53,8 +52,6 @@ main(int argc, char *argv[])
>   long nsecs = 0;
>   struct timespec rqtp;
>   int i;
> -
> - setlocale(LC_ALL, "");
>  
>   signal(SIGALRM, alarmh);
>  



Re: lighter sleep

2015-09-21 Thread Ted Unangst
Stefan Sperling wrote:
> 
> Just remove the setlocale() call to leave sleep(1) in the default "C" locale.

here's a diff that does that. you're right, there's no need to rewrite ctype
if it hasn't been altered.  I also checked that there are no calls to err()
or strerror() or whatever, and so there's no need to load localized klingon
error messages or whatever else setlocale does.


Index: sleep.c
===
RCS file: /cvs/src/bin/sleep/sleep.c,v
retrieving revision 1.20
diff -u -p -r1.20 sleep.c
--- sleep.c 21 Nov 2013 15:54:46 -  1.20
+++ sleep.c 21 Sep 2015 17:21:17 -
@@ -32,7 +32,6 @@
 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -53,8 +52,6 @@ main(int argc, char *argv[])
long nsecs = 0;
struct timespec rqtp;
int i;
-
-   setlocale(LC_ALL, "");
 
signal(SIGALRM, alarmh);
 



mg(1) dired mode - line numbers and delete functions

2015-09-21 Thread Mark Lumsden
Hi,

Line numbers are not handled very well in the dired mode delete
functions. This diff should fix that. ok? 

-lum


Index: dired.c
===
RCS file: /cvs/src/usr.bin/mg/dired.c,v
retrieving revision 1.73
diff -u -p -u -p -r1.73 dired.c
--- dired.c 21 Sep 2015 06:59:54 -  1.73
+++ dired.c 21 Sep 2015 16:42:23 -
@@ -273,8 +273,10 @@ d_del(int f, int n)
while (n--) {
if (llength(curwp->w_dotp) > 0)
lputc(curwp->w_dotp, 0, 'D');
-   if (lforw(curwp->w_dotp) != curbp->b_headp)
+   if (lforw(curwp->w_dotp) != curbp->b_headp) {
curwp->w_dotp = lforw(curwp->w_dotp);
+   curwp->w_dotline++;
+   }
}
curwp->w_rflag |= WFEDIT | WFMOVE;
return (d_warpdot(curwp->w_dotp, &curwp->w_doto));
@@ -289,8 +291,10 @@ d_undel(int f, int n)
while (n--) {
if (llength(curwp->w_dotp) > 0)
lputc(curwp->w_dotp, 0, ' ');
-   if (lforw(curwp->w_dotp) != curbp->b_headp)
+   if (lforw(curwp->w_dotp) != curbp->b_headp) {
curwp->w_dotp = lforw(curwp->w_dotp);
+   curwp->w_dotline++;
+   }
}
curwp->w_rflag |= WFEDIT | WFMOVE;
return (d_warpdot(curwp->w_dotp, &curwp->w_doto));
@@ -303,8 +307,10 @@ d_undelbak(int f, int n)
if (n < 0)
return (d_undel(f, -n));
while (n--) {
-   if (lback(curwp->w_dotp) != curbp->b_headp)
+   if (lback(curwp->w_dotp) != curbp->b_headp) {
curwp->w_dotp = lback(curwp->w_dotp);
+   curwp->w_dotline--;
+   }
if (llength(curwp->w_dotp) > 0)
lputc(curwp->w_dotp, 0, ' ');
}
@@ -364,20 +370,27 @@ d_expunge(int f, int n)
 {
struct line *lp, *nlp;
char fname[NFILEN], sname[NFILEN];
+   int  tmp;
+
+   tmp = curwp->w_dotline;
+   curwp->w_dotline = 0;
 
for (lp = bfirstlp(curbp); lp != curbp->b_headp; lp = nlp) {
+   curwp->w_dotline++;
nlp = lforw(lp);
if (llength(lp) && lgetc(lp, 0) == 'D') {
switch (d_makename(lp, fname, sizeof(fname))) {
case ABORT:
dobeep();
ewprintf("Bad line in dired buffer");
+   curwp->w_dotline = tmp;
return (FALSE);
case FALSE:
if (unlink(fname) < 0) {
(void)xbasename(sname, fname, NFILEN);
dobeep();
ewprintf("Could not delete '%s'", 
sname);
+   curwp->w_dotline = tmp;
return (FALSE);
}
break;
@@ -387,15 +400,19 @@ d_expunge(int f, int n)
dobeep();
ewprintf("Could not delete directory "
"'%s'", sname);
+   curwp->w_dotline = tmp;
return (FALSE);
}
break;
}
lfree(lp);
curwp->w_bufp->b_lines--;
+   if (tmp > curwp->w_dotline)
+   tmp--;
curwp->w_rflag |= WFFULL;
}
}
+   curwp->w_dotline = tmp;
return (TRUE);
 }
 



Re: remove SIGALRM handling from sleep(1)

2015-09-21 Thread Philip Guenther
On Mon, Sep 21, 2015 at 2:06 AM, Mark Kettenis  wrote:
...
>> AFAICT, we don't use SIGALRM in any of our install or rc scripting, so
>> let's remove the unnecessary signal work.
>>
>> ok?
>
> Why?  The standard still allows our current behaviour.  And it's not a
> particular invasive bit of code.

It can't be relied on in portable code (GNU coreutils 8.4.37 doesn't
support it, for example), so since we don't use it it's a waste of
code and cycles.  Why have this wart in the code and docs for a wart
caused by the historical implementation?

Philip



cpuspeed in apm info

2015-09-21 Thread Ted Unangst
The frequency of the cpu is likely to be of interest (in fact, it is to me).
We can include it in the apm info.


Index: arch/i386/i386/apm.c
===
RCS file: /cvs/src/sys/arch/i386/i386/apm.c,v
retrieving revision 1.113
diff -u -p -r1.113 apm.c
--- arch/i386/i386/apm.c7 Feb 2015 01:19:40 -   1.113
+++ arch/i386/i386/apm.c21 Sep 2015 15:38:14 -
@@ -1084,6 +1084,8 @@ apmioctl(dev_t dev, u_long cmd, caddr_t 

swap16(powerp->minutes_left);
}
}
+   if (cpu_cpuspeed)
+   cpu_cpuspeed(&powerp->cpuspeed);
} else {
apm_perror("ioctl get power status", ®s);
error = EIO;
Index: arch/i386/include/apmvar.h
===
RCS file: /cvs/src/sys/arch/i386/include/apmvar.h,v
retrieving revision 1.20
diff -u -p -r1.20 apmvar.h
--- arch/i386/include/apmvar.h  6 Feb 2015 08:16:49 -   1.20
+++ arch/i386/include/apmvar.h  21 Sep 2015 15:36:31 -
@@ -270,7 +270,8 @@ struct apm_power_info {
u_char battery_life;
u_char spare1;
u_int minutes_left; /* estimate */
-   u_int spare2[6];
+   u_int cpuspeed;
+   u_int spare2[5];
 };
 
 struct apm_ctl {
Index: arch/amd64/include/apmvar.h
===
RCS file: /cvs/src/sys/arch/amd64/include/apmvar.h,v
retrieving revision 1.6
diff -u -p -r1.6 apmvar.h
--- arch/amd64/include/apmvar.h 6 Feb 2015 08:16:49 -   1.6
+++ arch/amd64/include/apmvar.h 21 Sep 2015 15:32:02 -
@@ -271,7 +271,8 @@ struct apm_power_info {
u_char battery_life;
u_char spare1;
u_int minutes_left; /* estimate */
-   u_int spare2[6];
+   u_int cpuspeed;
+   u_int spare2[5];
 };
 
 struct apm_ctl {
Index: dev/acpi/acpi.c
===
RCS file: /cvs/src/sys/dev/acpi/acpi.c,v
retrieving revision 1.294
diff -u -p -r1.294 acpi.c
--- dev/acpi/acpi.c 6 Sep 2015 16:47:48 -   1.294
+++ dev/acpi/acpi.c 21 Sep 2015 15:33:41 -
@@ -2928,6 +2928,8 @@ acpiioctl(dev_t dev, u_long cmd, caddr_t
pi->battery_state = APM_BATT_LOW;
else
pi->battery_state = APM_BATT_CRITICAL;
+   if (cpu_cpuspeed)
+   cpu_cpuspeed(&pi->cpuspeed);
 
break;
 



Re: lighter sleep

2015-09-21 Thread Alexandre Ratchov
On Mon, Sep 21, 2015 at 02:29:03PM +, Christian Weisgerber wrote:
> On 2015-09-21, Stefan Sperling  wrote:
> 
> > The function that parses funny numbers is iswdigit() which gets a wchar_t.
> > But sleep(1) doesn't need that.
> 
> The sole somewhat realistic use of i18n in sleep(1) is the decimal
> separator, so you could do
> 
> $ sleep 1,5
> 
> in an appropriate locale.  Of course the current code doesn't support
> that.

IMO commands syntax should be considered as "computer language" and
shouldn't depend on the locale.

In base commands, locale is only meaningful to generate strings
that won't be parsed by the machine, like text of error messages.



Re: lighter sleep

2015-09-21 Thread Mark Kettenis
> From: Christian Weisgerber 
> Date: Mon, 21 Sep 2015 14:29:03 + (UTC)
> 
> On 2015-09-21, Stefan Sperling  wrote:
> 
> > The function that parses funny numbers is iswdigit() which gets a wchar_t.
> > But sleep(1) doesn't need that.
> 
> The sole somewhat realistic use of i18n in sleep(1) is the decimal
> separator, so you could do
> 
> $ sleep 1,5
> 
> in an appropriate locale.  Of course the current code doesn't support
> that.

And fortunately POSIX agrees with our implementation:

  The following operand shall be supported:

  time
A non-negative decimal integer specifying the number of
seconds for which to suspend execution.

You could argue that the thousands separator should be supported though:

  $ sleep 1.000.000

if your locale is something vaguely european, and

  # sleep 1,000,000

for the north-americans.

But let's not go there...



Re: lighter sleep

2015-09-21 Thread Christian Weisgerber
On 2015-09-21, Stefan Sperling  wrote:

> The function that parses funny numbers is iswdigit() which gets a wchar_t.
> But sleep(1) doesn't need that.

The sole somewhat realistic use of i18n in sleep(1) is the decimal
separator, so you could do

$ sleep 1,5

in an appropriate locale.  Of course the current code doesn't support
that.

-- 
Christian "naddy" Weisgerber  na...@mips.inka.de



Re: kill struct inpcbtable's inpt_lastport

2015-09-21 Thread David Hill
On Sat, Sep 19, 2015 at 07:57:00PM +0200, Vincent Gross wrote:
> On 09/18/15 23:39, David Hill wrote:
> > On Fri, Sep 18, 2015 at 11:05:55PM +0200, Vincent Gross wrote:
> >> On 09/18/15 15:18, David Hill wrote:
> >>> Is this 'if (count)' statement needed?  We know first > last, so count
> >>> will always be positive.  lastport will always be set.
> >>
> >>> if last == first, then the if statement will be false and lastport will
> >>> be uninitialized, I believe.
> >>>
> >>
> >> Both remarks are true, but I think it is better to keep a more extensive
> >> refactoring in a separate diff, refactoring that shall get rid of this
> >> yucky code duplication.
> >>
> > 
> > Well, this code changes the current behavior.  I'd at least change
> > lastport to be initialized to 0 to keep the behavior the same.  It was
> > previously set to 0 with M_ZERO.
> > 
> 
> Fixed. Ok ?

LGTM.

> 
> Index: sys/netinet/in_pcb.c
> ===
> RCS file: /cvs/src/sys/netinet/in_pcb.c,v
> retrieving revision 1.179
> diff -u -p -r1.179 in_pcb.c
> --- sys/netinet/in_pcb.c  11 Sep 2015 15:29:47 -  1.179
> +++ sys/netinet/in_pcb.c  19 Sep 2015 17:52:42 -
> @@ -199,7 +199,6 @@ in_pcbinit(struct inpcbtable *table, int
>   &table->inpt_lhash);
>   if (table->inpt_lhashtbl == NULL)
>   panic("in_pcbinit: hashinit failed for lport");
> - table->inpt_lastport = 0;
>   table->inpt_count = 0;
>   arc4random_buf(&table->inpt_key, sizeof(table->inpt_key));
>  }
> @@ -281,8 +280,8 @@ in_pcbbind(struct inpcb *inp, struct mbu
>  {
>   struct socket *so = inp->inp_socket;
>   struct inpcbtable *table = inp->inp_table;
> - u_int16_t *lastport = &inp->inp_table->inpt_lastport;
>   struct sockaddr_in *sin;
> + u_int16_t lastport = 0;
>   u_int16_t lport = 0;
>   int wild = 0, reuseport = (so->so_options & SO_REUSEPORT);
>   int error;
> @@ -391,16 +390,16 @@ in_pcbbind(struct inpcb *inp, struct mbu
>*/
>   count = first - last;
>   if (count)
> - *lastport = first - arc4random_uniform(count);
> + lastport = first - arc4random_uniform(count);
>  
>   do {
>   if (count-- < 0)/* completely used? */
>   return (EADDRNOTAVAIL);
> - --*lastport;
> - if (*lastport > first || *lastport < last)
> - *lastport = first;
> - lport = htons(*lastport);
> - } while (in_baddynamic(*lastport, 
> so->so_proto->pr_protocol) ||
> + --lastport;
> + if (lastport > first || lastport < last)
> + lastport = first;
> + lport = htons(lastport);
> + } while (in_baddynamic(lastport, 
> so->so_proto->pr_protocol) ||
>   in_pcblookup(table, &zeroin_addr, 0,
>   &inp->inp_laddr, lport, wild, inp->inp_rtableid));
>   } else {
> @@ -409,16 +408,16 @@ in_pcbbind(struct inpcb *inp, struct mbu
>*/
>   count = last - first;
>   if (count)
> - *lastport = first + arc4random_uniform(count);
> + lastport = first + arc4random_uniform(count);
>  
>   do {
>   if (count-- < 0)/* completely used? */
>   return (EADDRNOTAVAIL);
> - ++*lastport;
> - if (*lastport < first || *lastport > last)
> - *lastport = first;
> - lport = htons(*lastport);
> - } while (in_baddynamic(*lastport, 
> so->so_proto->pr_protocol) ||
> + ++lastport;
> + if (lastport < first || lastport > last)
> + lastport = first;
> + lport = htons(lastport);
> + } while (in_baddynamic(lastport, 
> so->so_proto->pr_protocol) ||
>   in_pcblookup(table, &zeroin_addr, 0,
>   &inp->inp_laddr, lport, wild, inp->inp_rtableid));
>   }
> Index: sys/netinet/in_pcb.h
> ===
> RCS file: /cvs/src/sys/netinet/in_pcb.h,v
> retrieving revision 1.89
> diff -u -p -r1.89 in_pcb.h
> --- sys/netinet/in_pcb.h  16 Apr 2015 19:24:13 -  1.89
> +++ sys/netinet/in_pcb.h  19 Sep 2015 17:52:42 -
> @@ -152,7 +152,6 @@ struct inpcbtable {
>   struct inpcbh

Re: iked(8) cleanup

2015-09-21 Thread Mike Belopuhov
On 19 September 2015 at 20:08, Michael McConville
 wrote:
> Drop some unnecessary NULL checks

OK for those.

> explicitly bzero sensitive memory.
>

While SADB_GETSPI doesn't export keys, I think this change
won't harm nevertheless, so OK for it as well.



Re: Drop a distracting function from locate(1)

2015-09-21 Thread Bob Beck


Holy bikeshed batman.. Did I accidentally stumble into a FreeBSD list?



Re: Drop a distracting function from locate(1)

2015-09-21 Thread lists
On Mon, 21 Sep 2015 07:47:55 +0200
Otto Moerbeek  wrote:

> On Sun, Sep 20, 2015 at 07:43:46AM -0400, Michael McConville wrote:
> 
> > Otto Moerbeek wrote:
> > > I do not agree. You only have to remeber "that function does sensible
> > > error checking" and you do not have to remember at each spot which
> > > condition is the right one.
> > > 
> > > Function are the major way of structuring code, use them.
> > 
> > It's not the idea of functions that I'm questioning. I don't think
> > making a function for a simple if (x) then errx(...); condition is sane,
> > though. I'm a bit biased at the moment because I'm searching through the
> > tree for "creative" replacements for errx() et al.
> 
> If x is an expression involving relational operators, I do not like to
> see multiple copies of that. e.g. verifying if a condition should use
> > or >= is often hard enough. If I have to check that in multiple
> places, I'm wasting effort. Also, if I see a bug and fix it, I do like
> the fact that I do not have to check multiple occurrences of the same
> expression and decide if they are really the same or not.
> 
> So even if a function increases the number of lines in a program,
> often it reduces complexity.

We're all thinking about resulting machine cycles added on top of
visual code appeal, clarity and simplicity, right? There is also a
road map, while striking the right balance, one day "just another
OpenBSD user" will want the code to be of learning quality for his
kids. Locate is working OK as long as no new bugs creep in and
efficiency is kept, fuzz it.



Re: lighter sleep

2015-09-21 Thread Bob Beck
On Monday, 21 September 2015, Stefan Sperling  wrote:

> On Sun, Sep 20, 2015 at 09:40:05PM -0600, Bob Beck wrote:
> > I concur, I don't want to see a plethora of "isnumber"
> > "ismaybeanumber" bullshit in the tree that
> > do the same thing "isdigit" does.. if for whatever reason we want
> > isdigit to be more efficient because
> > the most important thing I have to do is make shell sleep more
> > efficient, we should fix isdigit, or the locale poo..
> >
> > But for sure not introduce non-standard ascii-only replacements into
> > all code that do not quite what libc does..
> >
> > Jesus ted did you learn nothing from OpenSSL? :)
>
> Just remove the setlocale() call to leave sleep(1) in the default "C"
> locale.
>
> isdigit() and friends can now be considered ASCII-only.
> When we still had latin1 etc. it was possible in theory that values between
> 128 and 255 represented a digit. But now, isdigit() does the same
> regardless
> of locale setting (C or UTF-8) since it cannot be given a multibyte
> sequence,
> i.e. it will not deal with character values above 127.
>
> The function that parses funny numbers is iswdigit() which gets a wchar_t.
> But sleep(1) doesn't need that.
>

but what if i want to sleep for💩 seconds?!!?  this feature could be
incredibly important!!


Re: no more _subdir in man.conf

2015-09-21 Thread Ingo Schwarze
Hi Jan,

Jan Stary wrote on Thu, Sep 17, 2015 at 04:53:34PM +0200:

> The new man.conf does not recognize _subdir

Committed, thanks.
  Ingo


> Index: man.1
> ===
> RCS file: /cvs/src/usr.bin/mandoc/man.1,v
> retrieving revision 1.11
> diff -u -p -u -p -r1.11 man.1
> --- man.1 16 Feb 2015 16:18:02 -  1.11
> +++ man.1 17 Sep 2015 14:51:34 -
> @@ -173,12 +173,6 @@ must be a colon
>  separated list of directories.
>  This search path may also be set using the environment variable
>  .Ev MANPATH .
> -The subdirectories to be searched, and their search order,
> -are specified by the
> -.Dq _subdir
> -line in the
> -.Nm
> -configuration file.
>  .It Fl m Ar path
>  Augment the list of standard directories which
>  .Nm
> @@ -194,12 +188,6 @@ the directories specified using the
>  option or the
>  .Ev MANPATH
>  environment variable.
> -The subdirectories to be searched, and their search order,
> -are specified by the
> -.Dq _subdir
> -line in the
> -.Nm
> -configuration file.
>  .It Fl O Ar option Ns = Ns Ar value
>  Comma-separated output options.
>  For each output format, the available options are described in the
> @@ -370,12 +358,6 @@ variable.
>  The format of the path is a colon
>  .Pq Ql \&:
>  separated list of directories.
> -The subdirectories to be searched, as well as their search order,
> -are specified by the
> -.Dq _subdir
> -line in the
> -.Nm
> -configuration file.
>  .It Ev PAGER
>  Specifies the pagination program to use when
>  .Ev MANPAGER



Re: perlpod conversion: crypto.3

2015-09-21 Thread Ingo Schwarze
Hi,

Michael Reed wrote on Sat, Sep 19, 2015 at 05:01:38PM -0400:

> This was done with pod2mdoc

This one was left unprocessed when we started the POD to mdoc
conversion because in OpenBSD, we generally hate manual pages in
the style of string(3) and curses(3).  They tend to be incomplete
and outdated.  Given apropos(1), they are mostly useless.

> + various manual tweaking.

I couldn't find any tweaking; what you sent was exactly the
output of pod2mdoc(1).  Well, you forgot these two options:

  -d Mdocdate -s 3

> Besides the macro changes, there are few differences between the
> original manual's text.  This is done in order to ease review.
> This is the reason why there are many references to non-existent
> manuals, e.g., rc4(3), stack(3), and txt_db(3).
> 
> If wanted, I'll remove the non-existent references.

I tried to figure that out myself but failed, this doesn't look
trivial.

For example, looking just at the first two links:

 * blowfish(3) does exists - not in LibreSSL, but in libc.
 * cast(3) does not exist, but it looks like it's described
   in EVP_EncryptInit(3).  No idea how to deal with that.
 * ...

This needs the attention of a LibreSSL expert (Brent, maybe?)
to update the content.  As it stands, it is very confusing
and probably mostly wrong.

Alternatively, i propose to just delete the page without any
replacement.

Any OKs for deletion?

Yours,
  Ingo


> Index: src/lib/libcrypto/man/Makefile
> ===
> RCS file: /cvs/src/lib/libcrypto/man/Makefile,v
> retrieving revision 1.24
> diff -u -p -r1.24 Makefile
> --- src/lib/libcrypto/man/Makefile17 Sep 2015 14:43:23 -  1.24
> +++ src/lib/libcrypto/man/Makefile19 Sep 2015 20:41:54 -
> @@ -52,6 +52,7 @@ MAN=\
>   BN_swap.3 \
>   BN_zero.3 \
>   BUF_MEM_new.3 \
> + crypto.3 \
>  
>  GENMAN= \
>   CONF_modules_free.3 \
> @@ -170,7 +171,6 @@ GENMAN= \
>   X509_verify_cert.3 \
>   bn.3 \
>   bn_internal.3 \
> - crypto.3 \
>   d2i_ASN1_OBJECT.3 \
>   d2i_DHparams.3 \
>   d2i_DSAPublicKey.3 \
> Index: src/lib/libcrypto/man/crypto.3
> ===
> RCS file: src/lib/libcrypto/man/crypto.3
> diff -N src/lib/libcrypto/man/crypto.3
> --- /dev/null 1 Jan 1970 00:00:00 -
> +++ src/lib/libcrypto/man/crypto.319 Sep 2015 20:41:54 -
> @@ -0,0 +1,94 @@
> +.Dd September 19, 2015
> +.Dt CRYPTO 3
> +.Os
> +.Sh NAME
> +.Nm crypto
> +.Nd OpenSSL cryptographic library
> +.Sh DESCRIPTION
> +The OpenSSL
> +.Nm
> +library implements a wide range of cryptographic algorithms used in various
> +Internet standards.
> +The services provided by this library are used by the OpenSSL implementations
> +of SSL, TLS and S/MIME, and they have also been used to implement SSH,
> +OpenPGP, and other cryptographic standards.
> +.Sh OVERVIEW
> +.Nm libcrypto
> +consists of a number of sub-libraries that implement the individual
> +algorithms.
> +.Pp
> +The functionality includes symmetric encryption, public key cryptography and
> +key agreement, certificate handling, cryptographic hash functions and a
> +cryptographic pseudo-random number generator.
> +.Bl -tag -width 3n
> +.It SYMMETRIC CIPHERS
> +.Xr blowfish 3 ,
> +.Xr cast 3 ,
> +.Xr des 3 ,
> +.Xr idea 3 ,
> +.Xr rc2 3 ,
> +.Xr rc4 3 ,
> +.Xr rc5 3
> +.It PUBLIC KEY CRYPTOGRAPHY AND KEY AGREEMENT
> +.Xr dsa 3 ,
> +.Xr dh 3 ,
> +.Xr rsa 3
> +.It CERTIFICATES
> +.Xr x509 3 ,
> +.Xr x509v3 3
> +.It AUTHENTICATION CODES, HASH FUNCTIONS
> +.Xr hmac 3 ,
> +.Xr md2 3 ,
> +.Xr md4 3 ,
> +.Xr md5 3 ,
> +.Xr ripemd 3 ,
> +.Xr sha 3
> +.It AUXILIARY FUNCTIONS
> +.Xr err 3 ,
> +.Xr threads 3 ,
> +.Xr rand 3 ,
> +.Xr OPENSSL_VERSION_NUMBER 3
> +.It INPUT/OUTPUT, DATA ENCODING
> +.Xr asn1 3 ,
> +.Xr bio 3 ,
> +.Xr evp 3 ,
> +.Xr pem 3 ,
> +.Xr pkcs7 3 ,
> +.Xr pkcs12 3
> +.It INTERNAL FUNCTIONS
> +.Xr bn 3 ,
> +.Xr buffer 3 ,
> +.Xr ec 3 ,
> +.Xr lhash 3 ,
> +.Xr objects 3 ,
> +.Xr stack 3 ,
> +.Xr txt_db 3
> +.El
> +.Sh NOTES
> +Some of the newer functions follow a naming convention using the numbers
> +0 and 1.
> +For example the functions:
> +.Bd -literal
> +.Ft int
> +.Fn X509_CRL_add0_revoked "X509_CRL *crl" "X509_REVOKED *rev"
> +.Ft int
> +.Fn X509_add1_trust_object "X509 *x" "ASN1_OBJECT *obj"
> +.Ed
> +.Pp
> +The 0 version uses the supplied structure pointer directly in the parent and
> +it will be freed up when the parent is freed.
> +In the above example
> +.Fa crl
> +would be freed, but
> +.Fa rev
> +would not.
> +.Pp
> +The 1 version uses a copy of the supplied structure pointer (or in some cases
> +increases its link count) in the parent and so both
> +.Fa x
> +and
> +.Fa obj
> +should be freed up.
> +.Sh SEE ALSO
> +.Xr openssl 1 ,
> +.Xr ssl 3
> Index: src/lib/libssl/src/doc/crypto/crypto.pod
> ===
> RCS file: src/lib/libssl/src/doc/crypto/crypto.pod
> diff -N

Re: [RFC] [PATCH] Implementation of POSIX message queues

2015-09-21 Thread Dimitris Papastamos
Hi everyone,

I had a chance to test this patch more and iron out some bugs.
The main changes from the previous version are:

* Uses pool(9) for allocations smaller than MQ_DEF_MSGSIZE.

* Add poll support.

* Fix a memory leak in domqrecv() that would eventually exhaust
  all available kernel memory.

* Return value of mq_receive() was always 0.  Fix it to return
  the length of the message that was dequeued.

* Small stylistic changes.

* Tune the default limits and add MQ_PRIO_MAX and MQ_OPEN_MAX.

I did some very crude benchmarking on my machine and I could push
about 100k messages per second through a single message queue.

At this point, I can start working on manpages + the necessary
userspace glue.

Is this patch going in the right direction?

Thanks,
Dimitris

>From a4a59e77788b6ac9340c5707b04cd924ab23c923 Mon Sep 17 00:00:00 2001
From: Dimitris Papastamos 
Date: Tue, 15 Sep 2015 16:54:34 +0100
Subject: [PATCH] Initial implementation of mq_*() interfaces

---
 conf/files   |   1 +
 kern/init_main.c |   4 +
 kern/sys_mqueue.c| 746 +++
 kern/syscalls.master |  14 +
 sys/_types.h |   1 +
 sys/file.h   |   1 +
 sys/mqueue.h |  33 +++
 sys/syslimits.h  |   2 +
 sys/types.h  |   1 +
 9 files changed, 803 insertions(+)
 create mode 100644 kern/sys_mqueue.c
 create mode 100644 sys/mqueue.h

diff --git a/conf/files b/conf/files
index 691d7f2..f3d5bfc 100644
--- a/conf/files
+++ b/conf/files
@@ -694,6 +694,7 @@ file kern/subr_prof.c
 file kern/subr_userconf.c  boot_config
 file kern/subr_xxx.c
 file kern/sys_generic.c
+file kern/sys_mqueue.c
 file kern/sys_pipe.c
 file kern/sys_process.cptrace | systrace
 file kern/sys_socket.c
diff --git a/kern/init_main.c b/kern/init_main.c
index e2505ea..cc323d9 100644
--- a/kern/init_main.c
+++ b/kern/init_main.c
@@ -67,6 +67,7 @@
 #ifdef SYSVSEM
 #include 
 #endif
+#include 
 #ifdef SYSVMSG
 #include 
 #endif
@@ -376,6 +377,9 @@ main(void *framep)
seminit();
 #endif
 
+   /* Initialize POSIX message queues. */
+   mqinit();
+
 #ifdef SYSVMSG
/* Initialize System V style message queues. */
msginit();
diff --git a/kern/sys_mqueue.c b/kern/sys_mqueue.c
new file mode 100644
index 000..ddd5d17
--- /dev/null
+++ b/kern/sys_mqueue.c
@@ -0,0 +1,746 @@
+/*
+ * Copyright (c) 2015 Dimitris Papastamos 
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define MQ_NAMELEN (NAME_MAX + 1)
+#define MQ_DEF_MSGSIZE 2048
+#define MQ_MAX_MSGSIZE (8 * MQ_DEF_MSGSIZE)
+#define MQ_DEF_MAXMSG  8
+#define MQ_MAX_MAXMSG  (8 * MQ_DEF_MAXMSG)
+
+/* Stored in mq_flags when message queue is marked for removal. */
+#define MQ_DYING   0x1000
+
+struct mq {
+   char   name[MQ_NAMELEN];/* mqueue name */
+   intoflag;   /* mqueue send/recv access flag */
+   mode_t mode;/* mqueue permissions */
+   struct mq_attr attr;/* mqueue attributes, see below */
+   intrchan;   /* read channel to sleep on */
+   intwchan;   /* write channel to sleep on */
+   uid_t  euid;/* mqueue euid owner */
+   gid_t  egid;/* mqueue egid owner */
+   u_int  refcnt;  /* mqueue reference count */
+#define MQ_RSEL 0x1
+#define MQ_WSEL 0x2
+   intpflag;   /* poll internal flags */
+   struct selinfo rsel;/* for compat with select */
+   struct selinfo wsel;
+   struct rwlock  lock;/* mqueue lock */
+   TAILQ_HEAD(, mq_msg) head;  /* mqueue message list */
+   LIST_ENTRY(mq)   entry; /* link with next mqueue */
+};
+
+struct mq_msg {
+   TAILQ_ENTRY(mq_msg) entry;  /* link with next message */
+   size_t   len;   /* message length */
+   u_intprio;  /* message priority */
+   uint8_t  data[];/* raw message data */
+};
+
+int mqread(struct file *, off_t *, struct uio *, struct

Re: rc.conf.8 should ref rcctl(8)

2015-09-21 Thread Jason McIntyre
On Fri, Sep 18, 2015 at 03:07:03PM -0400, Rob Pierce wrote:
> Reference the rcctl(8) utility in rc.conf.8 (which discusses rc.conf.local).
> 
> Rob
> 

this and the other rcctl patches committed (though tweaked slightly).
thanks,

jmc

> Index: rc.conf.8
> ===
> RCS file: /cvs/src/share/man/man8/rc.conf.8,v
> retrieving revision 1.26
> diff -u -p -r1.26 rc.conf.8
> --- rc.conf.8 4 May 2015 22:29:04 -   1.26
> +++ rc.conf.8 18 Sep 2015 19:06:50 -
> @@ -50,7 +50,9 @@ It is advisable to leave
>  .Nm rc.conf
>  untouched, and instead create and edit a new
>  .Nm rc.conf.local
> -file.
> +file or use the
> +.Xr rcctl 8
> +utility.
>  Since only the last assignment to any variable takes effect,
>  variables set in this file override variables previously set in
>  .Nm rc.conf .
> @@ -219,7 +221,8 @@ amd_master=/etc/amd/master# AMD 'master
>  .Xr init 8 ,
>  .Xr intro 8 ,
>  .Xr rc 8 ,
> -.Xr rc.d 8
> +.Xr rc.d 8 ,
> +.Xr rcctl 8
>  .Sh HISTORY
>  The
>  .Nm
> 



Re: bsd.port.mk.5: Use Xr where appropriate

2015-09-21 Thread Ingo Schwarze
Hi Michael,

committed with minimal tweaks, thanks.
  Ingo


Michael Reed wrote on Sun, Sep 20, 2015 at 03:54:09PM -0400:

> Index: src/share/man/man5/bsd.port.mk.5
> ===
> RCS file: /cvs/src/share/man/man5/bsd.port.mk.5,v
> retrieving revision 1.421
> diff -u -p -r1.421 bsd.port.mk.5
> --- src/share/man/man5/bsd.port.mk.5  20 Sep 2015 18:20:37 -  1.421
> +++ src/share/man/man5/bsd.port.mk.5  20 Sep 2015 19:48:04 -
> @@ -291,10 +291,9 @@ to change behavior.
>  Do not touch
>  .Ar pre-fake
>  unless you really know what you are doing.
> -Described in a separate section below
> -.Po
> -.Qq THE FAKE FRAMEWORK
> -.Pc .
> +See the
> +.Sx THE FAKE FRAMEWORK
> +section below.
>  .It Ar fake-wantlib-args
>  Check
>  .Ev WANTLIB
> @@ -379,8 +378,8 @@ Top-level target, see
>  .It Ar install
>  Install the package after building.
>  See the description of
> -.Qq THE FAKE FRAMEWORK
> -for the non-intuitive details of the way
> +.Sx THE FAKE FRAMEWORK
> +section for the non-intuitive details of the way
>  .Ar {pre,do,post}-install
>  hooks are actually used by the ports tree.
>  .It Ar install-all
> @@ -573,7 +572,7 @@ In
>  .Ev MULTI_PACKAGES
>  setups,
>  see
> -.Qq Flavors and multi-packages .
> +.Sx FLAVORS AND MULTI_PACKAGES .
>  .It Ar print-package-args
>  Print all dependency-related information that will be passed as parameters
>  to
> @@ -885,7 +884,7 @@ In a
>  .Ev MULTI_PACKAGES
>  setup, some variables have settings specific to a given subpackage.
>  See
> -.Qq Flavors and multi-packages .
> +.Sx FLAVORS AND MULTI_PACKAGES .
>  .Bl -tag -width MASTER_SITES
>  .It Ev show
>  Invoked as make show=name, show the contents of ${name}.
> @@ -1005,7 +1004,7 @@ and
>  The actual list of packages that will be built, once architecture problems
>  and pseudo-flavors have been taken into account.
>  See
> -.Qq Flavors and multi-packages .
> +.Sx FLAVORS AND MULTI_PACKAGES .
>  .It Ev BROKEN
>  Define only for broken ports, set to reason the port is broken.
>  See also
> @@ -1584,8 +1583,8 @@ Exposed so that modules may provide thei
>  .Ar do-install .
>  Read-only,
>  see
> -.Qq THE FAKE FRAMEWORK
> -for details.
> +.Sx THE FAKE FRAMEWORK
> +section for details.
>  .It Ev FAKE_TARGET
>  Target built by ${MAKE_PROGRAM} on fake invocation.
>  Defaults to ${INSTALL_TARGET}.
> @@ -2009,7 +2008,7 @@ See
>  .It Ev MULTI_PACKAGES
>  Set to a list of subpackage extensions for ports that create multiple 
> packages.
>  See
> -.Qq Flavors and multi-packages
> +.Sx FLAVORS AND MULTI_PACKAGES
>  below.
>  Especially read the part about
>  .Ev ONLY_FOR_ARCHS
> @@ -2117,7 +2116,7 @@ Can hold both processor-specific informa
>  specific model information (e.g., macppc).
>  This is subpackage dependent.
>  Read the corresponding part of
> -.Qq Flavors and multi-packages
> +.Sx FLAVORS AND MULTI_PACKAGES
>  if some subpackages should only be built on some architectures.
>  .It Ev OSREV
>  Revision number of
> @@ -2272,7 +2271,7 @@ Special arguments to pass to
>  .Xr pkg_create 1 ,
>  in addition to the default ones.
>  For mips64 and pic libraries, see
> -.Qq The generation of package information .
> +.Sx THE GENERATION OF PACKAGE INFORMATION .
>  .It Ev PKG_CREATE
>  User settings.
>  Path to
> @@ -2886,8 +2885,8 @@ Mostly the same as ${PREFIX}, except it 
>  during
>  .Ar fake .
>  Refer to
> -.Qq THE FAKE FRAMEWORK
> -for details.
> +.Sx THE FAKE FRAMEWORK
> +section for details.
>  .It Ev TRY_BROKEN
>  User settings.
>  If set to
> @@ -3407,7 +3406,9 @@ get copied to
>  .Pa ${WRKINST}
>  at the end of
>  .Ar fake
> -(see the FILES section above for details).
> +(see the
> +.Sx FILES
> +section above for details).
>  .Sh FLAVORS AND MULTI_PACKAGES
>  Starting with
>  .Ox 2.7 ,



Re: remove SIGALRM handling from sleep(1)

2015-09-21 Thread Mark Kettenis
> Date: Mon, 21 Sep 2015 01:37:27 -0700
> From: Philip Guenther 
> 
> POSIX no longer requires sleep(1) to exit with status zero when sent 
> SIGALRM:
> 
> 
>   If the sleep utility receives a SIGALRM signal, one of the following 
>   actions shall be taken:
> 
>1. Terminate normally with a zero exit status.
> 
>2. Effectively ignore the signal.
> 
>3. Provide the default behavior for signals described in the
>   ASYNCHRONOUS EVENTS section of Section 1.4 (on page 2310).
>   This could include terminating with a non-zero exit status.
> 
> 
> AFAICT, we don't use SIGALRM in any of our install or rc scripting, so 
> let's remove the unnecessary signal work.
> 
> ok?

Why?  The standard still allows our current behaviour.  And it's not a
particular invasive bit of code.

> Index: bin/sleep/sleep.1
> ===
> RCS file: /data/src/openbsd/src/bin/sleep/sleep.1,v
> retrieving revision 1.21
> diff -u -p -r1.21 sleep.1
> --- bin/sleep/sleep.1 27 May 2014 13:50:52 -  1.21
> +++ bin/sleep/sleep.1 21 Sep 2015 08:32:57 -
> @@ -51,11 +51,6 @@ suspends execution for a minimum of the 
>  This number must be positive and may contain a decimal fraction.
>  .Nm
>  is commonly used to schedule the execution of other commands (see below).
> -.Sh ASYNCHRONOUS EVENTS
> -.Bl -tag -width "SIGALRMXXX"
> -.It Dv SIGALRM
> -Terminate normally, with a zero exit status.
> -.El
>  .Sh EXIT STATUS
>  .Ex -std sleep
>  .Sh EXAMPLES
> Index: bin/sleep/sleep.c
> ===
> RCS file: /data/src/openbsd/src/bin/sleep/sleep.c,v
> retrieving revision 1.20
> diff -u -p -r1.20 sleep.c
> --- bin/sleep/sleep.c 21 Nov 2013 15:54:46 -  1.20
> +++ bin/sleep/sleep.c 21 Sep 2015 08:21:26 -
> @@ -33,7 +33,6 @@
>  #include 
>  #include 
>  #include 
> -#include 
>  #include 
>  #include 
>  #include 
> @@ -42,7 +41,6 @@
>  extern char *__progname;
>  
>  void usage(void);
> -void alarmh(int);
>  
>  int
>  main(int argc, char *argv[])
> @@ -56,8 +54,6 @@ main(int argc, char *argv[])
>  
>   setlocale(LC_ALL, "");
>  
> - signal(SIGALRM, alarmh);
> -
>   while ((ch = getopt(argc, argv, "")) != -1)
>   switch(ch) {
>   default:
> @@ -115,19 +111,4 @@ usage(void)
>  {
>   (void)fprintf(stderr, "usage: %s seconds\n", __progname);
>   exit(1);
> -}
> -
> -/*
> - * POSIX 1003.2 says sleep should exit with 0 return code on reception
> - * of SIGALRM.
> - */
> -/* ARGSUSED */
> -void
> -alarmh(int signo)
> -{
> - /*
> -  * exit() flushes stdio buffers, which is not legal in a signal
> -  * handler. Use _exit().
> -  */
> - _exit(0);
>  }
> 
> 



remove SIGALRM handling from sleep(1)

2015-09-21 Thread Philip Guenther

POSIX no longer requires sleep(1) to exit with status zero when sent 
SIGALRM:


  If the sleep utility receives a SIGALRM signal, one of the following 
  actions shall be taken:

   1. Terminate normally with a zero exit status.

   2. Effectively ignore the signal.

   3. Provide the default behavior for signals described in the
  ASYNCHRONOUS EVENTS section of Section 1.4 (on page 2310).
  This could include terminating with a non-zero exit status.


AFAICT, we don't use SIGALRM in any of our install or rc scripting, so 
let's remove the unnecessary signal work.

ok?

Index: bin/sleep/sleep.1
===
RCS file: /data/src/openbsd/src/bin/sleep/sleep.1,v
retrieving revision 1.21
diff -u -p -r1.21 sleep.1
--- bin/sleep/sleep.1   27 May 2014 13:50:52 -  1.21
+++ bin/sleep/sleep.1   21 Sep 2015 08:32:57 -
@@ -51,11 +51,6 @@ suspends execution for a minimum of the 
 This number must be positive and may contain a decimal fraction.
 .Nm
 is commonly used to schedule the execution of other commands (see below).
-.Sh ASYNCHRONOUS EVENTS
-.Bl -tag -width "SIGALRMXXX"
-.It Dv SIGALRM
-Terminate normally, with a zero exit status.
-.El
 .Sh EXIT STATUS
 .Ex -std sleep
 .Sh EXAMPLES
Index: bin/sleep/sleep.c
===
RCS file: /data/src/openbsd/src/bin/sleep/sleep.c,v
retrieving revision 1.20
diff -u -p -r1.20 sleep.c
--- bin/sleep/sleep.c   21 Nov 2013 15:54:46 -  1.20
+++ bin/sleep/sleep.c   21 Sep 2015 08:21:26 -
@@ -33,7 +33,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -42,7 +41,6 @@
 extern char *__progname;
 
 void usage(void);
-void alarmh(int);
 
 int
 main(int argc, char *argv[])
@@ -56,8 +54,6 @@ main(int argc, char *argv[])
 
setlocale(LC_ALL, "");
 
-   signal(SIGALRM, alarmh);
-
while ((ch = getopt(argc, argv, "")) != -1)
switch(ch) {
default:
@@ -115,19 +111,4 @@ usage(void)
 {
(void)fprintf(stderr, "usage: %s seconds\n", __progname);
exit(1);
-}
-
-/*
- * POSIX 1003.2 says sleep should exit with 0 return code on reception
- * of SIGALRM.
- */
-/* ARGSUSED */
-void
-alarmh(int signo)
-{
-   /*
-* exit() flushes stdio buffers, which is not legal in a signal
-* handler. Use _exit().
-*/
-   _exit(0);
 }



Re: lighter sleep

2015-09-21 Thread Stefan Sperling
On Sun, Sep 20, 2015 at 09:40:05PM -0600, Bob Beck wrote:
> I concur, I don't want to see a plethora of "isnumber"
> "ismaybeanumber" bullshit in the tree that
> do the same thing "isdigit" does.. if for whatever reason we want
> isdigit to be more efficient because
> the most important thing I have to do is make shell sleep more
> efficient, we should fix isdigit, or the locale poo..
> 
> But for sure not introduce non-standard ascii-only replacements into
> all code that do not quite what libc does..
> 
> Jesus ted did you learn nothing from OpenSSL? :)

Just remove the setlocale() call to leave sleep(1) in the default "C" locale.

isdigit() and friends can now be considered ASCII-only.
When we still had latin1 etc. it was possible in theory that values between
128 and 255 represented a digit. But now, isdigit() does the same regardless
of locale setting (C or UTF-8) since it cannot be given a multibyte sequence,
i.e. it will not deal with character values above 127.

The function that parses funny numbers is iswdigit() which gets a wchar_t.
But sleep(1) doesn't need that.



mg(1) - kill-paragraph tidy up

2015-09-21 Thread Mark Lumsden
Hi,

The kill-buffer command in mg doesn't behave quite as I would expect,
if you invoke it multiple times via C-u #, then follow with M-_ (undo)
or C-y (paste), only the last buffer killed (re)appears and not the
multiple paragraphs that I think should. This diff changes that
behaviour. 

Also, by fixing kill-paragraph I had worked out how to mark multiple
paragraphs in one go, so the mark-paragraph command was straight
forward to add in. This diff therefore is doing two things, fixing
kill-paragraph and introducing the mark-paragraph command. I can split
them out if required.  Comments/ok? 

-lum

Index: def.h
===
RCS file: /cvs/src/usr.bin/mg/def.h,v
retrieving revision 1.147
diff -u -p -u -p -r1.147 def.h
--- def.h   3 Jun 2015 23:40:01 -   1.147
+++ def.h   17 Sep 2015 18:44:39 -
@@ -587,6 +587,7 @@ int  fillpara(int, int);
 int killpara(int, int);
 int fillword(int, int);
 int setfillcol(int, int);
+int markpara(int, int);
 
 /* word.c X */
 int backword(int, int);
Index: funmap.c
===
RCS file: /cvs/src/usr.bin/mg/funmap.c,v
retrieving revision 1.49
diff -u -p -u -p -r1.49 funmap.c
--- funmap.c19 Mar 2015 21:22:15 -  1.49
+++ funmap.c17 Sep 2015 18:44:39 -
@@ -132,6 +132,7 @@ static struct funmap functnames[] = {
{localunbind, "local-unset-key",},
{makebkfile, "make-backup-files",},
{makedir, "make-directory",},
+   {markpara, "mark-paragraph",},
{markbuffer, "mark-whole-buffer",},
{do_meta, "meta-key-mode",},/* better name, anyone? */
{negative_argument, "negative-argument",},
Index: keymap.c
===
RCS file: /cvs/src/usr.bin/mg/keymap.c,v
retrieving revision 1.55
diff -u -p -u -p -r1.55 keymap.c
--- keymap.c19 Mar 2015 21:48:05 -  1.55
+++ keymap.c17 Sep 2015 18:44:39 -
@@ -268,7 +268,9 @@ static PF metasqf[] = {
capword,/* c */
delfword,   /* d */
rescan, /* e */
-   forwword/* f */
+   forwword,   /* f */
+   rescan, /* g */
+   markpara/* h */
 };
 
 static PF metal[] = {
@@ -333,7 +335,7 @@ struct KEYMAPE (8) metamap = {
'*', '>', metami, NULL
},
{
-   '[', 'f', metasqf, (KEYMAP *) &metasqlmap
+   '[', 'h', metasqf, (KEYMAP *) &metasqlmap
},
{
'l', '}', metal, NULL
Index: mg.1
===
RCS file: /cvs/src/usr.bin/mg/mg.1,v
retrieving revision 1.91
diff -u -p -u -p -r1.91 mg.1
--- mg.19 Sep 2015 19:03:13 -   1.91
+++ mg.117 Sep 2015 18:44:39 -
@@ -292,6 +292,8 @@ capitalize-word
 kill-word
 .It M-f
 forward-word
+.It M-h
+mark-paragraph
 .It M-l
 downcase-word
 .It M-m
@@ -672,6 +674,8 @@ Unbind a key mapping in the local (topmo
 Toggle generation of backup files.
 .It make-directory
 Prompt the user for a path or directory name which is then created.
+.It mark-paragraph
+Mark the current paragraph.
 .It mark-whole-buffer
 Marks whole buffer as a region by putting dot at the beginning and mark
 at the end of buffer.
Index: paragraph.c
===
RCS file: /cvs/src/usr.bin/mg/paragraph.c,v
retrieving revision 1.36
diff -u -p -u -p -r1.36 paragraph.c
--- paragraph.c 19 Mar 2015 21:22:15 -  1.36
+++ paragraph.c 17 Sep 2015 18:44:39 -
@@ -20,6 +20,9 @@ static intfillcol = 70;
 
 #define MAXWORD 256
 
+static int findpara(void);
+static int do_gotoeop(int, int, int *);
+
 /*
  * Move to start of paragraph.
  * Move backwards by line, checking from the 1st character forwards for the
@@ -70,7 +73,15 @@ gotobop(int f, int n)
 int
 gotoeop(int f, int n)
 {
-   int col, nospace;
+   int i;
+
+   return(do_gotoeop(f, n, &i));
+}
+
+int
+do_gotoeop(int f, int n, int *i)
+{
+   int col, nospace, j = 0;
 
/* the other way... */
if (n < 0)
@@ -78,6 +89,7 @@ gotoeop(int f, int n)
 
/* for each one asked for */
while (n-- > 0) {
+   *i = ++j;
nospace = 0;
while (lforw(curwp->w_dotp) != curbp->b_headp) {
col = 0;
@@ -251,32 +263,82 @@ cleanup:
 int
 killpara(int f, int n)
 {
-   int status, end = FALSE;/* returned status of functions */
+   int lineno, status;
+
+   if (findpara() == FALSE)
+   return (TRUE);
+
+   /* goto beginning of para */
+   (void)gotobop(FFRAND, 1);
 
-   /* for each paragraph to delete */
-   while (n--)