Changeset 17731
- Timestamp:
- 10/10/11 10:21:26 (20 months ago)
- File:
-
- 1 edited
-
src/router/rc/ttraff.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/router/rc/ttraff.c
r15334 r17731 8 8 #include <stdio.h> 9 9 #include <time.h> 10 #include <string.h> 10 11 #include <stdlib.h> 11 12 #include <unistd.h> … … 16 17 #include <syslog.h> 17 18 #include <utils.h> 19 20 21 void 22 remove_oldest_entry(int cur_month, int cur_year) 23 { 24 char old[32]; 25 int month, year; 26 int len = 0; 27 28 for (year = 2008; year <= cur_year; year++) { 29 for (month = 1; month <= 12; month++) { 30 if (month == cur_month && year == cur_year) { 31 return; 32 } 33 sprintf(old, "traff-%02u-%u", month, year); 34 len = strlen(nvram_safe_get(old)); 35 if (len > 0) { 36 dd_syslog(LOG_DEBUG, 37 "ttraff: old data for %d-%d removed, freeing %d bytes of nvram\n", month, year, len + 15); 38 nvram_unset(old); 39 return; 40 } 41 } 42 } 43 44 return; 45 } 18 46 19 47 void … … 37 65 memset(buffer, 0, 2048); 38 66 sprintf(tq, "traff-%02u-%u", month, year); 67 68 /* keep some nvram free by removing oldest traf data */ 69 int space = 0; 70 int used = nvram_used(&space); 71 if ((space - used) < 2048) { /* 2048 bytes to be on a safe side */ 72 remove_oldest_entry(month, year); 73 } 74 39 75 tdata = nvram_safe_get(tq); 40 76 … … 89 125 return; 90 126 } 127 91 128 92 129 int main(int argc, char **argv)
Note: See TracChangeset
for help on using the changeset viewer.
