Author: mlandres Date: Wed Nov 12 13:24:50 2008 New Revision: 11653 URL: http://svn.opensuse.org/viewcvs/zypp?rev=11653&view=rev Log: - Check for modaliases below /sys (bnc #430179) Modified: trunk/libzypp/VERSION.cmake trunk/libzypp/package/libzypp.changes trunk/libzypp/zypp/target/modalias/Modalias.cc Modified: trunk/libzypp/VERSION.cmake URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/VERSION.cmake?rev=11653&r1=11652&r2=11653&view=diff ============================================================================== --- trunk/libzypp/VERSION.cmake (original) +++ trunk/libzypp/VERSION.cmake Wed Nov 12 13:24:50 2008 @@ -59,7 +59,7 @@ # changes file. See './mkChangelog -h' for help. # SET(LIBZYPP_MAJOR "5") -SET(LIBZYPP_COMPATMINOR "21") +SET(LIBZYPP_COMPATMINOR "23") SET(LIBZYPP_MINOR "23") SET(LIBZYPP_PATCH "0") # Modified: trunk/libzypp/package/libzypp.changes URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/package/libzypp.changes?rev=11653&r1=11652&r2=11653&view=diff ============================================================================== --- trunk/libzypp/package/libzypp.changes (original) +++ trunk/libzypp/package/libzypp.changes Wed Nov 12 13:24:50 2008 @@ -1,4 +1,10 @@ ------------------------------------------------------------------- +Wed Nov 12 13:19:02 CET 2008 - ma@suse.de + +- Check for modaliases below /sys (bnc #430179) +- revision 11653 + +------------------------------------------------------------------- Tue Nov 11 18:36:33 CET 2008 - ma@suse.de - Avoid superfluous file copying and gpg invocation in keyring handling. Modified: trunk/libzypp/zypp/target/modalias/Modalias.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/target/modalias/Modalias.cc?rev=11653&r1=11652&r2=11653&view=diff ============================================================================== --- trunk/libzypp/zypp/target/modalias/Modalias.cc (original) +++ trunk/libzypp/zypp/target/modalias/Modalias.cc Wed Nov 12 13:24:50 2008 @@ -30,6 +30,7 @@ #include "zypp/base/Logger.h" #include "zypp/target/modalias/Modalias.h" +#include "zypp/PathInfo.h" using std::endl; @@ -59,23 +60,38 @@ * If FUNC returns a non-zero return value, stop reading the directory * and return that value. Returns -1 if an error occurs. */ + int -foreach_file(const char *path, int (*func)(const char *, const char *, void *), +foreach_file_recursive(const char *path_rec, int (*func)(const char *, const char *, void *), void *arg) { DIR *dir; struct dirent *dirent; + char path_tmp[PATH_MAX]; int ret = 0; - if (!(dir = opendir(path))) + if (!(dir = opendir(path_rec))) return -1; while ((dirent = readdir(dir)) != NULL) { if (strcmp(dirent->d_name, ".") == 0 || strcmp(dirent->d_name, "..") == 0) continue; - if ((ret = func(path, dirent->d_name, arg)) != 0) - break; + snprintf(path_tmp, sizeof(path_tmp), "%s/%s", path_rec, dirent->d_name); + + PathInfo path(path_tmp, PathInfo::LSTAT); + + if (path.isLink ()) { + continue; + } + if (path.isDir ()){ + (void) foreach_file_recursive(path_tmp, func, arg); + }else if (path.isFile ()){ + if ((ret = func(path_rec, dirent->d_name, arg)) != 0) + break; + }else{ + continue; + } } if (closedir(dir) != 0) return -1; @@ -95,7 +111,10 @@ char modalias[PATH_MAX]; struct modalias_list **list = (struct modalias_list **)arg, *entry; - snprintf(path, sizeof(path), "%s/%s/modalias", dir, file); + if (strcmp(file, "modalias") != 0){ + return 0; + } + snprintf(path, sizeof(path), "%s/%s", dir, file); if ((fd = open(path, O_RDONLY)) == -1) return 0; len = read(fd, modalias, sizeof(modalias) - 1); @@ -120,38 +139,6 @@ return 0; } -/* - * Iterate over all devices on a bus (/sys/bus/BUS/devices/<*>) - * and remembers all module aliases for those devices on - * the linked modalias list passed in in ARG. - */ -int -iterate_bus(const char *dir, const char *file, void *arg) -{ - char path[PATH_MAX]; - - snprintf(path, sizeof(path), "%s/%s/devices", dir, file); - (void) foreach_file(path, read_modalias, arg); - - return 0; -} - -/* - * Iterate over all devices in a class (/sys/class/CLASS/<*>) - * and remembers all module aliases for those devices on - * the linked modalias list passed in in ARG. - */ -int -iterate_class(const char *dir, const char *file, void *arg) -{ - char path[PATH_MAX]; - - snprintf(path, sizeof(path), "%s/%s", dir, file); - (void) foreach_file(path, read_modalias, arg); - - return 0; -} - ///////////////////////////////////////////////////////////////// } // namespace /////////////////////////////////////////////////////////////////// @@ -177,11 +164,9 @@ dir = "/sys"; DBG << "Using /sys directory : " << dir << endl; - snprintf(path, sizeof(path), "%s/bus", dir); - foreach_file( path, iterate_bus, &_modaliases ); + snprintf(path, sizeof(path), "%s", dir); + foreach_file_recursive( path, read_modalias, &_modaliases ); - snprintf(path, sizeof(path), "%s/class", dir); - foreach_file( path, iterate_class, &_modaliases ); } /** Dtor. */ -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org