diff options
author | Erik Troan <ewt@redhat.com> | 1999-07-21 18:47:36 +0000 |
---|---|---|
committer | Erik Troan <ewt@redhat.com> | 1999-07-21 18:47:36 +0000 |
commit | d9d8892643bd70514e7901974aa54ae118c784f0 (patch) | |
tree | 2c3b8489e8e2ebb3ffe3be33b0a14174b163d5cf /loader | |
parent | 5c2121605db0ad710eb6c9f6d120eafe1c1aa212 (diff) | |
download | anaconda-d9d8892643bd70514e7901974aa54ae118c784f0.tar.gz anaconda-d9d8892643bd70514e7901974aa54ae118c784f0.tar.xz anaconda-d9d8892643bd70514e7901974aa54ae118c784f0.zip |
1) rewrote fineNetList() to use /proc/net/dev as the ioctl seemed unhappy
2) pass testing parameter to mlLoadModule()
Diffstat (limited to 'loader')
-rw-r--r-- | loader/loader.c | 48 |
1 files changed, 30 insertions, 18 deletions
diff --git a/loader/loader.c b/loader/loader.c index ad7b79f47..099ab6239 100644 --- a/loader/loader.c +++ b/loader/loader.c @@ -70,29 +70,41 @@ int deviceKnown(char * dev) { } static int findNetList(void) { - struct ifconf ifc; - struct ifreq intfs[50]; /* should be enough <shrug> */ - int s; - - ifc.ifc_req = intfs; - ifc.ifc_len = sizeof(intfs); - s = socket(AF_INET, SOCK_DGRAM, 0); + int fd; + char buf[1024]; + char * start, * end; - if (ioctl(s, SIOCGIFCONF, &ifc)) { - logMessage("failed to get list of networking interfaces"); - close(s); + if ((fd = open("/proc/net/dev", O_RDONLY)) < 0) { + fprintf(stderr, "failed to open /proc/net/dev!\n"); return 1; } - close(s); + read(fd, buf, sizeof(buf)); + close(fd); - for (s = 0; s < ifc.ifc_len / sizeof(struct ifreq); s++) { - if (!strcmp(intfs[s].ifr_name, "lo")) continue; - if (deviceKnown(intfs[s].ifr_name)) continue; + /* skip the first two lines */ + start = strchr(buf, '\n'); + if (!start) return 0; + start = strchr(start + 1, '\n'); + if (!start) return 0; + + start++; + while (start && *start) { + while (isspace(*start)) start++; + end = strchr(start, ':'); + if (!end) return 0; + *end = '\0'; + + if (strcmp(start, "lo")) { + if (deviceKnown(start)) continue; + + knownDevices[numKnownDevices].name = strdup(start); + knownDevices[numKnownDevices].model = NULL; + knownDevices[numKnownDevices++].class = DEVICE_NET; + } - knownDevices[numKnownDevices].name = strdup(intfs[s].ifr_name); - knownDevices[numKnownDevices].model = NULL; - knownDevices[numKnownDevices++].class = DEVICE_NET; + start = strchr(end + 1, '\n'); + if (start) start++; } return 0; @@ -402,7 +414,7 @@ int main(int argc, char ** argv) { } else if (modList) { for (i = 0; modList[i]; i++) { if (modList[i]->major == DRIVER_NET) { - mlLoadModule(modList[i], modLoaded, modDeps); + mlLoadModule(modList[i], modLoaded, modDeps, testing); } } |