[PATCH] make lcdproc parse Linux interface names properly
Anders Eriksson <[email protected]> Sat, 27 Apr 2013 19:33:26 +0200
| Newsgroups | gmane.comp.sysutils.lcdproc |
|---|---|
| Message-ID | <CAGncdOYWndUDPsvoB3RVcXgLY0isOse+LZhh5HaND_t46dHxew@mail.gmail.com> |
--===============3878772300866419037==
Content-Type: multipart/alternative; boundary=089e015368c899687004db5b0cfa
--089e015368c899687004db5b0cfa
Content-Type: text/plain; charset=ISO-8859-1
Hi all,
Linux interface names like eth0 and eth0.1, i.e. where one name is a
substring of the other.
Current code in lcdproc iface fails to pick up the right interface name
under these circumstances. This patch fixes that by checking for ':' at the
end of the interface name in /proc/net/dev.
diff -Naur lcdproc-0.5.2/clients/lcdproc/machine_Linux.c
lcdproc-0.5.2_new/clients/lcdproc/machine_Linux.c
--- lcdproc-0.5.2/clients/lcdproc/machine_Linux.c 2007-04-14
16:38:15.000000000 +0200
+++ lcdproc-0.5.2_new/clients/lcdproc/machine_Linux.c 2013-04-27
19:22:02.000000000 +0200
@@ -534,7 +534,8 @@
/* Search iface_name and scan values */
while ((fgets(buffer, sizeof(buffer), file) != NULL)) {
- if (strstr(buffer, interface->name)) {
+ char *s;
+ if ((s=strstr(buffer, interface->name)) &&
s[strlen(interface->name)]==':') {
/* interface exists */
interface->status = up; /* is up */
interface->last_online = time(NULL); /*
save actual time */
--089e015368c899687004db5b0cfa
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div><div>Hi all,<br><br></div>Linux interface names like =
eth0 and eth0.1, i.e. where one name is a substring of the other.<br></div>=
Current code in lcdproc iface fails to pick up the right interface name und=
er these circumstances. This patch fixes that by checking for ':' a=
t the end of the interface name in /proc/net/dev.<br>
<br>=A0 diff -Naur=A0 lcdproc-0.5.2/clients/lcdproc/machine_Linux.c lcdproc=
-0.5.2_new/clients/lcdproc/machine_Linux.c<br>--- lcdproc-0.5.2/clients/lcd=
proc/machine_Linux.c=A0=A0=A0=A0=A0=A0 2007-04-14 16:38:15.000000000 +0200<=
br>+++ lcdproc-0.5.2_new/clients/lcdproc/machine_Linux.c=A0=A0 2013-04-27 1=
9:22:02.000000000 +0200<br>
@@ -534,7 +534,8 @@<br><br>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 /*=
Search iface_name and scan values */<br>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0 while ((fgets(buffer, sizeof(buffer), file) !=3D NULL)) {<br>-=
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 if (strs=
tr(buffer, interface->name)) {<br>
+=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 char *s=
;<br>+=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 if=
((s=3Dstrstr(buffer, interface->name)) && s[strlen(interface-&g=
t;name)]=3D=3D':') {<br>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 /* interface exists */<=
br>
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0 interface->status =3D up; /* is up */<br>=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0 interface->last_online =3D time(NULL); /* save actual time */<br>=
<br></div>
--089e015368c899687004db5b0cfa--
--===============3878772300866419037==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
LCDproc mailing list
[email protected]
http://lists.omnipotent.net/mailman/listinfo/lcdproc
--===============3878772300866419037==--