cmd/auxstats: improve wireless interface name matcher in Linux
This commit is contained in:
parent
e683bdfa76
commit
0ac2a105ae
1 changed files with 4 additions and 1 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
#include <u.h>
|
#include <u.h>
|
||||||
#include <libc.h>
|
#include <libc.h>
|
||||||
#include <bio.h>
|
#include <bio.h>
|
||||||
|
#include <regexp.h>
|
||||||
#include "dat.h"
|
#include "dat.h"
|
||||||
|
|
||||||
void xapm(int);
|
void xapm(int);
|
||||||
|
|
@ -235,10 +236,12 @@ void
|
||||||
xwireless(int first)
|
xwireless(int first)
|
||||||
{
|
{
|
||||||
static int fd = -1;
|
static int fd = -1;
|
||||||
|
static Reprog *wlan = nil;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if(first){
|
if(first){
|
||||||
fd = open("/proc/net/wireless", OREAD);
|
fd = open("/proc/net/wireless", OREAD);
|
||||||
|
wlan = regcomp("^(wlan[0-9]+|wlp[0-9]+s[0-9]+):$");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -247,7 +250,7 @@ xwireless(int first)
|
||||||
tokens(i);
|
tokens(i);
|
||||||
if(ntok < 3)
|
if(ntok < 3)
|
||||||
continue;
|
continue;
|
||||||
if(strcmp(tok[0], "wlan0:") == 0)
|
if(regexec(wlan, tok[0], nil, 0) == 1)
|
||||||
Bprint(&bout, "802.11 =%lld 100\n", atoll(tok[2]));
|
Bprint(&bout, "802.11 =%lld 100\n", atoll(tok[2]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue