Cleanup of dead code in pr(1)

2015-04-13 Thread Kurt Mosiejczuk
Inspired by the work I saw bcallah@ doing in cleaning up vi I started
hunting ifdefs for other operating systems and dead code that was ifdef'd
out.

First up is a cleanout of dead code in /usr/bin/pr.  The patch kills code 
that is ifdef'd out.  Resulting binary is identical.

--Kurt


Index: pr.c
===
RCS file: /cvs/src/usr.bin/pr/pr.c,v
retrieving revision 1.35
diff -u -p -r1.35 pr.c
--- pr.c8 Feb 2015 23:40:34 -   1.35
+++ pr.c7 Apr 2015 16:49:20 -
@@ -1396,36 +1396,6 @@ otln(char *buf, int cnt, int *svips, int
 return(0);
 }
 
-#ifdef notused
-/*
- * inskip():skip over pgcnt pages with lncnt lines per page
- *file is closed at EOF (if not stdin).
- *
- *infFILE * to read from
- *pgcntnumber of pages to skip
- *lncntnumber of lines per page
- */
-int
-inskip(FILE *inf, int pgcnt, int lncnt)
-{
-int c;
-int cnt;
-
-while(--pgcnt  0) {
-   cnt = lncnt;
-   while ((c = getc(inf)) != EOF) {
-   if ((c == '\n')  (--cnt == 0))
-   break;
-   }
-   if (c == EOF) {
-   if (inf != stdin)
-   (void)fclose(inf);
-   return(1);
-   }
-}
-return(0);
-}
-#endif
 
 /*
  * nxtfile:returns a FILE * to next file in arg list and sets the
@@ -1927,9 +1897,6 @@ setup(int argc, char *argv[])
if (merge) {
if ((clcnt = argc - eoptind) = 1) {
clcnt = CLCNT;
-#ifdef stupid
-   merge = 0;
-#endif
}
} else
clcnt = CLCNT;



Re: AR8161 patch

2015-04-13 Thread Atanas Vladimirov
 The whitespace errors make the diff mostly unreadable, fix those
 and remove the conflict marker.

Hi,
I spent some time to clean up whitespace errors. 
I'm not sure if I did it right.
The patch now apply against if_alc.c 1.32 and if_alcreg.h 1.5.


 Don't duplicate pcie defines.  Drop device_printf/device_print_prettyname.
 Don't #if 0 alc_init, patch it.

I have moved some of #defines to if_alcreg.h. 
Once again I'm not sure if it's right.
I removed device_printf/device_print_prettyname.
I don't know how to patch alc_init. Your help will be appreciated.
My programming skills are limited, sorry.
Thanks for your time,
Atanas

Index: if_alc.c
===
RCS file: /home/vlado/cvsync/cvsroot/src/sys/dev/pci/if_alc.c,v
retrieving revision 1.32
diff -u -p -r1.32 if_alc.c
--- if_alc.c20 Mar 2015 16:48:13 -  1.32
+++ if_alc.c13 Apr 2015 19:00:08 -
@@ -26,7 +26,7 @@
  * SUCH DAMAGE.
  */
 
-/* Driver for Atheros AR8131/AR8132 PCIe Ethernet. */
+/* Driver for Atheros AR8131/AR8132 AR8161/AR8162 AR8171/AR8172 PCIe Ethernet. 
*/
 
 #include bpfilter.h
 #include vlan.h
@@ -79,12 +79,17 @@ voidalc_watchdog(struct ifnet *);
 intalc_mediachange(struct ifnet *);
 void   alc_mediastatus(struct ifnet *, struct ifmediareq *);
 
-void   alc_aspm(struct alc_softc *, int);
+void   alc_aspm(struct alc_softc *, int, int);
+void   alc_aspm_813x(struct alc_softc *, int);
+void   alc_aspm_816x(struct alc_softc *, int);
 void   alc_disable_l0s_l1(struct alc_softc *);
 intalc_dma_alloc(struct alc_softc *);
 void   alc_dma_free(struct alc_softc *);
 intalc_encap(struct alc_softc *, struct mbuf **);
 void   alc_get_macaddr(struct alc_softc *);
+void   alc_get_macaddr_813x(struct alc_softc *);
+void   alc_get_macaddr_816x(struct alc_softc *);
+void   alc_get_macaddr_par(struct alc_softc *);
 void   alc_init_cmb(struct alc_softc *);
 void   alc_init_rr_ring(struct alc_softc *);
 intalc_init_rx_ring(struct alc_softc *);
@@ -92,9 +97,26 @@ void alc_init_smb(struct alc_softc *);
 void   alc_init_tx_ring(struct alc_softc *);
 intalc_intr(void *);
 void   alc_mac_config(struct alc_softc *);
+uint32_t   alc_mii_readreg_813x(struct alc_softc *, int, int);
+uint32_t   alc_mii_readreg_816x(struct alc_softc *, int, int);
+uint32_t   alc_mii_writereg_813x(struct alc_softc *, int, int, int);
+uint32_t   alc_mii_writereg_816x(struct alc_softc *, int, int, int);
+void   alc_dsp_fixup(struct alc_softc *, int);
+
 intalc_miibus_readreg(struct device *, int, int);
 void   alc_miibus_statchg(struct device *);
+intalc_miibus_writeregr(struct device *, int, int, int);
 void   alc_miibus_writereg(struct device *, int, int, int);
+uint32_t   alc_miidbg_readreg(struct alc_softc *, int);
+uint32_t   alc_miidbg_writereg(struct alc_softc *, int, int);
+uint32_t   alc_miiext_readreg(struct alc_softc *, int, int);
+uint32_t   alc_miiext_writereg(struct alc_softc *, int, int, int);
+//int  alc_mediachange_locked(struct alc_softc *);
+void   alc_phy_reset_813x(struct alc_softc *);
+void   alc_phy_reset_816x(struct alc_softc *);
+void   alc_setwol_813x(struct alc_softc *);
+void   alc_setwol_816x(struct alc_softc *);
+
 intalc_newbuf(struct alc_softc *, struct alc_rxdesc *);
 void   alc_phy_down(struct alc_softc *);
 void   alc_phy_reset(struct alc_softc *);
@@ -111,6 +133,13 @@ void   alc_stop_mac(struct alc_softc *);
 void   alc_stop_queue(struct alc_softc *);
 void   alc_tick(void *);
 void   alc_txeof(struct alc_softc *);
+void   alc_init_pcie(struct alc_softc *, int);
+void   alc_config_msi(struct alc_softc *);
+
+intalc_dma_alloc(struct alc_softc *);
+void   alc_dma_free(struct alc_softc *);
+intalc_encap(struct alc_softc *, struct mbuf **);
+void   alc_osc_reset(struct alc_softc *);
 
 uint32_t alc_dma_burst[] = { 128, 256, 512, 1024, 2048, 4096, 0 };
 
