Re: ed(1) man page doesn't mention use of single / and ?

2019-07-06 Thread Jason McIntyre
On Sun, Jul 07, 2019 at 08:07:48AM +0300, cho...@jtan.com wrote:
> ropers writes:
> > Okay, so since nobody else appears to be making any pertinent noise, I
> > guess it falls to me:
> >
> > Index: ed.1
> > ===
> > RCS file: /cvs/src/bin/ed/ed.1,v
> > retrieving revision 1.70
> > diff -u -r1.70 ed.1
> > --- ed.126 Apr 2018 12:18:54 -  1.70
> > +++ ed.16 Jul 2019 21:20:15 -
> > @@ -269,6 +269,9 @@
> >  current line, if necessary.
> >  .Qq //
> >  repeats the last search.
> > +The second slash is optional for a bare search without any suffixed
> > command, i.e.\&
> > +.Qq / Ns Ar re
> > +is sufficient when followed by a newline.
> >  .It Pf ? Ar re ?
> >  The previous line containing the regular expression
> >  .Ar re .
> > @@ -276,6 +279,9 @@
> >  current line, if necessary.
> >  .Qq ??
> >  repeats the last search.
> > +The second question mark is optional for a bare search without any
> > suffixed command, i.e.\&
> > +.Ns Qq ? Ns Ar re
> > +is sufficient when followed by a newline.
> >  .It \&' Ns Ar lc
> >  The line previously marked by a
> >  .Ic k
> >
> > Questions? Comments? Complaints? Secondary trade sanctions?
> 
> Better to be thorough, if this is to be done. The final slash in a 
> substitution is also unnecessary and ed reacts differently depending whether 
> or not it's included. I expect it's the same for the other commands with 
> delimited options.
> 
> Matthew
> 

let's keep this on one mailing list only. since there's a diff, i guess
tech is now fine.

matthew: "ed reacts differently depending whether or not it's included".
can you explain how?

jmc



Re: OpenBSD::Unveil perl module

2019-07-06 Thread Bryan Steele
On Sat, Jul 06, 2019 at 03:27:04PM -0700, Andrew Hewus Fresh wrote:
> I wrote up a tiny unveil(2) wrapper for perl, similar to the pledge(2)
> wrapper we have in tree.  It passes the tests I wrote, but it's entirely
> possible I'm doing something terrible wrong.
> 
> But, I think it could be useful, OK to commit, comments?

I think this is cool, and could be helpful for some perl scripts, same
as OpenBSD::Pledge(3p), perhaps more so.

ok brynet@

> l8rZ,
> -- 
> andrew - http://afresh1.com
> 
> Speed matters.  
> Almost as much as some things, and nowhere near as much as others.
>   -- Nick Holland

