Re: [patch] -H flag for grep.

2011-02-21 Thread Andres Perera
On Mon, Feb 21, 2011 at 7:01 PM, Philip Guenther  wrote:
> On Mon, Feb 21, 2011 at 2:30 PM, Fred Crowson  wrote:
>> On 02/21/11 15:54, Alexander Schrijver wrote:
> ...
>>> grep(1) only prints the filename when it receives more then 1 filename as
>>> arguments. Thus, when you do this:
>>>
>>> $ find . -name '*.c' -exec grep bla {} \;
>>>
>>> It doesn't print the filename.
>>>
>>> But when you use xargs(1), like Bret suggests it does.
>>
>> $ find . -name "*.php" -exec grep blah {} \; -print
>>
>> Will print the file name after the line that grep matches.
>
> The other classical solution is to always pass multiple filenames by
> including a /dev/null argument:
>
> B  find . -name '*.c' -exec grep bla {} /dev/null \;
>
> That works with the xargs case too:
>
> B find . -name '*.c' -print0 | xargs -0 grep bla /dev/null

these two ugly hacks and the the redundant flag have been sought while
what's natural has been overlooked

find . -name '*.c' -exec awk '/bla/ {print FILENAME $0}'

why complicate grep?

>
>
> Philip Guenther



Re: allow "underruns" on mpii controllers

2011-02-21 Thread David Gwynne
On 22/02/2011, at 3:44 AM, Miod Vallat wrote:

>> we do some scsi ops where we give a device a large buffer and expect
>> it to only fill part of it because we dont know how big that part
>> will be.
>>
>> the underrun handling in mpii always caused this to fail, so devices
>> relying on this didnt work as expected (eg, ses).
>>
>> according to the solaris driver we only get underruns on ok scsi
>> commands, so we dont have to check the NO_SCSI_STATUS bit, we can
>> trust that its ok but with a residual calculation.
>>
>> tests please :)
>
> Are you sure you don't want to /* FALLTHROUGH */ ?

no, because xs->resid will be overwritten.

> It would probably be better to do something like
>
>   set xs->resid
>   if (NO_SCSI_STATUS)
>   xs->status = SCSI_OK;   /* otherwise nonsensical value */
>   /* FALLTHROUGH */
>
> instead.

the solaris code only lets this through if the scsi status was OK. perhaps
this is better reflects that:

case MPII_IOCSTATUS_SCSI_DATA_UNDERRUN:
switch (xs->status) {
case SCSI_OK:
xs->resid = xs->datalen -
letoh32(sie->transfer_count);
break;
default:
xs->error = XS_DRIVER_STUFFUP;
break;
}
break;


