Hello community, here is the log from the commit of package libzypp for openSUSE:Factory checked in at 2013-06-20 12:31:45 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/libzypp (Old) and /work/SRC/openSUSE:Factory/.libzypp.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "libzypp" Changes: -------- --- /work/SRC/openSUSE:Factory/libzypp/libzypp.changes 2013-06-05 12:54:44.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.libzypp.new/libzypp.changes 2013-06-20 15:19:07.000000000 +0200 @@ -1,0 +2,6 @@ +Tue Jun 11 11:37:48 CEST 2013 - [email protected] + +- Speedup scanning for modaliases (bnc#824110) +- version 13.3.0 (2) + +------------------------------------------------------------------- Old: ---- libzypp-13.2.0.tar.bz2 New: ---- libzypp-13.3.0.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ libzypp.spec ++++++ --- /var/tmp/diff_new_pack.we5WIL/_old 2013-06-20 15:19:08.000000000 +0200 +++ /var/tmp/diff_new_pack.we5WIL/_new 2013-06-20 15:19:08.000000000 +0200 @@ -24,7 +24,7 @@ Group: System/Packages BuildRoot: %{_tmppath}/%{name}-%{version}-build Summary: Package, Patch, Pattern, and Product Management -Version: 13.2.0 +Version: 13.3.0 Release: 1 Source: %{name}-%{version}.tar.bz2 Source1: %{name}-rpmlintrc ++++++ libzypp-13.2.0.tar.bz2 -> libzypp-13.3.0.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzypp-13.2.0/VERSION.cmake new/libzypp-13.3.0/VERSION.cmake --- old/libzypp-13.2.0/VERSION.cmake 2013-05-16 12:07:02.000000000 +0200 +++ new/libzypp-13.3.0/VERSION.cmake 2013-06-11 10:22:16.000000000 +0200 @@ -60,9 +60,9 @@ # SET(LIBZYPP_MAJOR "13") SET(LIBZYPP_COMPATMINOR "2") -SET(LIBZYPP_MINOR "2") +SET(LIBZYPP_MINOR "3") SET(LIBZYPP_PATCH "0") # -# LAST RELEASED: 13.2.0 (2) +# LAST RELEASED: 13.3.0 (2) # (The number in parenthesis is LIBZYPP_COMPATMINOR) #======= diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzypp-13.2.0/package/libzypp.changes new/libzypp-13.3.0/package/libzypp.changes --- old/libzypp-13.2.0/package/libzypp.changes 2013-05-25 23:54:59.000000000 +0200 +++ new/libzypp-13.3.0/package/libzypp.changes 2013-06-12 07:26:16.000000000 +0200 @@ -1,4 +1,10 @@ ------------------------------------------------------------------- +Tue Jun 11 11:37:48 CEST 2013 - [email protected] + +- Speedup scanning for modaliases (bnc#824110) +- version 13.3.0 (2) + +------------------------------------------------------------------- Sun May 26 01:13:15 CEST 2013 - [email protected] - Update zypp-po.tar.bz2 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzypp-13.2.0/zypp/Arch.cc new/libzypp-13.3.0/zypp/Arch.cc --- old/libzypp-13.2.0/zypp/Arch.cc 2013-05-02 11:11:26.000000000 +0200 +++ new/libzypp-13.3.0/zypp/Arch.cc 2013-06-12 08:02:16.000000000 +0200 @@ -170,6 +170,7 @@ DEF_BUILTIN( ppc ); DEF_BUILTIN( ppc64 ); + DEF_BUILTIN( ppc64p7 ); DEF_BUILTIN( ia64 ); @@ -298,6 +299,7 @@ // defCompatibleWith( _ppc(), _noarch() ); defCompatibleWith( _ppc64(), _noarch(),_ppc() ); + defCompatibleWith( _ppc64p7(), _noarch(),_ppc(),_ppc64() ); // defCompatibleWith( _alpha(), _noarch() ); defCompatibleWith( _alphaev5(), _noarch(),_alpha() ); @@ -415,6 +417,7 @@ const Arch Arch_ppc( _ppc() ); const Arch Arch_ppc64( _ppc64() ); + const Arch Arch_ppc64p7( _ppc64p7() ); const Arch Arch_ia64( _ia64() ); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzypp-13.2.0/zypp/Arch.h new/libzypp-13.3.0/zypp/Arch.h --- old/libzypp-13.2.0/zypp/Arch.h 2013-03-28 13:01:31.000000000 +0100 +++ new/libzypp-13.3.0/zypp/Arch.h 2013-06-12 08:02:16.000000000 +0200 @@ -188,6 +188,8 @@ extern const Arch Arch_s390; /** \relates Arch */ + extern const Arch Arch_ppc64p7; + /** \relates Arch */ extern const Arch Arch_ppc64; /** \relates Arch */ extern const Arch Arch_ppc; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzypp-13.2.0/zypp/base/LogControl.cc new/libzypp-13.3.0/zypp/base/LogControl.cc --- old/libzypp-13.2.0/zypp/base/LogControl.cc 2013-03-20 09:29:30.000000000 +0100 +++ new/libzypp-13.3.0/zypp/base/LogControl.cc 2013-06-19 12:18:16.000000000 +0200 @@ -46,17 +46,19 @@ } else { + if ( mode_r ) + { + // not filesystem::assert_file as filesystem:: functions log, + // and this FileWriter is not yet in place. + int fd = ::creat( file_r.c_str(), mode_r ); + if ( fd != -1 ) + ::close( fd ); + } // set unbuffered write std::ofstream * fstr = 0; _outs.reset( (fstr = new std::ofstream( file_r.asString().c_str(), std::ios_base::app )) ); fstr->rdbuf()->pubsetbuf(0,0); _str = &(*fstr); - if ( mode_r ) - { - // not filesystem::chmod, as filesystem:: functions log, - // and this FileWriter is not yet in place. - ::chmod( file_r.asString().c_str(), mode_r ); - } } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzypp-13.2.0/zypp/target/modalias/Modalias.cc new/libzypp-13.3.0/zypp/target/modalias/Modalias.cc --- old/libzypp-13.2.0/zypp/target/modalias/Modalias.cc 2013-03-20 09:29:30.000000000 +0100 +++ new/libzypp-13.3.0/zypp/target/modalias/Modalias.cc 2013-06-11 10:22:16.000000000 +0200 @@ -11,278 +11,185 @@ */ extern "C" { -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <unistd.h> -#include <dirent.h> #include <fnmatch.h> } -#include <cstdlib> -#include <cstdio> -#include <cstring> -#include <cerrno> #include <iostream> +#include <fstream> +#include <vector> #undef ZYPP_BASE_LOGGER_LOGGROUP #define ZYPP_BASE_LOGGER_LOGGROUP "MODALIAS" -#include "zypp/base/Logger.h" -#include "zypp/target/modalias/Modalias.h" +#include "zypp/base/LogTools.h" +#include "zypp/base/IOStream.h" +#include "zypp/AutoDispose.h" #include "zypp/PathInfo.h" +#include "zypp/target/modalias/Modalias.h" using std::endl; -using std::string; - /////////////////////////////////////////////////////////////////// namespace zypp -{ ///////////////////////////////////////////////////////////////// +{ /////////////////////////////////////////////////////////////////// namespace target - { ///////////////////////////////////////////////////////////////// - -struct modalias_list { - char *modalias; - struct modalias_list *next; -}; - + { /////////////////////////////////////////////////////////////////// namespace - { ///////////////////////////////////////////////////////////////// - -/* - * For each file in the directory PATH other than . and .., call - * FUNC with the arguments PATH, the file's name, and ARG. - * - * 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_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_rec))) - return -1; - while ((dirent = readdir(dir)) != NULL) { - - if (strcmp(dirent->d_name, ".") == 0 || - strcmp(dirent->d_name, "..") == 0) - continue; - 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; - return ret; -} - -/* - * If DIR/FILE/modalias exists, remember this modalias on the linked modalias list - * passed in in ARG. Never returns an error. - */ -int -read_modalias(const char *dir, const char *file, void *arg) -{ - char path[PATH_MAX]; - int fd; - ssize_t len; - char modalias[PATH_MAX]; - struct modalias_list **list = (struct modalias_list **)arg, *entry; - - if (strcmp(file, "modalias") != 0){ - return 0; + { + /** Filter subtrees known to contain no modalias files */ + inline bool isBlackListed( const Pathname & dir_r, const char * file_r ) + { +#define PATH_IS( D, F ) ( ::strcmp( file_r, F ) == 0 && ::strcmp( dir_r.c_str(), D ) == 0 ) + switch ( file_r[0] ) + { + case 'm': + return PATH_IS( "/sys/devices/system", "memory" ); // bnc#824110: huge tree for systems with large RAM + break; } - snprintf(path, sizeof(path), "%s/%s", dir, file); - if ((fd = open(path, O_RDONLY|O_CLOEXEC)) == -1) - return 0; - len = read(fd, modalias, sizeof(modalias) - 1); - if (len < 0) - goto out; - while (len > 0 && modalias[len - 1] == '\n') - len--; - modalias[len] = 0; - - if ((entry = (struct modalias_list *)malloc(sizeof(*entry))) == NULL) - goto out; - if ((entry->modalias = strdup(modalias)) == NULL) { - free(entry); - goto out; + return false; +#undef PATH_IS + } + + /** Recursively scan for modalias files and scan them to \a arg. */ + void foreach_file_recursive( const Pathname & dir_r, Modalias::ModaliasList & arg ) + { + AutoDispose<DIR *> dir( ::opendir( dir_r.c_str() ), ::closedir ); + if ( ! dir ) + return; + + struct dirent * dirent = NULL; + while ( (dirent = ::readdir(dir)) != NULL ) + { + if ( dirent->d_name[0] == '.' ) + continue; + + if ( isBlackListed( dir_r, dirent->d_name ) ) + continue; + + PathInfo pi( dir_r / dirent->d_name, PathInfo::LSTAT ); + + if ( pi.isDir() ) + { + foreach_file_recursive( pi.path(), arg ); + } + else if ( pi.isFile() && ::strcmp( dirent->d_name, "modalias" ) == 0 ) + { + // read modalias line from file + std::ifstream str( pi.path().c_str() ); + std::string line( iostr::getline( str ) ); + if ( ! line.empty() ) + arg.push_back( line ); + } } - entry->next = *list; - *list = entry; - XXX << "system modalias: " << entry->modalias << endl; - -out: - (void) close(fd); - return 0; -} - - ///////////////////////////////////////////////////////////////// + } } // namespace /////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////// -// -// CLASS NAME : Modalias::Impl -// -/** Modalias implementation. */ -struct Modalias::Impl -{ - struct modalias_list *_modaliases; - - /** Ctor. */ - Impl() - : _modaliases(0) + /////////////////////////////////////////////////////////////////// + // + // CLASS NAME : Modalias::Impl + // + /** Modalias implementation. */ + struct Modalias::Impl { - const char *dir; - char path[PATH_MAX]; - - dir = getenv("ZYPP_MODALIAS_SYSFS"); - if (!dir) - dir = "/sys"; + /** Ctor. */ + Impl() + { + const char * dir = getenv("ZYPP_MODALIAS_SYSFS"); + if ( !dir ) + dir = "/sys"; DBG << "Using /sys directory : " << dir << endl; - snprintf(path, sizeof(path), "%s", dir); - foreach_file_recursive( path, read_modalias, &_modaliases ); + foreach_file_recursive( dir, _modaliases ); + } - } - - /** Dtor. */ - ~Impl() - { - while (_modaliases != NULL) { - struct modalias_list *l = _modaliases; - _modaliases = _modaliases->next; - free(l->modalias); - free(l); + /** Dtor. */ + ~Impl() + {} + + /* + * Check if a device on the system matches a modalias PATTERN. + * + * Returns NULL if no matching device is found, and the modalias + * of the first matching device otherwise. (More than one device + * may match a given pattern.) + * + * On a system that has the following device, + * + * pci:v00008086d0000265Asv00008086sd00004556bc0Csc03i00 + * + * modalias_matches("pci:v00008086d0000265Asv*sd*bc*sc*i*") will + * return a non-NULL value. + */ + bool query( const char * cap_r ) const + { + if ( cap_r && *cap_r ) + { + for_( it, _modaliases.begin(), _modaliases.end() ) + { + if ( fnmatch( cap_r, (*it).c_str(), 0 ) == 0 ) + return true; + } } - } + return false; + } - /* - * Check if a device on the system matches a modalias PATTERN. - * - * Returns NULL if no matching device is found, and the modalias - * of the first matching device otherwise. (More than one device - * may match a given pattern.) - * - * On a system that has the following device, - * - * pci:v00008086d0000265Asv00008086sd00004556bc0Csc03i00 - * - * modalias_matches("pci:v00008086d0000265Asv*sd*bc*sc*i*") will - * return a non-NULL value. - */ - bool query( const char * cap_r ) const - { - if ( cap_r ) - { - struct modalias_list *l; - for (l = _modaliases; l; l = l->next) { - if ( fnmatch( cap_r, l->modalias, 0 ) == 0 ) - return true; - } - } - return false; - } + public: + ModaliasList _modaliases; - public: - /** Offer default Impl. */ - static shared_ptr<Impl> nullimpl() - { + public: + /** Offer default Impl. */ + static shared_ptr<Impl> nullimpl() + { static shared_ptr<Impl> _nullimpl( new Impl ); return _nullimpl; - } - -}; // struct Modalias::Impl + } -/////////////////////////////////////////////////////////////////// + }; + /////////////////////////////////////////////////////////////////// -/** \relates Modalias::Impl Stream output + /** \relates Modalias::Impl Stream output * And maybe std::ostream & operator<< Modalias::Impl below too. * return libhal version or something like that. - */ -inline std::ostream & operator<<( std::ostream & str, const Modalias::Impl & obj ) -{ - return str << "Modalias::Impl"; -} + */ + inline std::ostream & operator<<( std::ostream & str, const Modalias::Impl & obj ) + { + return dumpRange( str << "Modaliases: (" << obj._modaliases.size() << ") ", obj._modaliases.begin(), obj._modaliases.end() ); + } -/////////////////////////////////////////////////////////////////// -// -// CLASS NAME : Modalias -// -/////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////// + // + // CLASS NAME : Modalias + // + /////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////// -// -// METHOD NAME : Modalias::Modalias -// METHOD TYPE : Ctor -// -Modalias::Modalias() -: _pimpl( Impl::nullimpl() ) -{} + Modalias::Modalias() + : _pimpl( Impl::nullimpl() ) + {} -/////////////////////////////////////////////////////////////////// -// -// METHOD NAME : Modalias::~Modalias -// METHOD TYPE : Dtor -// -Modalias::~Modalias() -{} + Modalias::~Modalias() + {} -/////////////////////////////////////////////////////////////////// -// -// METHOD NAME : Modalias::instance -// METHOD TYPE : Modalias & -// -Modalias & Modalias::instance() -{ - static Modalias _singleton; - return _singleton; -} + Modalias & Modalias::instance() + { + static Modalias _singleton; + return _singleton; + } -/////////////////////////////////////////////////////////////////// -// Foreward to implenemtation -/////////////////////////////////////////////////////////////////// + bool Modalias::query( const char * cap_r ) const + { return _pimpl->query( cap_r ); } -bool Modalias::query( const char * cap_r ) const -{ return _pimpl->query( cap_r ); } + const Modalias::ModaliasList & Modalias::modaliasList() const + { return _pimpl->_modaliases; } -/****************************************************************** -** -** FUNCTION NAME : operator<< -** FUNCTION TYPE : std::ostream & -*/ -std::ostream & operator<<( std::ostream & str, const Modalias & obj ) -{ - return str << *obj._pimpl; -} + std::ostream & operator<<( std::ostream & str, const Modalias & obj ) + { return str << *obj._pimpl; } - ///////////////////////////////////////////////////////////////// } // namespace target /////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////// } // namespace zypp /////////////////////////////////////////////////////////////////// diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzypp-13.2.0/zypp/target/modalias/Modalias.h new/libzypp-13.3.0/zypp/target/modalias/Modalias.h --- old/libzypp-13.2.0/zypp/target/modalias/Modalias.h 2013-03-20 09:29:30.000000000 +0100 +++ new/libzypp-13.3.0/zypp/target/modalias/Modalias.h 2013-06-11 10:22:16.000000000 +0200 @@ -13,6 +13,7 @@ #define ZYPP_TARGET_MODALIAS_MODALIAS_H #include <iosfwd> +#include <vector> #include <string> #include "zypp/base/PtrTypes.h" @@ -40,6 +41,8 @@ class Impl; public: + typedef std::vector<std::string> ModaliasList; + /** Singleton access. */ static Modalias & instance(); @@ -71,6 +74,9 @@ bool query( const std::string & cap_r ) const { return query( cap_r.c_str() ); } + /** List of modaliases found on system */ + const ModaliasList & modaliasList() const; + private: /** Singleton ctor. */ Modalias(); -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