> Index: gnu/usr.bin/perl/MANIFEST
> ===
> RCS file: /tmp/perl/cvs/src/gnu/usr.bin/perl/MANIFEST,v
> retrieving revision 1.52
> diff -u -p -u -p -r1.52 MANIFEST
> --- gnu/usr.bin/perl/MANIFEST 24 May 2019 21:33:50 -  1.52
> +++ gnu/usr.bin/perl/MANIFEST 6 Jul 2019 22:00:52 -
> @@ -1558,6 +1558,9 @@ cpan/OpenBSD-MkTemp/t/OpenBSD-MkTemp.t  O
>  cpan/OpenBSD-Pledge/lib/OpenBSD/Pledge.pmOpenBSD::Pledge
>  cpan/OpenBSD-Pledge/Pledge.xsOpenBSD::Pledge
>  cpan/OpenBSD-Pledge/t/OpenBSD-Pledge.t   OpenBSD::Pledge test file
> +cpan/OpenBSD-Unveil/lib/OpenBSD/Unveil.pmOpenBSD::Unveil
> +cpan/OpenBSD-Unveil/t/OpenBSD-Unveil.t   OpenBSD::Unveil test file
> +cpan/OpenBSD-Unveil/Unveil.xsOpenBSD::Unveil
>  cpan/Params-Check/lib/Params/Check.pmParams::Check
>  cpan/Params-Check/t/01_Params-Check.tParams::Check tests
>  cpan/parent/lib/parent.pmEstablish an ISA relationship 
> with base classes at compile time
> Index: gnu/usr.bin/perl/cpan/OpenBSD-Unveil/Unveil.xs
> ===
> RCS file: gnu/usr.bin/perl/cpan/OpenBSD-Unveil/Unveil.xs
> diff -N gnu/usr.bin/perl/cpan/OpenBSD-Unveil/Unveil.xs
> --- /dev/null 1 Jan 1970 00:00:00 -
> +++ gnu/usr.bin/perl/cpan/OpenBSD-Unveil/Unveil.xs6 Jul 2019 22:00:53 
> -
> @@ -0,0 +1,33 @@
> +/*   $OpenBSD$   */
> +
> +/*
> + * Copyright (c) 2019 Andrew Hewus Fresh 
> + *
> + * 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.
> + */
> +
> +#define PERL_NO_GET_CONTEXT
> +#include "EXTERN.h"
> +#include "perl.h"
> +#include "XSUB.h"
> +
> +#include 
> +
> +MODULE = OpenBSD::Unveil PACKAGE = OpenBSD::Unveil
> +
> +int
> +_unveil(const char * path = NULL, const char * permissions = NULL)
> +CODE:
> + RETVAL = unveil(path, permissions) != -1;
> +OUTPUT:
> + RETVAL
> Index: gnu/usr.bin/perl/cpan/OpenBSD-Unveil/lib/OpenBSD/Unveil.pm
> ===
> RCS file: gnu/usr.bin/perl/cpan/OpenBSD-Unveil/lib/OpenBSD/Unveil.pm
> diff -N gnu/usr.bin/perl/cpan/OpenBSD-Unveil/lib/OpenBSD/Unveil.pm
> --- /dev/null 1 Jan 1970 00:00:00 -
> +++ gnu/usr.bin/perl/cpan/OpenBSD-Unveil/lib/OpenBSD/Unveil.pm6 Jul 
> 2019 22:00:53 -
> @@ -0,0 +1,95 @@
> +#$OpenBSD$   #
> +package OpenBSD::Unveil;
> +
> +use 5.028;
> +use strict;
> +use warnings;
> +
> +use Carp;
> +
> +use parent 'Exporter';
> +our %EXPORT_TAGS = ( 'all' => [qw( unveil )] );
> +our @EXPORT_OK   = ( @{ $EXPORT_TAGS{'all'} } );
> +our @EXPORT  = qw( unveil );   ## no critic 
> 'export'
> +
> +our $VERSION = '0.02';
> +
> +require XSLoader;
> +XSLoader::load( 'OpenBSD::Unveil', $VERSION );
> +
> +sub unveil
> +{   ## no critic 'unpack'
> + croak("Usage: OpenBSD::Unveil::unveil([path, permissions])")
> + unless @_ == 0 || @_ == 2; ## no critic 'postfix'
> + return _unveil(@_);
> +}
> +
> +1;
> +
> +## no critic 'pod sections'
> +__END__
> +
> +=head1 NAME
> +
> +OpenBSD::Unveil - Perl interface to OpenBSD unveil(2)
> +
> +=head1 SYNOPSIS
> +
> +  use OpenBSD::Unveil;
> +
> +  my $file = "/usr/share/dict/words";
> +  unveil( $file, "r" ) || die "Unable to unveil: $!";
> +  unveil() || die "Unable to lock unveil: $!";
> +  open my $fh, '<', $file or die "Unable to open $file: $!";
> +
> +  print grep { /unveil/i } readline($fh);
> +  close $fh;
> +
> +
> +=head1 DESCRIPTION
> +
> +This module provides a perl interface to OpenBSD's L 
> L.
> +
> +=head1 EXPORT
> +
> +Exports L by default.
>