>
>> Index: mpii.c
>> ===
>> RCS file: /cvs/src/sys/dev/pci/mpii.c,v
>> retrieving revision 1.38
>> diff -u -p -r1.38 mpii.c
>> --- mpii.c   21 Feb 2011 09:36:15 -  1.38
>> +++ mpii.c   21 Feb 2011 13:03:15 -
>> @@ -4649,11 +4649,7 @@ mpii_scsi_cmd_done(struct mpii_ccb *ccb)
>>  switch (letoh16(sie->ioc_status) & MPII_IOCSTATUS_MASK) {
>>  case MPII_IOCSTATUS_SCSI_DATA_UNDERRUN:
>>  xs->resid = xs->datalen - letoh32(sie->transfer_count);
>> -if (sie->scsi_state & MPII_SCSIIO_ERR_STATE_NO_SCSI_STATUS) {
>> -xs->error = XS_DRIVER_STUFFUP;
>> -break;
>> -}
>> -/* FALLTHROUGH */
>> +break;
>>  case MPII_IOCSTATUS_SUCCESS:
>>  case MPII_IOCSTATUS_SCSI_RECOVERED_ERROR:
>>  switch (xs->status) {



Re: [patch] -H flag for grep.

2011-02-21 Thread Philip Guenther
On Mon, Feb 21, 2011 at 2:30 PM, Fred Crowson  wrote:
> On 02/21/11 15:54, Alexander Schrijver wrote:
...
>> grep(1) only prints the filename when it receives more then 1 filename as
>> arguments. Thus, when you do this:
>>
>> $ find . -name '*.c' -exec grep bla {} \;
>>
>> It doesn't print the filename.
>>
>> But when you use xargs(1), like Bret suggests it does.
>
> $ find . -name "*.php" -exec grep blah {} \; -print
>
> Will print the file name after the line that grep matches.

The other classical solution is to always pass multiple filenames by
including a /dev/null argument:

   find . -name '*.c' -exec grep bla {} /dev/null \;

That works with the xargs case too:

  find . -name '*.c' -print0 | xargs -0 grep bla /dev/null


Philip Guenther



Re: [patch] -H flag for grep.

2011-02-21 Thread Fred Crowson

On 02/21/11 15:54, Alexander Schrijver wrote:

On Mon, Feb 21, 2011 at 01:34:51PM +0100, Pascal Stumpf wrote:

Implement a -H flag for grep, useful for combining e.g. find and grep.


-o used to do this but has been removed. (See the commit logs for the reason, i
forgot it)

grep(1) only prints the filename when it receives more then 1 filename as
arguments. Thus, when you do this:

$ find . -name '*.c' -exec grep bla {} \;

It doesn't print the filename.

But when you use xargs(1), like Bret suggests it does.



$ find . -name "*.php" -exec grep blah {} \; -print

Will print the file name after the line that grep matches.

hth

Fred



Re: [patch] -H flag for grep.

2011-02-21 Thread Ted Unangst
On Mon, Feb 21, 2011 at 3:46 PM, Mark Kettenis 
wrote:
> Also, -H is non-standard AFIK, and we try to avoid adding non-standard
> options to our tools.  Theo has objected to changes like this before.
> So I don't think this should go in without giving him a chance to
> comment.

Yes, but let's be honest.  In the case of grep, there is only one
standard that counts, "what GNU grep does".



Re: [patch] -H flag for grep.

2011-02-21 Thread Pascal Stumpf
On Mon, Feb 21, 2011 at 04:20:24PM -0500, Ted Unangst wrote:
> On Mon, Feb 21, 2011 at 3:46 PM, Mark Kettenis  
> wrote:
> > Also, -H is non-standard AFIK, and we try to avoid adding non-standard
> > options to our tools.  Theo has objected to changes like this before.
> > So I don't think this should go in without giving him a chance to
> > comment.
> 
> Yes, but let's be honest.  In the case of grep, there is only one
> standard that counts, "what GNU grep does".
> 
> 
Well, I kind of disagree. First priority should be to obey POSIX (which
GNU grep violates e.g. by making EREs the default even when given the -G
flag). But concerning everything that goes beyond POSIX, GNU is a
defacto standard.

In this case, there are already a lot of flags not required by POSIX, so
'we don't like non-standard options' can hardly be a valid objection.
The only problem I could come up with is that it changes the previous
meaning of the -H flag on OpenBSD (which was removed exactly because it
was an OpenBSD-only flag).

Concerning ports, I don't see how this could cause problems. Rather, any
script that might use the -H flag should be fixed by this change as they
will rely on GNU behaviour. However, I don't think there are any.

But let Theo decide ... :)



Re: [patch] -H flag for grep.

2011-02-21 Thread Mark Kettenis
> Date: Mon, 21 Feb 2011 14:29:37 -0500
> From: Ted Unangst 
> 
> On Mon, Feb 21, 2011 at 7:34 AM, Pascal Stumpf  wrote:
> > Implement a -H flag for grep, useful for combining e.g. find and grep.
> >
> > Can anyone commit it?
> 
> I think I can do so tonight, unless someone has a serious problem with it.

Yes, I have an issue with this.  The tree is in soft-lock.  Changing
the command line options of a common tool like grep(1) may affect
ports.  That is not acceptable at this point.

Also, -H is non-standard AFIK, and we try to avoid adding non-standard
options to our tools.  Theo has objected to changes like this before.
So I don't think this should go in without giving him a chance to
comment.



Re: [patch] -H flag for grep.

2011-02-21 Thread Ted Unangst
On Mon, Feb 21, 2011 at 7:34 AM, Pascal Stumpf  wrote:
> Implement a -H flag for grep, useful for combining e.g. find and grep.
>
> Can anyone commit it?

I think I can do so tonight, unless someone has a serious problem with it.



Compresores

2011-02-21 Thread TBX
$ 
660 Pesos


  

  
   
 
  
 
   

  


  

 
  
 
   
 Mini 
  Compresor Con Pistola de Pintar
  


 
   
 
  Mini Compresor ideal 
para todo tipo de usos , principalmente para el
pintado 
con cualquier tipo de pinturas , esmaltes ,
imprimaciones 
, latex , sinteticos , barniz , provisto con
pistolade 
pintar que le permite pintar paredes , muebles,
automoviles 
, rejas , artensanias
  

  

  


  




   
 
  
 
   
  $ 
450 Pesos


  

  
   
 
  
 
   

  


  

 
  
 
   
 Compresor 
  2 HP 24 lts
  


 
   
 
  Peso: 24 Kg / Potencia 
2 HP / Presión 125 lbs / Rendimiento 200
L/m 
/ Tanque 324 lts / Velocidad 2800 rpm /
Compresor 
de mando directo / Cabezal tipo FINI

  

  


  


   
 
  
 
   
  $ 
590 Pesos


  

  
   
 
  
 
   

  


  

 
  
 
   
 Compresor 
  de aire 2,5 HP 50 lts
  


 
   Compresor 
de aire 2,5 HP 50 Lts / Compresor de alta
recuperacion 
/ Ideal para usar con pistolas de Pintar y
herramientas 
neumaticas. / Potencia 2,5HP / Presión 125
lbs
Tanque 50 lts / Caudal 366 l/min 

  

  



   
 
  
 
   
  $ 
1100 Pesos

  


  
   
 
  
 
   

  

  


 
  
 
   
 Compresor 
  de aire 2,5 HP 100 lts
  

 
   
 
  Compresor de aire 2 
HP 100 Lts/ Potencia 2,5 HP / Presión 125
lbs 
/ Tanque 100lts / Admisión de aire 206
l/min



Re: [patch] -H flag for grep.

2011-02-21 Thread Dan Harnett
On Mon, Feb 21, 2011 at 04:54:40PM +0100, Alexander Schrijver wrote:
> On Mon, Feb 21, 2011 at 01:34:51PM +0100, Pascal Stumpf wrote:
> grep(1) only prints the filename when it receives more then 1 filename as
> arguments. Thus, when you do this:
> 
> $ find . -name '*.c' -exec grep bla {} \;
> 
> It doesn't print the filename.

grep will always print the filename if you specify the -R flag.  It's
more of a side effect, though.  Also, you'd probably want to specify
'-type f' to avoid recursing through a directory.

  $ find . -type f -name '*.c' -exec grep -R blah {} \;



Re: [patch] -H flag for grep.

2011-02-21 Thread Todd C. Miller
On Mon, 21 Feb 2011 13:34:51 +0100, Pascal Stumpf wrote:

> Implement a -H flag for grep, useful for combining e.g. find and grep.

Seems reasonable to me given that GNU grep implements -H and we
already have the -h flag.

 - todd



Re: allow "underruns" on mpii controllers

2011-02-21 Thread Miod Vallat
> we do some scsi ops where we give a device a large buffer and expect
> it to only fill part of it because we dont know how big that part
> will be.
> 
> the underrun handling in mpii always caused this to fail, so devices
> relying on this didnt work as expected (eg, ses).
> 
> according to the solaris driver we only get underruns on ok scsi
> commands, so we dont have to check the NO_SCSI_STATUS bit, we can
> trust that its ok but with a residual calculation.
> 
> tests please :)

Are you sure you don't want to /* FALLTHROUGH */ ?

It would probably be better to do something like

set xs->resid
if (NO_SCSI_STATUS)
xs->status = SCSI_OK;   /* otherwise nonsensical value */
/* FALLTHROUGH */

instead.

> Index: mpii.c
> ===
> RCS file: /cvs/src/sys/dev/pci/mpii.c,v
> retrieving revision 1.38
> diff -u -p -r1.38 mpii.c
> --- mpii.c21 Feb 2011 09:36:15 -  1.38
> +++ mpii.c21 Feb 2011 13:03:15 -
> @@ -4649,11 +4649,7 @@ mpii_scsi_cmd_done(struct mpii_ccb *ccb)
>   switch (letoh16(sie->ioc_status) & MPII_IOCSTATUS_MASK) {
>   case MPII_IOCSTATUS_SCSI_DATA_UNDERRUN:
>   xs->resid = xs->datalen - letoh32(sie->transfer_count);
> - if (sie->scsi_state & MPII_SCSIIO_ERR_STATE_NO_SCSI_STATUS) {
> - xs->error = XS_DRIVER_STUFFUP;
> - break;
> - }
> - /* FALLTHROUGH */
> + break;
>   case MPII_IOCSTATUS_SUCCESS:
>   case MPII_IOCSTATUS_SCSI_RECOVERED_ERROR:
>   switch (xs->status) {



Re: [patch] -H flag for grep.

2011-02-21 Thread Pascal Stumpf
On Mon, Feb 21, 2011 at 04:54:40PM +0100, Alexander Schrijver wrote:
> On Mon, Feb 21, 2011 at 01:34:51PM +0100, Pascal Stumpf wrote:
> > Implement a -H flag for grep, useful for combining e.g. find and grep.
> 
> -o used to do this but has been removed. (See the commit logs for the reason, 
> i
> forgot it)
Because it's neither POSIX nor GNU behaviour. -H is the same flag GNU
grep uses.

> grep(1) only prints the filename when it receives more then 1 filename as
> arguments. Thus, when you do this:
> 
> $ find . -name '*.c' -exec grep bla {} \;
> 
> It doesn't print the filename.
> 
> But when you use xargs(1), like Bret suggests it does.
> 
> 
I know, but given this is such an easy change, I don't really see a
reason why one shouldn't be able to use grep in an -exec statement.

Plus, it provides compatibility with scripts that use it (although one
shouldn't).



Re: [patch] -H flag for grep.

2011-02-21 Thread Alexander Schrijver
On Mon, Feb 21, 2011 at 05:05:56PM +0100, Paul de Weerd wrote:
> It does not when there's only one file matching the find-experssion
> (which is unclear when using find | xargs grep).
> 
> [weerd@despair] $ find . -name pi.c
> ./pi.c
> [weerd@despair] $ find . -name pi.c | xargs grep main
> main(int argc, char *argv[]) {
> 

Yes, i think there is another exception when you accidently hit the maximum
number + 1 of arguments for one invocation, by default 5001 files then xargs
would execute:

grep main <5000 files>

and the last file as: grep main  (and thus not printing the filename)



Sony y Panasonic Digitales

2011-02-21 Thread DigitalesNet
USD495   Sony   
  DSC-HX1  Cámara  digital compacta,
visor electrónico / Sensor  CMOS
Exmor de 9,10 MP efectivos / Objetivo (en 
35 mm) 28,0 - 560,0 mm / Zoom 20x (óptico)   
  / Soportes compatibles MemoryStick Duo, MemoryStick   
  Pro Duo, MemoryStick Pro-HG Duo / Pantalla TFT
 de 3,00 pulgadas   USD399  
Sony  DSC-H5V  Cámara
 digital compacta, sin visor / Sensor CMOS Exmor
 R de 10,20 MP efectivos / Objetivo (en 35 mm)  
   25,0 - 250,0 mm / Zoom 10x (óptico) / Soportes
 compatibles SD Card, MemoryStick Duo,
MemoryStick  Pro Duo, SDHC, MemoryStick
Pro-HG Duo, MemoryStick  Pro Duo High Speed
/ Pantalla TFT de 3,00 pulgadas Panasonic FZ100   USD   
  590 Panasonic FZ35  USD  395
Panasonic TZ10/ZS7  USD  369 Panasonic
TZ8/ZS5  USD  299



Re: [patch] -H flag for grep.

2011-02-21 Thread Paul de Weerd
On Mon, Feb 21, 2011 at 04:54:40PM +0100, Alexander Schrijver wrote:
| On Mon, Feb 21, 2011 at 01:34:51PM +0100, Pascal Stumpf wrote:
| > Implement a -H flag for grep, useful for combining e.g. find and grep.
| 
| -o used to do this but has been removed. (See the commit logs for the reason, 
i
| forgot it)
| 
| grep(1) only prints the filename when it receives more then 1 filename as
| arguments. Thus, when you do this:
| 
| $ find . -name '*.c' -exec grep bla {} \;
| 
| It doesn't print the filename.
| 
| But when you use xargs(1), like Bret suggests it does.

It does not when there's only one file matching the find-experssion
(which is unclear when using find | xargs grep).

[weerd@despair] $ find . -name pi.c
./pi.c
[weerd@despair] $ find . -name pi.c | xargs grep main
main(int argc, char *argv[]) {

Paul 'WEiRD' de Weerd

-- 
>[<++>-]<+++.>+++[<-->-]<.>+++[<+
+++>-]<.>++[<>-]<+.--.[-]
 http://www.weirdnet.nl/ 



Re: [patch] -H flag for grep.

2011-02-21 Thread Alexander Schrijver
On Mon, Feb 21, 2011 at 01:34:51PM +0100, Pascal Stumpf wrote:
> Implement a -H flag for grep, useful for combining e.g. find and grep.

-o used to do this but has been removed. (See the commit logs for the reason, i
forgot it)

grep(1) only prints the filename when it receives more then 1 filename as
arguments. Thus, when you do this:

$ find . -name '*.c' -exec grep bla {} \;

It doesn't print the filename.

But when you use xargs(1), like Bret suggests it does.



Re: allow "underruns" on mpii controllers

2011-02-21 Thread Kenneth R Westerback
On Mon, Feb 21, 2011 at 11:05:40PM +1000, David Gwynne wrote:
> we do some scsi ops where we give a device a large buffer and expect
> it to only fill part of it because we dont know how big that part
> will be.
> 
> the underrun handling in mpii always caused this to fail, so devices
> relying on this didnt work as expected (eg, ses).
> 
> according to the solaris driver we only get underruns on ok scsi
> commands, so we dont have to check the NO_SCSI_STATUS bit, we can
> trust that its ok but with a residual calculation.
> 
> tests please :)
> 
> Index: mpii.c
> ===
> RCS file: /cvs/src/sys/dev/pci/mpii.c,v
> retrieving revision 1.38
> diff -u -p -r1.38 mpii.c
> --- mpii.c21 Feb 2011 09:36:15 -  1.38
> +++ mpii.c21 Feb 2011 13:03:15 -
> @@ -4649,11 +4649,7 @@ mpii_scsi_cmd_done(struct mpii_ccb *ccb)
>   switch (letoh16(sie->ioc_status) & MPII_IOCSTATUS_MASK) {
>   case MPII_IOCSTATUS_SCSI_DATA_UNDERRUN:
>   xs->resid = xs->datalen - letoh32(sie->transfer_count);
> - if (sie->scsi_state & MPII_SCSIIO_ERR_STATE_NO_SCSI_STATUS) {
> - xs->error = XS_DRIVER_STUFFUP;
> - break;
> - }
> - /* FALLTHROUGH */
> + break;
>   case MPII_IOCSTATUS_SUCCESS:
>   case MPII_IOCSTATUS_SCSI_RECOVERED_ERROR:
>   switch (xs->status) {
> 

Makes sense to me.

 Ken



Re: [patch] -H flag for grep.

2011-02-21 Thread Bret Lambert
find / -name my\*balls | xargs grep -e batman -e robocop

On Mon, Feb 21, 2011 at 1:34 PM, Pascal Stumpf 
wrote:
> Implement a -H flag for grep, useful for combining e.g. find and grep.
>
> Can anyone commit it?
>
> Index: grep.1
> ===
> RCS file: /cvs/src/usr.bin/grep/grep.1,v
> retrieving revision 1.39
> diff -u -r1.39 grep.1
> --- grep.1  3 Sep 2010 11:09:28 -   1.39
> +++ grep.1  21 Feb 2011 12:29:41 -
> @@ -38,7 +38,7 @@
>  .Sh SYNOPSIS
>  .Nm grep
>  .Bk -words
> -.Op Fl abcEFGhIiLlnqRsUVvwxZ
> +.Op Fl abcEFGHhIiLlnqRsUVvwxZ
>  .Op Fl A Ar num
>  .Op Fl B Ar num
>  .Op Fl C Ns Op Ar num
> @@ -184,6 +184,10 @@
>  .Nm grep
>  to behave as traditional
>  .Nm grep ) .
> +.It Fl H
> +Always print filename headers
> +.Pq i.e. filenames
> +with output lines.
>  .It Fl h
>  Never print filename headers
>  .Pq i.e. filenames
> @@ -349,7 +353,7 @@
>  specification.
>  .Pp
>  The flags
> -.Op Fl AaBbCGhILRUVwZ
> +.Op Fl AaBbCGHhILRUVwZ
>  are extensions to that specification, and the behaviour of the
>  .Fl f
>  flag when used with an empty pattern file is left undefined.
> Index: grep.c
> ===
> RCS file: /cvs/src/usr.bin/grep/grep.c,v
> retrieving revision 1.42
> diff -u -r1.42 grep.c
> --- grep.c  2 Jul 2010 22:18:03 -   1.42
> +++ grep.c  21 Feb 2011 12:29:41 -
> @@ -62,6 +62,7 @@
>  int Eflag; /* -E: interpret pattern as extended regexp */
>  int Fflag; /* -F: interpret pattern as list of fixed strings
*/
>  int Gflag; /* -G: interpret pattern as basic regexp */
> +int Hflag; /* -H: always print filename header */
>  int Lflag; /* -L: only show names of files with no matches */
>  int Rflag; /* -R: recursively search directory trees */
>  #ifndef NOZ
> @@ -106,9 +107,9 @@
>  {
>fprintf(stderr,
>  #ifdef NOZ
> -   "usage: %s [-abcEFGhIiLlnqRsUVvwx] [-A num] [-B num]
[-C[num]]\n"
> +   "usage: %s [-abcEFGHhIiLlnqRsUVvwx] [-A num] [-B num]
[-C[num]]\n"
>  #else
> -   "usage: %s [-abcEFGhIiLlnqRsUVvwxZ] [-A num] [-B num]
[-C[num]]\n"
> +   "usage: %s [-abcEFGHhIiLlnqRsUVvwxZ] [-A num] [-B num]
[-C[num]]\n"
>  #endif
>"\t[-e pattern] [-f file] [--binary-files=value]
[--context[=num]]\n"
>"\t[--line-buffered] [pattern] [file ...]\n", __progname);
> @@ -116,9 +117,9 @@
>  }
>
>  #ifdef NOZ
> -static char *optstr = "0123456789A:B:CEFGILRUVabce:f:hilnqrsuvwxy";
> +static char *optstr = "0123456789A:B:CEFGHILRUVabce:f:hilnqrsuvwxy";
>  #else
> -static char *optstr = "0123456789A:B:CEFGILRUVZabce:f:hilnqrsuvwxy";
> +static char *optstr = "0123456789A:B:CEFGHILRUVZabce:f:hilnqrsuvwxy";
>  #endif
>
>  struct option long_options[] =
> @@ -134,6 +135,7 @@
>{"extended-regexp", no_argument,NULL, 'E'},
>{"fixed-strings",   no_argument,NULL, 'F'},
>{"basic-regexp",no_argument,NULL, 'G'},
> +   {"with-filename",   no_argument,NULL, 'H'},
>{"binary",  no_argument,NULL, 'U'},
>{"version", no_argument,NULL, 'V'},
>{"text",no_argument,NULL, 'a'},
> @@ -315,6 +317,9 @@
>Eflag = Fflag = 0;
>Gflag++;
>break;
> +   case 'H':
> +   Hflag++;
> +   break;
>case 'I':
>binbehave = BIN_FILE_SKIP;
>break;
> @@ -476,7 +481,7 @@
>if (lbflag)
>setlinebuf(stdout);
>
> -   if ((argc == 0 || argc == 1) && !Rflag)
> +   if ((argc == 0 || argc == 1) && !Rflag && !Hflag)
>hflag = 1;
>
>if (argc == 0)
> Index: grep.h
> ===
> RCS file: /cvs/src/usr.bin/grep/grep.h,v
> retrieving revision 1.15
> diff -u -r1.15 grep.h
> --- grep.h  5 Apr 2010 03:03:55 -   1.15
> +++ grep.h  21 Feb 2011 12:29:41 -
> @@ -63,7 +63,7 @@
>  extern int  cflags, eflags;
>
>  /* Command line flags */
> -extern int  Aflag, Bflag, Eflag, Fflag, Gflag, Lflag,
> +extern int  Aflag, Bflag, Eflag, Fflag, Gflag, Hflag, Lflag,
> Rflag, Zflag,
> bflag, cflag, hflag, iflag, lflag, nflag, qflag, sflag,
> vflag, wflag, xflag;



allow "underruns" on mpii controllers

2011-02-21 Thread David Gwynne
we do some scsi ops where we give a device a large buffer and expect
it to only fill part of it because we dont know how big that part
will be.

the underrun handling in mpii always caused this to fail, so devices
relying on this didnt work as expected (eg, ses).

according to the solaris driver we only get underruns on ok scsi
commands, so we dont have to check the NO_SCSI_STATUS bit, we can
trust that its ok but with a residual calculation.

tests please :)

Index: mpii.c
===
RCS file: /cvs/src/sys/dev/pci/mpii.c,v
retrieving revision 1.38
diff -u -p -r1.38 mpii.c
--- mpii.c  21 Feb 2011 09:36:15 -  1.38
+++ mpii.c  21 Feb 2011 13:03:15 -
@@ -4649,11 +4649,7 @@ mpii_scsi_cmd_done(struct mpii_ccb *ccb)
switch (letoh16(sie->ioc_status) & MPII_IOCSTATUS_MASK) {
case MPII_IOCSTATUS_SCSI_DATA_UNDERRUN:
xs->resid = xs->datalen - letoh32(sie->transfer_count);
-   if (sie->scsi_state & MPII_SCSIIO_ERR_STATE_NO_SCSI_STATUS) {
-   xs->error = XS_DRIVER_STUFFUP;
-   break;
-   }
-   /* FALLTHROUGH */
+   break;
case MPII_IOCSTATUS_SUCCESS:
case MPII_IOCSTATUS_SCSI_RECOVERED_ERROR:
switch (xs->status) {



Re: [patch] -H flag for grep.

2011-02-21 Thread Pascal Stumpf
On Mon, Feb 21, 2011 at 01:38:41PM +0100, Bret Lambert wrote:
> find / -name my\*balls | xargs grep -e batman -e robocop
> 
Lol. I donbt have CVS access. ;)



[patch] -H flag for grep.

2011-02-21 Thread Pascal Stumpf
Implement a -H flag for grep, useful for combining e.g. find and grep.

Can anyone commit it?

Index: grep.1
===
RCS file: /cvs/src/usr.bin/grep/grep.1,v
retrieving revision 1.39
diff -u -r1.39 grep.1
--- grep.1  3 Sep 2010 11:09:28 -   1.39
+++ grep.1  21 Feb 2011 12:29:41 -
@@ -38,7 +38,7 @@
 .Sh SYNOPSIS
 .Nm grep
 .Bk -words
-.Op Fl abcEFGhIiLlnqRsUVvwxZ
+.Op Fl abcEFGHhIiLlnqRsUVvwxZ
 .Op Fl A Ar num
 .Op Fl B Ar num
 .Op Fl C Ns Op Ar num
@@ -184,6 +184,10 @@
 .Nm grep
 to behave as traditional
 .Nm grep ) .
+.It Fl H
+Always print filename headers
+.Pq i.e. filenames
+with output lines.
 .It Fl h
 Never print filename headers
 .Pq i.e. filenames
@@ -349,7 +353,7 @@
 specification.
 .Pp
 The flags
-.Op Fl AaBbCGhILRUVwZ
+.Op Fl AaBbCGHhILRUVwZ
 are extensions to that specification, and the behaviour of the
 .Fl f
 flag when used with an empty pattern file is left undefined.
Index: grep.c
===
RCS file: /cvs/src/usr.bin/grep/grep.c,v
retrieving revision 1.42
diff -u -r1.42 grep.c
--- grep.c  2 Jul 2010 22:18:03 -   1.42
+++ grep.c  21 Feb 2011 12:29:41 -
@@ -62,6 +62,7 @@
 int Eflag; /* -E: interpret pattern as extended regexp */
 int Fflag; /* -F: interpret pattern as list of fixed strings */
 int Gflag; /* -G: interpret pattern as basic regexp */
+int Hflag; /* -H: always print filename header */
 int Lflag; /* -L: only show names of files with no matches */
 int Rflag; /* -R: recursively search directory trees */
 #ifndef NOZ
@@ -106,9 +107,9 @@
 {
fprintf(stderr,
 #ifdef NOZ
-   "usage: %s [-abcEFGhIiLlnqRsUVvwx] [-A num] [-B num] [-C[num]]\n"
+   "usage: %s [-abcEFGHhIiLlnqRsUVvwx] [-A num] [-B num] [-C[num]]\n"
 #else
-   "usage: %s [-abcEFGhIiLlnqRsUVvwxZ] [-A num] [-B num] [-C[num]]\n"
+   "usage: %s [-abcEFGHhIiLlnqRsUVvwxZ] [-A num] [-B num] [-C[num]]\n"
 #endif
"\t[-e pattern] [-f file] [--binary-files=value] 
[--context[=num]]\n"
"\t[--line-buffered] [pattern] [file ...]\n", __progname);
@@ -116,9 +117,9 @@
 }
 
 #ifdef NOZ
-static char *optstr = "0123456789A:B:CEFGILRUVabce:f:hilnqrsuvwxy";
+static char *optstr = "0123456789A:B:CEFGHILRUVabce:f:hilnqrsuvwxy";
 #else
-static char *optstr = "0123456789A:B:CEFGILRUVZabce:f:hilnqrsuvwxy";
+static char *optstr = "0123456789A:B:CEFGHILRUVZabce:f:hilnqrsuvwxy";
 #endif
 
 struct option long_options[] =
@@ -134,6 +135,7 @@
{"extended-regexp", no_argument,NULL, 'E'},
{"fixed-strings",   no_argument,NULL, 'F'},
{"basic-regexp",no_argument,NULL, 'G'},
+   {"with-filename",   no_argument,NULL, 'H'},
{"binary",  no_argument,NULL, 'U'},
{"version", no_argument,NULL, 'V'},
{"text",no_argument,NULL, 'a'},
@@ -315,6 +317,9 @@
Eflag = Fflag = 0;
Gflag++;
break;
+   case 'H':
+   Hflag++;
+   break;
case 'I':
binbehave = BIN_FILE_SKIP;
break;
@@ -476,7 +481,7 @@
if (lbflag)
setlinebuf(stdout);
 
-   if ((argc == 0 || argc == 1) && !Rflag)
+   if ((argc == 0 || argc == 1) && !Rflag && !Hflag)
hflag = 1;
 
if (argc == 0)
Index: grep.h
===
RCS file: /cvs/src/usr.bin/grep/grep.h,v
retrieving revision 1.15
diff -u -r1.15 grep.h
--- grep.h  5 Apr 2010 03:03:55 -   1.15
+++ grep.h  21 Feb 2011 12:29:41 -
@@ -63,7 +63,7 @@
 extern int  cflags, eflags;
 
 /* Command line flags */
-extern int  Aflag, Bflag, Eflag, Fflag, Gflag, Lflag,
+extern int  Aflag, Bflag, Eflag, Fflag, Gflag, Hflag, Lflag,
 Rflag, Zflag,
 bflag, cflag, hflag, iflag, lflag, nflag, qflag, sflag,
 vflag, wflag, xflag;



Re: 3 small net80211 fixes

2011-02-21 Thread Stefan Sperling
On Mon, Feb 21, 2011 at 12:57:08PM +0100, Damien Bergamini wrote:
> | Index: ieee80211_pae_output.c
> | ===
> | RCS file: /cvs/src/sys/net80211/ieee80211_pae_output.c,v
> | retrieving revision 1.16
> | diff -u -p -r1.16 ieee80211_pae_output.c
> | --- ieee80211_pae_output.c  5 Jun 2010 15:54:35 -   1.16
> | +++ ieee80211_pae_output.c  20 Feb 2011 17:55:51 -
> | @@ -417,7 +417,6 @@ ieee80211_send_4way_msg3(struct ieee8021
> | frm = ieee80211_add_rsn(frm, ic, ic->ic_bss);
> | /* encapsulate the GTK */
> | frm = ieee80211_add_gtk_kde(frm, ni, k);
> | -   LE_WRITE_6(key->rsc, k->k_tsc);
> | /* encapsulate the IGTK if MFP was negotiated */
> | if (ni->ni_flags & IEEE80211_NODE_MFP) {
> | frm = ieee80211_add_igtk_kde(frm,
> | @@ -427,6 +426,9 @@ ieee80211_send_4way_msg3(struct ieee8021
> | info |= EAPOL_KEY_ENCRYPTED | EAPOL_KEY_SECURE;
> | } else  /* WPA */
> | frm = ieee80211_add_wpa(frm, ic, ic->ic_bss);
> | +
> | +   /* RSC = last transmit sequence number for the GTK */
> | +   LE_WRITE_6(key->rsc, k->k_tsc);
> |  
> | /* write the key info field */
> | BE_WRITE_2(key->info, info);
> 
> 
> nack.  you'll get a null deref with wpa1 (k is not initialized).
> with wpa1, message 3/4 of the 4-way handshake does not carry the
> group key (it is sent in message 1/2 of the group key handshake
> that follows the 4-way handshake instead).
> the TSC of the pairwise key is always 0 in our case, which is
> the reason why it is not set here, but used when receiving
> msg 3/4 since other implementations may use non-zero values.

Ah, that makes sense. Thanks for clarifying.

I'll commit the others when Miod has acked them.



Re: 3 small net80211 fixes

2011-02-21 Thread Damien Bergamini
| Index: ieee80211_input.c
| ===
| RCS file: /cvs/src/sys/net80211/ieee80211_input.c,v
| retrieving revision 1.116
| diff -u -p -r1.116 ieee80211_input.c
| --- ieee80211_input.c 7 Jun 2010 16:51:22 -   1.116
| +++ ieee80211_input.c 20 Feb 2011 19:51:24 -
| @@ -789,7 +789,7 @@ ieee80211_deliver_data(struct ieee80211c
|   int error, len;
|  
|   if (ETHER_IS_MULTICAST(eh->ether_dhost)) {
| - m1 = m_copym(m, 0, M_COPYALL, M_DONTWAIT);
| + m1 = m_copym2(m, 0, M_COPYALL, M_DONTWAIT);
|   if (m1 == NULL)
|   ifp->if_oerrors++;
|   else

ok


| This one I'm not entirely sure about.
| But the code that receives the 3/4 message seems to expect an RSC for
| both the RSN and WPA cases. Also, this makes the code match up with
| how it's done in ieee80211_send_group_msg1().
| 
| I spotted this one trying to hunt down a phantom bug with replay
| counter
| handling (which in fact seems to be fine).
| On the client side, netstat -W shows TKIP replays for every broadcast
| packet
| sent from the hostap to the station (both running -current).
| Is anyone else seeing this? There might be some driver/hardware
| problem with
| ath(4) that causes the AP to send duplicate frames. Or signal
| reflection
| issues? I tried with both wpi(4) and ral(4) cards on the client side.
| I've given up on trying to fix this, but the diff below felt worth
| keeping.
| 
| Index: ieee80211_pae_output.c
| ===
| RCS file: /cvs/src/sys/net80211/ieee80211_pae_output.c,v
| retrieving revision 1.16
| diff -u -p -r1.16 ieee80211_pae_output.c
| --- ieee80211_pae_output.c5 Jun 2010 15:54:35 -   1.16
| +++ ieee80211_pae_output.c20 Feb 2011 17:55:51 -
| @@ -417,7 +417,6 @@ ieee80211_send_4way_msg3(struct ieee8021
|   frm = ieee80211_add_rsn(frm, ic, ic->ic_bss);
|   /* encapsulate the GTK */
|   frm = ieee80211_add_gtk_kde(frm, ni, k);
| - LE_WRITE_6(key->rsc, k->k_tsc);
|   /* encapsulate the IGTK if MFP was negotiated */
|   if (ni->ni_flags & IEEE80211_NODE_MFP) {
|   frm = ieee80211_add_igtk_kde(frm,
| @@ -427,6 +426,9 @@ ieee80211_send_4way_msg3(struct ieee8021
|   info |= EAPOL_KEY_ENCRYPTED | EAPOL_KEY_SECURE;
|   } else  /* WPA */
|   frm = ieee80211_add_wpa(frm, ic, ic->ic_bss);
| +
| + /* RSC = last transmit sequence number for the GTK */
| + LE_WRITE_6(key->rsc, k->k_tsc);
|  
|   /* write the key info field */
|   BE_WRITE_2(key->info, info);


nack.  you'll get a null deref with wpa1 (k is not initialized).
with wpa1, message 3/4 of the 4-way handshake does not carry the
group key (it is sent in message 1/2 of the group key handshake
that follows the 4-way handshake instead).
the TSC of the pairwise key is always 0 in our case, which is
the reason why it is not set here, but used when receiving
msg 3/4 since other implementations may use non-zero values.


| This last one is pretty obvious.
| ieee80211_alloc_node() does the same increment already, so the stats
| about node allocation failures are wrong.
| Index: ieee80211_proto.c
| ===
| RCS file: /cvs/src/sys/net80211/ieee80211_proto.c,v
| retrieving revision 1.44
| diff -u -p -r1.44 ieee80211_proto.c
| --- ieee80211_proto.c 7 Aug 2010 03:50:02 -   1.44
| +++ ieee80211_proto.c 6 Feb 2011 15:14:42 -
| @@ -704,7 +704,6 @@ ieee80211_auth_open(struct ieee80211com 
|   if (ni == ic->ic_bss) {
|   ni = ieee80211_alloc_node(ic, wh->i_addr2);
|   if (ni == NULL) {
| - ic->ic_stats.is_rx_nodealloc++;
|   return;
|   }
|   IEEE80211_ADDR_COPY(ni->ni_bssid, ic->ic_bss->ni_bssid);

ok.

Damien



Re: mos(4) broadcast fix

2011-02-21 Thread Stefan Sperling
On Mon, Feb 21, 2011 at 12:03:43PM +0100, Claudio Jeker wrote:
> On Sun, Feb 20, 2011 at 10:59:48PM +0100, Stefan Sperling wrote:
> > mos(4) doesn't set IFF_BROADCAST, which prevents hostapd(8) from using it.
> > hostapd tries a SIOCGIFBRDADDR ioctl which fails with EINVAL in 
> > netinet/in.c:
> > 
> > case SIOCGIFBRDADDR:
> > if ((ifp->if_flags & IFF_BROADCAST) == 0)
> > return (EINVAL);
> > 
> > Index: if_mos.c
> > ===
> > RCS file: /cvs/src/sys/dev/usb/if_mos.c,v
> > retrieving revision 1.13
> > diff -u -p -r1.13 if_mos.c
> > --- if_mos.c25 Jan 2011 20:03:35 -  1.13
> > +++ if_mos.c20 Feb 2011 21:46:53 -
> > @@ -719,7 +719,7 @@ mos_attach(struct device *parent, struct
> > /* Initialize interface info.*/
> > ifp = GET_IFP(sc);
> > ifp->if_softc = sc;
> > -   ifp->if_flags = IFF_SIMPLEX | IFF_MULTICAST;
> > +   ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
> > ifp->if_ioctl = mos_ioctl;
> > ifp->if_start = mos_start;
> > ifp->if_watchdog = mos_watchdog;
> > 
> 
> Makes sense. All ethernet devices should set at least IFF_BROADCAST and
> IFF_MULTICAST. OK claudio@
> 
> -- 
> :wq Claudio

Thanks!

I have three OKs for this simple diff now and don't need more.
Just waiting for Miod to confirm (we're in soft lock).

But I haven't received anything yet for the net80211 fixes I sent in the other
thread. I think they would be worth having in 4.9, especially the first
of the bunch because it fixes hostap issues with WPA.



Re: mos(4) broadcast fix

2011-02-21 Thread Claudio Jeker
On Sun, Feb 20, 2011 at 10:59:48PM +0100, Stefan Sperling wrote:
> mos(4) doesn't set IFF_BROADCAST, which prevents hostapd(8) from using it.
> hostapd tries a SIOCGIFBRDADDR ioctl which fails with EINVAL in netinet/in.c:
> 
> case SIOCGIFBRDADDR:
> if ((ifp->if_flags & IFF_BROADCAST) == 0)
> return (EINVAL);
> 
> Index: if_mos.c
> ===
> RCS file: /cvs/src/sys/dev/usb/if_mos.c,v
> retrieving revision 1.13
> diff -u -p -r1.13 if_mos.c
> --- if_mos.c  25 Jan 2011 20:03:35 -  1.13
> +++ if_mos.c  20 Feb 2011 21:46:53 -
> @@ -719,7 +719,7 @@ mos_attach(struct device *parent, struct
>   /* Initialize interface info.*/
>   ifp = GET_IFP(sc);
>   ifp->if_softc = sc;
> - ifp->if_flags = IFF_SIMPLEX | IFF_MULTICAST;
> + ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
>   ifp->if_ioctl = mos_ioctl;
>   ifp->if_start = mos_start;
>   ifp->if_watchdog = mos_watchdog;
> 

Makes sense. All ethernet devices should set at least IFF_BROADCAST and
IFF_MULTICAST. OK claudio@

-- 
:wq Claudio



Fw: Segue em anexo relatorio orcamento.

2011-02-21 Thread Silvia Nogueira
[IMAGE] 1 anexos

Relatorio-orcamento.pdf (144,1 kb)

Segue em anexo o relatorio para orC'amento.
tenha um bom dia.
__



Re: Syslogd: Adding log sockets that are only writeable by a single group

2011-02-21 Thread Joachim Schipper
On Sat, Feb 19, 2011 at 10:17:21PM -0500, Eric wrote:
> On Sun, Feb 13, 2011 at 8:45 PM, Philip Guenther  wrote:
> > On Sun, Feb 13, 2011 at 8:27 AM, Eric  wrote:
> >> On (...) Philip Guenther  wrote:
> >>> (...) if you're intending that this should affect all
> >>> programs without any changes to the program themselves, then this will
> >>> require much care and verification that it doesn't bloat everything.
> >>> Consider that *every* C program on OpenBSD pulls in syslog_r() to
> >>> support the stack-protector check code.  If that starts pulling the
> >>> NIS code for getgrgid() to do the gid -> name mapping to find the
> >>> syslog socket, then many binaries will grow.
> >>
> >> I can only think of two ways to avoid having NIS linked into everything:
> >>
> >> - Only use the modified syslog functions though LD_PRELOAD
> >>
> >> - Make openlog/syslog/closelog system calls (this would also allow
> >>  us to ensure the accuracy of the pid and program name strings, and
> >>  we could filter by program name in syslogd).
> >
> > Yow!  Group names are strictly user-space right now; how exactly where
> > you planning on having the kernel get the group name for a process?
> >
> > Backing up a step, syslog_r() MUST remain async-signal-safe, so
> > whatever designs you ponder, please check them against that
> > requirement.  That would be true even of an LD_PRELOAD replacement...
> 
> I've decided to stay in user-space and stick with group-based
> controls, but I've come across a small problem with modifying openlog
> to find the current process' group:
> 
> Daemons like httpd perform openlog before they drop privileges,
> meaning that most daemons would end up logging to
> /dev/syslog_wheel/log.  Not that this is such a horrible outcome, but
> it would be nice i these daemons logged to their own sockets.
> 
> I'm not sure how to handle this problem, but I thought of two possible
> solutions:
> 
> - It might be alright to have the group or perhaps the path of the log
> socket passed as part of the struct syslog_data that's explcitly
> provided by programs that use openlog_r/syslog_r.  To get the daemons
> to use this option, we would have to modify each one to use the new
> struct member (many small changes).

syslog() should Just Work - your proposal requires modification of every
daemon and port in a way that only works on OpenBSD.

> - I noticed that the syslog code uses connect() and send() to send
> messages to syslog.  I could modify syslog to use sendto()
> instead--Would it be unreasonable to call getresgid and getgrgid for
> each call to syslog()?

getgrgid() isn't signal-safe, so this is not a good idea. It would also
make syslog() quite slow.

> - If each process only had to call getresgid, would that help me avoid
> enlarging each process (avoiding NIS by not using getgrgid/getgrnam?)
> If I did this, I could use the gid_t instead of the group name as the
> path, e.g. /dev/syslog_123/log.

I don't know. Note, however, that all of these things rely on every
process being nice and using syslog() - didn't your first message in
this thread contain the phrase "high integrity log files"? (To spell it
out, syslog() just writes a message to a socket; there are other ways to
do that.)

Backing up a step, pretty much every daemon already has an option to set
the path to /dev/log, and syslog already knows where its sockets are.
Why not just extend /etc/syslog.conf to accept syntax like this:

# Already supported
!sudo
*.* /var/log/sudo
# Extension
:/var/www/dev/log
*.* /var/log/apache
# You may also want to support
127.0.0.1:syslog
*.* /var/log/localhost

You could then do access control via permissions on the socket or the
directory the socket is in. In fact, I'm pretty sure that at least one
of the syslogd replacements in ports already does this.

I'm not convinced that what you're proposing is worth implementing, but
at least the above design is minimally intrusive and may even be
convenient for other uses.

Joachim