Commit Graph

180 Commits

Author SHA1 Message Date
Lucas De Marchi
54ba8b3416 kmod: Add documentation and format comments 2011-12-11 20:55:09 -02:00
Gustavo Sverzut Barbieri
7fe602b689 update TODO 2011-12-10 13:32:27 -02:00
Gustavo Sverzut Barbieri
27fdf63153 index: fix memleak for non-matchin aliases. 2011-12-10 13:28:18 -02:00
Gustavo Sverzut Barbieri
d091546448 index-mm: allocate values inline into node, strings points to mmap.
For mmap mode, we can avoid allocating and copying strings from the
mmap'ed memory.

With that we have fixed length "struct index_mm_value" that can be
allocated inline with "struct index_mm_node".
2011-12-10 13:04:43 -02:00
Gustavo Sverzut Barbieri
148226ed92 index: cleanup header, move as much as possible to libkmod-index.c 2011-12-10 11:53:51 -02:00
Gustavo Sverzut Barbieri
15c1c143f2 index-mm: no need to allocate prefix. 2011-12-10 11:44:31 -02:00
Gustavo Sverzut Barbieri
fc2d835df5 index-mm: fix memory access.
uint32_t reads must be aligned, they're not then use memcpy().

read_alloc_chars_mm() and read_chars_mm() were wrong, normalize all
address calculation using single byte pointer "addr" that is
incremented by the amount read, this will avoid further errors.
2011-12-10 11:36:35 -02:00
Gustavo Sverzut Barbieri
fe514b1ed0 test-lookup: allow loading resources for testing. 2011-12-10 10:28:11 -02:00
Gustavo Sverzut Barbieri
79d57fcb29 kmod_load_resources: use proper full path to binary files to be mmaped. 2011-12-10 10:27:27 -02:00
Gustavo Sverzut Barbieri
3e245be100 kmod_lookup_alias_from_alias_bin: debug message for mmap case. 2011-12-10 09:28:42 -02:00
Gustavo Sverzut Barbieri
85132101e4 kmod_search_moddep: reorder to avoid creating path when not required.
if we're using mmap'ed index, say so and avoid creating the path as it
won't be used.
2011-12-10 09:26:27 -02:00
Gustavo Sverzut Barbieri
3b2099595b fix snprintf usage.
snprintf() takes the full buffer size, including \0 and guarantees it
will be there.
2011-12-10 09:21:03 -02:00
Lucas De Marchi
65a84f5591 Use alias/symbol index_mm if it's open 2011-12-09 16:11:42 -02:00
Lucas De Marchi
810803dbe8 Pass enum around instead of filename
This will allow us to later use the index to search these indexes.
2011-12-09 16:07:33 -02:00
Lucas De Marchi
d65d71ceff Use index_mm if it's open for moddep search 2011-12-09 15:55:30 -02:00
Lucas De Marchi
4272d08780 Do not allocate path for known places an close resource asap
This place is not supposed to exceed PATH_MAX. So, use snprintf instead
of asprintf.

Close the index before iterating the values.
2011-12-09 15:45:55 -02:00
Lucas De Marchi
33bb69b943 Load and unload resources
This call will mmap all the index files and in future some of the work
done in ctx creation can be put here.
2011-12-08 19:51:06 -02:00
Lucas De Marchi
5109f2b422 index: mm: Add flag to open call to populate buffer 2011-12-08 19:51:06 -02:00
Lucas De Marchi
a4a750297d Refactor index file handling
Put all names in a static vector and declare a enum containing the
number of indexes. This way it's easier to create vectors inside ctx
that depend on these files.
2011-12-08 19:51:06 -02:00
Gustavo Sverzut Barbieri
558b020704 remove useless look checking for duplicates 2011-12-08 16:36:48 -02:00
Gustavo Sverzut Barbieri
1433ba9ef5 index: avoid strlen() whenever possible. 2011-12-08 16:35:36 -02:00
Gustavo Sverzut Barbieri
435ad788e2 reduce calls to realloc() if size did not change. 2011-12-08 16:35:36 -02:00
Gustavo Sverzut Barbieri
405f614af9 index: improve buffer management and reduce mallocs.
Grow buffer based on a step, avoiding hitting the system over and over
again.

Do not allocate the 'struct buffer' as in all cases the lifetime is
known and the pattern was allocate then free in every call site.
2011-12-08 14:38:22 -02:00
Gustavo Sverzut Barbieri
e18ad35c64 fix path handling at dependencies parsing.
paths come relative to dirname, make them absolute to avoid confusion
later.
2011-12-08 14:12:39 -02:00
Gustavo Sverzut Barbieri
e5c60f1c28 NULL safety in public places, allows disable logging. 2011-12-08 14:07:13 -02:00
Gustavo Sverzut Barbieri
1bdd951ee2 log: give log function its data instead of kmod_ctx.
This will be the most common use case for logging, also changed
log_stderr() to log_filep() with data being stderr to test it.
2011-12-08 14:06:50 -02:00
Gustavo Sverzut Barbieri
e1a6b30dc4 modname_normalize: fix const and buffer overflow.
"buf[NAME_MAX] = value" is invalid since it would access the byte
right after the array.

Also fix the const of modname, do not mess with it to avoid mistakes.
2011-12-08 13:33:25 -02:00
Lucas De Marchi
8fc83fe1de kmod_loaded: document exported function 2011-12-08 12:59:16 -02:00
Lucas De Marchi
7e1b3ae2b9 kmod_list: document exported functions 2011-12-08 12:25:36 -02:00
Gustavo Sverzut Barbieri
f1fb6f8525 kmod_module: Remove const from path
It's an ugly hack. This is an internal variable, we know we shouldn't
change it everywhere.
2011-12-08 11:37:03 -02:00
Gustavo Sverzut Barbieri
1487a64ffa add kmod_module_get_filtered_blacklist()
This function will filter the given list against the known blacklist,
returning a new list with remaining modules with the reference
incremented.
2011-12-08 11:17:16 -02:00
Lucas De Marchi
e005facdb9 Only search path in moddep if it's not already set
rmmod/insmod should be able to operate directly on files, not relying on
indexes and configuration.

The following test was not working and now it is:

$ # go to a dir != mod->dirname
$ cd /lib/modules/$(uname -r)/kernel
$ # try to insert module giving a relative path
$ insmod drivers/acpi/ac.ko
2011-12-08 11:15:24 -02:00
Lucas De Marchi
4eb2c0fca1 Fix abs path helper function 2011-12-08 11:15:24 -02:00
Lucas De Marchi
ac9f8761fe test-insmod: show the path libkmod is using 2011-12-08 11:15:24 -02:00
Gustavo Sverzut Barbieri
97a3ea9e9d test-insmod: print name to test modname_normalize(). 2011-12-08 11:15:24 -02:00
Lucas De Marchi
6bd0b8d01d kmod_module: treat module creation by path with same names
If a module with the same name already exists, try to reference it if
paths are the same. Otherwise fail.
2011-12-07 14:15:49 -02:00
Lucas De Marchi
71e975cd4d kmod_module: store absolute path when creating module from path 2011-12-07 13:53:53 -02:00
Lucas De Marchi
06363cc126 Add helper path_make_absolute_cwd() 2011-12-07 13:51:40 -02:00
Lucas De Marchi
3a468809b8 Add helper path_is_absolute() 2011-12-07 13:50:52 -02:00
Lucas De Marchi
a5cce6d6ef kmod_config: parse install and remove commands 2011-12-07 11:31:28 -02:00
Lucas De Marchi
615c42be5c kmod_config: parse module options 2011-12-07 10:59:44 -02:00
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