Re: ed(1) man page doesn't mention use of single / and ?

2019-07-06 Thread ropers
Second thought, maybe the 'i.e.'s should be changed to 'e.g.'s,
because '/' and '?' also work (instead of '//' and '??',
respectively), so '/re' and '?re' are indeed only examples.

Or maybe this is overdoing it. I don't know. Whatever you all think is
best and most correct. I have no strong personal opinion on this. I'm
just trying to respond to mazocomp's reasonable observation and
suggestion.

Ian

On 07/07/2019, ropers  wrote:
> mazocomp opined:
>> Hi!
>>
>> I am not good at explaining something shortly and clearly to fit into
>> proper documentation, so I'll just describe my experience here.
>>
>> Terminating regular expressions with / or ? is necessary only if they
>> are followed by commands, otherwise the following are legal in both
>> OpenBSD ed, Plan 9 ed and GNU ed:
>> /something
>> /
>> ?
>> g/ing
>>
>> I hope I made life of many ed users easier :)
>
>
>> On Thu, Jul 04, 2019 at 11:47:50PM +0200, ropers wrote:
>>> Do I understand correctly that this is in reference to these parts of
>>> man
>>> 1 ed:
>>>
>>> > /re/
>>> >The next line containing the regular expression re. The search
>>> > wraps
>>> > to the beginning of the buffer and continues down to the current line,
>>> > if necessary. ???//??? repeats the last search.
>>>
>>> > ?re?
>>> >The previous line containing the regular expression re. The search
>>> > wraps to the end of the buffer and continues up to the current line,
>>> > if
>>> > necessary.  repeats the last search.
>>>
>>> and:
>>>
>>> > (1,$)g/re/command-list
>>> >Applies command-list to each of the addressed lines matching a
>>> > regular expression re. The current address is set to the line
>>> > currently
>>> > matched before command-list is executed. At the end of the g command,
>>> > the current address is set to the last line affected by command-list.
>>> > If
>>> > no lines were matched, the current line number remains unchanged.
>>> >
>>> >Each command in command-list must be on a separate line, and every
>>> > line except for the last must be terminated by a backslash (???\???).
>>> > Any commands are allowed, except for g, G, v, and V. A newline alone
>>> > in
>>> > command-list is equivalent to a p command.
>>>
>>>
>>> If yes, then the corresponding parts of ed.1 are:
>>>
>>> 
>>>
>>> and:
>>>
>>> 
>>>
>>> I'm not actually sure how to rewrite that. Would this call for
>>> separate /re, ?re and (1,$)g/re entries, or would it suffice to say
>>> that the second question mark or slash can be omitted if immediately
>>> followed by a newline?
>>>
>>> Does anyone else have any ideas?
>>>
>>> NB: In case people haven't seen it, here's an excellent ed(1)
>>> tutorial: https://sanctum.geek.nz/arabesque/actually-using-ed/
>>> I just thought I'd mention that.
>
>
> Mohamed proffered:
>> To add to Ian's reference. "Ed Mastery" is the only book I know
>> specific to ed(1).
>>
>> Mo
>
>
> Jason McIntyre expounded:
>>
>> hi.
>>
>> if we were going to document it, i'd say it definitely wouldn;t warrant
>> adding separate entries. it would be enough to describe when the / or ?
>> were optional.
>>
>> neither freebsd nor netbsd seemingly document this.
>>
>> posix documents it for /re/ and ?re?, but not g/RE/command-list, like
>> this:
>>
>>  In addition, the second  can be omitted at the end of a
>>  command line.
>>
>> without having tested any of this, i guess we'd want to add such a note
>> to /re/ and ?re?, but not g/RE/command-list. something along the lines
>> of:
>>
>>  The second slash is optional when followed by a newline.
>>
>> you could ping a diff to tech, and see if anyone has any input that
>> could help. if no one does, i'll take it.
>
>
> Okay, so since nobody else appears to be making any pertinent noise, I
> guess it falls to me:
>
> Index: ed.1
> ===
> RCS file: /cvs/src/bin/ed/ed.1,v
> retrieving revision 1.70
> diff -u -r1.70 ed.1
> --- ed.1  26 Apr 2018 12:18:54 -  1.70
> +++ ed.1  6 Jul 2019 21:20:15 -
> @@ -269,6 +269,9 @@
>  current line, if necessary.
>  .Qq //
>  repeats the last search.
> +The second slash is optional for a bare search without any suffixed
> command, i.e.\&
> +.Qq / Ns Ar re
> +is sufficient when followed by a newline.
>  .It Pf ? Ar re ?
>  The previous line containing the regular expression
>  .Ar re .
> @@ -276,6 +279,9 @@
>  current line, if necessary.
>  .Qq ??
>  repeats the last search.
> +The second question mark is optional for a bare search without any
> suffixed command, i.e.\&
> +.Ns Qq ? Ns Ar re
> +is sufficient when followed by a newline.
>  .It \&' Ns Ar lc
>  The line previously marked by a
>  .Ic k
>
> Questions? Comments? Complaints? Secondary trade sanctions?
>
> And no, don't ask me how much of my weekend I wasted figuring out how
> to suppress mandoc's insistence upon two spaces after the 'i.e.' just
> because there's a period at the end of a line. Because *&#%$!!!
> everything about the &"£$" of @~

