21 #undef ZYPP_BASE_LOGGER_LOGGROUP
22 #define ZYPP_BASE_LOGGER_LOGGROUP "MODALIAS"
44 inline bool isBlackListed(
const Pathname & dir_r,
const char * file_r )
46 #define PATH_IS( D, F ) ( ::strcmp( file_r, F ) == 0 && ::strcmp( dir_r.c_str(), D ) == 0 )
50 return PATH_IS(
"/sys/devices/system",
"memory" );
57 void foreach_file_recursive(
const Pathname & dir_r, std::set<std::string> & arg_r )
59 AutoDispose<DIR *> dir( ::opendir( dir_r.c_str() ), ::closedir );
63 struct dirent * dirent = NULL;
64 while ( (dirent = ::
readdir(dir)) != NULL )
66 if ( dirent->d_name[0] ==
'.' )
69 if ( isBlackListed( dir_r, dirent->d_name ) )
73 unsigned char d_type = dirent->d_type;
74 if ( d_type == DT_UNKNOWN )
76 path = dir_r/dirent->d_name;
77 PathInfo pi( path, PathInfo::LSTAT );
80 else if ( pi.isFile() )
84 if ( d_type == DT_DIR )
87 path = dir_r/dirent->d_name;
88 foreach_file_recursive( path, arg_r );
90 else if ( d_type == DT_REG && ::strcmp( dirent->d_name,
"modalias" ) == 0 )
93 path = dir_r/dirent->d_name;
95 std::ifstream str( path.c_str() );
106 std::set<std::string> arg;
107 foreach_file_recursive( dir_r, arg );
108 arg_r.insert( arg_r.end(), arg.begin(), arg.end() );
123 const char * dir = getenv(
"ZYPP_MODALIAS_SYSFS");
132 DBG <<
"Using $ZYPP_MODALIAS_SYSFS modalias file: " << dir << endl;
134 [&](
int num_r, std::string line_r )->bool
141 DBG <<
"Using $ZYPP_MODALIAS_SYSFS: " << dir << endl;
146 DBG <<
"Using /sys directory." << endl;
170 bool query(
const char * cap_r )
const
172 if ( cap_r && *cap_r )
176 if ( fnmatch( cap_r, (*it).c_str(), 0 ) == 0 )
190 static shared_ptr<Impl> _nullimpl(
new Impl );
213 : _pimpl(
Impl::nullimpl() )
235 {
return str << *obj.
_pimpl; }