Gustavo Sverzut Barbieri
bd3f553526
export module's options and commands.
...
This will be required to implement modprobe later. The implementation
follows "man modprobe.conf" and allows options to be specified for
alias as well, thus the need for kmod_resolve_alias_options().
Example mod-a.conf:
options mod-a a=1 b=2
options mod-a c=3
alias mymod-a mod-a
options mymod-a d=4
Results in:
options mod-a a=1 b=2 c=3
options mymod-a a=1 b=2 c=3 d=4
Install commands are being concatenated with ";", but manpage is not
clean about this behavior.
2011-12-11 20:58:21 -02:00
Lucas De Marchi
54ba8b3416
kmod: Add documentation and format comments
2011-12-11 20:55:09 -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
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
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
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
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
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
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
1ce08a563e
improve "const" keyword usage.
...
functions that do not modify their parameters get them as const pointers.
special cases:
* kmod_get_userdata/kmod_set_userdata: return as void* for user convenience.
* kmod_list_append/kmod_list_prepend: take const void* for user convenience.
2011-12-03 03:51:55 -02:00
Lucas De Marchi
6f1bc6e36e
Clean 'unused variable' warnings
2011-12-02 10:02:05 -02:00
Lucas De Marchi
0fbdfef3f9
Clean 'shadowed declaration' warnings
...
index is a function in string.h, so replace index with idx all over the
source code.
2011-12-02 09:56:22 -02:00
Lucas De Marchi
a009482ccf
Clean 'no previous prototype' warning
2011-12-02 09:53:31 -02:00
Lucas De Marchi
4a3eb3a4cc
Add dependencies when module is create by name lookup
...
We already have the data needed to add the dependencies, so call
fucntion to transform it in a list and save in kmod_module structure.
2011-12-01 17:57:07 -02:00
Lucas De Marchi
e915f92ad3
Add missing newlines
2011-12-01 17:47:49 -02:00
Lucas De Marchi
49e61ca347
Lookup for alias in modules.alias.bin
2011-12-01 16:27:04 -02:00
Lucas De Marchi
7b30f4f4ff
Generalize function to be used by other lookups
2011-12-01 16:25:37 -02:00
Lucas De Marchi
64700e4747
Lookup modules from modules.dep.bin file
2011-12-01 15:58:12 -02:00
Lucas De Marchi
23fc91c642
Make lookup functions return number of elements found
2011-12-01 15:35:31 -02:00
Lucas De Marchi
9ba6f57b5b
Lookup modules.symbols.bin
...
Test in my system:
./test/test-lookup symbol:sas_slave_destroy
libkmod version 0.1
Alias: 'symbol:sas_slave_destroy'
Modules matching:
libsas
2011-11-30 20:32:53 -02:00
Lucas De Marchi
904c63aa96
Fix initialization of kernel modules dir
2011-11-30 20:27:50 -02:00
Lucas De Marchi
7f3eb0cced
Add lookup to create modules list from alias
...
We return a kmod_list when searching for an alias. Right now, it only
search for aliases in config files.
To use it, we create a list:
list = NULL;
kmod_module_new_from_lookup(..., &list);
And iterate over it to get the modules and their details:
kmod_list_foreach(l, list) {
struct kmod_mod *mod = kmod_module_get_module(l);
...
... kmod_module_get_name(mod);
... kmod_module_get_path(mod);
}
Aliases might contain globs and are match by using fnmatch().
2011-11-30 19:03:41 -02:00
Lucas De Marchi
7c2ab358fd
Add support for parsing config files
...
Right now only alias keyword is treated.
2011-11-29 18:07:43 -02:00
Lucas De Marchi
191ab4b9e0
Fix wrong copyright
...
I'm the author, not the copyright owner.
2011-11-28 16:59:06 -02:00
Lucas De Marchi
1b2e26a1e2
Back to logging without \n
...
It possibly breaks when not logging to stderr
2011-11-28 11:28:18 -02:00
Lucas De Marchi
9df4bda566
When logging to stderr, put a \n by default
2011-11-25 01:07:04 -02:00
Lucas De Marchi
ae6df84a3c
Make log function uppercase
...
The worst case is the err() macro. Usually err is used as a variable,
which clashes with this macro.
2011-11-25 01:05:30 -02:00
Lucas De Marchi
221631d511
Accept dir where we should lookup for modules
2011-11-24 23:20:42 -02:00
Lucas De Marchi
4d1e689ada
Format refcount handling
2011-11-24 23:09:39 -02:00
Lucas De Marchi
6d177553dc
Constify API
2011-11-23 12:28:23 -02:00
Lucas De Marchi
8b69b37629
Remove leftover declarations
2011-11-23 11:50:27 -02:00
Lucas De Marchi
9d77b96c7a
Remove unused functions
2011-11-21 15:15:54 -02:00
Lucas De Marchi
52a7704f67
Make kmod_new return a pointer
2011-11-21 15:15:54 -02:00
Lucas De Marchi
e4351b053f
Convert spaces to tabs
2011-11-21 15:15:54 -02:00
Lucas De Marchi
586fc304d8
Rename libabc to libkmod
2011-11-21 14:35:35 -02:00