Re: ed(1) man page doesn't mention use of single / and ?

2019-07-06 Thread ropers
mazocomp opined:
> Hi!
>
> I am not good at explaining something shortly and clearly to fit into
> proper documentation, so I'll just describe my experience here.
>
> Terminating regular expressions with / or ? is necessary only if they
> are followed by commands, otherwise the following are legal in both
> OpenBSD ed, Plan 9 ed and GNU ed:
> /something
> /
> ?
> g/ing
>
> I hope I made life of many ed users easier :)


> On Thu, Jul 04, 2019 at 11:47:50PM +0200, ropers wrote:
>> Do I understand correctly that this is in reference to these parts of man
>> 1 ed:
>>
>> > /re/
>> >The next line containing the regular expression re. The search wraps
>> > to the beginning of the buffer and continues down to the current line,
>> > if necessary. ???//??? repeats the last search.
>>
>> > ?re?
>> >The previous line containing the regular expression re. The search
>> > wraps to the end of the buffer and continues up to the current line, if
>> > necessary.  repeats the last search.
>>
>> and:
>>
>> > (1,$)g/re/command-list
>> >Applies command-list to each of the addressed lines matching a
>> > regular expression re. The current address is set to the line currently
>> > matched before command-list is executed. At the end of the g command,
>> > the current address is set to the last line affected by command-list. If
>> > no lines were matched, the current line number remains unchanged.
>> >
>> >Each command in command-list must be on a separate line, and every
>> > line except for the last must be terminated by a backslash (???\???).
>> > Any commands are allowed, except for g, G, v, and V. A newline alone in
>> > command-list is equivalent to a p command.
>>
>>
>> If yes, then the corresponding parts of ed.1 are:
>>
>> 
>>
>> and:
>>
>> 
>>
>> I'm not actually sure how to rewrite that. Would this call for
>> separate /re, ?re and (1,$)g/re entries, or would it suffice to say
>> that the second question mark or slash can be omitted if immediately
>> followed by a newline?
>>
>> Does anyone else have any ideas?
>>
>> NB: In case people haven't seen it, here's an excellent ed(1)
>> tutorial: https://sanctum.geek.nz/arabesque/actually-using-ed/
>> I just thought I'd mention that.


Mohamed proffered:
> To add to Ian's reference. "Ed Mastery" is the only book I know
> specific to ed(1).
>
> Mo


Jason McIntyre expounded:
>
> hi.
>
> if we were going to document it, i'd say it definitely wouldn;t warrant
> adding separate entries. it would be enough to describe when the / or ?
> were optional.
>
> neither freebsd nor netbsd seemingly document this.
>
> posix documents it for /re/ and ?re?, but not g/RE/command-list, like
> this:
>
>   In addition, the second  can be omitted at the end of a
>   command line.
>
> without having tested any of this, i guess we'd want to add such a note
> to /re/ and ?re?, but not g/RE/command-list. something along the lines
> of:
>
>   The second slash is optional when followed by a newline.
>
> you could ping a diff to tech, and see if anyone has any input that
> could help. if no one does, i'll take it.


Okay, so since nobody else appears to be making any pertinent noise, I
guess it falls to me:

Index: ed.1
===
RCS file: /cvs/src/bin/ed/ed.1,v
retrieving revision 1.70
diff -u -r1.70 ed.1
--- ed.126 Apr 2018 12:18:54 -  1.70
+++ ed.16 Jul 2019 21:20:15 -
@@ -269,6 +269,9 @@
 current line, if necessary.
 .Qq //
 repeats the last search.
+The second slash is optional for a bare search without any suffixed
command, i.e.\&
+.Qq / Ns Ar re
+is sufficient when followed by a newline.
 .It Pf ? Ar re ?
 The previous line containing the regular expression
 .Ar re .
@@ -276,6 +279,9 @@
 current line, if necessary.
 .Qq ??
 repeats the last search.
+The second question mark is optional for a bare search without any
suffixed command, i.e.\&
+.Ns Qq ? Ns Ar re
+is sufficient when followed by a newline.
 .It \&' Ns Ar lc
 The line previously marked by a
 .Ic k

Questions? Comments? Complaints? Secondary trade sanctions?

And no, don't ask me how much of my weekend I wasted figuring out how
to suppress mandoc's insistence upon two spaces after the 'i.e.' just
because there's a period at the end of a line. Because *&#%$!!!
everything about the &"£$" of @~"£$"£ '£$""! Which I'm saying with
love and in the best possible humour of course.

Ian

PS:
Oh, and Mo: At the peril of joking about weak-sauce wedge issues that
were astroturficially whipped up and media-amplified for *divide et
impera* purposes: The Manly McManface Edition of Ed Mastery lends a
whole new meaning to `man ed`.



OpenBSD::Unveil perl module

2019-07-06 Thread Andrew Hewus Fresh
I wrote up a tiny unveil(2) wrapper for perl, similar to the pledge(2)
wrapper we have in tree.  It passes the tests I wrote, but it's entirely
possible I'm doing something terrible wrong.

But, I think it could be useful, OK to commit, comments?

l8rZ,
-- 
andrew - http://afresh1.com

Speed matters.  
Almost as much as some things, and nowhere near as much as others.
  -- Nick Holland
Index: gnu/usr.bin/perl/MANIFEST
===
RCS file: /tmp/perl/cvs/src/gnu/usr.bin/perl/MANIFEST,v
retrieving revision 1.52
diff -u -p -u -p -r1.52 MANIFEST
--- gnu/usr.bin/perl/MANIFEST   24 May 2019 21:33:50 -  1.52
+++ gnu/usr.bin/perl/MANIFEST   6 Jul 2019 22:00:52 -
@@ -1558,6 +1558,9 @@ cpan/OpenBSD-MkTemp/t/OpenBSD-MkTemp.tO
 cpan/OpenBSD-Pledge/lib/OpenBSD/Pledge.pm  OpenBSD::Pledge
 cpan/OpenBSD-Pledge/Pledge.xs  OpenBSD::Pledge
 cpan/OpenBSD-Pledge/t/OpenBSD-Pledge.t OpenBSD::Pledge test file