@@ -120,11 +149,15 @@ const struct pci_matchid alc_devices[] =
{ PCI_VENDOR_ATTANSIC, PCI_PRODUCT_ATTANSIC_L1D },
{ PCI_VENDOR_ATTANSIC, PCI_PRODUCT_ATTANSIC_L1D_1 },
{ PCI_VENDOR_ATTANSIC, PCI_PRODUCT_ATTANSIC_L2C_1 },
-   { PCI_VENDOR_ATTANSIC, PCI_PRODUCT_ATTANSIC_L2C_2 }
+   { PCI_VENDOR_ATTANSIC, PCI_PRODUCT_ATTANSIC_L2C_2 },
+   { PCI_VENDOR_ATTANSIC, PCI_PRODUCT_ATTANSIC_AR8161 },
+   { PCI_VENDOR_ATTANSIC, PCI_PRODUCT_ATTANSIC_AR8162 },
+   { PCI_VENDOR_ATTANSIC, PCI_PRODUCT_ATTANSIC_AR8171 },
+   { PCI_VENDOR_ATTANSIC, PCI_PRODUCT_ATTANSIC_AR8172 }
 };
 
 struct cfattach alc_ca = {
-   sizeof (struct alc_softc), alc_match, alc_attach, NULL,
+   sizeof (struct alc_softc), alc_match, alc_attach, alc_detach,
alc_activate
 };
 
