Jakub Jelinek schrieb:
With a prepared binary blob which would include a hash table for easy finding of dependencies for a module we could just open that, and only once. If the binary blob starts with a magic number and then has st_ino/st_dev/st_ctime of both modules.dep and modules.aliases in the same dir, then you can easily keep the text files for handediting purposes and only use the binary blob if the text files haven't changed since the binary blob was recreated, and let the depmod or whatever creates the binary files also create the binary blob and have a mode in which it creates the blob from the text files rather than from whatever it found on disk. modules.dep searches just for the basenames of modules without extension and dir component, and ignores differences between - and _. So, just create a hash function which handles - and _ the same and gives good results on the usual module names and stick a hash table (e.g. with chains) after the file header, then the chains would contain the actual module name's basename for module_equal comparison, full 32-bit hash and pointer to where the full strings are found in the string table (which should probably be compressed using a directory table). module.aliases is harder, because it contains wildcards, so hash table isn't useful, but some kind of tree, where each node would contain a length, sorted prefixes of that length plus leaf nodes that contain wildcards at that point already and thus need to be tested all by fnmatch. Searching would just in each node test all the wildcardish leaf nodes, if none matched binary search for what matches the prefix and recurse into that node. E.g. root node could have length of minimum of smallest alias name and smallest number of chars before first wildcard in any alias name (unless that is zero, otherwise the alias names starting with wildcard would go into the set needed to go through fnmatch at that level). Jakub
udev linked with libmodprobe.so, reading the config only once and having the above search tables in memory, would be the fastest solution.
Description: S/MIME Cryptographic Signature