+cpan/OpenBSD-Unveil/lib/OpenBSD/Unveil.pm  OpenBSD::Unveil
+cpan/OpenBSD-Unveil/t/OpenBSD-Unveil.t OpenBSD::Unveil test file
+cpan/OpenBSD-Unveil/Unveil.xs  OpenBSD::Unveil
 cpan/Params-Check/lib/Params/Check.pm  Params::Check
 cpan/Params-Check/t/01_Params-Check.t  Params::Check tests
 cpan/parent/lib/parent.pm  Establish an ISA relationship 
with base classes at compile time
Index: gnu/usr.bin/perl/cpan/OpenBSD-Unveil/Unveil.xs
===
RCS file: gnu/usr.bin/perl/cpan/OpenBSD-Unveil/Unveil.xs
diff -N gnu/usr.bin/perl/cpan/OpenBSD-Unveil/Unveil.xs
--- /dev/null   1 Jan 1970 00:00:00 -
+++ gnu/usr.bin/perl/cpan/OpenBSD-Unveil/Unveil.xs  6 Jul 2019 22:00:53 
-
@@ -0,0 +1,33 @@
+/* $OpenBSD$   */
+
+/*
+ * Copyright (c) 2019 Andrew Hewus Fresh 
+ *
+ * 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.
+ */
+
+#define PERL_NO_GET_CONTEXT
+#include "EXTERN.h"
+#include "perl.h"
+#include "XSUB.h"
+
+#include 
+
+MODULE = OpenBSD::Unveil   PACKAGE = OpenBSD::Unveil
+
+int
+_unveil(const char * path = NULL, const char * permissions = NULL)
+CODE:
+   RETVAL = unveil(path, permissions) != -1;
+OUTPUT:
+   RETVAL
Index: gnu/usr.bin/perl/cpan/OpenBSD-Unveil/lib/OpenBSD/Unveil.pm
===
RCS file: gnu/usr.bin/perl/cpan/OpenBSD-Unveil/lib/OpenBSD/Unveil.pm
diff -N gnu/usr.bin/perl/cpan/OpenBSD-Unveil/lib/OpenBSD/Unveil.pm
--- /dev/null   1 Jan 1970 00:00:00 -
+++ gnu/usr.bin/perl/cpan/OpenBSD-Unveil/lib/OpenBSD/Unveil.pm  6 Jul 2019 
22:00:53 -
@@ -0,0 +1,95 @@
+#  $OpenBSD$   #
+package OpenBSD::Unveil;
+
+use 5.028;
+use strict;
+use warnings;
+
+use Carp;
+
+use parent 'Exporter';
+our %EXPORT_TAGS = ( 'all' => [qw( unveil )] );
+our @EXPORT_OK   = ( @{ $EXPORT_TAGS{'all'} } );
+our @EXPORT  = qw( unveil );   ## no critic 
'export'
+
+our $VERSION = '0.02';
+
+require XSLoader;
+XSLoader::load( 'OpenBSD::Unveil', $VERSION );
+
+sub unveil
+{   ## no critic 'unpack'
+   croak("Usage: OpenBSD::Unveil::unveil([path, permissions])")
+   unless @_ == 0 || @_ == 2; ## no critic 'postfix'
+   return _unveil(@_);
+}
+
+1;
+
+## no critic 'pod sections'
+__END__
+
+=head1 NAME
+
+OpenBSD::Unveil - Perl interface to OpenBSD unveil(2)
+
+=head1 SYNOPSIS
+
+  use OpenBSD::Unveil;
+
+  my $file = "/usr/share/dict/words";
+  unveil( $file, "r" ) || die "Unable to unveil: $!";
+  unveil() || die "Unable to lock unveil: $!";
+  open my $fh, '<', $file or die "Unable to open $file: $!";
+
+  print grep { /unveil/i } readline($fh);
+  close $fh;
+
+
+=head1 DESCRIPTION
+
+This module provides a perl interface to OpenBSD's L L.
+
+=head1 EXPORT
+
+Exports L by default.
+
+=head1 FUNCTIONS
+
+=head2 unveil
+
+Perl interface to L.
+
+   unveil($paths, $permissions)
+   unveil() # to lock
+
+Returns true on success, returns false and sets $! on failure.
+Throws an exception on incorrect number of parameters.
+
+=head1 SEE ALSO
+
+L
+
+L
+
+=head1 AUTHOR
+
+Andrew Hewus Fresh, Eafre...@openbsd.orge
+
+=head1 LICENSE AND COPYRIGHT
+
+Copyright (C) 2019 by Andrew Hewus Fresh Eafre...@openbsd.orge
+
+Pe

