diff options
author | Mike Christie <michaelc@cs.wisc.edu> | 2009-02-02 16:42:54 -0600 |
---|---|---|
committer | Mike Christie <michaelc@cs.wisc.edu> | 2009-02-02 16:42:54 -0600 |
commit | 222947129ca97998aa69ecafcaefb48cb9328c6a (patch) | |
tree | 5071fdcb81a4bb3bb0fb3ac66d5f1544fd1ed0d1 /utils | |
parent | 78da93a3b934759b5cd288cfbf414eaf84ce6ba9 (diff) | |
download | open-iscsi-222947129ca97998aa69ecafcaefb48cb9328c6a.tar.gz |
PATCH: fix iBFT firmware reading with newer kernels
Patch and mail from Hans De Goede:
Hi,
While testing I noticed that "iscsiadmin -m fw" does not work properly
on newer
(rawhide atleast) kernels, the attached patch (already applied to the
Fedora
devel packages) fixes this.
Regards,
Hans
Diffstat (limited to 'utils')
-rw-r--r-- | utils/fwparam_ibft/fwparam_ibft_sysfs.c | 61 |
1 files changed, 34 insertions, 27 deletions
diff --git a/utils/fwparam_ibft/fwparam_ibft_sysfs.c b/utils/fwparam_ibft/fwparam_ibft_sysfs.c index a79c1c6..3ce1b74 100644 --- a/utils/fwparam_ibft/fwparam_ibft_sysfs.c +++ b/utils/fwparam_ibft/fwparam_ibft_sysfs.c @@ -103,33 +103,6 @@ static int get_iface_from_device(char *id, struct boot_context *context) rc = EINVAL; rc = 0; break; - } else if (!strncmp(dent->d_name, "net", 3)) { - DIR *net_dirfd; - struct dirent *net_dent; - - strncat(dev_dir, "/", FILENAMESZ); - strncat(dev_dir, dent->d_name, FILENAMESZ); - - net_dirfd = opendir(dev_dir); - if (!net_dirfd) { - printf("Could not open net path %s.\n", - dev_dir); - rc = errno; - break; - } - - while ((net_dent = readdir(net_dirfd))) { - if (!strcmp(net_dent->d_name, ".") || - !strcmp(net_dent->d_name, "..")) - continue; - - strncpy(context->iface, net_dent->d_name, - sizeof(context->iface)); - break; - } - closedir(net_dirfd); - rc = 0; - break; } else { printf("Could not read ethernet to net link\n."); rc = EOPNOTSUPP; @@ -137,6 +110,40 @@ static int get_iface_from_device(char *id, struct boot_context *context) } } + closedir(dirfd); + + if (rc != ENODEV) + return rc; + + /* If not found try again with newer kernel networkdev sysfs layout */ + strncat(dev_dir, "/net", FILENAMESZ - strlen(dev_dir)); + + if (!file_exist(dev_dir)) + return rc; + + dirfd = opendir(dev_dir); + if (!dirfd) + return errno; + + while ((dent = readdir(dirfd))) { + if (!strcmp(dent->d_name, ".") || !strcmp(dent->d_name, "..")) + continue; + + /* Take the first "regular" directory entry */ + if (strlen(dent->d_name) > (sizeof(context->iface) - 1)) { + rc = EINVAL; + printf("Net device %s too big for iface buffer.\n", + dent->d_name); + break; + } + + strcpy(context->iface, dent->d_name); + rc = 0; + break; + } + + closedir(dirfd); + return rc; } |