diff options
author | Bill Nottingham <notting@redhat.com> | 2006-10-30 21:40:26 +0000 |
---|---|---|
committer | Bill Nottingham <notting@redhat.com> | 2006-10-30 21:40:26 +0000 |
commit | bc9008aa85ecef1668f4a15eab430dccc9bf45fc (patch) | |
tree | a206f767d7c1e167782d186ec7fd06de61142e12 | |
parent | 604ab7992adb790ba2ea1ace7217588d65f13ba7 (diff) | |
download | initscripts-bc9008aa85ecef1668f4a15eab430dccc9bf45fc.tar initscripts-bc9008aa85ecef1668f4a15eab430dccc9bf45fc.tar.gz initscripts-bc9008aa85ecef1668f4a15eab430dccc9bf45fc.tar.bz2 initscripts-bc9008aa85ecef1668f4a15eab430dccc9bf45fc.tar.xz initscripts-bc9008aa85ecef1668f4a15eab430dccc9bf45fc.zip |
more SUBCHANNELS related fixage (#204803)r8-45-6-EL
-rw-r--r-- | initscripts.spec | 5 | ||||
-rw-r--r-- | src/rename_device.c | 61 |
2 files changed, 52 insertions, 14 deletions
diff --git a/initscripts.spec b/initscripts.spec index a9ce9045..30cb960e 100644 --- a/initscripts.spec +++ b/initscripts.spec @@ -1,6 +1,6 @@ Summary: The inittab file and the /etc/init.d scripts. Name: initscripts -Version: 8.45.5.EL +Version: 8.45.6.EL License: GPL Group: System Environment/Base Release: 1 @@ -193,6 +193,9 @@ rm -rf $RPM_BUILD_ROOT %ghost %attr(0664,root,utmp) /var/run/utmp %changelog +* Mon Oct 30 2006 Bill Nottingham <notting@redhat.com> 8.45.6.EL-1 +- further refinement of the SUBCHANNELS support (#204803) + * Fri Oct 27 2006 Bill Nottingham <notting@redhat.com> 8.45.5.EL-1 - fix handling of undisplayable locales on the console some more (#209579, #212438) - use SUBCHANNEL as the primary identifier for s390 networking (#204803) diff --git a/src/rename_device.c b/src/rename_device.c index c845b7ab..968bd015 100644 --- a/src/rename_device.c +++ b/src/rename_device.c @@ -53,6 +53,52 @@ struct netdev { struct netdev *configs = NULL; struct netdev *devs = NULL; +#if defined(__s390__) || defined(__s390x__) +static int is_cdev(const struct dirent *dent) { + char *end = NULL; + + if (strncmp(dent->d_name,"cdev",4)) + return 0; + strtoul(dent->d_name+4,&end, 10); + if (*end) + return 0; + return 1; +} + +static inline char *getdev(char *path, char *ent) { + char *a, *b, *ret; + + asprintf(&a,"%s/%s",path,ent); + b = canonicalize_file_name(a); + ret = strdup(basename(b)); + free(b); + free(a); + return ret; +} + +char *read_subchannels(char *device) { + char *tmp, *path, *ret; + int n, x; + struct dirent **cdevs; + + if (asprintf(&path,"/sys/class/net/%s/device",device) == -1) + return NULL; + if ((n = scandir(path, &cdevs, is_cdev, alphasort)) <= 0) + return NULL; + + ret = getdev(path,cdevs[0]->d_name); + for (x = 1 ; x < n ; x++ ) { + if (asprintf(&tmp, "%s,%s", ret, getdev(path, cdevs[x]->d_name)) == -1) + return NULL; + free(ret); + ret = tmp; + } + free(path); + return ret; +} + +#endif + struct netdev *get_devs() { DIR *dir; struct dirent *entry; @@ -81,14 +127,7 @@ struct netdev *get_devs() { g_free(contents); contents = NULL; #if defined(__s390__) || defined(__s390x__) - if (asprintf(&path,"/sys/class/net/%s/device",entry->d_name) == -1) - continue; - char *tmp = canonicalize_file_name(path); - if (!tmp) - continue; - contents = strdup(basename(tmp)); - printf("found device %s\n",contents); - free(tmp); + contents = read_subchannels(entry->d_name); #else if (asprintf(&path,"/sys/class/net/%s/address",entry->d_name) == -1) continue; @@ -159,11 +198,7 @@ struct netdev *get_configs() { } #if defined(__s390__) || defined(__s390x__) if (g_str_has_prefix(lines[i],"SUBCHANNELS=")) { - char *tmp = lines[i] + 12; - hwaddr = tmp; - while (*tmp && *tmp != ',') tmp++; - *tmp = '\0'; - printf("got hwaddr %s\n",hwaddr); + hwaddr = lines[i] + 12; } #else if (g_str_has_prefix(lines[i],"HWADDR=")) { |