wd: use timeout_add_msec(9)

2019-07-06 Thread Klemens Nanni
In case of errors, wd(4) generally retries transfers after
hz / 2 [ticks] = 500 [ms].

Builds and boots, but (sadly) my PowerBook G4's disk is working fine so
this code has not been triggered.

OK?

Index: dev/ata/wd.c
===
RCS file: /cvs/src/sys/dev/ata/wd.c,v
retrieving revision 1.125
diff -u -p -r1.125 wd.c
--- dev/ata/wd.c30 Dec 2017 23:08:29 -  1.125
+++ dev/ata/wd.c6 Jul 2019 21:42:39 -
@@ -94,7 +94,7 @@
 
 #defineWDIORETRIES_SINGLE 4/* number of retries before 
single-sector */
 #defineWDIORETRIES 5   /* number of retries before giving up */
-#defineRECOVERYTIME hz/2   /* time to wait before retrying a cmd */
+#defineRECOVERYTIME_MSEC 500   /* time to wait before retrying a cmd */
 
 #define DEBUG_INTR   0x01
 #define DEBUG_XFERS  0x02
@@ -555,7 +555,8 @@ retry:
wd->sc_wdc_bio.blkdone, wd->sc_dk.dk_label);
if (wd->retries++ < WDIORETRIES) {
printf(", retrying\n");
-   timeout_add(&wd->sc_restart_timeout, RECOVERYTIME);
+   timeout_add_msec(&wd->sc_restart_timeout,
+   RECOVERYTIME_MSEC);
return;
}
printf("\n");



Re: sparc64 ldomctl(8) fix

2019-07-06 Thread Jan Klemkow
On Sat, Jul 06, 2019 at 12:59:55AM +0200, Mark Kettenis wrote:
> The diff below fixes interction between ldomctl(8) and the firmware on
> a SPARC T4 system that I have access to.  To make sure that this
> doesn't break other machines it would be good if people could test
> this on a few more ldoms-capable sparc64 machines.  To test just build
> ldomctl with this patch, install it and run "ldomctl list":
> 
> # cd /usr/src/usr.sbin/ldomctl
> # make obj
> # make
> # make install
> # ldomctl list

Tested on:
hw.model=SUNW,UltraSPARC-T2 (rev 0.0) @ 1415.103 MHz
hw.product=SUNW,SPARC-Enterprise-T5220

# ldomctl list
factory-default
openbsd [current]

Works fine for me.

bye,
Jan

> Index: usr.sbin/ldomctl/mdstore.c
> ===
> RCS file: /cvs/src/usr.sbin/ldomctl/mdstore.c,v
> retrieving revision 1.8
> diff -u -p -r1.8 mdstore.c
> --- usr.sbin/ldomctl/mdstore.c15 Sep 2018 13:20:16 -  1.8
> +++ usr.sbin/ldomctl/mdstore.c5 Jul 2019 22:54:01 -
> @@ -55,6 +55,7 @@ struct mdstore_msg {
>   uint64_tsvc_handle;
>   uint64_treqnum;
>   uint16_tcommand;
> + uint8_t reserved[6];
>  } __packed;
>  
>  struct mdstore_begin_end_req {
> @@ -104,7 +105,7 @@ struct mdstore_sel_del_req {
>   uint64_tsvc_handle;
>   uint64_treqnum;
>   uint16_tcommand;
> - uint16_treserved;
> + uint8_t reserved[2];
>   uint32_tnamelen;
>   charname[1];
>  } __packed;
>