Commit Graph

139 Commits

Author SHA1 Message Date
Lucas De Marchi afca78015b Add helper strchr_replace() 2011-12-07 10:59:44 -02:00
Lucas De Marchi 877e80cd93 Use streq() when possible 2011-12-07 02:32:28 -02:00
Lucas De Marchi 6c343b1aee Split function so we don't call basename() unnecessarily 2011-12-06 09:02:13 -02:00
Lucas De Marchi fab4978ac1 test: add test for modules' hash 2011-12-06 03:49:30 -02:00
Lucas De Marchi fd186ae996 Maintain a pool of modules alive
Based on previous implementation by
	Gustavo Sverzut Barbieri <barbieri@profusion.mobi>
2011-12-06 03:49:07 -02:00
Lucas De Marchi b7b7ac298f kmod_config: optimize config files handling
1) Allocate less by not sorting the result with qsort. Instead,
    insert the nodes in the correct order;
 2) Do not maintain the whole path in memory, but rely on openat()
2011-12-06 03:34:51 -02:00
Lucas De Marchi e16e27f4a4 kmod_list: remove nodes in order 2011-12-06 03:34:51 -02:00
Lucas De Marchi 1965029cb0 kmod_list: add helper function to merge two lists
This helper function will append the second list in the first one, so
they become one single list.
2011-12-06 03:34:51 -02:00
Lucas De Marchi b91a1c6d3d kmod_list: add helper kmod_list_insert_before() 2011-12-06 03:34:51 -02:00
Lucas De Marchi 86e8788572 kmod_list: add helper kmod_list_insert_after() 2011-12-06 03:34:51 -02:00
Lucas De Marchi 1843b153b4 test: add test to get dependencies of a module 2011-12-06 03:34:51 -02:00
Lucas De Marchi c5b5ea9c7c test: add test to convert name to path
If we create a kmod_module from a name, the path returned is relative to
the module dirname, as passed during kmod_ctx creation. Note that if
kmod_ctx is created with kmod_new(NULL), the dir used is the one
returned by uname.
2011-12-06 03:34:51 -02:00
Lucas De Marchi 4f2bb7cdd4 kmod_module: normalize module name 2011-12-06 03:34:51 -02:00
Lucas De Marchi c5e7b1f7ef kmod_module: get path on demand 2011-12-06 02:48:04 -02:00
Lucas De Marchi 671d489424 kmod_module: parse dependencies on demand 2011-12-06 02:48:04 -02:00
Lucas De Marchi 1eb2ef694c Split function to search moddep file 2011-12-06 02:48:04 -02:00
Lucas De Marchi f1cd799fb0 kmod_module: return a new list and increase ref of dependencies
kmod_module_get_dependency is renamed to kmod_module_get_dependencies
since it's returning a list. To match other APIs, now it returns a new
list that user must free with kmod_module_unref_list().
2011-12-06 02:48:03 -02:00
Lucas De Marchi d2d648dfaf Fix missing parenthesis in macro 2011-12-06 02:48:03 -02:00
Gustavo Sverzut Barbieri 7db08652cd Add simple hash implementation 2011-12-05 19:24:06 -02:00
Lucas De Marchi d753b8ca35 kmod_module: inline name and make it always available 2011-12-05 18:14:51 -02:00
Gustavo Sverzut Barbieri 43c29d10ff kmod_alias: reduce from 3 mallocs to a single one. 2011-12-05 13:42:13 -02:00
Lucas De Marchi 40923bdb64 Use readdir_r in kmod_module_get_sections()
readdir() is not thread-safe. Use readdir_r instead.
2011-12-05 13:41:10 -02:00
Lucas De Marchi 53886ddd87 Use readdir_r in kmod_module_get_holders()
readdir() is not thread-safe. Use readdir_r instead.
2011-12-05 13:29:46 -02:00
Lucas De Marchi 49b741d0b0 Add padding to enum to make sure it's an int 2011-12-05 11:42:12 -02:00
Lucas De Marchi cf91579b8d Inline foreach macro for internal usage
Avoid calling _next() function because it's an exported function and
linker can not optimize it.

