Re: svn commit: r334941 - head/usr.bin/top

2018-06-10 Thread Mark Millard via svn-src-head
Eitan Adler eadler at FreeBSD.org wrote on
Mon Jun 11 05:05:22 UTC 2018 :

. . .
> - *   positive numbers.  If val <= 0 then digits(val) == 0.
> + *   non-negative numbers.  If val <= 0 then digits(val) == 0.
>   */
>  
> -int
> +int __pure2
>  digits(int val)
>  {
>  int cnt = 0;
> + if (val == 0) {
> + return 1;
> + }
. . .

The code has digits(0) == 1 but the comment says digits(0) == 0
still.

(The indentation was odd in how it showed in the
web browser before I copied/pasted it above.)


===
Mark Millard
marklmi at yahoo.com
( dsl-only.net went
away in early 2018-Mar)

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


Re: svn commit: r334928 - head/lib/libc/stdlib

2018-06-10 Thread Bruce Evans

On Sun, 10 Jun 2018, Konstantin Belousov wrote:


Log:
 libc qsort(3): stop aliasing.

 Qsort swap code aliases the sorted array elements to ints and longs in
 order to do swap by machine words.  Unfortunately this breaks with the
 full code optimization, e.g. LTO.

 See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83201 which seems to
 reference code directly copied from libc/stdlib/qsort.c.


This can be fixed without much churn or any loss of efficiency using
memcpy().

However, optimization of this was silly, since he slow part of qsort() is
doing many more comparisons than swaps, with relative slowness of comparisons
guranteed by them being in extern functions.


Modified: head/lib/libc/stdlib/qsort.c
==
--- head/lib/libc/stdlib/qsort.cSun Jun 10 16:44:18 2018
(r334927)
+++ head/lib/libc/stdlib/qsort.cSun Jun 10 17:54:44 2018
(r334928)
@@ -43,53 +43,27 @@ typedef int  cmp_t(void *, const void *, const void 
*
typedef int  cmp_t(const void *, const void *);
#endif
static inline char  *med3(char *, char *, char *, cmp_t *, void *);
-static inline void  swapfunc(char *, char *, size_t, int, int);

#define MIN(a, b)   ((a) < (b) ? a : b)

/*
 * Qsort routine from Bentley & McIlroy's "Engineering a Sort Function".
 */
-#defineswapcode(TYPE, parmi, parmj, n) {   \
-   size_t i = (n) / sizeof (TYPE); \
-   TYPE *pi = (TYPE *) (parmi);\
-   TYPE *pj = (TYPE *) (parmj);\
-   do {\
-   TYPEt = *pi;\
-   *pi++ = *pj;\
-   *pj++ = t;  \
-   } while (--i > 0);   \
-}


I doubt that Bentley & McIlroy wrote this silly optimization.

Change TYPE to unsigned char to fix this with minimal churn and the same
pessimizations as in this commit.

Change TYPE to unsigned char[sizeof(old TYPE)] and use memcpy() to assign
the variables to fix this with small churn and without the pessimizations
in this commit.  This gives portable code back to K + memcpy(), and
is as efficient as the above when the above works.  On x86, even gcc-3.3
produces a load and store for memcpy(p, q, sizeof(register_t)) when p and
q are void *.

Change TYPE to unsigned char[n] and use a single memcpy() without a loop
to assign the variables to fix this with larger churn and with different
(smaller?) pessimizations than in this commit.  Setup and initialization
for this method is also simpler.  This uses the newfangled VLA feature,
and since n is variable for qsort(), builtin memcpy() with length n
doesn't work so well.


-#defineSWAPINIT(TYPE, a, es) swaptype_ ## TYPE =   \
-   ((char *)a - (char *)0) % sizeof(TYPE) ||   \
-   es % sizeof(TYPE) ? 2 : es == sizeof(TYPE) ? 0 : 1;

-

static inline void
-swapfunc(char *a, char *b, size_t n, int swaptype_long, int swaptype_int)
+swapfunc(char *a, char *b, size_t es)
{
-   if (swaptype_long <= 1)
-   swapcode(long, a, b, n)
-   else if (swaptype_int <= 1)
-   swapcode(int, a, b, n)
-   else
-   swapcode(char, a, b, n)
+   char t;
+
+   do {
+   t = *a;
+   *a++ = *b;
+   *b++ = t;
+   } while (--es > 0);
}


Copying bytewise asks for pessimal code.  Since es is variable, the
compiler can't usefully replace this by inline memcpy()'s, and it probably
shouldn't bother combining the bytes either.  clang actually combines the
bytes and inlines the result, but doesn't inline the memcpy()s.


...


Test program:

XX #include 
XX 
XX volatile char qq, rr;;
XX 
XX static inline void

XX slowswap(void *iap, void *ibp, size_t len)
XX {
XX  unsigned char *ap, *bp, tmp;
XX 
XX 	for (ap = iap, bp = ibp; len != 0; ap++, bp++, len--) {

XX  tmp = *ap;
XX  *ap = *bp;
XX  *bp = tmp;
XX  }
XX }
XX 
XX static inline void

XX swap(void *ap, void *bp, int len)
XX {
XX  unsigned char tmp[len];
XX 
XX 	memcpy(, ap, len);

XX  memcpy(ap, bp, len);
XX  memcpy(bp, , len);
XX }
XX 
XX int a, b;

XX void *p, *q;
XX size_t plen;
XX 
XX void

XX foo(void)
XX {
XX  swap(, , sizeof(a));
XX  swap(p, q, plen);
XX }
XX 
XX 
XX void

XX slowfoo(void)
XX {
XX  slowswap(, , sizeof(a));
XX  slowswap(p, q, plen);
XX }

clang generates very good code for swap() on small fixed-size data.  It
inlines the memcpy()s to load-store (using AVX for larger sizes if available).

clang generates not so good code for slowswap() on small fixed-sized data.
It inlines the 4-byte swap of 'a' and 'b', but does this weirdly using
16-bit and 8-bit register loads and stores instead of 32-bit ones.  This
takes 5 loads and 5 stores but should take 2 loads and 2 stores.

clang generates 

svn commit: r334944 - in head/usr.bin/indent: . tests

2018-06-10 Thread Piotr Pawel Stefaniak
Author: pstef
Date: Mon Jun 11 05:35:57 2018
New Revision: 334944
URL: https://svnweb.freebsd.org/changeset/base/334944

Log:
  indent(1): rename -nsac/-sac ("space after cast") to -ncs/-cs
  
  Also update tests and the manpage.
  
  GNU indent had the option earlier as -cs, let's not diverge unnecessarily.

Added:
  head/usr.bin/indent/tests/cs.0
 - copied unchanged from r334943, head/usr.bin/indent/tests/sac.0
  head/usr.bin/indent/tests/cs.0.pro
 - copied, changed from r334943, head/usr.bin/indent/tests/sac.0.pro
  head/usr.bin/indent/tests/cs.0.stdout
 - copied unchanged from r334943, head/usr.bin/indent/tests/sac.0.stdout
  head/usr.bin/indent/tests/ncs.0
 - copied unchanged from r334943, head/usr.bin/indent/tests/nsac.0
  head/usr.bin/indent/tests/ncs.0.pro
 - copied, changed from r334943, head/usr.bin/indent/tests/nsac.0.pro
  head/usr.bin/indent/tests/ncs.0.stdout
 - copied unchanged from r334943, head/usr.bin/indent/tests/nsac.0.stdout
Deleted:
  head/usr.bin/indent/tests/nsac.0
  head/usr.bin/indent/tests/nsac.0.pro
  head/usr.bin/indent/tests/nsac.0.stdout
  head/usr.bin/indent/tests/sac.0
  head/usr.bin/indent/tests/sac.0.pro
  head/usr.bin/indent/tests/sac.0.stdout
Modified:
  head/usr.bin/indent/args.c
  head/usr.bin/indent/indent.1
  head/usr.bin/indent/tests/Makefile

Modified: head/usr.bin/indent/args.c
==
--- head/usr.bin/indent/args.c  Mon Jun 11 05:28:00 2018(r334943)
+++ head/usr.bin/indent/args.c  Mon Jun 11 05:35:57 2018(r334944)
@@ -116,6 +116,7 @@ struct pro {
 {"ce", PRO_BOOL, true, ON, _else},
 {"ci", PRO_INT, 0, 0, _indent},
 {"cli", PRO_SPECIAL, 0, CLI, 0},
+{"cs", PRO_BOOL, false, ON, _after_cast},
 {"c", PRO_INT, 33, 0, _ind},
 {"di", PRO_INT, 16, 0, _indent},
 {"dj", PRO_BOOL, false, ON, _decl},
@@ -141,6 +142,7 @@ struct pro {
 {"nbs", PRO_BOOL, false, OFF, _Shannon},
 {"ncdb", PRO_BOOL, true, OFF, _delimiter_on_blankline},
 {"nce", PRO_BOOL, true, OFF, _else},
+{"ncs", PRO_BOOL, false, OFF, _after_cast},
 {"ndj", PRO_BOOL, false, OFF, _decl},
 {"neei", PRO_BOOL, false, OFF, _expression_indent},
 {"nei", PRO_BOOL, true, OFF, _if},
@@ -153,14 +155,12 @@ struct pro {
 {"npcs", PRO_BOOL, false, OFF, _calls_space},
 {"npro", PRO_SPECIAL, 0, IGN, 0},
 {"npsl", PRO_BOOL, true, OFF, _start_line},
-{"nsac", PRO_BOOL, false, OFF, _after_cast},
 {"nsc", PRO_BOOL, true, OFF, _comment_cont},
 {"nsob", PRO_BOOL, false, OFF, _optional_blanklines},
 {"nut", PRO_BOOL, true, OFF, _tabs},
 {"nv", PRO_BOOL, false, OFF, },
 {"pcs", PRO_BOOL, false, ON, _calls_space},
 {"psl", PRO_BOOL, true, ON, _start_line},
-{"sac", PRO_BOOL, false, ON, _after_cast},
 {"sc", PRO_BOOL, true, ON, _comment_cont},
 {"sob", PRO_BOOL, false, ON, _optional_blanklines},
 {"st", PRO_SPECIAL, 0, STDIN, 0},

Modified: head/usr.bin/indent/indent.1
==
--- head/usr.bin/indent/indent.1Mon Jun 11 05:28:00 2018
(r334943)
+++ head/usr.bin/indent/indent.1Mon Jun 11 05:35:57 2018
(r334944)
@@ -30,7 +30,7 @@
 .\"@(#)indent.18.1 (Berkeley) 7/1/93
 .\" $FreeBSD$
 .\"
-.Dd June 4, 2018
+.Dd June 11, 2018
 .Dt INDENT 1
 .Os
 .Sh NAME
@@ -55,6 +55,7 @@
 .Op Fl \ | Fl nce
 .Op Fl \ Ns Ar n
 .Op Fl cli Ns Ar n
+.Op Fl cs | Fl ncs
 .Op Fl d Ns Ar n
 .Op Fl \ Ns Ar n
 .Op Fl dj | Fl ndj
@@ -78,7 +79,6 @@
 .Op Fl P Ns Ar file
 .Op Fl pcs | Fl npcs
 .Op Fl psl | Fl npsl
-.Op Fl sac | Fl nsac
 .Op Fl \ | Fl nsc
 .Bk -words
 .Op Fl sob | Fl nsob
@@ -259,6 +259,11 @@ causes case labels to be indented half a tab stop.
 The
 default is
 .Fl cli0 .
+.It Fl cs , ncs
+Control whether parenthesized type names in casts are followed by a space or
+not.
+The default is
+.Fl ncs .
 .It Fl d Ns Ar n
 Controls the placement of comments which are not to the
 right of code.
@@ -423,11 +428,6 @@ column 1 \- their types, if any, will be left on the p
 The
 default is
 .Fl psl .
-.It Fl sac , nsac
-Control whether parenthesized type names in casts are followed by a space or
-not.
-The default is
-.Fl nsac .
 .It Fl \ , nsc
 Enables (disables) the placement of asterisks (`*'s) at the left edge of all
 comments.

Modified: head/usr.bin/indent/tests/Makefile
==
--- head/usr.bin/indent/tests/Makefile  Mon Jun 11 05:28:00 2018
(r334943)
+++ head/usr.bin/indent/tests/Makefile  Mon Jun 11 05:35:57 2018
(r334944)
@@ -20,9 +20,9 @@ ${PACKAGE}FILES+= label.0.stdout
 ${PACKAGE}FILES+=  label.0.pro
 ${PACKAGE}FILES+=  list_head.0
 ${PACKAGE}FILES+=  list_head.0.stdout
-${PACKAGE}FILES+=  nsac.0
-${PACKAGE}FILES+=  nsac.0.stdout
-${PACKAGE}FILES+=  nsac.0.pro
+${PACKAGE}FILES+=  ncs.0
+${PACKAGE}FILES+=  

svn commit: r334943 - head/sys/dev/usb

2018-06-10 Thread Eitan Adler
Author: eadler
Date: Mon Jun 11 05:28:00 2018
New Revision: 334943
URL: https://svnweb.freebsd.org/changeset/base/334943

Log:
  usbdevs: sort my prior commit

Modified:
  head/sys/dev/usb/usbdevs

Modified: head/sys/dev/usb/usbdevs
==
--- head/sys/dev/usb/usbdevsMon Jun 11 05:27:07 2018(r334942)
+++ head/sys/dev/usb/usbdevsMon Jun 11 05:28:00 2018(r334943)
@@ -714,10 +714,10 @@ vendor AMIT   0x18c5  AMIT
 vendor GOOGLE  0x18d1  Google
 vendor QCOM0x18e8  Qcom
 vendor ELV 0x18ef  ELV
-vendor ZTE 0x19d2  ZTE
 vendor LINKSYS30x1915  Linksys
 vendor MEINBERG0x1938  Meinberg Funkuhren
 vendor BECEEM  0x198f  Beceem Communications
+vendor ZTE 0x19d2  ZTE
 vendor QUALCOMMINC 0x19d2  Qualcomm, Incorporated
 vendor QUALCOMM3   0x19f5  Qualcomm, Inc.
 vendor QUANTA2 0x1a32  Quanta
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r334942 - head/sys/dev/usb

2018-06-10 Thread Eitan Adler
Author: eadler
Date: Mon Jun 11 05:27:07 2018
New Revision: 334942
URL: https://svnweb.freebsd.org/changeset/base/334942

Log:
  usbdevs: adding vendor
  
  PR:   228856
  Reported by:  hrs, ys-h@imail.earth

Modified:
  head/sys/dev/usb/usbdevs

Modified: head/sys/dev/usb/usbdevs
==
--- head/sys/dev/usb/usbdevsMon Jun 11 05:05:20 2018(r334941)
+++ head/sys/dev/usb/usbdevsMon Jun 11 05:27:07 2018(r334942)
@@ -714,6 +714,7 @@ vendor AMIT 0x18c5  AMIT
 vendor GOOGLE  0x18d1  Google
 vendor QCOM0x18e8  Qcom
 vendor ELV 0x18ef  ELV
+vendor ZTE 0x19d2  ZTE
 vendor LINKSYS30x1915  Linksys
 vendor MEINBERG0x1938  Meinberg Funkuhren
 vendor BECEEM  0x198f  Beceem Communications
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r334941 - head/usr.bin/top

2018-06-10 Thread Eitan Adler
Author: eadler
Date: Mon Jun 11 05:05:20 2018
New Revision: 334941
URL: https://svnweb.freebsd.org/changeset/base/334941

Log:
  top(1): handle 0 in "digits" functions

Modified:
  head/usr.bin/top/Makefile
  head/usr.bin/top/utils.c

Modified: head/usr.bin/top/Makefile
==
--- head/usr.bin/top/Makefile   Mon Jun 11 02:09:20 2018(r334940)
+++ head/usr.bin/top/Makefile   Mon Jun 11 05:05:20 2018(r334941)
@@ -5,7 +5,6 @@
 PROG=  top
 SRCS=  commands.c display.c machine.c screen.c top.c \
username.c utils.c
-CFLAGS+= -I ${.OBJDIR}
 MAN=   top.1
 
 .if ${COMPILER_TYPE} == "gcc"

Modified: head/usr.bin/top/utils.c
==
--- head/usr.bin/top/utils.cMon Jun 11 02:09:20 2018(r334940)
+++ head/usr.bin/top/utils.cMon Jun 11 05:05:20 2018(r334941)
@@ -124,16 +124,18 @@ itoa7(int val)
 
 /*
  *  digits(val) - return number of decimal digits in val.  Only works for
- * positive numbers.  If val <= 0 then digits(val) == 0.
+ * non-negative numbers.  If val <= 0 then digits(val) == 0.
  */
 
-int
+int __pure2
 digits(int val)
 {
 int cnt = 0;
+   if (val == 0) {
+   return 1;
+   }
 
-while (val > 0)
-{
+while (val > 0) {
cnt++;
val /= 10;
 }
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r334940 - head/usr.sbin/bhyve

2018-06-10 Thread Pedro Giffuni



On 10/06/2018 21:41, Marcelo Araujo wrote:



2018-06-11 10:25 GMT+08:00 Pedro Giffuni >:




On 10/06/2018 21:09, Marcelo Araujo wrote:

Author: araujo
Date: Mon Jun 11 02:09:20 2018
New Revision: 334940
URL: https://svnweb.freebsd.org/changeset/base/334940


Log:
   - Add bhyve virtio-scsi storage backend support.
      Example of configuration:
   ctl.conf:
   portal-group pg0 {
           discovery-auth-group no-authentication
           listen 0.0.0.0
           listen [::]
   }
      target iqn.2012-06.com.example:target0 {
           auth-group no-authentication
           portal-group pg0
           port ioctl/5/3
              lun 0 {
                   path /z/test.img
                   size 8G
           }
           lun 1 {
                   path /z/test1.img
                   size 8G
           }
   }
      bhyve <...> -s 4,virtio-scsi,/dev/cam/ctl5.3,iid=3 
      From inside guest:
   root@:~ # zpool status test
     pool: test
    state: ONLINE
     scan: none requested
   config:
              NAME        STATE     READ WRITE CKSUM
           test        ONLINE       0     0     0
             da0       ONLINE       0     0     0
             da1       ONLINE       0     0     0
      dmesg:
   da0 at vtscsi0 bus 0 scbus0 target 0 lun 0
   da0:  Fixed Direct Access SPC-5 SCSI
device
   da0: Serial Number MYSERIAL
   da0: 300.000MB/s transfers
   da0: Command Queueing enabled
   da0: 8192MB (16777216 512 byte sectors)
   da1 at vtscsi0 bus 0 scbus0 target 0 lun 1
   da1:  Fixed Direct Access SPC-5 SCSI
device
   da1: Serial Number MYSERIAL0001
   da1: 300.000MB/s transfers
   da1: Command Queueing enabled
   da1: 8192MB (16777216 512 byte sectors)
      Discussed with:           grehan
   Reviewed by:         mav
   Obtained from:               TrueOS
   Relnotes:            Yes
   Sponsored by:                iXsystems Inc.
   Tested with:         FreeBSD HEAD, Fedora 28 (Workstation) and
                        Ubuntu 18.04.
   Differential Revision: https://reviews.freebsd.org/D15276


Added:
   head/usr.sbin/bhyve/iov.c   (contents, props changed)
   head/usr.sbin/bhyve/iov.h   (contents, props changed)
   head/usr.sbin/bhyve/pci_virtio_scsi.c  (contents, props
changed)
Modified:
   head/usr.sbin/bhyve/Makefile
   head/usr.sbin/bhyve/bhyve.8
   head/usr.sbin/bhyve/virtio.h

...


Added: head/usr.sbin/bhyve/pci_virtio_scsi.c

==
--- /dev/null   00:00:00 1970   (empty, because file is newly
added)
+++ head/usr.sbin/bhyve/pci_virtio_scsi.c  Mon Jun 11 02:09:20
2018        (r334940)
@@ -0,0 +1,718 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2016 Jakub Klama .
+ * Copyright (c) 2018 Marcelo Araujo .
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
without
+ * modification, are permitted provided that the following
conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above
copyright
+ *    notice, this list of conditions and the following
disclaimer
+ *    in this position and unchanged.
+ * 2. Redistributions in binary form must reproduce the above
copyright
+ *    notice, this list of conditions and the following
disclaimer in the
+ *    documentation and/or other materials provided with the
distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS
``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR
CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY 

Re: svn commit: r334940 - head/usr.sbin/bhyve

2018-06-10 Thread Marcelo Araujo
2018-06-11 10:25 GMT+08:00 Pedro Giffuni :

>
>
> On 10/06/2018 21:09, Marcelo Araujo wrote:
>
>> Author: araujo
>> Date: Mon Jun 11 02:09:20 2018
>> New Revision: 334940
>> URL: https://svnweb.freebsd.org/changeset/base/334940
>>
>> Log:
>>- Add bhyve virtio-scsi storage backend support.
>>   Example of configuration:
>>ctl.conf:
>>portal-group pg0 {
>>discovery-auth-group no-authentication
>>listen 0.0.0.0
>>listen [::]
>>}
>>   target iqn.2012-06.com.example:target0 {
>>auth-group no-authentication
>>portal-group pg0
>>port ioctl/5/3
>>   lun 0 {
>>path /z/test.img
>>size 8G
>>}
>>lun 1 {
>>path /z/test1.img
>>size 8G
>>}
>>}
>>   bhyve <...> -s 4,virtio-scsi,/dev/cam/ctl5.3,iid=3 
>>   From inside guest:
>>root@:~ # zpool status test
>>  pool: test
>> state: ONLINE
>>  scan: none requested
>>config:
>>   NAMESTATE READ WRITE CKSUM
>>testONLINE   0 0 0
>>  da0   ONLINE   0 0 0
>>  da1   ONLINE   0 0 0
>>   dmesg:
>>da0 at vtscsi0 bus 0 scbus0 target 0 lun 0
>>da0:  Fixed Direct Access SPC-5 SCSI device
>>da0: Serial Number MYSERIAL
>>da0: 300.000MB/s transfers
>>da0: Command Queueing enabled
>>da0: 8192MB (16777216 512 byte sectors)
>>da1 at vtscsi0 bus 0 scbus0 target 0 lun 1
>>da1:  Fixed Direct Access SPC-5 SCSI device
>>da1: Serial Number MYSERIAL0001
>>da1: 300.000MB/s transfers
>>da1: Command Queueing enabled
>>da1: 8192MB (16777216 512 byte sectors)
>>   Discussed with:   grehan
>>Reviewed by: mav
>>Obtained from:   TrueOS
>>Relnotes:Yes
>>Sponsored by:iXsystems Inc.
>>Tested with: FreeBSD HEAD, Fedora 28 (Workstation) and
>> Ubuntu 18.04.
>>Differential Revision:  https://reviews.freebsd.org/D15276
>>
>> Added:
>>head/usr.sbin/bhyve/iov.c   (contents, props changed)
>>head/usr.sbin/bhyve/iov.h   (contents, props changed)
>>head/usr.sbin/bhyve/pci_virtio_scsi.c   (contents, props changed)
>> Modified:
>>head/usr.sbin/bhyve/Makefile
>>head/usr.sbin/bhyve/bhyve.8
>>head/usr.sbin/bhyve/virtio.h
>>
>> ...
>>
>
> Added: head/usr.sbin/bhyve/pci_virtio_scsi.c
>> 
>> ==
>> --- /dev/null   00:00:00 1970   (empty, because file is newly added)
>> +++ head/usr.sbin/bhyve/pci_virtio_scsi.c   Mon Jun 11 02:09:20
>> 2018(r334940)
>> @@ -0,0 +1,718 @@
>> +/*-
>> + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
>> + *
>> + * Copyright (c) 2016 Jakub Klama .
>> + * Copyright (c) 2018 Marcelo Araujo .
>> + * All rights reserved.
>> + *
>> + * Redistribution and use in source and binary forms, with or without
>> + * modification, are permitted provided that the following conditions
>> + * are met:
>> + * 1. Redistributions of source code must retain the above copyright
>> + *notice, this list of conditions and the following disclaimer
>> + *in this position and unchanged.
>> + * 2. Redistributions in binary form must reproduce the above copyright
>> + *notice, this list of conditions and the following disclaimer in the
>> + *documentation and/or other materials provided with the
>> distribution.
>> + *
>> + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
>> + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
>> + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
>> PURPOSE
>> + * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE
>> LIABLE
>> + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
>> CONSEQUENTIAL
>> + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
>> GOODS
>> + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
>> + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
>> STRICT
>> + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
>> WAY
>> + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>> + * SUCH DAMAGE.
>> + */
>> +
>> +#include 
>> +__FBSDID("$FreeBSD$");
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#include "bhyverun.h"
>> +#include "pci_emul.h"
>> +#include "virtio.h"
>> +#include "iov.h"
>> +
>> 

Re: svn commit: r334940 - head/usr.sbin/bhyve

2018-06-10 Thread Pedro Giffuni




On 10/06/2018 21:09, Marcelo Araujo wrote:

Author: araujo
Date: Mon Jun 11 02:09:20 2018
New Revision: 334940
URL: https://svnweb.freebsd.org/changeset/base/334940

Log:
   - Add bhyve virtio-scsi storage backend support.
   
   Example of configuration:

   ctl.conf:
   portal-group pg0 {
   discovery-auth-group no-authentication
   listen 0.0.0.0
   listen [::]
   }
   
   target iqn.2012-06.com.example:target0 {

   auth-group no-authentication
   portal-group pg0
   port ioctl/5/3
   
   lun 0 {

   path /z/test.img
   size 8G
   }
   lun 1 {
   path /z/test1.img
   size 8G
   }
   }
   
   bhyve <...> -s 4,virtio-scsi,/dev/cam/ctl5.3,iid=3 
   
   From inside guest:

   root@:~ # zpool status test
 pool: test
state: ONLINE
 scan: none requested
   config:
   
   NAMESTATE READ WRITE CKSUM

   testONLINE   0 0 0
 da0   ONLINE   0 0 0
 da1   ONLINE   0 0 0
   
   dmesg:

   da0 at vtscsi0 bus 0 scbus0 target 0 lun 0
   da0:  Fixed Direct Access SPC-5 SCSI device
   da0: Serial Number MYSERIAL
   da0: 300.000MB/s transfers
   da0: Command Queueing enabled
   da0: 8192MB (16777216 512 byte sectors)
   da1 at vtscsi0 bus 0 scbus0 target 0 lun 1
   da1:  Fixed Direct Access SPC-5 SCSI device
   da1: Serial Number MYSERIAL0001
   da1: 300.000MB/s transfers
   da1: Command Queueing enabled
   da1: 8192MB (16777216 512 byte sectors)
   
   Discussed with:		grehan

   Reviewed by: mav
   Obtained from:   TrueOS
   Relnotes:Yes
   Sponsored by:iXsystems Inc.
   Tested with: FreeBSD HEAD, Fedora 28 (Workstation) and
Ubuntu 18.04.
   Differential Revision:  https://reviews.freebsd.org/D15276

Added:
   head/usr.sbin/bhyve/iov.c   (contents, props changed)
   head/usr.sbin/bhyve/iov.h   (contents, props changed)
   head/usr.sbin/bhyve/pci_virtio_scsi.c   (contents, props changed)
Modified:
   head/usr.sbin/bhyve/Makefile
   head/usr.sbin/bhyve/bhyve.8
   head/usr.sbin/bhyve/virtio.h

...



Added: head/usr.sbin/bhyve/pci_virtio_scsi.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/usr.sbin/bhyve/pci_virtio_scsi.c   Mon Jun 11 02:09:20 2018
(r334940)
@@ -0,0 +1,718 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2016 Jakub Klama .
+ * Copyright (c) 2018 Marcelo Araujo .
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer
+ *in this position and unchanged.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "bhyverun.h"
+#include "pci_emul.h"
+#include "virtio.h"
+#include "iov.h"
+
+#define VTSCSI_RINGSZ  64
+#defineVTSCSI_REQUESTQ 1
+#defineVTSCSI_THR_PER_Q16
+#defineVTSCSI_MAXQ (VTSCSI_REQUESTQ + 2)
+#defineVTSCSI_MAXSEG   64
+
+#defineVTSCSI_IN_HEADER_LEN(_sc)   \
+   (sizeof(struct pci_vtscsi_req_cmd_rd) + _sc->vss_config.cdb_size)
+
+#defineVTSCSI_OUT_HEADER_LEN(_sc)  \
+   (sizeof(struct pci_vtscsi_req_cmd_wr) + _sc->vss_config.sense_size)
+
+#define 

svn commit: r334940 - head/usr.sbin/bhyve

2018-06-10 Thread Marcelo Araujo
Author: araujo
Date: Mon Jun 11 02:09:20 2018
New Revision: 334940
URL: https://svnweb.freebsd.org/changeset/base/334940

Log:
  - Add bhyve virtio-scsi storage backend support.
  
  Example of configuration:
  ctl.conf:
  portal-group pg0 {
  discovery-auth-group no-authentication
  listen 0.0.0.0
  listen [::]
  }
  
  target iqn.2012-06.com.example:target0 {
  auth-group no-authentication
  portal-group pg0
  port ioctl/5/3
  
  lun 0 {
  path /z/test.img
  size 8G
  }
  lun 1 {
  path /z/test1.img
  size 8G
  }
  }
  
  bhyve <...> -s 4,virtio-scsi,/dev/cam/ctl5.3,iid=3 
  
  From inside guest:
  root@:~ # zpool status test
pool: test
   state: ONLINE
scan: none requested
  config:
  
  NAMESTATE READ WRITE CKSUM
  testONLINE   0 0 0
da0   ONLINE   0 0 0
da1   ONLINE   0 0 0
  
  dmesg:
  da0 at vtscsi0 bus 0 scbus0 target 0 lun 0
  da0:  Fixed Direct Access SPC-5 SCSI device
  da0: Serial Number MYSERIAL
  da0: 300.000MB/s transfers
  da0: Command Queueing enabled
  da0: 8192MB (16777216 512 byte sectors)
  da1 at vtscsi0 bus 0 scbus0 target 0 lun 1
  da1:  Fixed Direct Access SPC-5 SCSI device
  da1: Serial Number MYSERIAL0001
  da1: 300.000MB/s transfers
  da1: Command Queueing enabled
  da1: 8192MB (16777216 512 byte sectors)
  
  Discussed with:   grehan
  Reviewed by:  mav
  Obtained from:TrueOS
  Relnotes: Yes
  Sponsored by: iXsystems Inc.
  Tested with:  FreeBSD HEAD, Fedora 28 (Workstation) and
Ubuntu 18.04.
  Differential Revision:  https://reviews.freebsd.org/D15276

Added:
  head/usr.sbin/bhyve/iov.c   (contents, props changed)
  head/usr.sbin/bhyve/iov.h   (contents, props changed)
  head/usr.sbin/bhyve/pci_virtio_scsi.c   (contents, props changed)
Modified:
  head/usr.sbin/bhyve/Makefile
  head/usr.sbin/bhyve/bhyve.8
  head/usr.sbin/bhyve/virtio.h

Modified: head/usr.sbin/bhyve/Makefile
==
--- head/usr.sbin/bhyve/MakefileMon Jun 11 01:32:18 2018
(r334939)
+++ head/usr.sbin/bhyve/MakefileMon Jun 11 02:09:20 2018
(r334940)
@@ -3,6 +3,8 @@
 #
 
 .include 
+CFLAGS+=-I${SRCTOP}/sys
+.PATH:  ${SRCTOP}/sys/cam/ctl
 
 PROG=  bhyve
 PACKAGE=   bhyve
@@ -22,6 +24,8 @@ SRCS= \
bootrom.c   \
console.c   \
consport.c  \
+   ctl_util.c  \
+   ctl_scsi_all.c  \
dbgport.c   \
fwctl.c \
gdb.c   \
@@ -42,6 +46,7 @@ SRCS= \
pci_virtio_console.c\
pci_virtio_net.c\
pci_virtio_rnd.c\
+   pci_virtio_scsi.c   \
pci_uart.c  \
pci_xhci.c  \
pm.c\
@@ -59,12 +64,13 @@ SRCS=   \
virtio.c\
vga.c   \
xmsr.c  \
-   spinup_ap.c
+   spinup_ap.c \
+   iov.c
 
 .PATH:  ${BHYVE_SYSDIR}/sys/amd64/vmm
 SRCS+= vmm_instruction_emul.c
 
-LIBADD=vmmapi md pthread z
+LIBADD=vmmapi md pthread z util sbuf cam
 
 .if ${MK_OPENSSL} == "no"
 CFLAGS+=-DNO_OPENSSL

Modified: head/usr.sbin/bhyve/bhyve.8
==
--- head/usr.sbin/bhyve/bhyve.8 Mon Jun 11 01:32:18 2018(r334939)
+++ head/usr.sbin/bhyve/bhyve.8 Mon Jun 11 02:09:20 2018(r334940)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd May 1, 2018
+.Dd Jun 11, 2018
 .Dt BHYVE 8
 .Os
 .Sh NAME
@@ -216,6 +216,8 @@ PCI pass-through device.
 Virtio network interface.
 .It Li virtio-blk
 Virtio block storage interface.
+.It Li virtio-scsi
+Virtio SCSI interface.
 .It Li virtio-rnd
 Virtio RNG interface.
 .It Li virtio-console
@@ -285,6 +287,11 @@ Force the file to be opened read-only.
 Specify the logical and physical sector sizes of the emulated disk.
 The physical sector size is optional and is equal to the logical sector size
 if not explicitly specified.
+.El
+.Pp
+SCSI devices:
+.Bl -tag -width 10n
+.It Pa /dev/cam/ Ns Oo , Ns Ar port and initiator_id Oc
 .El
 .Pp
 TTY devices:

Added: head/usr.sbin/bhyve/iov.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/usr.sbin/bhyve/iov.c   Mon Jun 11 02:09:20 2018(r334940)
@@ -0,0 +1,141 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2016 Jakub Klama .
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are 

svn commit: r334939 - head/stand/lua

2018-06-10 Thread Kyle Evans
Author: kevans
Date: Mon Jun 11 01:32:18 2018
New Revision: 334939
URL: https://svnweb.freebsd.org/changeset/base/334939

Log:
  lualoader: Allow brand-*.lua for adding new brands
  
  dteske@, I believe, had originally pointed out that lualoader failed to
  allow logo-*.lua for new logos to be added. When correcting this mistake, I
  failed to do the same for brands.
  
  Correct the sub-mistake: creating new brands is almost identical to creating
  new logos, except one must use `drawer.addBrand` and 'graphic' is the only
  valid key for a branddef at the moment.
  
  While here, I've added `drawer.default_brand` to be set to name of brand to
  be used (e.g. 'fbsd', project default).
  
  Eventually this whole goolash will be documented.
  
  Reported by:  kmoore, iXsystems

Modified:
  head/stand/lua/drawer.lua

Modified: head/stand/lua/drawer.lua
==
--- head/stand/lua/drawer.lua   Mon Jun 11 01:22:01 2018(r334938)
+++ head/stand/lua/drawer.lua   Mon Jun 11 01:32:18 2018(r334939)
@@ -51,6 +51,22 @@ local function menuEntryName(drawing_menu, entry)
return entry.name
 end
 
+local function getBranddef(brand)
+   if brand == nil then
+   return nil
+   end
+   -- Look it up
+   local branddef = drawer.branddefs[brand]
+
+   -- Try to pull it in
+   if branddef == nil then
+   try_include('brand-' .. brand)
+   branddef = drawer.branddefs[brand]
+   end
+
+   return branddef
+end
+
 local function getLogodef(logo)
if logo == nil then
return nil
@@ -79,6 +95,8 @@ fbsd_brand = {
 none = {""}
 
 -- Module exports
+drawer.default_brand = 'fbsd'
+
 drawer.menu_name_handlers = {
-- Menu name handlers should take the menu being drawn and entry being
-- drawn as parameters, and return the name of the item.
@@ -315,8 +333,13 @@ function drawer.drawbrand()
local y = tonumber(loader.getenv("loader_brand_y")) or
drawer.brand_position.y
 
-   local graphic = drawer.branddefs[loader.getenv("loader_brand")] or
-   fbsd_brand
+   local branddef = getBranddef(loader.getenv("loader_brand"))
+
+   if branddef == nil then
+   branddef = getBranddef(drawer.default_brand)
+   end
+
+   local graphic = branddef.graphic
 
x = x + drawer.shift.x
y = y + drawer.shift.y
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r334933 - head/tests/sys/audit

2018-06-10 Thread Alan Somers
Author: asomers
Date: Sun Jun 10 21:36:29 2018
New Revision: 334933
URL: https://svnweb.freebsd.org/changeset/base/334933

Log:
  audit(4): add tests for stat(2) and friends
  
  This revision adds auditability tests for stat, lstat, fstat, and fstatat,
  all from the fa audit class.  More tests from that audit class will follow.
  
  Submitted by: aniketp
  MFC after:2 weeks
  Sponsored by: Google, Inc. (GSoC 2018)
  Differential Revision:https://reviews.freebsd.org/D15709

Added:
  head/tests/sys/audit/file-attribute-access.c   (contents, props changed)
Modified:
  head/tests/sys/audit/Makefile

Modified: head/tests/sys/audit/Makefile
==
--- head/tests/sys/audit/Makefile   Sun Jun 10 19:42:44 2018
(r334932)
+++ head/tests/sys/audit/Makefile   Sun Jun 10 21:36:29 2018
(r334933)
@@ -2,13 +2,16 @@
 
 TESTSDIR=  ${TESTSBASE}/sys/audit
 
-ATF_TESTS_C=   file-create
+ATF_TESTS_C=   file-attribute-access
+ATF_TESTS_C+=  file-create
 ATF_TESTS_C+=  file-delete
 ATF_TESTS_C+=  file-close
 ATF_TESTS_C+=  file-write
 ATF_TESTS_C+=  file-read
 ATF_TESTS_C+=  open
 
+SRCS.file-attribute-access+=   file-attribute-access.c
+SRCS.file-attribute-access+=   utils.c
 SRCS.file-create+= file-create.c
 SRCS.file-create+= utils.c
 SRCS.file-delete+= file-delete.c

Added: head/tests/sys/audit/file-attribute-access.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tests/sys/audit/file-attribute-access.cSun Jun 10 21:36:29 
2018(r334933)
@@ -0,0 +1,239 @@
+/*-
+ * Copyright (c) 2018 Aniket Pandey
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include "utils.h"
+
+static struct pollfd fds[1];
+static mode_t mode = 0777;
+static char extregex[80];
+static struct stat statbuff;
+static const char *auclass = "fa";
+static const char *path = "fileforaudit";
+static const char *errpath = "dirdoesnotexist/fileforaudit";
+static const char *successreg = "fileforaudit.*return,success";
+static const char *failurereg = "fileforaudit.*return,failure";
+
+
+ATF_TC_WITH_CLEANUP(stat_success);
+ATF_TC_HEAD(stat_success, tc)
+{
+   atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
+   "stat(2) call");
+}
+
+ATF_TC_BODY(stat_success, tc)
+{
+   /* File needs to exist to call stat(2) */
+   ATF_REQUIRE(open(path, O_CREAT, mode) != -1);
+   FILE *pipefd = setup(fds, auclass);
+   ATF_REQUIRE_EQ(0, stat(path, ));
+   check_audit(fds, successreg, pipefd);
+}
+
+ATF_TC_CLEANUP(stat_success, tc)
+{
+   cleanup();
+}
+
+
+ATF_TC_WITH_CLEANUP(stat_failure);
+ATF_TC_HEAD(stat_failure, tc)
+{
+   atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
+   "stat(2) call");
+}
+
+ATF_TC_BODY(stat_failure, tc)
+{
+   FILE *pipefd = setup(fds, auclass);
+   /* Failure reason: file does not exist */
+   ATF_REQUIRE_EQ(-1, stat(errpath, ));
+   check_audit(fds, failurereg, pipefd);
+}
+
+ATF_TC_CLEANUP(stat_failure, tc)
+{
+   cleanup();
+}
+
+
+ATF_TC_WITH_CLEANUP(lstat_success);
+ATF_TC_HEAD(lstat_success, tc)
+{
+   atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
+   "lstat(2) call");
+}
+
+ATF_TC_BODY(lstat_success, tc)
+{
+   /* Symbolic link needs to exist to call lstat(2) */
+   ATF_REQUIRE_EQ(0, symlink("symlink", path));
+   FILE *pipefd = setup(fds, auclass);
+  

Re: svn commit: r334931 - in head: . sys/sys

2018-06-10 Thread Oliver Pinter
On 6/10/18, Jonathan Anderson  wrote:
> On 10 Jun 2018, at 16:49, Antoine Brodin wrote:
>
>> On Sun, Jun 10, 2018 at 9:15 PM, Eitan Adler 
>> wrote:
>>> Author: eadler
>>> Date: Sun Jun 10 19:15:38 2018
>>> New Revision: 334931
>>> URL: https://svnweb.freebsd.org/changeset/base/334931
>>>
>>> Log:
>>>   Revert r334929
>>>
>>>   Apparently some software might depend on a header whose sole
>>> contents is
>>>   a `#warning` to remove it. Revert pending exp-run.
>>
>> Hi,
>>
>> It's not just a #warning,  there is a #include line below...
>> And after this change,  most ports that supported sandboxing were no
>> longer sandboxed.
>
> This used the be the primary header file for Capsicum, but we switched
> to the somewhat-more-portable sys/capsicum.h awhile ago. The current
> sys/capability.h includes the new header while emitting a warning in
> order to encourage people to switch to capsicum.h without breaking
> anything (yet). This is a transitional step, and I think the plan is to
> remove sys/capability.h after... maybe the 12-STABLE branch?
>

As second step, it would be fine to slip the #warning over to #error,
and fix the ports.

>
> Jon
> --
> Jonathan Anderson
> jonat...@freebsd.org
> ___
> svn-src-head@freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/svn-src-head
> To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
>
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r334931 - in head: . sys/sys

2018-06-10 Thread Jonathan Anderson

On 10 Jun 2018, at 16:49, Antoine Brodin wrote:

On Sun, Jun 10, 2018 at 9:15 PM, Eitan Adler  
wrote:

Author: eadler
Date: Sun Jun 10 19:15:38 2018
New Revision: 334931
URL: https://svnweb.freebsd.org/changeset/base/334931

Log:
  Revert r334929

  Apparently some software might depend on a header whose sole 
contents is

  a `#warning` to remove it. Revert pending exp-run.


Hi,

It's not just a #warning,  there is a #include line below...
And after this change,  most ports that supported sandboxing were no
longer sandboxed.


This used the be the primary header file for Capsicum, but we switched 
to the somewhat-more-portable sys/capsicum.h awhile ago. The current 
sys/capability.h includes the new header while emitting a warning in 
order to encourage people to switch to capsicum.h without breaking 
anything (yet). This is a transitional step, and I think the plan is to 
remove sys/capability.h after... maybe the 12-STABLE branch?



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


svn commit: r334932 - in head/sys: arm64/arm64 arm64/conf conf

2018-06-10 Thread Andrew Turner
Author: andrew
Date: Sun Jun 10 19:42:44 2018
New Revision: 334932
URL: https://svnweb.freebsd.org/changeset/base/334932

Log:
  Remove the psci option from arm64. It is now a standard option as it is
  required to boot correctly.
  
  Sponsored by: DARPA, AFRL

Modified:
  head/sys/arm64/arm64/cpu_errata.c
  head/sys/arm64/arm64/vm_machdep.c
  head/sys/arm64/conf/GENERIC
  head/sys/conf/files.arm64
  head/sys/conf/options.arm64

Modified: head/sys/arm64/arm64/cpu_errata.c
==
--- head/sys/arm64/arm64/cpu_errata.c   Sun Jun 10 19:15:38 2018
(r334931)
+++ head/sys/arm64/arm64/cpu_errata.c   Sun Jun 10 19:42:44 2018
(r334932)
@@ -41,9 +41,7 @@ __FBSDID("$FreeBSD$");
 
 #include 
 
-#ifdef DEV_PSCI
 #include 
-#endif
 
 typedef void (cpu_quirk_install)(void);
 struct cpu_quirks {
@@ -81,9 +79,7 @@ static void
 install_psci_bp_hardening(void)
 {
 
-#ifdef DEV_PSCI
PCPU_SET(bp_harden, psci_get_version);
-#endif
 }
 
 void

Modified: head/sys/arm64/arm64/vm_machdep.c
==
--- head/sys/arm64/arm64/vm_machdep.c   Sun Jun 10 19:15:38 2018
(r334931)
+++ head/sys/arm64/arm64/vm_machdep.c   Sun Jun 10 19:42:44 2018
(r334932)
@@ -54,9 +54,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #endif
 
-#ifdef DEV_PSCI
 #include 
-#endif
 
 /*
  * Finish a fork operation, with process p2 nearly set up.
@@ -119,9 +117,7 @@ void
 cpu_reset(void)
 {
 
-#ifdef DEV_PSCI
psci_reset();
-#endif
 
printf("cpu_reset failed");
while(1)

Modified: head/sys/arm64/conf/GENERIC
==
--- head/sys/arm64/conf/GENERIC Sun Jun 10 19:15:38 2018(r334931)
+++ head/sys/arm64/conf/GENERIC Sun Jun 10 19:42:44 2018(r334932)
@@ -239,7 +239,6 @@ device  tun # Packet tunnel.
 device md  # Memory "disks"
 device gif # IPv6 and IPv4 tunneling
 device firmware# firmware assist module
-device psci# Support for ARM PSCI
 optionsEFIRT   # EFI Runtime Services
 
 # EXT_RESOURCES pseudo devices

Modified: head/sys/conf/files.arm64
==
--- head/sys/conf/files.arm64   Sun Jun 10 19:15:38 2018(r334931)
+++ head/sys/conf/files.arm64   Sun Jun 10 19:42:44 2018(r334932)
@@ -206,8 +206,8 @@ dev/ofw/ofwpci.coptionalfdt pci
 dev/pci/pci_host_generic.c optionalpci
 dev/pci/pci_host_generic_acpi.coptionalpci acpi
 dev/pci/pci_host_generic_fdt.c optionalpci fdt
-dev/psci/psci.coptionalpsci
-dev/psci/psci_arm64.S  optionalpsci
+dev/psci/psci.cstandard
+dev/psci/psci_arm64.S  standard
 dev/uart/uart_cpu_arm64.c  optionaluart
 dev/uart/uart_dev_pl011.c  optionaluart pl011
 dev/usb/controller/dwc_otg_hisi.c optional dwcotg fdt soc_hisi_hi6220

Modified: head/sys/conf/options.arm64
==
--- head/sys/conf/options.arm64 Sun Jun 10 19:15:38 2018(r334931)
+++ head/sys/conf/options.arm64 Sun Jun 10 19:42:44 2018(r334932)
@@ -13,9 +13,6 @@ COMPAT_FREEBSD32  opt_global.h
 # EFI Runtime services support
 EFIRT  opt_efirt.h
 
-# Devices
-DEV_PSCI   opt_platform.h
-
 # SoC Support
 SOC_ALLWINNER_A64  opt_soc.h
 SOC_ALLWINNER_H5   opt_soc.h
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r334929 - in head: . sys/sys

2018-06-10 Thread Eitan Adler
On 10 June 2018 at 11:53, Antoine Brodin  wrote:
> On Sun, Jun 10, 2018 at 8:43 PM, Mark Johnston  wrote:
>> On Sun, Jun 10, 2018 at 06:38:48PM +, Eitan Adler wrote:
>>> Author: eadler
>>> Date: Sun Jun 10 18:38:48 2018
>>> New Revision: 334929
>>> URL: https://svnweb.freebsd.org/changeset/base/334929
>>>
>>> Log:
>>>   include: remove sys/capability.h
>>>
>>>   This file has only generated a warning for the last 18 months. Its
>>>   existence at this point only serves to confuse software looking for
>>>   POSIX.1e capabilities and produce actionless warnings.
>>
>> Don't you need an exp-run to make this claim?
...
Reverted and exp-run request in
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=228878



-- 
Eitan Adler
Source, Ports, Doc committer
Bugmeister, Ports Security teams
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r334931 - in head: . sys/sys

2018-06-10 Thread Antoine Brodin
On Sun, Jun 10, 2018 at 9:15 PM, Eitan Adler  wrote:
> Author: eadler
> Date: Sun Jun 10 19:15:38 2018
> New Revision: 334931
> URL: https://svnweb.freebsd.org/changeset/base/334931
>
> Log:
>   Revert r334929
>
>   Apparently some software might depend on a header whose sole contents is
>   a `#warning` to remove it. Revert pending exp-run.

Hi,

It's not just a #warning,  there is a #include line below...
And after this change,  most ports that supported sandboxing were no
longer sandboxed.

Cheers,

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


svn commit: r334931 - in head: . sys/sys

2018-06-10 Thread Eitan Adler
Author: eadler
Date: Sun Jun 10 19:15:38 2018
New Revision: 334931
URL: https://svnweb.freebsd.org/changeset/base/334931

Log:
  Revert r334929
  
  Apparently some software might depend on a header whose sole contents is
  a `#warning` to remove it. Revert pending exp-run.

Added:
  head/sys/sys/capability.h
 - copied unchanged from r334928, head/sys/sys/capability.h
Modified:
  head/ObsoleteFiles.inc

Modified: head/ObsoleteFiles.inc
==
--- head/ObsoleteFiles.inc  Sun Jun 10 19:03:21 2018(r334930)
+++ head/ObsoleteFiles.inc  Sun Jun 10 19:15:38 2018(r334931)
@@ -38,8 +38,6 @@
 #   xargs -n1 | sort | uniq -d;
 # done
 
-# 20180610: Remove sys/capability.h
-OLD_FILES+=usr/include/sys/capability.h
 # 20180609: obsolete libc++ files missed from the 5.0.0 import
 OLD_FILES+=usr/include/c++/v1/__refstring
 OLD_FILES+=usr/include/c++/v1/__undef_min_max

Copied: head/sys/sys/capability.h (from r334928, head/sys/sys/capability.h)
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/sys/capability.h   Sun Jun 10 19:15:38 2018(r334931, copy 
of r334928, head/sys/sys/capability.h)
@@ -0,0 +1,46 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2014 Robert N. M. Watson
+ * All rights reserved.
+ *
+ * This software was developed at the University of Cambridge Computer
+ * Laboratory with support from a grant from Google, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+/*
+ * Historically, the key userspace and kernel Capsicum definitions were found
+ * in this file.  However, it conflicted with POSIX.1e's capability.h, so has
+ * been renamed capsicum.h.  The file remains for backwards compatibility
+ * reasons as a nested include.
+ */
+#ifndef _SYS_CAPABILITY_H_
+#define_SYS_CAPABILITY_H_
+
+#warning this file includes  which is deprecated
+#include 
+
+#endif /* !_SYS_CAPABILITY_H_ */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r334930 - head/sys/fs/nfsclient

2018-06-10 Thread Rick Macklem
Author: rmacklem
Date: Sun Jun 10 19:03:21 2018
New Revision: 334930
URL: https://svnweb.freebsd.org/changeset/base/334930

Log:
  Add checks for the Flexible File layout to LayoutRecall callbacks.
  
  The Flexible File layout case wasn't handled by LayoutRecall callbacks
  because it just checked for File layout and returned NFSERR_NOMATCHLAYOUT
  otherwise. This patch adds the Flexible File layout handling.
  Found during testing of the pNFS server.
  
  MFC after:2 weeks

Modified:
  head/sys/fs/nfsclient/nfs_clstate.c

Modified: head/sys/fs/nfsclient/nfs_clstate.c
==
--- head/sys/fs/nfsclient/nfs_clstate.c Sun Jun 10 18:38:48 2018
(r334929)
+++ head/sys/fs/nfsclient/nfs_clstate.c Sun Jun 10 19:03:21 2018
(r334930)
@@ -3422,9 +3422,12 @@ nfscl_docb(struct nfsrv_descript *nd, NFSPROC_T *p)
else
changed = 0;
recalltype = fxdr_unsigned(int, *tl);
+   NFSCL_DEBUG(4, "layt=%d iom=%d ch=%d rectyp=%d\n",
+   laytype, iomode, changed, recalltype);
recallp = malloc(sizeof(*recallp), M_NFSLAYRECALL,
M_WAITOK);
-   if (laytype != NFSLAYOUT_NFSV4_1_FILES)
+   if (laytype != NFSLAYOUT_NFSV4_1_FILES &&
+   laytype != NFSLAYOUT_FLEXFILE)
error = NFSERR_NOMATCHLAYOUT;
else if (recalltype == NFSLAYOUTRETURN_FILE) {
error = nfsm_getfh(nd, );
@@ -3441,6 +3444,9 @@ nfscl_docb(struct nfsrv_descript *nd, NFSPROC_T *p)
error = NFSERR_NOTSUPP;
else if (i == 0)
error = NFSERR_OPNOTINSESS;
+   NFSCL_DEBUG(4, "off=%ju len=%ju sq=%u err=%d\n",
+   (uintmax_t)off, (uintmax_t)len,
+   stateid.seqid, error);
if (error == 0) {
NFSLOCKCLSTATE();
clp = nfscl_getclntsess(sessionid);
@@ -3453,7 +3459,8 @@ nfscl_docb(struct nfsrv_descript *nd, NFSPROC_T *p)
lyp);
if (lyp != NULL &&
(lyp->nfsly_flags &
-NFSLY_FILES) != 0 &&
+(NFSLY_FILES |
+ NFSLY_FLEXFILE)) != 0 &&
!NFSBCMP(stateid.other,
lyp->nfsly_stateid.other,
NFSX_STATEIDOTHER)) {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r334929 - in head: . sys/sys

2018-06-10 Thread Antoine Brodin
On Sun, Jun 10, 2018 at 8:43 PM, Mark Johnston  wrote:
> On Sun, Jun 10, 2018 at 06:38:48PM +, Eitan Adler wrote:
>> Author: eadler
>> Date: Sun Jun 10 18:38:48 2018
>> New Revision: 334929
>> URL: https://svnweb.freebsd.org/changeset/base/334929
>>
>> Log:
>>   include: remove sys/capability.h
>>
>>   This file has only generated a warning for the last 18 months. Its
>>   existence at this point only serves to confuse software looking for
>>   POSIX.1e capabilities and produce actionless warnings.
>
> Don't you need an exp-run to make this claim?

Yes,  please revert.

Cheers,

Antoine (with hat: portmgr)


>
>> Deleted:
>>   head/sys/sys/capability.h
>> Modified:
>>   head/ObsoleteFiles.inc
>
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r334929 - in head: . sys/sys

2018-06-10 Thread Mark Johnston
On Sun, Jun 10, 2018 at 06:38:48PM +, Eitan Adler wrote:
> Author: eadler
> Date: Sun Jun 10 18:38:48 2018
> New Revision: 334929
> URL: https://svnweb.freebsd.org/changeset/base/334929
> 
> Log:
>   include: remove sys/capability.h
>   
>   This file has only generated a warning for the last 18 months. Its
>   existence at this point only serves to confuse software looking for
>   POSIX.1e capabilities and produce actionless warnings.

Don't you need an exp-run to make this claim?

> Deleted:
>   head/sys/sys/capability.h
> Modified:
>   head/ObsoleteFiles.inc
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r334929 - in head: . sys/sys

2018-06-10 Thread Eitan Adler
Author: eadler
Date: Sun Jun 10 18:38:48 2018
New Revision: 334929
URL: https://svnweb.freebsd.org/changeset/base/334929

Log:
  include: remove sys/capability.h
  
  This file has only generated a warning for the last 18 months. Its
  existence at this point only serves to confuse software looking for
  POSIX.1e capabilities and produce actionless warnings.

Deleted:
  head/sys/sys/capability.h
Modified:
  head/ObsoleteFiles.inc

Modified: head/ObsoleteFiles.inc
==
--- head/ObsoleteFiles.inc  Sun Jun 10 17:54:44 2018(r334928)
+++ head/ObsoleteFiles.inc  Sun Jun 10 18:38:48 2018(r334929)
@@ -38,6 +38,8 @@
 #   xargs -n1 | sort | uniq -d;
 # done
 
+# 20180610: Remove sys/capability.h
+OLD_FILES+=usr/include/sys/capability.h
 # 20180609: obsolete libc++ files missed from the 5.0.0 import
 OLD_FILES+=usr/include/c++/v1/__refstring
 OLD_FILES+=usr/include/c++/v1/__undef_min_max
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r334928 - head/lib/libc/stdlib

2018-06-10 Thread Konstantin Belousov
Author: kib
Date: Sun Jun 10 17:54:44 2018
New Revision: 334928
URL: https://svnweb.freebsd.org/changeset/base/334928

Log:
  libc qsort(3): stop aliasing.
  
  Qsort swap code aliases the sorted array elements to ints and longs in
  order to do swap by machine words.  Unfortunately this breaks with the
  full code optimization, e.g. LTO.
  
  See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83201 which seems to
  reference code directly copied from libc/stdlib/qsort.c.
  
  PR:   228780
  Reported by:  mli...@suse.cz
  Reviewed by:  brooks
  Sponsored by: The FreeBSD Foundation
  MFC after:2 weeks
  Differential revision:https://reviews.freebsd.org/D15714

Modified:
  head/lib/libc/stdlib/qsort.c

Modified: head/lib/libc/stdlib/qsort.c
==
--- head/lib/libc/stdlib/qsort.cSun Jun 10 16:44:18 2018
(r334927)
+++ head/lib/libc/stdlib/qsort.cSun Jun 10 17:54:44 2018
(r334928)
@@ -43,53 +43,27 @@ typedef int  cmp_t(void *, const void *, const void 
*
 typedef int cmp_t(const void *, const void *);
 #endif
 static inline char *med3(char *, char *, char *, cmp_t *, void *);
-static inline void  swapfunc(char *, char *, size_t, int, int);
 
 #defineMIN(a, b)   ((a) < (b) ? a : b)
 
 /*
  * Qsort routine from Bentley & McIlroy's "Engineering a Sort Function".
  */
-#defineswapcode(TYPE, parmi, parmj, n) {   \
-   size_t i = (n) / sizeof (TYPE); \
-   TYPE *pi = (TYPE *) (parmi);\
-   TYPE *pj = (TYPE *) (parmj);\
-   do {\
-   TYPEt = *pi;\
-   *pi++ = *pj;\
-   *pj++ = t;  \
-   } while (--i > 0);  \
-}
 
-#defineSWAPINIT(TYPE, a, es) swaptype_ ## TYPE =   \
-   ((char *)a - (char *)0) % sizeof(TYPE) ||   \
-   es % sizeof(TYPE) ? 2 : es == sizeof(TYPE) ? 0 : 1;
-
 static inline void
-swapfunc(char *a, char *b, size_t n, int swaptype_long, int swaptype_int)
+swapfunc(char *a, char *b, size_t es)
 {
-   if (swaptype_long <= 1)
-   swapcode(long, a, b, n)
-   else if (swaptype_int <= 1)
-   swapcode(int, a, b, n)
-   else
-   swapcode(char, a, b, n)
+   char t;
+
+   do {
+   t = *a;
+   *a++ = *b;
+   *b++ = t;
+   } while (--es > 0);
 }
 
-#defineswap(a, b)  \
-   if (swaptype_long == 0) {   \
-   long t = *(long *)(a);  \
-   *(long *)(a) = *(long *)(b);\
-   *(long *)(b) = t;   \
-   } else if (swaptype_int == 0) { \
-   int t = *(int *)(a);\
-   *(int *)(a) = *(int *)(b);  \
-   *(int *)(b) = t;\
-   } else  \
-   swapfunc(a, b, es, swaptype_long, swaptype_int)
-
 #definevecswap(a, b, n)\
-   if ((n) > 0) swapfunc(a, b, n, swaptype_long, swaptype_int)
+   if ((n) > 0) swapfunc(a, b, n)
 
 #ifdef I_AM_QSORT_R
 #defineCMP(t, x, y) (cmp((t), (x), (y)))
@@ -121,17 +95,16 @@ qsort(void *a, size_t n, size_t es, cmp_t *cmp)
char *pa, *pb, *pc, *pd, *pl, *pm, *pn;
size_t d1, d2;
int cmp_result;
-   int swaptype_long, swaptype_int, swap_cnt;
+   int swap_cnt;
 
-loop:  SWAPINIT(long, a, es);
-   SWAPINIT(int, a, es);
+loop:
swap_cnt = 0;
if (n < 7) {
for (pm = (char *)a + es; pm < (char *)a + n * es; pm += es)
for (pl = pm; 
 pl > (char *)a && CMP(thunk, pl - es, pl) > 0;
 pl -= es)
-   swap(pl, pl - es);
+   swapfunc(pl, pl - es, es);
return;
}
pm = (char *)a + (n / 2) * es;
@@ -147,7 +120,7 @@ loop:   SWAPINIT(long, a, es);
}
pm = med3(pl, pm, pn, cmp, thunk);
}
-   swap(a, pm);
+   swapfunc(a, pm, es);
pa = pb = (char *)a + es;
 
pc = pd = (char *)a + (n - 1) * es;
@@ -155,7 +128,7 @@ loop:   SWAPINIT(long, a, es);
while (pb <= pc && (cmp_result = CMP(thunk, pb, a)) <= 0) {
if (cmp_result == 0) {
swap_cnt = 1;
-   swap(pa, pb);
+   swapfunc(pa, pb, es);
pa += es;
}
pb += es;
@@ -163,14 +136,14 @@ loop: 

svn commit: r334927 - head/usr.bin/indent

2018-06-10 Thread Piotr Pawel Stefaniak
Author: pstef
Date: Sun Jun 10 16:44:18 2018
New Revision: 334927
URL: https://svnweb.freebsd.org/changeset/base/334927

Log:
  indent(1): group global option variables into an options structure
  
  It's clearer now when a variable represents a toggable command line option.
  
  Many options were stored in the parser's state structure, so fix also that.

Modified:
  head/usr.bin/indent/args.c
  head/usr.bin/indent/indent.c
  head/usr.bin/indent/indent_globs.h
  head/usr.bin/indent/io.c
  head/usr.bin/indent/lexi.c
  head/usr.bin/indent/parse.c
  head/usr.bin/indent/pr_comment.c

Modified: head/usr.bin/indent/args.c
==
--- head/usr.bin/indent/args.c  Sun Jun 10 16:21:21 2018(r334926)
+++ head/usr.bin/indent/args.c  Sun Jun 10 16:44:18 2018(r334927)
@@ -102,72 +102,72 @@ struct pro {
 {"U", PRO_SPECIAL, 0, KEY_FILE, 0},
 {"-version", PRO_SPECIAL, 0, VERSION, 0},
 {"P", PRO_SPECIAL, 0, IGN, 0},
-{"bacc", PRO_BOOL, false, ON, _around_conditional_compilation},
-{"badp", PRO_BOOL, false, ON, _after_declarations_at_proctop},
-{"bad", PRO_BOOL, false, ON, _after_declarations},
-{"bap", PRO_BOOL, false, ON, _after_procs},
-{"bbb", PRO_BOOL, false, ON, _before_blockcomments},
-{"bc", PRO_BOOL, true, OFF, _comma},
-{"bl", PRO_BOOL, true, OFF, _2},
-{"br", PRO_BOOL, true, ON, _2},
-{"bs", PRO_BOOL, false, ON, _Shannon},
-{"cdb", PRO_BOOL, true, ON, _delimiter_on_blankline},
-{"cd", PRO_INT, 0, 0, _com_ind},
-{"ce", PRO_BOOL, true, ON, _else},
-{"ci", PRO_INT, 0, 0, _indent},
+{"bacc", PRO_BOOL, false, ON, 
_around_conditional_compilation},
+{"badp", PRO_BOOL, false, ON, 
_after_declarations_at_proctop},
+{"bad", PRO_BOOL, false, ON, _after_declarations},
+{"bap", PRO_BOOL, false, ON, _after_procs},
+{"bbb", PRO_BOOL, false, ON, _before_blockcomments},
+{"bc", PRO_BOOL, true, OFF, _comma},
+{"bl", PRO_BOOL, true, OFF, _2},
+{"br", PRO_BOOL, true, ON, _2},
+{"bs", PRO_BOOL, false, ON, _Shannon},
+{"cdb", PRO_BOOL, true, ON, _delimiter_on_blankline},
+{"cd", PRO_INT, 0, 0, _com_ind},
+{"ce", PRO_BOOL, true, ON, _else},
+{"ci", PRO_INT, 0, 0, _indent},
 {"cli", PRO_SPECIAL, 0, CLI, 0},
-{"c", PRO_INT, 33, 0, _ind},
-{"di", PRO_INT, 16, 0, _indent},
-{"dj", PRO_BOOL, false, ON, _decl},
-{"d", PRO_INT, 0, 0, _displace},
-{"eei", PRO_BOOL, false, ON, _expression_indent},
-{"ei", PRO_BOOL, true, ON, _if},
-{"fbs", PRO_BOOL, true, ON, _brace_split},
-{"fc1", PRO_BOOL, true, ON, _col1_comments},
-{"fcb", PRO_BOOL, true, ON, _block_comments},
-{"ip", PRO_BOOL, true, ON, _parameters},
-{"i", PRO_INT, 8, 0, _size},
-{"lc", PRO_INT, 0, 0, _comment_max_col},
-{"ldi", PRO_INT, -1, 0, _decl_indent},
-{"lpl", PRO_BOOL, false, ON, _to_parens_always},
-{"lp", PRO_BOOL, true, ON, _to_parens},
-{"l", PRO_INT, 78, 0, _col},
-{"nbacc", PRO_BOOL, false, OFF, 
_around_conditional_compilation},
-{"nbadp", PRO_BOOL, false, OFF, _after_declarations_at_proctop},
-{"nbad", PRO_BOOL, false, OFF, _after_declarations},
-{"nbap", PRO_BOOL, false, OFF, _after_procs},
-{"nbbb", PRO_BOOL, false, OFF, _before_blockcomments},
-{"nbc", PRO_BOOL, true, ON, _comma},
-{"nbs", PRO_BOOL, false, OFF, _Shannon},
-{"ncdb", PRO_BOOL, true, OFF, _delimiter_on_blankline},
-{"nce", PRO_BOOL, true, OFF, _else},
-{"ndj", PRO_BOOL, false, OFF, _decl},
-{"neei", PRO_BOOL, false, OFF, _expression_indent},
-{"nei", PRO_BOOL, true, OFF, _if},
-{"nfbs", PRO_BOOL, true, OFF, _brace_split},
-{"nfc1", PRO_BOOL, true, OFF, _col1_comments},
-{"nfcb", PRO_BOOL, true, OFF, _block_comments},
-{"nip", PRO_BOOL, true, OFF, _parameters},
-{"nlpl", PRO_BOOL, false, OFF, _to_parens_always},
-{"nlp", PRO_BOOL, true, OFF, _to_parens},
-{"npcs", PRO_BOOL, false, OFF, _calls_space},
+{"c", PRO_INT, 33, 0, _ind},
+{"di", PRO_INT, 16, 0, _indent},
+{"dj", PRO_BOOL, false, ON, _decl},
+{"d", PRO_INT, 0, 0, _displace},
+{"eei", PRO_BOOL, false, ON, _expression_indent},
+{"ei", PRO_BOOL, true, ON, _if},
+{"fbs", PRO_BOOL, true, ON, _brace_split},
+{"fc1", PRO_BOOL, true, ON, _col1_comments},
+{"fcb", PRO_BOOL, true, ON, _block_comments},
+{"ip", PRO_BOOL, true, ON, _parameters},
+{"i", PRO_INT, 8, 0, _size},
+{"lc", PRO_INT, 0, 0, _comment_max_col},
+{"ldi", PRO_INT, -1, 0, _decl_indent},
+{"lpl", PRO_BOOL, false, ON, _to_parens_always},
+{"lp", PRO_BOOL, true, ON, _to_parens},
+{"l", PRO_INT, 78, 0, _col},
+{"nbacc", PRO_BOOL, false, OFF, 
_around_conditional_compilation},
+{"nbadp", PRO_BOOL, false, OFF, 
_after_declarations_at_proctop},
+{"nbad", PRO_BOOL, false, OFF, _after_declarations},
+{"nbap", PRO_BOOL, false, OFF, _after_procs},
+{"nbbb", PRO_BOOL, false, OFF, 

Re: svn commit: r333945 - head/usr.bin/top

2018-06-10 Thread Alexey Dokuchaev
On Sun, Jun 10, 2018 at 08:56:24AM -0700, Eitan Adler wrote:
> On 10 June 2018 at 05:28, Alexey Dokuchaev  wrote:
> > I've just tried the latest top(1).  Now it's even worse:
> > ...
> > Also, it is COMMA now.  Can we please do something about this?  I am not
> > calling for "USER PRI" as Bruce had suggested, but "USERNAME PRI" is just
> > about right.
> 
> FWIW I have not forgotten about this. I am planning on completely
> rewriting how the header, and data, get displayed so its low my
> priority (pun intended) list to fix this specific case until then.

Great!  Looking forward to improvements.  top(1) should be neat(TM).
Take your time Eitan, it's not that urgent.

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


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

2018-06-10 Thread Andrew Turner
Author: andrew
Date: Sun Jun 10 16:21:21 2018
New Revision: 334926
URL: https://svnweb.freebsd.org/changeset/base/334926

Log:
  Clean up handling of unexpected exceptions. Previously we would issue a
  breakpoint instruction, however this would lose information that may be
  useful for debugging.
  
  These are now handled in a similar way to other exceptions, however it
  won't exit out of the exception handler until it is known if we can
  handle these exceptions in a useful way.
  
  Sponsored by: DARPA, AFRL

Modified:
  head/sys/arm64/arm64/exception.S
  head/sys/arm64/arm64/trap.c

Modified: head/sys/arm64/arm64/exception.S
==
--- head/sys/arm64/arm64/exception.SSun Jun 10 14:49:13 2018
(r334925)
+++ head/sys/arm64/arm64/exception.SSun Jun 10 16:21:21 2018
(r334926)
@@ -161,10 +161,6 @@ ENTRY(handle_el1h_irq)
eret
 END(handle_el1h_irq)
 
-ENTRY(handle_el1h_error)
-   brk 0xf13
-END(handle_el1h_error)
-
 ENTRY(handle_el0_sync)
save_registers 0
ldr x0, [x18, #PC_CURTHREAD]
@@ -185,18 +181,23 @@ ENTRY(handle_el0_irq)
eret
 END(handle_el0_irq)
 
-ENTRY(handle_el0_error)
+ENTRY(handle_serror)
save_registers 0
mov x0, sp
-   bl  do_el0_error
-   brk 0xf23
-   1: b 1b
-END(handle_el0_error)
+1: bl  do_serror
+   b   1b
+END(handle_serror)
 
+ENTRY(handle_empty_exception)
+   save_registers 0
+   mov x0, sp
+1: bl  unhandled_exception
+   b   1b
+END(handle_unhandled_exception)
+
 .macro vempty
.align 7
-   brk 0xfff
-   1: b1b
+   b   handle_empty_exception
 .endm
 
 .macro vector  name
@@ -215,15 +216,15 @@ exception_vectors:
vector el1h_sync/* Synchronous EL1h */
vector el1h_irq /* IRQ EL1h */
vempty  /* FIQ EL1h */
-   vector el1h_error   /* Error EL1h */
+   vector serror   /* Error EL1h */
 
vector el0_sync /* Synchronous 64-bit EL0 */
vector el0_irq  /* IRQ 64-bit EL0 */
vempty  /* FIQ 64-bit EL0 */
-   vector el0_error/* Error 64-bit EL0 */
+   vector serror   /* Error 64-bit EL0 */
 
vector el0_sync /* Synchronous 32-bit EL0 */
vector el0_irq  /* IRQ 32-bit EL0 */
vempty  /* FIQ 32-bit EL0 */
-   vector el0_error/* Error 32-bit EL0 */
+   vector serror   /* Error 32-bit EL0 */
 

Modified: head/sys/arm64/arm64/trap.c
==
--- head/sys/arm64/arm64/trap.c Sun Jun 10 14:49:13 2018(r334925)
+++ head/sys/arm64/arm64/trap.c Sun Jun 10 16:21:21 2018(r334926)
@@ -76,6 +76,9 @@ extern register_t fsu_intr_fault;
 void do_el1h_sync(struct thread *, struct trapframe *);
 void do_el0_sync(struct thread *, struct trapframe *);
 void do_el0_error(struct trapframe *);
+void do_serror(struct trapframe *);
+void unhandled_exception(struct trapframe *);
+
 static void print_registers(struct trapframe *frame);
 
 int (*dtrace_invop_jump_addr)(struct trapframe *);
@@ -477,10 +480,33 @@ do_el0_sync(struct thread *td, struct trapframe *frame
("Kernel VFP state in use when entering userspace"));
 }
 
+/*
+ * TODO: We will need to handle these later when we support ARMv8.2 RAS.
+ */
 void
-do_el0_error(struct trapframe *frame)
+do_serror(struct trapframe *frame)
 {
+   uint64_t esr, far;
 
-   panic("ARM64TODO: do_el0_error");
+   far = READ_SPECIALREG(far_el1);
+   esr = frame->tf_esr;
+
+   print_registers(frame);
+   printf(" far: %16lx\n", far);
+   printf(" esr: %.8lx\n", esr);
+   panic("Unhandled System Error");
 }
 
+void
+unhandled_exception(struct trapframe *frame)
+{
+   uint64_t esr, far;
+
+   far = READ_SPECIALREG(far_el1);
+   esr = frame->tf_esr;
+
+   print_registers(frame);
+   printf(" far: %16lx\n", far);
+   printf(" esr: %.8lx\n", esr);
+   panic("Unhandled exception");
+}
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r333945 - head/usr.bin/top

2018-06-10 Thread Eitan Adler
On 10 June 2018 at 05:28, Alexey Dokuchaev  wrote:
> On Mon, May 21, 2018 at 06:39:53AM +, Alexey Dokuchaev wrote:
>> I [...] have to patch top(1) locally to use namelength = 8 and header
>> format so it neatly looks like this:
>>
>>   PID USERNAME THR PRI NICE   SIZERES STATE   C   TIMEWCPU COMMAND
>>   844 danfe  2  210   114M 38836K select  0  49:39   3.82% Xorg
>>  5836 danfe 12  200   101M 23020K select  0  38:19   2.26% deadbeef
>>
>> instead of our ugly, default this:
>>
>>   
>>   PID USERNAMETHR PRI NICE   SIZERES STATE   C   TIMEWCPU COMMAND
>> 41086 danfe 1  200 13280K  3112K CPU11   0:00   0.09% top
>>   751 root  1  200 10812K   596K select  2  16:53   0.03% powerd
>>   ^^
>> The amount of wasted space (shown above) is unjustified IMO.
>
> I've just tried the latest top(8).  Now it's even worse:
>
>   vvv (7, was 4)
>   PID USERNAME   THR PRI NICE   SIZERES STATE   C   TIMEWCPU 
> COMMAN
>   818 root 1  200  4484K  2148K select  0   0:01   1.57% 
> moused
>   995 danfe2  200 94208K 40084K select  1   0:06   0.47% Xorg
>  1107 danfe1  200 35728K 14544K select  0   0:00   0.05% xterm
>
> Notice COMMAN (before it was not truncated) and increased amount of wasted
> space.
>
> If I switch to separate threads mode ('H'), alignment breaks:
>
>   PID USERNAME   PRI NICE   SIZERES STATE   C   TIMEWCPU COMMAND
>   818 root   200  4484K  2148K select  0   0:01   1.96% moused
>   995 danfe  200 93660K 38912K select  1   0:06   0.57% Xorg{Xorg}
>  1107 danfe  200 35728K 13624K select  0   0:01   0.05% xterm
>
> If I press 'T', it says "Displaying tid", but the column name is THR, not
> TID.  This is a bit confusing.
>
>  Displaying tid
>THR USERNAME   THR PRI NICE   SIZERES STATE   C   TIMEWCPU 
> COMMA
> 100122 root 1  200  4484K  2148K select  0   0:01   0.49% 
> mouse
>
> Also, it is COMMA now.  Can we please do something about this?  I am not
> calling for "USER PRI" as Bruce had suggested, but "USERNAME PRI" is just
> about right.

FWIW I have not forgotten about this. I am planning on completely
rewriting how the header, and data, get displayed so its low my
priority (pun intended) list to fix this specific case until then.



-- 
Eitan Adler
Source, Ports, Doc committer
Bugmeister, Ports Security teams
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r334925 - in head/sys: amd64/amd64 x86/x86

2018-06-10 Thread Bruce Evans
Author: bde
Date: Sun Jun 10 14:49:13 2018
New Revision: 334925
URL: https://svnweb.freebsd.org/changeset/base/334925

Log:
  Untangle configuration ifdefs a little.  On x86, msi is optional on pci,
  and also on apic in common and i386 files (except for xen it is optional
  only on xenhvm), but it was not ifdefed except on apic in common and i386
  files.
  
  This is all that is left from an attempt to build a (sub-)minimal kernel
  without any devices.  The isa "option" is still used without ifdefs in many
  standard files even on amd64.  ISAPNP is not optional on at least i386.
  ATPIC is not optional on i386 (it is used mainly for Xspuriousint).  But
  pci is now supposed to be optional on x86.

Modified:
  head/sys/amd64/amd64/machdep.c
  head/sys/x86/x86/nexus.c

Modified: head/sys/amd64/amd64/machdep.c
==
--- head/sys/amd64/amd64/machdep.c  Sun Jun 10 14:21:01 2018
(r334924)
+++ head/sys/amd64/amd64/machdep.c  Sun Jun 10 14:49:13 2018
(r334925)
@@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$");
 #include "opt_kstack_pages.h"
 #include "opt_maxmem.h"
 #include "opt_mp_watchdog.h"
+#include "opt_pci.h"
 #include "opt_platform.h"
 #include "opt_sched.h"
 
@@ -184,7 +185,9 @@ struct init_ops init_ops = {
.mp_bootaddress =   mp_bootaddress,
.start_all_aps =native_start_all_aps,
 #endif
+#ifdef DEV_PCI
.msi_init = msi_init,
+#endif
 };
 
 /*

Modified: head/sys/x86/x86/nexus.c
==
--- head/sys/x86/x86/nexus.cSun Jun 10 14:21:01 2018(r334924)
+++ head/sys/x86/x86/nexus.cSun Jun 10 14:49:13 2018(r334925)
@@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$");
 #include "opt_apic.h"
 #endif
 #include "opt_isa.h"
+#include "opt_pci.h"
 
 #include 
 #include 
@@ -131,7 +132,7 @@ static  int nexus_get_resource(device_t, device_t, int,
 static void nexus_delete_resource(device_t, device_t, int, int);
 static int nexus_get_cpus(device_t, device_t, enum cpu_sets, size_t,
   cpuset_t *);
-#ifdef DEV_APIC
+#if defined(DEV_APIC) && defined(DEV_PCI)
 static int nexus_alloc_msi(device_t pcib, device_t dev, int count, int 
maxcount, int *irqs);
 static int nexus_release_msi(device_t pcib, device_t dev, int count, int 
*irqs);
 static int nexus_alloc_msix(device_t pcib, device_t dev, int *irq);
@@ -172,7 +173,7 @@ static device_method_t nexus_methods[] = {
DEVMETHOD(bus_get_cpus, nexus_get_cpus),
 
/* pcib interface */
-#ifdef DEV_APIC
+#if defined(DEV_APIC) && defined(DEV_PCI)
DEVMETHOD(pcib_alloc_msi,   nexus_alloc_msi),
DEVMETHOD(pcib_release_msi, nexus_release_msi),
DEVMETHOD(pcib_alloc_msix,  nexus_alloc_msix),
@@ -701,7 +702,7 @@ nexus_add_irq(u_long irq)
panic("%s: failed", __func__);
 }
 
-#ifdef DEV_APIC
+#if defined(DEV_APIC) && defined(DEV_PCI)
 static int
 nexus_alloc_msix(device_t pcib, device_t dev, int *irq)
 {
@@ -736,7 +737,7 @@ nexus_map_msi(device_t pcib, device_t dev, int irq, ui
 
return (msi_map(irq, addr, data));
 }
-#endif
+#endif /* DEV_APIC && DEV_PCI */
 
 /* Placeholder for system RAM. */
 static void
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r334924 - head/sys/i386/i386

2018-06-10 Thread Bruce Evans
Author: bde
Date: Sun Jun 10 14:21:01 2018
New Revision: 334924
URL: https://svnweb.freebsd.org/changeset/base/334924

Log:
  Fix panics in potentially all x86bios calls on i386 since r332489.
  
  A call to npxsave() in the exception trampolines was not relocated.
  This call to a garbage address usually paniced when made, but it is only
  made when the thread has used an FPU recently, and this is not the usual
  case.
  
  PR:   228755
  Reviewed by:  kib

Modified:
  head/sys/i386/i386/vm86bios.s

Modified: head/sys/i386/i386/vm86bios.s
==
--- head/sys/i386/i386/vm86bios.s   Sun Jun 10 10:23:31 2018
(r334923)
+++ head/sys/i386/i386/vm86bios.s   Sun Jun 10 14:21:01 2018
(r334924)
@@ -67,7 +67,8 @@ ENTRY(vm86_bioscall)
pushl   %edx
movlTD_PCB(%ecx),%ecx
pushl   PCB_SAVEFPU(%ecx)
-   callnpxsave
+   movl$npxsave,%eax
+   call*%eax
addl$4,%esp
popl%edx/* recover our pcb */
 1:
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r333945 - head/usr.bin/top

2018-06-10 Thread Alexey Dokuchaev
On Mon, May 21, 2018 at 06:39:53AM +, Alexey Dokuchaev wrote:
> I [...] have to patch top(1) locally to use namelength = 8 and header
> format so it neatly looks like this:
> 
>   PID USERNAME THR PRI NICE   SIZERES STATE   C   TIMEWCPU COMMAND
>   844 danfe  2  210   114M 38836K select  0  49:39   3.82% Xorg
>  5836 danfe 12  200   101M 23020K select  0  38:19   2.26% deadbeef
> 
> instead of our ugly, default this:
> 
>   
>   PID USERNAMETHR PRI NICE   SIZERES STATE   C   TIMEWCPU COMMAND
> 41086 danfe 1  200 13280K  3112K CPU11   0:00   0.09% top
>   751 root  1  200 10812K   596K select  2  16:53   0.03% powerd
>   ^^
> The amount of wasted space (shown above) is unjustified IMO.

I've just tried the latest top(8).  Now it's even worse:

  vvv (7, was 4)
  PID USERNAME   THR PRI NICE   SIZERES STATE   C   TIMEWCPU COMMAN
  818 root 1  200  4484K  2148K select  0   0:01   1.57% moused
  995 danfe2  200 94208K 40084K select  1   0:06   0.47% Xorg
 1107 danfe1  200 35728K 14544K select  0   0:00   0.05% xterm

Notice COMMAN (before it was not truncated) and increased amount of wasted
space.

If I switch to separate threads mode ('H'), alignment breaks:

  PID USERNAME   PRI NICE   SIZERES STATE   C   TIMEWCPU COMMAND
  818 root   200  4484K  2148K select  0   0:01   1.96% moused
  995 danfe  200 93660K 38912K select  1   0:06   0.57% Xorg{Xorg}
 1107 danfe  200 35728K 13624K select  0   0:01   0.05% xterm

If I press 'T', it says "Displaying tid", but the column name is THR, not
TID.  This is a bit confusing.

 Displaying tid
   THR USERNAME   THR PRI NICE   SIZERES STATE   C   TIMEWCPU COMMA
100122 root 1  200  4484K  2148K select  0   0:01   0.49% mouse

Also, it is COMMA now.  Can we please do something about this?  I am not
calling for "USER PRI" as Bruce had suggested, but "USERNAME PRI" is just
about right.  Most of the usernames are 8 characters or less.  Even if they
are longer, it makes more sense to truncate usernames than the column names
and, especially, command lines.  Thanks,

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


svn commit: r334923 - in head: share/man/man4 share/man/man4/man4.i386 sys/dev/atkbdc sys/dev/mse sys/dev/syscons sys/sys

2018-06-10 Thread Vladimir Kondratyev
Author: wulf
Date: Sun Jun 10 10:23:31 2018
New Revision: 334923
URL: https://svnweb.freebsd.org/changeset/base/334923

Log:
  Drop MOUSE_GETVARS and MOUSE_SETVARS ioctls support.
  
  These ioctls are not documented and only stubbed in a few drivers: mse(4),
  psm(4) and syscon's sysmouse(4). The only exception is MOUSE_GETVARS
  implemented in psm(4)
  
  Given the fact that they were introduced 20 years ago and implementation
  has never been completed, remove any related code.
  
  PR:   228718 (exp-run)
  Reviewed by:  imp
  Differential Revision:https://reviews.freebsd.org/D15726

Modified:
  head/share/man/man4/man4.i386/mse.4
  head/share/man/man4/mouse.4
  head/share/man/man4/psm.4
  head/share/man/man4/sysmouse.4
  head/sys/dev/atkbdc/psm.c
  head/sys/dev/mse/mse.c
  head/sys/dev/syscons/sysmouse.c
  head/sys/sys/mouse.h

Modified: head/share/man/man4/man4.i386/mse.4
==
--- head/share/man/man4/man4.i386/mse.4 Sun Jun 10 09:15:13 2018
(r334922)
+++ head/share/man/man4/man4.i386/mse.4 Sun Jun 10 10:23:31 2018
(r334923)
@@ -319,12 +319,6 @@ and
 may be modifiable.
 Setting values in the other field does not generate
 error and has no effect.
-.\" .Pp
-.\" .It Dv MOUSE_GETVARS Ar mousevar_t *vars
-.\" .It Dv MOUSE_SETVARS Ar mousevar_t *vars
-.\" These commands are not supported by the
-.\" .Nm
-.\" driver.
 .Pp
 .It Dv MOUSE_READDATA Ar mousedata_t *data
 .It Dv MOUSE_READSTATE Ar mousedata_t *state

Modified: head/share/man/man4/mouse.4
==
--- head/share/man/man4/mouse.4 Sun Jun 10 09:15:13 2018(r334922)
+++ head/share/man/man4/mouse.4 Sun Jun 10 10:23:31 2018(r334923)
@@ -292,27 +292,6 @@ You may also put zero in
 and
 .Dv rate ,
 and the default value for the fields will be selected.
-.\" .Pp
-.\" .It Dv MOUSE_GETVARS Ar mousevar_t *vars
-.\" Get internal variables of the mouse driver.
-.\" The variables which can be manipulated through these commands
-.\" are specific to each driver.
-.\" This command may not be supported by all drivers.
-.\" .Bd -literal
-.\" typedef struct mousevar {
-.\" int var[16];/* internal variables */
-.\" } mousevar_t;
-.\" .Ed
-.\" .Pp
-.\" If the commands are supported, the first element of the array is
-.\" filled with a signature value.
-.\" Apart from the signature data, there is currently no standard concerning
-.\" the other elements of the buffer.
-.\" .Pp
-.\" .It Dv MOUSE_SETVARS Ar mousevar_t *vars
-.\" Get internal variables of the mouse driver.
-.\" The first element of the array must be a signature value.
-.\" This command may not be supported by all drivers.
 .Pp
 .It Dv MOUSE_READDATA Ar mousedata_t *data
 The command reads the raw data from the device.

Modified: head/share/man/man4/psm.4
==
--- head/share/man/man4/psm.4   Sun Jun 10 09:15:13 2018(r334922)
+++ head/share/man/man4/psm.4   Sun Jun 10 10:23:31 2018(r334923)
@@ -591,12 +591,6 @@ You may also put zero in
 and
 .Dv rate ,
 and the default value for the fields will be selected.
-.\" .Pp
-.\" .It Dv MOUSE_GETVARS Ar mousevar_t *vars
-.\" .It Dv MOUSE_SETVARS Ar mousevar_t *vars
-.\" These commands are not supported by the
-.\" .Nm
-.\" driver.
 .Pp
 .It Dv MOUSE_READDATA Ar mousedata_t *data
 .\" The command reads the raw data from the device.

Modified: head/share/man/man4/sysmouse.4
==
--- head/share/man/man4/sysmouse.4  Sun Jun 10 09:15:13 2018
(r334922)
+++ head/share/man/man4/sysmouse.4  Sun Jun 10 10:23:31 2018
(r334923)
@@ -264,12 +264,6 @@ Only
 may be modifiable.
 Setting values in the other field does not generate
 error and has no effect.
-.\" .Pp
-.\" .It Dv MOUSE_GETVARS Ar mousevar_t *vars
-.\" .It Dv MOUSE_SETVARS Ar mousevar_t *vars
-.\" These commands are not supported by the
-.\" .Nm
-.\" driver.
 .Pp
 .It Dv MOUSE_READDATA Ar mousedata_t *data
 .It Dv MOUSE_READSTATE Ar mousedata_t *state

Modified: head/sys/dev/atkbdc/psm.c
==
--- head/sys/dev/atkbdc/psm.c   Sun Jun 10 09:15:13 2018(r334922)
+++ head/sys/dev/atkbdc/psm.c   Sun Jun 10 10:23:31 2018(r334923)
@@ -2560,9 +2560,6 @@ psmioctl(struct cdev *dev, u_long cmd, caddr_t addr, i
struct psm_softc *sc = dev->si_drv1;
mousemode_t mode;
mousestatus_t status;
-#if (defined(MOUSE_GETVARS))
-   mousevar_t *var;
-#endif
mousedata_t *data;
int stat[3];
int command_byte;
@@ -2758,21 +2755,6 @@ psmioctl(struct cdev *dev, u_long cmd, caddr_t addr, i
splx(s);
*(mousestatus_t *)addr = status;
break;
-
-#if (defined(MOUSE_GETVARS))
-   case 

svn commit: r334922 - head/usr.bin/top

2018-06-10 Thread Eitan Adler
Author: eadler
Date: Sun Jun 10 09:15:13 2018
New Revision: 334922
URL: https://svnweb.freebsd.org/changeset/base/334922

Log:
  top(1): use modern interfaces for nice and related
  
  - attempt and fail, rather than check for permission.
  - use macro rather than explicit "-20"

Modified:
  head/usr.bin/top/commands.c
  head/usr.bin/top/top.c

Modified: head/usr.bin/top/commands.c
==
--- head/usr.bin/top/commands.c Sun Jun 10 09:04:56 2018(r334921)
+++ head/usr.bin/top/commands.c Sun Jun 10 09:15:13 2018(r334922)
@@ -379,14 +379,10 @@ kill_procs(char *str)
 char *nptr;
 int signum = SIGTERM;  /* default */
 int procnum;
-int uid;
 
 /* reset error array */
 ERR_RESET;
 
-/* remember our uid */
-uid = getuid();
-
 /* skip over leading white space */
 while (isspace(*str)) str++;
 
@@ -429,13 +425,8 @@ kill_procs(char *str)
}
else
{
-   /* check process owner if we're not root */
-   if (uid && (uid != proc_owner(procnum)))
-   {
-   ERROR(str, EACCES);
-   }
/* go in for the kill */
-   else if (kill(procnum, signum) == -1)
+   if (kill(procnum, signum) == -1)
{
/* chalk up an error */
ERROR(str, errno);
@@ -458,10 +449,8 @@ renice_procs(char *str)
 char negate;
 int prio;
 int procnum;
-int uid;
 
 ERR_RESET;
-uid = getuid();
 
 /* allow for negative priority values */
 if ((negate = (*str == '-')) != 0)
@@ -499,12 +488,7 @@ renice_procs(char *str)
ERROR(str, 0);
}
 
-   /* check process owner if we're not root */
-   else if (uid && (uid != proc_owner(procnum)))
-   {
-   ERROR(str, EACCES);
-   }
-   else if (setpriority(PRIO_PROCESS, procnum, prio) == -1)
+   if (setpriority(PRIO_PROCESS, procnum, prio) == -1)
{
ERROR(str, errno);
}

Modified: head/usr.bin/top/top.c
==
--- head/usr.bin/top/top.c  Sun Jun 10 09:04:56 2018(r334921)
+++ head/usr.bin/top/top.c  Sun Jun 10 09:15:13 2018(r334922)
@@ -16,9 +16,9 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
-#include 
 
 #include 
 #include 
@@ -439,19 +439,13 @@ _Static_assert(sizeof(command_chars) == CMD_toggletid 
break;
 
  case 'q': /* be quick about it */
-   /* only allow this if user is really root */
-   if (getuid() == 0)
-   {
-   /* be very un-nice! */
-   nice(-20);
-   }
-   else
-   {
-   fprintf(stderr,
-   "%s: warning: `-q' option can only be used by root\n",
-   myname);
-   warnings++;
-   }
+   errno = 0;
+   i = setpriority(PRIO_PROCESS, 0, PRIO_MIN);
+   if (i == -1 && errno != 0) {
+   fprintf(stderr,
+   "%s: warning: `-q' option 
failed (%m)\n", myname);
+   warnings++;
+   }
break;
 
  case 'm': /* select display mode */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r334921 - head/usr.bin/top

2018-06-10 Thread Eitan Adler
Author: eadler
Date: Sun Jun 10 09:04:56 2018
New Revision: 334921
URL: https://svnweb.freebsd.org/changeset/base/334921

Log:
  top(1): add command aliases; correct dumb support

Modified:
  head/usr.bin/top/commands.c

Modified: head/usr.bin/top/commands.c
==
--- head/usr.bin/top/commands.c Sun Jun 10 09:00:01 2018(r334920)
+++ head/usr.bin/top/commands.c Sun Jun 10 09:04:56 2018(r334921)
@@ -56,14 +56,17 @@ static const struct command all_commands[] =
{'d', "change number of displays to show", false},
{'e', "list errors generated by last \"kill\" or \"renice\" command", 
false},
{'H', "toggle the displaying of threads", false},
-   {'h', "show this help text", false},
+   {'h', "show this help text", true},
+   {'?', "show this help text", true},
{'i', "toggle the displaying of idle processes", false},
+   {'I', "toggle the displaying of idle processes", false},
{'j', "toggle the displaying of jail ID", false},
{'J', "display processes for only one jail (+ selects all jails)", 
false},
{'k', "kill processes; send a signal to a list of processes", false},
-   {'q', "quit" , false},
+   {'q', "quit" , true},
{'m', "toggle the display between 'cpu' and 'io' modes", false},
{'n', "change number of processes to display", false},
+   {'#', "change number of processes to display", false},
{'o', "specify the sort order", false},
{'p', "display one process (+ selects all processes)", false},
{'P', "toggle the displaying of per-CPU statistics", false},
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r334920 - head/usr.bin/top

2018-06-10 Thread Eitan Adler
Author: eadler
Date: Sun Jun 10 09:00:01 2018
New Revision: 334920
URL: https://svnweb.freebsd.org/changeset/base/334920

Log:
  top(1): use sys_signame instead of hard coding signals
  
  This enables the removal of the signal.h awk script. Shamelessly stolen
  from kill(1).

Deleted:
  head/usr.bin/top/sigconv.awk
Modified:
  head/usr.bin/top/Makefile
  head/usr.bin/top/commands.c

Modified: head/usr.bin/top/Makefile
==
--- head/usr.bin/top/Makefile   Sun Jun 10 08:59:57 2018(r334919)
+++ head/usr.bin/top/Makefile   Sun Jun 10 09:00:01 2018(r334920)
@@ -4,7 +4,7 @@
 
 PROG=  top
 SRCS=  commands.c display.c machine.c screen.c top.c \
-   username.c utils.c sigdesc.h
+   username.c utils.c
 CFLAGS+= -I ${.OBJDIR}
 MAN=   top.1
 
@@ -19,10 +19,4 @@ NO_WERROR=
 CFLAGS.clang=-Wno-error=incompatible-pointer-types-discards-qualifiers 
-Wno-error=cast-qual
 
 LIBADD=ncursesw m kvm jail
-
-CLEANFILES= sigdesc.h
-SIGNAL_H= ${SRCTOP}/sys/sys/signal.h
-sigdesc.h: sigconv.awk ${SIGNAL_H}
-   awk -f ${SRCTOP}/usr.bin/top/sigconv.awk < ${SIGNAL_H} > ${.TARGET}
-
 .include 

Modified: head/usr.bin/top/commands.c
==
--- head/usr.bin/top/commands.c Sun Jun 10 08:59:57 2018(r334919)
+++ head/usr.bin/top/commands.c Sun Jun 10 09:00:01 2018(r334920)
@@ -30,7 +30,6 @@
 #include 
 
 #include "commands.h"
-#include "sigdesc.h"   /* generated automatically */
 #include "top.h"
 #include "machine.h"
 
@@ -352,6 +351,20 @@ static const char invalid_signal_number[] = " invalid_
 static const char bad_signal_name[] = " bad signal name";
 static const char bad_pri_value[] = " bad priority value";
 
+static int
+signame_to_signum(const char * sig)
+{
+int n;
+
+if (strncasecmp(sig, "SIG", 3) == 0)
+sig += 3;
+for (n = 1; n < sys_nsig; n++) {
+if (!strcasecmp(sys_signame[n], sig))
+return (n);
+}
+return (-1);
+}
+
 /*
  *  kill_procs(str) - send signals to processes, much like the "kill"
  * command does; invoked in response to 'k'.
@@ -363,7 +376,6 @@ kill_procs(char *str)
 char *nptr;
 int signum = SIGTERM;  /* default */
 int procnum;
-struct sigdesc *sigp;
 int uid;
 
 /* reset error array */
@@ -393,18 +405,10 @@ kill_procs(char *str)
}
else 
{
-   /* translate the name into a number */
-   for (sigp = sigdesc; sigp->name != NULL; sigp++)
-   {
-   if (strcasecmp(sigp->name, str + 1) == 0)
-   {
-   signum = sigp->number;
-   break;
-   }
-   }
+   signum = signame_to_signum(str + 1);
 
/* was it ever found */
-   if (sigp->name == NULL)
+   if (signum == -1 )
{
return(bad_signal_name);
}
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r334919 - head/usr.bin/top

2018-06-10 Thread Eitan Adler
Author: eadler
Date: Sun Jun 10 08:59:57 2018
New Revision: 334919
URL: https://svnweb.freebsd.org/changeset/base/334919

Log:
  top(1): bring some structure to commands
  
  Right now this is only used for help text but it'll eventually be used
  to build up long options array, dispatch commands, etc.

Modified:
  head/usr.bin/top/commands.c
  head/usr.bin/top/commands.h
  head/usr.bin/top/top.h

Modified: head/usr.bin/top/commands.c
==
--- head/usr.bin/top/commands.c Sun Jun 10 06:33:49 2018(r334918)
+++ head/usr.bin/top/commands.c Sun Jun 10 08:59:57 2018(r334919)
@@ -51,61 +51,56 @@ static int str_addarg(char *str, int len, char *arg, b
  * either 'h' or '?'.
  */
 
+static const struct command all_commands[] =
+{
+   {'C', "toggle the displaying of weighted CPU percentage", false },
+   {'d', "change number of displays to show", false},
+   {'e', "list errors generated by last \"kill\" or \"renice\" command", 
false},
+   {'H', "toggle the displaying of threads", false},
+   {'h', "show this help text", false},
+   {'i', "toggle the displaying of idle processes", false},
+   {'j', "toggle the displaying of jail ID", false},
+   {'J', "display processes for only one jail (+ selects all jails)", 
false},
+   {'k', "kill processes; send a signal to a list of processes", false},
+   {'q', "quit" , false},
+   {'m', "toggle the display between 'cpu' and 'io' modes", false},
+   {'n', "change number of processes to display", false},
+   {'o', "specify the sort order", false},
+   {'p', "display one process (+ selects all processes)", false},
+   {'P', "toggle the displaying of per-CPU statistics", false},
+   {'r', "renice a process", false},
+   {'s', "change number of seconds to delay between updates", false},
+   {'S', "toggle the displaying of system processes", false},
+   {'a', "toggle the displaying of process titles", false},
+   {'T', "toggle the displaying of thread IDs", false},
+   {'t', "toggle the display of this process", false},
+   {'u', "display processes for only one user (+ selects all users)", 
false},
+   {'w', "toggle the display of swap use for each process", false},
+   {'z', "toggle the displaying of the system idle process", false },
+   {0, NULL, true}
+};
+/* XXX: eventually remove command_chars, but assert they are the same for now 
*/
+
 void
 show_help(void)
 {
-printf("Top version FreeBSD, %s\n", copyright);
-fputs("\n\n\
-A top users display for Unix\n\
-\n\
-These single-character commands are available:\n\
-\n\
-^L  - redraw screen\n\
-q   - quit\n\
-h or ?  - help; show this text\n", stdout);
+   const struct command *curcmd;
 
-/* not all commands are available with overstrike terminals */
+printf("Top version FreeBSD, %s\n", copyright);
+   curcmd = all_commands;
+   while (curcmd->c != 0) {
+   if (overstrike && !curcmd->available_to_dumb) {
+   ++curcmd;
+   continue;
+   }
+   printf("%c\t- %s\n", curcmd->c, curcmd->desc);
+   ++curcmd;
+   }
 if (overstrike)
 {
-   fputs("\n\
-Other commands are also available, but this terminal is not\n\
-sophisticated enough to handle those commands gracefully.\n\n", stdout);
-}
-else
-{
-   fputs("\
-C   - toggle the displaying of weighted CPU percentage\n\
-d   - change number of displays to show\n\
-e   - list errors generated by last \"kill\" or \"renice\" command\n\
-H   - toggle the displaying of threads\n\
-i or I  - toggle the displaying of idle processes\n\
-j   - toggle the displaying of jail ID\n\
-J   - display processes for only one jail (+ selects all jails)\n\
-k   - kill processes; send a signal to a list of processes\n\
-m   - toggle the display between 'cpu' and 'io' modes\n\
-n or #  - change number of processes to display\n", stdout);
-   if (displaymode == DISP_CPU)
fputs("\
-o   - specify sort order (pri, size, res, cpu, time, threads, jid, pid)\n",
-   stdout);
-   else
-   fputs("\
-o   - specify sort order (vcsw, ivcsw, read, write, fault, total, jid, 
pid)\n",
-   stdout);
-   fputs("\
-p   - display one process (+ selects all processes)\n\
-P   - toggle the displaying of per-CPU statistics\n\
-r   - renice a process\n\
-s   - change number of seconds to delay between updates\n\
-S   - toggle the displaying of system processes\n\
-a   - toggle the displaying of process titles\n\
-T   - toggle the displaying of thread IDs\n\
-t   - toggle the display of this process\n\
-u   - display processes for only one user (+ selects all users)\n\
-w   - toggle the display of swap use for each process\n\
-z   - toggle the 

svn commit: r334918 - head/usr.bin/top

2018-06-10 Thread Eitan Adler
Author: eadler
Date: Sun Jun 10 06:33:49 2018
New Revision: 334918
URL: https://svnweb.freebsd.org/changeset/base/334918

Log:
  top(1): use correct word when displaying threads
  
  PR:   182204
  Reported by:  "Brodey Dover" 

Modified:
  head/usr.bin/top/display.c

Modified: head/usr.bin/top/display.c
==
--- head/usr.bin/top/display.c  Sun Jun 10 06:21:51 2018(r334917)
+++ head/usr.bin/top/display.c  Sun Jun 10 06:33:49 2018(r334918)
@@ -349,7 +349,7 @@ i_procstates(int total, int *brkdn)
 int i;
 
 /* write current number of processes and remember the value */
-printf("%d processes:", total);
+printf("%d %s:", total, (ps.thread) ? "threads" :"processes");
 ltotal = total;
 
 /* put out enough spaces to get to column 15 */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r334917 - head/usr.bin/top

2018-06-10 Thread Eitan Adler
Author: eadler
Date: Sun Jun 10 06:21:51 2018
New Revision: 334917
URL: https://svnweb.freebsd.org/changeset/base/334917

Log:
  top(1): filter fewer warnings; clean up
  
  - remove WARNS?=6. It is default
  - we no longer have cast-qual problems
  - remove unused macros
  - remove unneeded casts
  - add include guard for loadavg.h

Modified:
  head/usr.bin/top/Makefile
  head/usr.bin/top/loadavg.h
  head/usr.bin/top/top.c
  head/usr.bin/top/top.h
  head/usr.bin/top/username.c

Modified: head/usr.bin/top/Makefile
==
--- head/usr.bin/top/Makefile   Sun Jun 10 06:21:45 2018(r334916)
+++ head/usr.bin/top/Makefile   Sun Jun 10 06:21:51 2018(r334917)
@@ -8,17 +8,15 @@ SRCS= commands.c display.c machine.c screen.c top.c \
 CFLAGS+= -I ${.OBJDIR}
 MAN=   top.1
 
-WARNS?=6
-
 .if ${COMPILER_TYPE} == "gcc"
 .if ${COMPILER_VERSION} >= 5
-CFLAGS.gcc=-Wno-error=cast-align -Wno-error=cast-qual 
-Wno-error=discarded-qualifiers -Wno-error=incompatible-pointer-types \
+CFLAGS.gcc=-Wno-error=cast-qual -Wno-error=discarded-qualifiers 
-Wno-error=incompatible-pointer-types \
-Wno-error=maybe-uninitialized
 .else #base gcc
 NO_WERROR=
 .endif
 .endif
-CFLAGS.clang=-Wno-error=incompatible-pointer-types-discards-qualifiers 
-Wno-error=cast-qual -Wno-error=cast-align
+CFLAGS.clang=-Wno-error=incompatible-pointer-types-discards-qualifiers 
-Wno-error=cast-qual
 
 LIBADD=ncursesw m kvm jail
 

Modified: head/usr.bin/top/loadavg.h
==
--- head/usr.bin/top/loadavg.h  Sun Jun 10 06:21:45 2018(r334916)
+++ head/usr.bin/top/loadavg.h  Sun Jun 10 06:21:51 2018(r334917)
@@ -14,12 +14,14 @@
  * $FreeBSD$
  */
 
-#define FIXED_LOADAVG FSCALE
-#define FIXED_PCTCPU FSCALE
+#ifndef LOADAVG_H
+#define LOADAVG_H
 
+#include 
+
 typedef long pctcpu;
-#define pctdouble(p) ((double)(p) / FIXED_PCTCPU)
+#define pctdouble(p) ((double)(p) / FSCALE)
 
 typedef fixpt_t load_avg;
-#define loaddouble(la) ((double)(la) / FIXED_LOADAVG)
-#define intload(i) ((int)((i) * FIXED_LOADAVG))
+#define loaddouble(la) ((double)(la) / FSCALE)
+#endif /* LOADAVG_H */

Modified: head/usr.bin/top/top.c
==
--- head/usr.bin/top/top.c  Sun Jun 10 06:21:45 2018(r334916)
+++ head/usr.bin/top/top.c  Sun Jun 10 06:21:51 2018(r334917)
@@ -643,8 +643,8 @@ _Static_assert(sizeof(command_chars) == CMD_toggletid 
 if (warnings)
 {
fputs("", stderr);
-   fflush(stderr); /* why must I do this? */
-   sleep((unsigned)(3 * warnings));
+   fflush(stderr);
+   sleep(3 * warnings);
fputc('\n', stderr);
 }
 

Modified: head/usr.bin/top/top.h
==
--- head/usr.bin/top/top.h  Sun Jun 10 06:21:45 2018(r334916)
+++ head/usr.bin/top/top.h  Sun Jun 10 06:21:51 2018(r334917)
@@ -23,10 +23,6 @@ extern int Header_lines; /* 7 */
 /* maximum number we can have */
 #define Largest0x7fff
 
-/*
- * The entire display is based on these next numbers being defined as is.
- */
-
 /* Exit code for system errors */
 #define TOP_EX_SYS_ERROR   23
 
@@ -43,7 +39,6 @@ extern int pcpu_stats;
 extern int overstrike;
 extern pid_t mypid;
 
-
 extern const char * myname;
 
 extern int (*compares[])(const void*, const void*);
@@ -74,13 +69,5 @@ void quit(int);
  *  overridden on the command line, even with the value "infinity".
  */
 #define Nominal_TOPN   18
-
-/*
- *  If the local system's getpwnam interface uses random access to retrieve
- *  a record (i.e.: 4.3 systems, Sun "yellow pages"), then defining
- *  RANDOM_PW will take advantage of that fact.  
- */
-
-#define RANDOM_PW  1
 
 #endif /* TOP_H */

Modified: head/usr.bin/top/username.c
==
--- head/usr.bin/top/username.c Sun Jun 10 06:21:45 2018(r334916)
+++ head/usr.bin/top/username.c Sun Jun 10 06:21:51 2018(r334917)
@@ -115,8 +115,6 @@ int enter_user(int uid, char name[], bool wecare)
 
 /*
  * Get a userid->name mapping from the system.
- * If the passwd database is hashed (#define RANDOM_PW), we
- * just handle this uid.
  */
 
 int
@@ -127,7 +125,7 @@ get_user(int uid)
 /* no performance penalty for using getpwuid makes it easy */
 if ((pwd = getpwuid(uid)) != NULL)
 {
-   return(enter_user(pwd->pw_uid, pwd->pw_name, 1));
+   return(enter_user(pwd->pw_uid, pwd->pw_name, 1));
 }
 
 /* if we can't find the name at all, then use the uid as the name */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to 

svn commit: r334916 - head/usr.bin/top

2018-06-10 Thread Eitan Adler
Author: eadler
Date: Sun Jun 10 06:21:45 2018
New Revision: 334916
URL: https://svnweb.freebsd.org/changeset/base/334916

Log:
  top(1): permit sending signal with any case

Modified:
  head/usr.bin/top/commands.c

Modified: head/usr.bin/top/commands.c
==
--- head/usr.bin/top/commands.c Sun Jun 10 05:48:03 2018(r334915)
+++ head/usr.bin/top/commands.c Sun Jun 10 06:21:45 2018(r334916)
@@ -401,17 +401,17 @@ kill_procs(char *str)
/* translate the name into a number */
for (sigp = sigdesc; sigp->name != NULL; sigp++)
{
-   if (strcmp(sigp->name, str + 1) == 0)
-   {
-   signum = sigp->number;
-   break;
+   if (strcasecmp(sigp->name, str + 1) == 0)
+   {
+   signum = sigp->number;
+   break;
+   }
}
-   }
 
/* was it ever found */
if (sigp->name == NULL)
{
-   return(bad_signal_name);
+   return(bad_signal_name);
}
}
/* put the new pointer in place */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"