| 151 | } |
| 152 | |
| 153 | static void |
| 154 | setNetStat(TSMutex stat_creation_mutex, const char *interface, const char *entry, const char *subdir, bool subdirstatname) |
| 155 | { |
| 156 | char sysfs_name[PATH_MAX]; |
| 157 | char stat_name[255]; |
| 158 | char data[255]; |
| 159 | |
| 160 | memset(&stat_name[0], 0, sizeof(stat_name)); |
| 161 | memset(&sysfs_name[0], 0, sizeof(sysfs_name)); |
| 162 | memset(&data[0], 0, sizeof(data)); |
| 163 | |
| 164 | if ((interface == nullptr) || (entry == nullptr)) { |
| 165 | TSError("%s: nullptr subdir or entry", DEBUG_TAG); |
| 166 | return; |
| 167 | } |
| 168 | |
| 169 | // Generate the ATS stats name |
| 170 | if (subdirstatname) { |
| 171 | snprintf(&stat_name[0], sizeof(stat_name), "%s%s.%s.%s", NET_STATS, interface, subdir, entry); |
| 172 | } else { |
| 173 | snprintf(&stat_name[0], sizeof(stat_name), "%s%s.%s", NET_STATS, interface, entry); |
| 174 | } |
| 175 | |
| 176 | // Determine if this is a toplevel netdev stat, or one from statistics. |
| 177 | if (subdir == nullptr) { |
| 178 | snprintf(&sysfs_name[0], sizeof(sysfs_name), "%s/%s/%s", NET_STATS_DIR, interface, entry); |
| 179 | } else { |
| 180 | snprintf(&sysfs_name[0], sizeof(sysfs_name), "%s/%s/%s/%s", NET_STATS_DIR, interface, subdir, entry); |
| 181 | } |
| 182 | |
| 183 | if (getFile(&sysfs_name[0], &data[0], sizeof(data)) < 0) { |
| 184 | Dbg(dbg_ctl, "Error reading file %s", sysfs_name); |
| 185 | } else { |
| 186 | statSet(stat_name, atol(data), stat_creation_mutex); |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | static void |
| 191 | setBondingStat(TSMutex stat_creation_mutex, const char *interface) |
no test coverage detected