Thanks to "Gustavo Sverzut Barbieri <barbieri@profusion.mobi>" for
suggestion.
2011-12-05 11:33:15 -02:00
Gustavo Sverzut Barbieri 8226058343 tests: release memory before error exits.
this makes it easier to valgrind the error cases as well.
2011-12-05 01:45:21 -02:00
Gustavo Sverzut Barbieri 69f9dd4369 no more kmod_loaded and kmod_loaded_module.
kmod_loaded_get_list() now returns a regular list of kmod_modules, use
kmod_module_get_module(), kmod_module_unref() and
kmod_module_unref_list() to operate on it.
2011-12-04 17:24:08 -02:00
Gustavo Sverzut Barbieri f12ae3c438 kmod_module: extended information gathering.
provide means to get:
 * refcount
 * initstate
 * holders
 * sections

this can be used to individually query properties from modules,
similar to /proc/modules (kmod_loaded / kmod_loaded_module).
2011-12-04 17:24:08 -02:00
Gustavo Sverzut Barbieri ad4d1ae565 kmod_module_get_module: safety against NULL pointers 2011-12-04 17:24:08 -02:00
Gustavo Sverzut Barbieri 87ca03bd07 module refcount should start at 1.
the current way was having the referenced modules to be released given
the unref comparison checking for "> 0".
2011-12-04 17:24:08 -02:00
Gustavo Sverzut Barbieri 32c328d28e fix missing ")". 2011-12-04 15:34:43 -02:00
Lucas De Marchi 478af97f1c TODO: update file 2011-12-03 20:51:01 -02:00
Lucas De Marchi 94fe3dfbb9 License library as LGPL
The only part under GPL was the index, that is now re-licensed. Switch
back to LGPL.
2011-12-03 04:30:41 -02:00
Lucas De Marchi 8f923be69a index: change license to LGPL
I've got an explicit permit from index author to re-license it as LGPL.
2011-12-03 04:30:16 -02:00
Lucas De Marchi 5a7ade7191 index: update copyrignt
mmap implementation
2011-12-03 04:07:16 -02:00
Lucas De Marchi bf89f70ca3 index: mmap: add support for seaching with wildcards
Almost a clean copy & paste from the previous implementation.
2011-12-03 04:07:16 -02:00
Lucas De Marchi b797b79183 index: mmap: add support for searching
Almost a clean copy & paste from the previous implementation.
2011-12-03 04:07:16 -02:00
Lucas De Marchi e33bb87cae index: mmap: add support for searching node
Almost a clean copy & paste from the previous implementation.
2011-12-03 04:07:16 -02:00
Lucas De Marchi 91298dc79e index: mmap: read child node 2011-12-03 04:07:15 -02:00
Lucas De Marchi 77bf936a89 index: mmap: read root node 2011-12-03 04:07:15 -02:00
Lucas De Marchi 836be9ac5f index: mmap: create and destroy node 2011-12-03 04:07:15 -02:00
Lucas De Marchi e22c85f357 Add memdup() helper 2011-12-03 04:07:15 -02:00
Lucas De Marchi b471a6b494 index: mmap: open and close file 2011-12-03 04:06:16 -02:00
Lucas De Marchi 4a4876d6a7 index: use idx instead of index due to name clash 2011-12-03 04:06:16 -02:00
Lucas De Marchi 2295acc5da Fix some coding style issues 2011-12-03 04:05:22 -02:00
Gustavo Sverzut Barbieri d13e606ff6 improve kmod_config api.
make the function names reflect the structure they are operating on.

the structure is now allocated and remembers the context it was
created, then no need to give the context in every function call.
2011-12-03 03:56:57 -02:00
Gustavo Sverzut Barbieri 8d3f3ef815 reorder struct fields to avoid holes, improving packing 2011-12-03 03:56:02 -02:00
Gustavo Sverzut Barbieri 91b44c77ae README with purpose and initial overview. 2011-12-03 03:55:35 -02:00
Lucas De Marchi ad5555b272 Fix extra attribute
linenum can be NULL in case we are not interested in the number of lines
parsed.
2011-12-03 03:53:10 -02:00
Gustavo Sverzut Barbieri 12d9419d08 improve compiler warnings and checks for internal functions. 2011-12-03 03:52:35 -02:00