#! /bin/sh /usr/share/dpatch/dpatch-run ## 04_fix_long_ifnames.dpatch by ## ## All lines beginning with `## DP:' are a description of the patch. ## DP: Fix parsing of /proc/net/dev for interface names longer than 6 ## DP: characters. Make parsing more robust in general. @DPATCH@ diff -urNad vnstat-1.4~/src/proc.c vnstat-1.4/src/proc.c --- vnstat-1.4~/src/proc.c 2007-09-19 11:58:07.856562156 +0200 +++ vnstat-1.4/src/proc.c 2007-09-19 11:58:24.000000000 +0200 @@ -63,7 +63,6 @@ void parseproc(int newdb) { - char temp[64]; uint64_t rx, tx, rxchange=0, txchange=0, btime; /* rxchange = rx change in MB */ uint64_t krxchange=0, ktxchange=0; /* krxchange = rx change in kB */ time_t current; @@ -86,13 +85,11 @@ current=time(NULL); - /* get rx from procline, easy since it's always procline+7 */ + /* read rx and tx from procline */ + sscanf(procline,"%*[^:]:%Lu %*s %*s %*s %*s %*s %*s %*s %Lu %*s %*s %*s %*s %*s %*s %*s",&rx,&tx); -#ifdef BLIMIT - rx=strtoull(procline+7, (char **)NULL, 0); -#else - rx=strtoul(procline+7, (char **)NULL, 0); -#endif + if (debug) + printf("tx: %Lu, rx: %Lu\n", tx, rx); if (newdb!=1) { if (data.currx<=rx) { @@ -115,15 +112,6 @@ addtraffic(&data.totalrx, &data.totalrxk, rxchange, rxkchange); - /* get tx from procline, ugly hack */ - sscanf(procline+7,"%s %s %s %s %s %s %s %s %s",temp,temp,temp,temp,temp,temp,temp,temp,temp); - -#ifdef BLIMIT - tx=strtoull(temp, (char **)NULL, 0); -#else - tx=strtoul(temp, (char **)NULL, 0); -#endif - if (newdb!=1) { if (data.curtx<=tx) { txchange=(tx-data.curtx)/1024/1024;