@@ -141,9 +174,22 @@ int
 alc_miibus_readreg(struct device *dev, int phy, int reg)
 {
struct alc_softc *sc = (struct alc_softc *)dev;
+   uint32_t v = 0;
+   if (phy != sc-alc_phyaddr)
+   return (0);
+
+   if ((sc-alc_flags  

Re: Tweak to daily df to use human output

2015-04-13 Thread Kenneth Gober
On Mon, Apr 13, 2015 at 1:13 PM, Kurt Mosiejczuk kurt-open...@se.rit.edu
wrote:

 I came up with the following tweak to get the filesystem status in the
 daily
 emails back into 80 columns.  I liked the addition of the inodes in the
 emails,
 but that addition started pushing many of the filesystems past the 80
 column
 mark, making them hard to read.


easier to read, but less useful may not be an improvement.  for people
with
large filesystems they will start seeing output like:
/dev/sd0e  3.6T  2.3T  1.3T  66% (followed by inode info)

that's all well and good, but it's then possible to add 40 GB of data to the
filesystem, and have this output:
/dev/sd0e  3.6T  2.3T  1.3T  66% (inode info, perhaps with more inodes used)

in other words, the -h flag causes df to treat large changes in disk usage
as
not worth reporting (assuming you consider 40GB a large change).

when a change in utilization of 40GB becomes invisible, the output of df
arguably
becomes much less useful (especially if you keep a history of daily emails
so
that you can track changes over time).

In my own .kshrc file I have an alias df=df -h which I find very useful,
but for
the daily emails I would prefer the output to stay as it is.  if df had a
-m option
akin to the -k option I wouldn't mind switching to that, but I think -h
swings
the pendulum too far from more detail than I need all the way into too
little.

-ken


Cleanup of PAM and other gunk in /usr/sbin/pppd

2015-04-13 Thread Kurt Mosiejczuk
Here is some more ifdef cleanup.  This patch kills all the gunk for PAM
which we don't need.  Also gone is some stuff for other operating systems
like ultrix and NeXT.  

--Kurt


Index: auth.c
===
RCS file: /cvs/src/usr.sbin/pppd/auth.c,v
retrieving revision 1.34
diff -u -p -r1.34 auth.c
--- auth.c  16 Jan 2015 06:40:19 -  1.34
+++ auth.c  7 Apr 2015 17:10:14 -
@@ -86,18 +86,11 @@
 #include sys/socket.h
 #include utmp.h
 #include fcntl.h
-#if defined(_PATH_LASTLOG)  defined(_linux_)
-#include lastlog.h
-#endif
 
 #include netdb.h
 #include netinet/in.h
 #include arpa/inet.h
 
-#ifdef USE_PAM
-#include security/pam_appl.h
-#endif
-
 #ifdef HAS_SHADOW
 #include shadow.h
 #ifndef PW_PPP
@@ -733,74 +726,6 @@ check_passwd(unit, auser, userlen, apass
 return ret;
 }
 
-/*
- * This function is needed for PAM.
- */
-
-#ifdef USE_PAM
-static char *PAM_username = ;
-static char *PAM_password = ;
-
-#ifdef PAM_ESTABLISH_CRED   /* new PAM defines :(^ */
-#define MY_PAM_STRERROR(err_code)  (char *) pam_strerror(pamh,err_code)
-#else
-#define MY_PAM_STRERROR(err_code)  (char *) pam_strerror(err_code)
-#endif
-
-static int pam_conv (int num_msg,
- const struct pam_message **msg,
- struct pam_response **resp,
- void *appdata_ptr)
-{
-int count = 0, replies = 0;
-struct pam_response *reply = NULL;
-int size = 0;
-
-for (count = 0; count  num_msg; count++)
-  {
-   struct pam_response *newreply;
-   int newsize = size + sizeof (struct pam_response);
-   newreply = realloc (reply, newsize); /* ANSI: is malloc() if 
reply==NULL */
-   if (!newreply) {
-   free(reply);
-   reply = NULL;
-   return PAM_CONV_ERR;
-   }
-   reply = newreply;
-   size = newsize;
-
-   switch (msg[count]-msg_style)
- {
-   case PAM_PROMPT_ECHO_ON:
-   reply[replies].resp_retcode = PAM_SUCCESS;
-   reply[replies++].resp = strdup(PAM_username); /* never NULL */
-   break;
-
-   case PAM_PROMPT_ECHO_OFF:
-   reply[replies].resp_retcode = PAM_SUCCESS;
-   reply[replies++].resp = strdup(PAM_password); /* never NULL */
-   break;
-
-   case PAM_TEXT_INFO:
-   reply[replies].resp_retcode = PAM_SUCCESS;
-   reply[replies++].resp = NULL;
-   break;
-
-   case PAM_ERROR_MSG:
-   default:
-   free (reply);
-   return PAM_CONV_ERR;
- }
-  }
-
-if (resp)
-*resp = reply;
-else
-free (reply);
-
-return PAM_SUCCESS;
-}
-#endif
 
 /*
  * plogin - Check the user name and password against the system
@@ -820,56 +745,6 @@ plogin(user, passwd, msg, msglen)
 int *msglen;
 {
 
-#ifdef USE_PAM
-
-struct pam_conv pam_conversation;
-pam_handle_t *pamh;
-int pam_error;
-/*
- * Fill the pam_conversion structure
- */
-memset (pam_conversation, '\0', sizeof (struct pam_conv));
-pam_conversation.conv = pam_conv;
-
-pam_error = pam_start (ppp, user, pam_conversation, pamh);
-
-if (pam_error != PAM_SUCCESS) {
-   *msg = MY_PAM_STRERROR (pam_error);
-   return UPAP_AUTHNAK;
-}
-/*
- * Define the fields for the credential validation
- */
-(void) pam_set_item (pamh, PAM_TTY, devnam);
-PAM_username = user;
-PAM_password = passwd;
-/*
- * Validate the user
- */
-pam_error = pam_authenticate (pamh, PAM_SILENT);
-if (pam_error == PAM_SUCCESS) {
-pam_error = pam_acct_mgmt (pamh, PAM_SILENT);
-
-   /* start a session for this user. Session closed when link ends. */
-   if (pam_error == PAM_SUCCESS)
-   (void) pam_open_session (pamh, PAM_SILENT);
-}
-
-*msg = MY_PAM_STRERROR (pam_error);
-
-PAM_username =
-PAM_password = ;
-/*
- * Clean up the mess
- */
-(void) pam_end (pamh, pam_error);
-
-if (pam_error != PAM_SUCCESS)
-return UPAP_AUTHNAK;
-/*
- * Use the non-PAM methods directly
- */
-#else /* #ifdef USE_PAM */
 
 struct passwd *pw;
 char *tty;
@@ -910,12 +785,6 @@ plogin(user, passwd, msg, msglen)
|| strcmp(crypt(passwd, pw-pw_passwd), pw-pw_passwd) != 0)
return (UPAP_AUTHNAK);
 
-/* These functions are not enabled for PAM. The reason for this is that */
-/* there is not necessarily a passwd entry for this user. That is */
-/* real purpose of 'PAM' -- to virtualize the account data from the */
-/* application. If you want to do the same thing, write the entry in*/
-/* the 'session' hook.  */
-
 /*
  * Write a wtmp entry for this user.
  */
@@ -941,8 +810,6 @@ plogin(user, passwd, msg, msglen)
 }
 #endif
 
-#endif /* #ifdef USE_PAM */
-
 syslog(LOG_INFO, user %s logged in, user);
 logged_in = TRUE;
 
@@ -955,33 +822,12 @@ plogin(user, passwd, msg, msglen)
 static 

Re: Tweak to daily df to use human output

2015-04-13 Thread Kurt Mosiejczuk
On Mon, Apr 13, 2015 at 02:02:26PM -0400, Kenneth Gober wrote:

 easier to read, but less useful may not be an improvement.  for people
 with
 large filesystems they will start seeing output like:
 /dev/sd0e  3.6T  2.3T  1.3T  66% (followed by inode info)

 that's all well and good, but it's then possible to add 40 GB of data to the
 filesystem, and have this output:
 /dev/sd0e  3.6T  2.3T  1.3T  66% (inode info, perhaps with more inodes used)

 in other words, the -h flag causes df to treat large changes in disk usage
 as
 not worth reporting (assuming you consider 40GB a large change).

 when a change in utilization of 40GB becomes invisible, the output of df
 arguably
 becomes much less useful (especially if you keep a history of daily emails
 so
 that you can track changes over time).

 In my own .kshrc file I have an alias df=df -h which I find very useful,
 but for
 the daily emails I would prefer the output to stay as it is.  if df had a
 -m option
 akin to the -k option I wouldn't mind switching to that, but I think -h
 swings
 the pendulum too far from more detail than I need all the way into too
 little.

That's an excellent point.  I had originally looked for a -m
option for df, but saw only -k or -h (It seems that -m is a
GNUism).  I briefly thought about using BLOCKSIZE, but df puts the
blocksize into that column, eliminating the desired benefit.  It
seems this would require more thought.

--Kurt



Cleanup of tset(1) - Part 1 of 2

2015-04-13 Thread Kurt Mosiejczuk
More ifdef trimming.  This time tset is up.

Binary is still identical after this diff.

--Kurt

Index: tset.c
===
RCS file: /cvs/src/usr.bin/tset/tset.c,v
retrieving revision 1.36
diff -u -p -r1.36 tset.c
--- tset.c  18 Sep 2013 16:21:30 -  1.36
+++ tset.c  13 Apr 2015 20:45:25 -
@@ -83,9 +83,6 @@
 #if HAVE_GETTTYNAM  HAVE_TTYENT_H
 #include ttyent.h
 #endif
-#ifdef NeXT
-char *ttyname(int fd);
-#endif
 
 #if HAVE_SIZECHANGE
 # if !defined(sun) || !TERMIOS
@@ -95,29 +92,11 @@ char *ttyname(int fd);
 # endif
 #endif
 
-#if NEED_PTEM_H
-/* they neglected to define struct winsize in termios.h -- it's only
-   in termio.h */
-#include sys/stream.h
-#include sys/ptem.h
-#endif
-
 #include dump_entry.h
 #include transform.h
 
 MODULE_ID($Id: tset.c,v 1.36 2013/09/18 16:21:30 millert Exp $)
 
-/*
- * SCO defines TIOCGSIZE and the corresponding struct.  Other systems (SunOS,
- * Solaris, IRIX) define TIOCGWINSZ and struct winsize.
- */
-#ifdef TIOCGSIZE
-# define IOCTL_GET_WINSIZE TIOCGSIZE
-# define IOCTL_SET_WINSIZE TIOCSSIZE
-# define STRUCT_WINSIZE struct ttysize
-# define WINSIZE_ROWS(n) n.ts_lines
-# define WINSIZE_COLS(n) n.ts_cols
-#else
 # ifdef TIOCGWINSZ
 #  define IOCTL_GET_WINSIZE TIOCGWINSZ
 #  define IOCTL_SET_WINSIZE TIOCSWINSZ
@@ -125,7 +104,6 @@ MODULE_ID($Id: tset.c,v 1.36 2013/09/18
 #  define WINSIZE_ROWS(n) n.ws_row
 #  define WINSIZE_COLS(n) n.ws_col
 # endif
-#endif
 
 extern char **environ;
 



Cleanup of tset(1) - Part 2 of 2

2015-04-13 Thread Kurt Mosiejczuk
This is cleaning up completely redundant #defines housed in #ifdefs in
tset.c

This does not provide an identical binary, since it trims out redundant
information from speeds[].  The diff is fairly straightforward though.

I avoided trimming out the potentially redundant defines that use EXTA and 
EXTB since they are defined in /usr/include/termios.h.  I'm not sure of the
point of those in the code, but I held off for now.

Are there reasons/scenarios where all the ifdefs around the baud rates of
19200 and up are used/needed?  Would it be worth cleaning them up for easier
to read code?

--Kurt


? processed-tset.c
? termsort.c
? tset
Index: tset.c
===
RCS file: /cvs/src/usr.bin/tset/tset.c,v
retrieving revision 1.36
diff -u -p -r1.36 tset.c
--- tset.c  18 Sep 2013 16:21:30 -  1.36
+++ tset.c  13 Apr 2015 19:47:43 -
@@ -299,18 +299,6 @@ static const SPEEDS speeds[] =
 /* sgttyb may define up to this point */
 #ifdef B19200
 {19200, B19200},
-#endif
-#ifdef B38400
-{38400, B38400},
-#endif
-#ifdef B19200
-{19200, B19200},
-#endif
-#ifdef B38400
-{38400, B38400},
-#endif
-#ifdef B19200
-{19200, B19200},
 #else
 #ifdef EXTA
 {19200, EXTA},



xhci, thinkpad usb ports, uhub0: device problem

2015-04-13 Thread Rafal Brodewicz
Hi tech@

Enabling usb3 support in my ThinkPad T440s causes dock station usb ports
to stop working. I see uhub0: device problem, disabling port 3 message
in dmesg.
dmesg with usb3 on and off included.


OpenBSD 5.7-current (GENERIC.MP) #4: Fri Apr 10 21:36:33 CEST 2015
r...@current.bro:/usr/src/sys/arch/amd64/compile/GENERIC.MP
real mem = 12539600896 (11958MB)
avail mem = 12155719680 (11592MB)
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 2.7 @ 0xbcc0d000 (61 entries)
bios0: vendor LENOVO version GJET82WW (2.32 ) date 01/09/2015
bios0: LENOVO 20ARA03LPB
acpi0 at bios0: rev 2
acpi0: sleep states S0 S3 S4 S5
acpi0: tables DSDT FACP SLIC DBGP ECDT HPET APIC MCFG SSDT SSDT SSDT SSDT SSDT 
SSDT SSDT SSDT PCCT SSDT TCPA UEFI MSDM ASF! BATB FPDT UEFI SSDT DMAR
acpi0: wakeup devices LID_(S4) SLPB(S3) IGBE(S4) EXP2(S4) XHCI(S3) EHC1(S3)
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpiec0 at acpi0
acpihpet0 at acpi0: 14318179 Hz
acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: Intel(R) Core(TM) i5-4300U CPU @ 1.90GHz, 1796.11 MHz
cpu0: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,LONG,LAHF,ABM,PERF,ITSC,FSGSBASE,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID
cpu0: 256KB 64b/line 8-way L2 cache
cpu0: smt 0, core 0, package 0
mtrr: Pentium Pro MTRR support, 10 var ranges, 88 fixed ranges
cpu0: apic clock running at 99MHz
cpu0: mwait min=64, max=64, C-substates=0.2.1.2.4, IBE
cpu1 at mainbus0: apid 1 (application processor)
cpu1: Intel(R) Core(TM) i5-4300U CPU @ 1.90GHz, 1795.85 MHz
cpu1: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,LONG,LAHF,ABM,PERF,ITSC,FSGSBASE,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID
cpu1: 256KB 64b/line 8-way L2 cache
cpu1: smt 1, core 0, package 0
cpu2 at mainbus0: apid 2 (application processor)
cpu2: Intel(R) Core(TM) i5-4300U CPU @ 1.90GHz, 1795.85 MHz
cpu2: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,LONG,LAHF,ABM,PERF,ITSC,FSGSBASE,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID
cpu2: 256KB 64b/line 8-way L2 cache
cpu2: smt 0, core 1, package 0
cpu3 at mainbus0: apid 3 (application processor)
cpu3: Intel(R) Core(TM) i5-4300U CPU @ 1.90GHz, 1795.85 MHz
cpu3: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,LONG,LAHF,ABM,PERF,ITSC,FSGSBASE,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID
cpu3: 256KB 64b/line 8-way L2 cache
cpu3: smt 1, core 1, package 0
ioapic0 at mainbus0: apid 2 pa 0xfec0, version 20, 40 pins
acpimcfg0 at acpi0 addr 0xf800, bus 0-63
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus -1 (PEG_)
acpiprt2 at acpi0: bus 2 (EXP1)
acpiprt3 at acpi0: bus 3 (EXP2)
acpiprt4 at acpi0: bus -1 (EXP3)
acpicpu0 at acpi0: C3, C1, PSS
acpicpu1 at acpi0: C3, C1, PSS
acpicpu2 at acpi0: C3, C1, PSS
acpicpu3 at acpi0: C3, C1, PSS
acpipwrres0 at acpi0: PUBS, resource for XHCI, EHC1
acpipwrres1 at acpi0: NVP3, resource for PEG_
acpipwrres2 at acpi0: NVP2, resource for PEG_
acpitz0 at acpi0: critical temperature is 200 degC
acpibtn0 at acpi0: LID_
acpibtn1 at acpi0: SLPB
acpibat0 at acpi0: BAT0 model 45N1773 serial 29680 type LION oem SANYO
acpibat1 at acpi0: BAT1 model 45N1127 serial 11779 type LION oem LGC
acpiac0 at acpi0: AC unit online
acpithinkpad0 at acpi0
cpu0: Enhanced SpeedStep 1796 MHz: speeds: 2501, 2500, 2400, 2200, 2100, 1900, 
1800, 1700, 1600, 1500, 1300, 1200, 1100, 1000, 800, 775 MHz
pci0 at mainbus0 bus 0
pchb0 at pci0 dev 0 function 0 Intel Core 4G Host rev 0x0b
vga1 at pci0 dev 2 function 0 Intel HD Graphics rev 0x0b
intagp at vga1 not configured
inteldrm0 at vga1
drm0 at inteldrm0
error: [drm:pid0:i915_write32] *ERROR* Unknown unclaimed register before 
writing to 10
error: [drm:pid0:intel_dp_set_link_train] *ERROR* Timed out waiting for DP idle 
patterns
error: [drm:pid0:i915_write32] *ERROR* Unknown unclaimed register before 
writing to 64040
inteldrm0: 1920x1080
wsdisplay0 at vga1 mux 1: console (std, vt100 emulation)
wsdisplay0: screen 1-5 added (std, vt100 emulation)
azalia0 at pci0 dev 3 function 0 Intel Core 4G HD Audio rev 0x0b: msi
azalia0: No codecs found
xhci0 at pci0 dev 20 function 0 

Re: [NEW] Driver for the Araneus Alea II USB TRNG

2015-04-13 Thread attila
Hi tech@,

Ping?

attila att...@stalphonsos.com writes:

 Hi tech@,

 I've written a driver for the Araneus Alea II USB TRNG:
 http://www.araneus.fi/products/alea2/en/

 It produces 100kbit/sec of entropy, which my driver stuffs into
 add_true_randomness().  A small thing, but maybe valuable in
 situations that do a lot of crypto.  I mainly did it to get my head
 around more of the codebase, and I happened to have one lying around,
 so...  According to the docs the interface has not changed between the
 Alea I and the Alea II so this driver should work for both, but I only
 have a II.  I'm interested in writing drivers for other TRNGs if
 anyone else finds it useful.

 Tested under i386 and amd64.

 I'm sure I've made many mistakes.  Comments and feedback most welcome.

 Pax, -A

 diff -Nurp src.orig/sys/arch/amd64/conf/GENERIC 
 src/sys/arch/amd64/conf/GENERIC
 --- src.orig/sys/arch/amd64/conf/GENERIC  Thu Apr  2 08:24:02 2015
 +++ src/sys/arch/amd64/conf/GENERIC   Thu Apr  9 16:02:27 2015
 @@ -271,6 +271,7 @@ uvideo*   at uhub?# USB Video
  video*   at uvideo?
  udl* at uhub?# DisplayLink USB displays
  wsdisplay* at udl?
 +ualea*   at uhub?# Araneus Alea II USB TRNG
  
  puc* at pci? # PCI universal communication device
  com* at cardbus?
 diff -Nurp src.orig/sys/arch/i386/conf/GENERIC src/sys/arch/i386/conf/GENERIC
 --- src.orig/sys/arch/i386/conf/GENERIC   Thu Apr  2 08:24:02 2015
 +++ src/sys/arch/i386/conf/GENERICThu Apr  9 16:02:01 2015
 @@ -325,6 +325,7 @@ uvideo* at uhub?  # USB video
  video*  at uvideo?
  udl* at uhub?# DisplayLink USB displays
  wsdisplay* at udl?
 +ualea*   at uhub?# Araneus Alea II USB TRNG
  
  puc* at pci? # PCI universal communication device
  com* at cardbus?
 diff -Nurp src.orig/sys/arch/macppc/conf/GENERIC 
 src/sys/arch/macppc/conf/GENERIC
 --- src.orig/sys/arch/macppc/conf/GENERIC Thu Apr  2 08:24:02 2015
 +++ src/sys/arch/macppc/conf/GENERIC  Thu Apr  9 16:02:43 2015
 @@ -292,6 +292,7 @@ utrh* at uhidev?  # USBRH sensor
  utwitch* at uhidev?  # YUREX BBU sensor
  uow* at uhub?# Maxim/Dallas DS2490 1-Wire adapter
  onewire* at uow?
 +ualea*   at uhub?# Araneus Alea II USB TRNG
  
  # USB Video
  uvideo* at uhub?
 diff -Nurp src.orig/sys/arch/sparc64/conf/GENERIC 
 src/sys/arch/sparc64/conf/GENERIC
 --- src.orig/sys/arch/sparc64/conf/GENERICTue Mar 24 06:00:39 2015
 +++ src/sys/arch/sparc64/conf/GENERIC Thu Apr  9 16:02:58 2015
 @@ -245,6 +245,7 @@ ugold*at uhidev?  # gold TEMPer sensor
  utwitch* at uhidev?  # UYUREX BBU sensor
  uow* at uhub?# Maxim/Dallas DS2490 1-Wire adapter
  onewire* at uow?
 +ualea*   at uhub?# Araneus Alea II USB TRNG
  
  # USB Video
  uvideo* at uhub?
 diff -Nurp src.orig/sys/arch/zaurus/conf/GENERIC 
 src/sys/arch/zaurus/conf/GENERIC
 --- src.orig/sys/arch/zaurus/conf/GENERIC Sat Jan  3 15:24:19 2015
 +++ src/sys/arch/zaurus/conf/GENERIC  Thu Apr  9 16:03:25 2015
 @@ -135,6 +135,7 @@ umbg* at uhub?# Meinberg 
 Funkuhren USB5131
  uow* at uhub?# Maxim/Dallas DS2490 1-Wire adapter
  onewire* at uow?
  utwitch* at uhidev?  # YUREX BBU sensor
 +ualea*   at uhub?# Araneus Alea II USB TRNG
  
  scsibus* at scsi?
  sd*  at scsibus? # SCSI disk drives
 diff -Nurp src.orig/sys/dev/usb/files.usb src/sys/dev/usb/files.usb
 --- src.orig/sys/dev/usb/files.usbThu Apr  2 08:24:02 2015
 +++ src/sys/dev/usb/files.usb Thu Apr  9 16:04:38 2015
 @@ -195,6 +195,11 @@ device   utwitch: hid
  attach   utwitch at uhidbus
  file dev/usb/utwitch.c   utwitch
  
 +# Araneus Alea II TRNG
 +device   ualea
 +attach   ualea at uhub
 +file dev/usb/ualea.c ualea
 +
  # Ethernet adapters
  # ADMtek AN986 Pegasus
  device   aue: ether, ifnet, mii, ifmedia
 diff -Nurp src.orig/sys/dev/usb/ualea.c src/sys/dev/usb/ualea.c
 --- src.orig/sys/dev/usb/ualea.c  Wed Dec 31 18:00:00 1969
 +++ src/sys/dev/usb/ualea.c   Fri Apr 10 15:46:30 2015
 @@ -0,0 +1,265 @@
 +/* -*- mode:c; tab-width:8; indent-tabs-mode:t; c-basic-offset:8 -*- */
 +/*
 + * Copyright (C) 2015 by attila att...@stalphonsos.com
 + *
 + * Permission to use, copy, modify, and/or distribute this software
 + * for any purpose with or without fee is hereby granted, provided
 + * that the above copyright notice and this permission notice appear
 + * in all copies.
 + *
 + * THE SOFTWARE IS PROVIDED AS IS AND THE AUTHOR DISCLAIMS ALL
 + * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
 + * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
 + * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
 + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES 

Re: Cleanup of tset(1) - Part 1 of 2

2015-04-13 Thread Nicholas Marriott
Hi

Our tset comes pretty much unchanged from ncurses, I don't think it is
worth diverging from upstream like this.


On Mon, Apr 13, 2015 at 04:48:54PM -0400, Kurt Mosiejczuk wrote:
 More ifdef trimming.  This time tset is up.
 
 Binary is still identical after this diff.
 
 --Kurt
 
 Index: tset.c
 ===
 RCS file: /cvs/src/usr.bin/tset/tset.c,v
 retrieving revision 1.36
 diff -u -p -r1.36 tset.c
 --- tset.c18 Sep 2013 16:21:30 -  1.36
 +++ tset.c13 Apr 2015 20:45:25 -
 @@ -83,9 +83,6 @@
  #if HAVE_GETTTYNAM  HAVE_TTYENT_H
  #include ttyent.h
  #endif
 -#ifdef NeXT
 -char *ttyname(int fd);
 -#endif
  
  #if HAVE_SIZECHANGE
  # if !defined(sun) || !TERMIOS
 @@ -95,29 +92,11 @@ char *ttyname(int fd);
  # endif
  #endif
  
 -#if NEED_PTEM_H
 -/* they neglected to define struct winsize in termios.h -- it's only
 -   in termio.h   */
 -#include sys/stream.h
 -#include sys/ptem.h
 -#endif
 -
  #include dump_entry.h
  #include transform.h
  
  MODULE_ID($Id: tset.c,v 1.36 2013/09/18 16:21:30 millert Exp $)
  
 -/*
 - * SCO defines TIOCGSIZE and the corresponding struct.  Other systems (SunOS,
 - * Solaris, IRIX) define TIOCGWINSZ and struct winsize.
 - */
 -#ifdef TIOCGSIZE
 -# define IOCTL_GET_WINSIZE TIOCGSIZE
 -# define IOCTL_SET_WINSIZE TIOCSSIZE
 -# define STRUCT_WINSIZE struct ttysize
 -# define WINSIZE_ROWS(n) n.ts_lines
 -# define WINSIZE_COLS(n) n.ts_cols
 -#else
  # ifdef TIOCGWINSZ
  #  define IOCTL_GET_WINSIZE TIOCGWINSZ
  #  define IOCTL_SET_WINSIZE TIOCSWINSZ
 @@ -125,7 +104,6 @@ MODULE_ID($Id: tset.c,v 1.36 2013/09/18
  #  define WINSIZE_ROWS(n) n.ws_row
  #  define WINSIZE_COLS(n) n.ws_col
  # endif
 -#endif
  
  extern char **environ;
  
 



Re: Do you need/prefer the non-DUID option in the installer?

2015-04-13 Thread frantisek holop
Joel Sing, 12 Apr 2015 03:14:
 On Wednesday 01 April 2015, frantisek holop wrote:
  Theo de Raadt, 30 Mar 2015 18:09:
   IIRC 'bioctl -d' cannot deal with DUID's.
   not a showstopper, just sayin'
  
   Sounds like you might use this.  Want to trial a diff that adds
   support?  If it is wrong, don't worry, someone will hate your bad
   diff, and do it right.  (That is pretty much the history of DUID
   support in the tools)
 
  yes, i'd like to use it :)  i have numerous softraid
  encrypted usb dongles that i'd like to mount/unmount
  using DUID's.
 
  i started looking into this when i first reported it:
  http://marc.info/?l=openbsd-miscm=138198909623938w=2
  but it was not the one liner i hoped for :)
  i'll try to revisit.
 
  -f
 
 FWIW this is now fixed in r1.351 of src/sys/dev/softraid.c.

lovely, thank you very much.

-f
-- 
first came reality.  then there was wolfenstein 3d...



Tying time_t to pacman

2015-04-13 Thread Theo de Raadt
I don't normally do this.

http://motherboard.vice.com/read/32-bit-integers-and-why-old-computers-matter

This does a really good job educating people on integer overflow :)

In our non-pacman universe, the ports guys really did a good job
mopping up the 32bit time_t issues.

Near the end of that writeup, I hope everyone comes to realize that
what is holding back proliferation of 64-bit time_t solutions is
simply installed-base backwards-compatiblity.  A choice customers
re-make every day because that is what they are given to them by
vendors, and will keep making until the vendors give them a
replacement which does not have the problem.

Every time a vendor supplies a 32-bit time_t OS to a 32-bit computer
user, it creates a potential circumstance someone might be running
that close to one of the numerous issues coming close to 2038 (there
are a number of them, read the wikipedia page, and pay close attention
to NTP as well).  The potential is low today, but increases as time_t
ticks...

(Mailed from a 64-bit machine, though a sequence of machines, not all
of which are 64-bit... to you)



Tweak to daily df to use human output

2015-04-13 Thread Kurt Mosiejczuk
I came up with the following tweak to get the filesystem status in the daily
emails back into 80 columns.  I liked the addition of the inodes in the emails,
but that addition started pushing many of the filesystems past the 80 column
mark, making them hard to read.  

--Kurt

Index: daily
===
RCS file: /cvs/src/etc/daily,v
retrieving revision 1.82
diff -u -p -r1.82 daily
--- daily   17 Nov 2014 18:19:08 -  1.82
+++ daily   7 Apr 2015 02:07:07 -
@@ -130,7 +130,7 @@ next_part Checking subsystem status:
 if [ X$VERBOSESTATUS != X0 ]; then
echo 
echo disks:
-   df -ikl
+   df -ihl
echo 
dump W
 fi



Re: VXLAN with a private address on the external interface

2015-04-13 Thread Rob wylde
Both Server and Client are OpenBSD 5.7-current (GENERIC) #0: Sun Apr 12
22:01:35 MDT

SERVER
# route -n show -inet
Routing tables

Internet:
DestinationGatewayFlags   Refs  Use   Mtu  Prio
Iface
default216.x.x.x UGS8   202064 - 8 vlan50
10.1.1.101 10.1.1.101 UHl00 32768 1 lo0
10.1.1.103 10.1.1.103 UHl00 32768 1 lo0
10.1.1.105 10.1.1.105 UHl00 32768 1 lo0
10.1.1.107 10.1.1.107 UHl00 32768 1 lo0
10.1.1.109 10.1.1.109 UHl00 32768 1 lo0
10.10.10/24link#18UC 00 - 4
vlan4093
10.10.10.1 08:60:6e:47:e9:6c  UHLl   00 - 1 lo0
10.10.10.255   link#18UHLb   00 - 1
vlan4093
127/8  127.0.0.1  UGRS   00 32768 8 lo0
127.0.0.1  127.0.0.1  UHl10 32768 1 lo0
216.x.x.x/29  link#19UC 10 - 4 vlan50
216.x.x.x 00:d0:f6:dc:cb:4d  UHLc   10 - 4 vlan50
216.x.x.x 08:60:6e:47:e9:6c  UHLl   00 - 1 lo0
216.x.x.x link#19UHLb   00 - 1 vlan50
224/4  127.0.0.1  URS00 32768 8 lo0

# ifconfig trunk0
trunk0: flags=8943UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST mtu 1500
lladdr 08:60:6e:47:e9:6c
priority: 0
trunk: trunkproto lacp
trunk id: [(8000,08:60:6e:47:e9:6c,4064,,),
 (8000,00:17:94:51:4f:80,0003,,)]
trunkport em1 active,collecting,distributing
trunkport em0 active,collecting,distributing
groups: trunk
media: Ethernet autoselect
status: active
# ifconfig vlan1105
vlan1105: flags=8943UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST mtu
1500
lladdr 08:60:6e:47:e9:6c
description: Client-5
priority: 0
vlan: 1105 parent interface: trunk0
groups: vlan
status: active

# ifconfig vxlan1105
vxlan1105: flags=8943UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST mtu
1500
lladdr fe:e1:ba:d4:43:6d
description: Client-5
priority: 0
groups: vxlan
media: Ethernet autoselect
status: active
tunnel: inet 10.1.1.109 - 10.1.1.108 vnetid 1105

bridge1105: flags=41UP,RUNNING
description: Client-5
groups: bridge
priority 32768 hellotime 2 fwddelay 15 maxage 20 holdcnt 6 proto
rstp
designated: id 00:00:00:00:00:00 priority 0
vlan1105 flags=3LEARNING,DISCOVER
port 17 ifpriority 0 ifcost 0
vxlan1105 flags=3LEARNING,DISCOVER
port 11 ifpriority 0 ifcost 0
Addresses (max cache: 100, timeout: 240):
00:00:40:11:dd:37 vxlan1105 1 flags=0 tunnel 10.1.1.108:
vxlan
00:00:40:11:35:88 vxlan1105 1 flags=0 tunnel 10.1.1.108:
vxlan
00:00:40:11:4f:dd vxlan1105 0 flags=0 tunnel 10.1.1.108:
vxlan
00:00:40:11:a0:16 vxlan1105 1 flags=0 tunnel 10.1.1.108:
vxlan
00:00:40:11:a0:c2 vxlan1105 0 flags=0 tunnel 10.1.1.108:
vxlan
00:00:40:11:b3:32 vxlan1105 0 flags=0 tunnel 10.1.1.108:
vxlan
00:00:40:11:01:bf vxlan1105 0 flags=0 tunnel 10.1.1.108:
vxlan
00:00:40:11:6b:fb vxlan1105 0 flags=0 tunnel 10.1.1.108:
vxlan
00:00:40:11:92:95 vxlan1105 0 flags=0 tunnel 10.1.1.108:
vxlan
00:00:40:11:6a:2c vxlan1105 1 flags=0 tunnel 10.1.1.108:
vxlan
00:00:40:11:19:d3 vxlan1105 0 flags=0 tunnel 10.1.1.108:
vxlan
00:00:40:11:8b:cf vxlan1105 0 flags=0 tunnel 10.1.1.108:
vxlan
00:00:40:11:7b:a1 vxlan1105 1 flags=0 tunnel 10.1.1.108:
vxlan
00:00:40:11:2d:2c vxlan1105 0 flags=0 tunnel 10.1.1.108:
vxlan
00:00:40:11:ff:9c vxlan1105 1 flags=0 tunnel 10.1.1.108:
vxlan
00:00:40:11:7b:9b vxlan1105 0 flags=0 tunnel 10.1.1.108:
vxlan
00:00:40:11:57:24 vxlan1105 0 flags=0 tunnel 10.1.1.108:
vxlan
00:00:40:11:a1:f8 vxlan1105 0 flags=0 tunnel 10.1.1.108:
vxlan
00:00:40:11:4e:19 vxlan1105 0 flags=0 tunnel 10.1.1.108:
vxlan
00:00:40:11:77:72 vxlan1105 1 flags=0 tunnel 10.1.1.108:
vxlan
00:00:40:11:d6:9c vxlan1105 0 flags=0 tunnel 10.1.1.108:
vxlan
00:00:40:11:9d:bc vxlan1105 1 flags=0 tunnel 10.1.1.108:
vxlan
00:00:40:11:b9:33 vxlan1105 1 flags=0 tunnel 10.1.1.108:
vxlan
00:00:40:11:6d:f6 vxlan1105 1 flags=0 tunnel 10.1.1.108:
vxlan
.. Many more 00:00:00:40
00:90:1a:a0:3b:a5 vlan1105 1 flags=0
00:00:40:11:ad:50 vxlan1105 1 flags=0 tunnel 

[PATCH] Add support for dumping descriptors to usbdevs(8)

2015-04-13 Thread Dimitris Papastamos
Hi everyone,

This is a preliminary patch that adds descriptor dumping support
to usbdevs(8).  I have attempted to keep any unnecessary changes to
a minimum.  I will do some cleanup work incrementally on top of
this patch.

I've tested this on a single machine running -current so more testing
would be nice.

Let me know what you think and I will rework my patch.

Cheers,
Dimitris

Index: usr.sbin/usbdevs/usbdevs.8
===
RCS file: /cvs/src/usr.sbin/usbdevs/usbdevs.8,v
retrieving revision 1.9
diff -u -p -r1.9 usbdevs.8
--- usr.sbin/usbdevs/usbdevs.8  26 Jun 2008 05:42:21 -  1.9
+++ usr.sbin/usbdevs/usbdevs.8  13 Apr 2015 13:57:27 -
@@ -54,7 +54,13 @@ Show the device drivers associated with 
 .It Fl f Ar dev
 Only print information for the given USB controller.
 .It Fl v
-Be verbose.
+Verbose mode.  Causes
+.Nm
+to display detailed information about the devices present.
+Multiple
+.Fl v
+options increase verbosity.  At level 1 or above the device
+and configuration descriptors will be shown.
 .El
 .Sh FILES
 .Bl -tag -width Pa
Index: usr.sbin/usbdevs/usbdevs.c
===
RCS file: /cvs/src/usr.sbin/usbdevs/usbdevs.c,v
retrieving revision 1.24
diff -u -p -r1.24 usbdevs.c
--- usr.sbin/usbdevs/usbdevs.c  31 Mar 2015 13:38:27 -  1.24
+++ usr.sbin/usbdevs/usbdevs.c  13 Apr 2015 13:57:27 -
@@ -50,6 +50,14 @@ int verbose = 0;
 int showdevs = 0;
 
 void usage(void);
+int getddesc(int, int, int, struct usb_device_ddesc *);
+int getcdesc(int, int, int, struct usb_device_cdesc *);
+int getfdesc(int, int, int, int, struct usb_device_fdesc *);
+void dumpedesc(usb_endpoint_descriptor_t *);
+void dumpidesc(usb_interface_descriptor_t *);
+void dumpcdesc(usb_config_descriptor_t *);
+void dumpddesc(usb_device_descriptor_t *);
+void dumpdesc(int, int, int);
 void usbdev(int f, int a, int rec);
 void usbdump(int f);
 void dumpone(char *name, int f, int addr);
@@ -67,6 +75,236 @@ usage(void)
 char done[USB_MAX_DEVICES];
 int indent;
 
+int
+getddesc(int f, int b, int a, struct usb_device_ddesc *ddesc)
+{
+   int r;
+
+   ddesc-udd_bus = b;
+   ddesc-udd_addr = a;
+   r = ioctl(f, USB_DEVICE_GET_DDESC, ddesc);
+   if (r) {
+   if (errno != ENXIO)
+   warn(USB_DEVICE_GET_DDESC);
+   return -1;
+   }
+   return 0;
+}
+
+int
+getcdesc(int f, int b, int a, struct usb_device_cdesc *cdesc)
+{
+   int r;
+
+   cdesc-udc_bus = b;
+   cdesc-udc_addr = a;
+   cdesc-udc_config_index = USB_CURRENT_CONFIG_INDEX;
+   r = ioctl(f, USB_DEVICE_GET_CDESC, cdesc);
+   if (r) {
+   if (errno != ENXIO)
+   warn(USB_DEVICE_GET_CDESC);
+   return -1;
+   }
+   return 0;
+}
+
+int
+getfdesc(int f, int b, int a, int l, struct usb_device_fdesc *fdesc)
+{
+   int r;
+
+   fdesc-udf_bus = b;
+   fdesc-udf_addr = a;
+   fdesc-udf_config_index = USB_CURRENT_CONFIG_INDEX;
+   fdesc-udf_size = l;
+   fdesc-udf_data = malloc(l);
+   if (!fdesc-udf_data)
+   err(1, malloc);
+   r = ioctl(f, USB_DEVICE_GET_FDESC, fdesc);
+   if (r) {
+   if (errno != ENXIO)
+   warn(USB_DEVICE_GET_FDESC);
+   free(fdesc-udf_data);
+   return -1;
+   }
+   return 0;
+}
+
+void
+dumpedesc(usb_endpoint_descriptor_t *ed)
+{
+   char *xfertype, *synchtype;
+
+   printf(%*sEndpoint Descriptor:\n, indent, );
+   indent++;
+   printf(%*sbLength: %d\n, indent, , ed-bLength);
+   printf(%*sbDescriptorType: %d\n, indent, , ed-bDescriptorType);
+   printf(%*sbEndpointAddress: %#x EP %d %s\n, indent, , 
ed-bEndpointAddress,
+  UE_GET_ADDR(ed-bEndpointAddress),
+  UE_GET_DIR(ed-bEndpointAddress) ? in : out);
+   printf(%*sbmAttributes: %#x\n, indent, , ed-bmAttributes);
+
+   switch (UE_GET_XFERTYPE(ed-bmAttributes)) {
+   case UE_CONTROL:
+   xfertype = Control;
+   break;
+   case UE_ISOCHRONOUS:
+   xfertype = Isochronous;
+   break;
+   case UE_BULK:
+   xfertype = Bulk;
+   break;
+   case UE_INTERRUPT:
+   xfertype = Interrupt;
+   break;
+   default:
+   xfertype = Unknown;
+   break;
+   }
+
+   switch (UE_GET_ISO_TYPE(ed-bmAttributes)) {
+   case UE_ISO_ASYNC:
+   synchtype = Asynchronous;
+   break;
+   case UE_ISO_ADAPT:
+   synchtype = Adaptive;
+   break;
+   case UE_ISO_SYNC:
+   synchtype = Synchronous;
+   break;
+   default:
+   synchtype = No Synchronization;
+   break;
+   }
+
+   indent++;
+   printf(%*sTransfer type: %s\n, indent, , xfertype);
+   

Re: [PATCH] Add support for dumping descriptors to usbdevs(8)

2015-04-13 Thread Dimitris Papastamos
Hi,

Attached below an updated patch that makes the layout a bit more sensible.

Index: usr.sbin/usbdevs/usbdevs.8
===
RCS file: /cvs/src/usr.sbin/usbdevs/usbdevs.8,v
retrieving revision 1.9
diff -u -p -r1.9 usbdevs.8
--- usr.sbin/usbdevs/usbdevs.8  26 Jun 2008 05:42:21 -  1.9
+++ usr.sbin/usbdevs/usbdevs.8  13 Apr 2015 16:46:59 -
@@ -54,7 +54,13 @@ Show the device drivers associated with 
 .It Fl f Ar dev
 Only print information for the given USB controller.
 .It Fl v
-Be verbose.
+Verbose mode.  Causes
+.Nm
+to display detailed information about the devices present.
+Multiple
+.Fl v
+options increase verbosity.  At level 1 or above the device
+and configuration descriptors will be shown.
 .El
 .Sh FILES
 .Bl -tag -width Pa
Index: usr.sbin/usbdevs/usbdevs.c
===
RCS file: /cvs/src/usr.sbin/usbdevs/usbdevs.c,v
retrieving revision 1.24
diff -u -p -r1.24 usbdevs.c
--- usr.sbin/usbdevs/usbdevs.c  31 Mar 2015 13:38:27 -  1.24
+++ usr.sbin/usbdevs/usbdevs.c  13 Apr 2015 16:46:59 -
@@ -30,14 +30,17 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include sys/types.h
+
+#include err.h
+#include errno.h
+#include stdarg.h
 #include stdio.h
 #include stdlib.h
 #include string.h
-#include sys/types.h
 #include fcntl.h
 #include unistd.h
-#include err.h
-#include errno.h
+
 #include dev/usb/usb.h
 
 #ifndef nitems
@@ -45,15 +48,29 @@
 #endif
 
 #define USBDEV /dev/usb
+#define INDENT_LEVEL 3
 
-int verbose = 0;
-int showdevs = 0;
+int verbose;
+int showdevs;
+
+int indent;
+char done[USB_MAX_DEVICES];
 
 void usage(void);
+void pushlevel(void);
+void poplevel(void);
+void printent(const char *, ...);
+int getddesc(int, int, int, struct usb_device_ddesc *);
+int getcdesc(int, int, int, struct usb_device_cdesc *);
+int getfdesc(int, int, int, int, struct usb_device_fdesc *);
+void dumpedesc(usb_endpoint_descriptor_t *);
+void dumpidesc(usb_interface_descriptor_t *);
+void dumpcdesc(usb_config_descriptor_t *);
+void dumpddesc(usb_device_descriptor_t *);
+void dumpdesc(int, int, int);
 void usbdev(int f, int a, int rec);
 void usbdump(int f);
 void dumpone(char *name, int f, int addr);
-int main(int, char **);
 
 extern char *__progname;
 
@@ -64,8 +81,256 @@ usage(void)
exit(1);
 }
 
-char done[USB_MAX_DEVICES];
-int indent;
+void
+pushlevel(void)
+{
+   indent += INDENT_LEVEL;
+}
+
+void
+poplevel(void)
+{
+   indent -= INDENT_LEVEL;
+}
+
+void
+printent(const char *fmt, ...)
+{
+   va_list ap;
+
+   va_start(ap, fmt);
+   printf(%*s, indent, );
+   vprintf(fmt, ap);
+   va_end(ap);
+}
+
+int
+getddesc(int f, int b, int a, struct usb_device_ddesc *ddesc)
+{
+   int r;
+
+   ddesc-udd_bus = b;
+   ddesc-udd_addr = a;
+   r = ioctl(f, USB_DEVICE_GET_DDESC, ddesc);
+   if (r) {
+   if (errno != ENXIO)
+   warn(USB_DEVICE_GET_DDESC);
+   return -1;
+   }
+   return 0;
+}
+
+int
+getcdesc(int f, int b, int a, struct usb_device_cdesc *cdesc)
+{
+   int r;
+
+   cdesc-udc_bus = b;
+   cdesc-udc_addr = a;
+   cdesc-udc_config_index = USB_CURRENT_CONFIG_INDEX;
+   r = ioctl(f, USB_DEVICE_GET_CDESC, cdesc);
+   if (r) {
+   warn(USB_DEVICE_GET_CDESC);
+   return -1;
+   }
+   return 0;
+}
+
+int
+getfdesc(int f, int b, int a, int l, struct usb_device_fdesc *fdesc)
+{
+   int r;
+
+   fdesc-udf_bus = b;
+   fdesc-udf_addr = a;
+   fdesc-udf_config_index = USB_CURRENT_CONFIG_INDEX;
+   fdesc-udf_size = l;
+   fdesc-udf_data = malloc(l);
+   if (!fdesc-udf_data)
+   err(1, malloc);
+   r = ioctl(f, USB_DEVICE_GET_FDESC, fdesc);
+   if (r) {
+   warn(USB_DEVICE_GET_FDESC);
+   free(fdesc-udf_data);
+   return -1;
+   }
+   return 0;
+}
+
+void
+dumpedesc(usb_endpoint_descriptor_t *ed)
+{
+   char *xfertype, *synchtype;
+
+   printent(Endpoint Descriptor:\n);
+   pushlevel();
+   printent(bLength:  %d\n, ed-bLength);
+   printent(bDescriptorType:  %d\n, ed-bDescriptorType);
+   printent(bEndpointAddress: %#x EP %d %s\n, ed-bEndpointAddress,
+  UE_GET_ADDR(ed-bEndpointAddress),
+  UE_GET_DIR(ed-bEndpointAddress) ? in : out);
+   printent(bmAttributes: %#x\n, ed-bmAttributes);
+
+   switch (UE_GET_XFERTYPE(ed-bmAttributes)) {
+   case UE_CONTROL:
+   xfertype = Control;
+   break;
+   case UE_ISOCHRONOUS:
+   xfertype = Isochronous;
+   break;
+   case UE_BULK:
+   xfertype = Bulk;
+   break;
+   case UE_INTERRUPT:
+   xfertype = Interrupt;
+   break;
+   default:
+   xfertype = Unknown;
+   break;
+   }
+
+   switch 

Re: [PATCH] Add support for dumping descriptors to usbdevs(8)

2015-04-13 Thread Dimitris Papastamos
One more thing I forgot to mention, the current printing layout
is not ideal.  I'll look into making it a bit more readable.



getty[3246]: (null): Bad file descriptor

2015-04-13 Thread Craig Skinner
Hi,

It seems getty(8) needs an argument (in /etc/ttys at least):

Otherwise, loads of this in /var/log/authlog after rebooting:

Apr 13 15:27:03 pine getty[31932]: (null): Bad file descriptor
Apr 13 15:27:03 pine getty[12802]: (null): Bad file descriptor
Apr 13 15:27:03 pine getty[17719]: (null): Bad file descriptor
Apr 13 15:27:03 pine getty[30241]: (null): Bad file descriptor
Apr 13 15:27:03 pine getty[19066]: (null): Bad file descriptor
Apr 13 15:27:03 pine getty[23566]: (null): Bad file descriptor
Apr 13 15:27:03 pine getty[2623]: (null): Bad file descriptor
Apr 13 15:27:03 pine getty[3246]: (null): Bad file descriptor
Apr 13 15:27:04 pine getty[19976]: (null): Bad file descriptor
Apr 13 15:27:04 pine init: getty repeating too quickly on port /dev/tty00, 
sleeping


getty(8) says the 'default' table is used when no argument is given.



Noticed when changing /etc/gettytab default speed to 9600 baud:

default:\
:np:im=\r\n%s/%m (%h) (%t)\r\n\r\n:sp#9600:



With this entry in /etc/ttys:

tty00   /usr/libexec/gettyxterm   on secure


$ uanme -msrv
OpenBSD 5.6 GENERIC#274 i386