Commit Graph

599 Commits

Author SHA1 Message Date
Lucas De Marchi 91428ae1b8 Fix docs with wrong function names 2011-12-15 13:09:46 -02:00
Lucas De Marchi 5f3429cdad Add comment in public header about flags not implemented 2011-12-15 12:27:45 -02:00
Lucas De Marchi 128386a406 Rename symbol group 2011-12-15 12:26:15 -02:00
Lucas De Marchi 3e71947c1e Remove flags that likely will not be used 2011-12-15 12:18:00 -02:00
Lucas De Marchi 23c0d01279 Fix format of log message 2011-12-14 17:21:46 -02:00
Lucas De Marchi 1684e4402c kmod_config: parse kernel command line for options and blacklist 2011-12-14 17:19:19 -02:00
Lucas De Marchi 113c66a562 kmod_module: use 'modname/aliasname' as key for hash
1 alias may correspond to more than 1 module. This would cause a
conflict in the hash table when inserting a module there and bad things
could happen.

Now we use 'modname/aliasname' as key, '/aliasname' part being optional.
Internally kmod_module_new_from_alias() will setup a 'modname/aliasname'
string and pass to kmod_module_new_from_name() that will treat the case
with a '/' in the name.

User might call kmod_module_new_from_name() without any slashes, so the
key my not contain it.
2011-12-14 15:26:04 -02:00
Lucas De Marchi 788ef0f7e6 Use malloc + memset instead of calloc 2011-12-14 15:05:03 -02:00
Lucas De Marchi 2d7bab5c7d kmod_module: move function to the right section 2011-12-14 12:10:30 -02:00
Lucas De Marchi 63af0615d5 kmod_module: fix log message upon module removal 2011-12-14 12:10:30 -02:00
Lucas De Marchi 7afc98a1f6 kmod_module: add missing documentation 2011-12-14 12:10:30 -02:00
Lucas De Marchi 6de8f6e966 Simplify kmod_load_resources()
We have a static vector of indexes. There's no need to check if they
have a suffix or if they are absolute, we just already know in advance
and there are no plans to change it.
2011-12-14 10:53:10 -02:00
Lucas De Marchi 3e67676617 Log and break early if index is already open 2011-12-14 10:53:10 -02:00
Lucas De Marchi be5a6deaea Update documentation 2011-12-14 10:53:10 -02:00
Lucas De Marchi 25c0543ff6 Remove function kmod_resolve_alias_options()
Remove function kmod_resolve_alias_options since it's not needed
anymore. Test is using the following configuration file:

alias blablabla ac
options ac test=1
options blablabla test=2

Lookup test by module name:
	$ ./test/test-lookup ac
	libkmod version 1
	Alias: 'ac'
	Modules matching:
		ac
			options: 'test=1'

Lookup test by alias:
	$ ./test/test-lookup blablabla
	libkmod version 1
	Alias: 'blablabla'
	Modules matching:
		ac
			options: 'test=1 test=2'
2011-12-13 14:28:16 -02:00
Lucas De Marchi 07b8c823ed kmod_module: make get_options() search for alias names too 2011-12-13 14:21:24 -02:00
Lucas De Marchi ee3b3ff292 Create module by alias name where appropriate 2011-12-13 14:20:48 -02:00
Lucas De Marchi 6ad5f26362 Add private function kmod_module_new_from_alias()
This function will create a new kmod_module() by calling
kmod_module_new_from_name(), but instead of given the module name, it
gives the alias. This way, the modules' hash will contain the alias
instead of the name. If module was created successfully, then it swap
the alias with the actual name.

The downside is that the structure is not shared anymore if we create a
kmod_module by alias and after by name. However, in modprobe's
configuration it's possible to have different options for different
aliases. In future we might want to create a way to share the common
part of the structure (then having only one instance as we had before).
2011-12-13 14:12:50 -02:00
Lucas De Marchi 219f9c38bb kmod_module: use pointer instead of vector for its name
We still have name allocated just after the struct kmod_module, but
now we use a pointer instead of putting name as a vector in the end of
the structure.

The previous way has some problems, the worst is:
	- it's not possible to swap the name with another value: this is
	  the real problem that this patch is solving. Later patches
	  will make name be swappable with alias, which is not possible
	  if name is a vector.
2011-12-13 13:15:49 -02:00
Lucas De Marchi ecd6bcd204 Return early on lookup error
There's no reason to keep looking for options if alias didn't match.
2011-12-13 10:52:00 -02:00
Lucas De Marchi d470db10a3 Use alias_normalize() instead of modname_normalize()
When normalizing alias names (or if we don't know if it's an alias or
modname), use alias_normalize() instead of modname_normalize(). The
difference is that alias names can contain dashes withing brackets, and
those should not be changed to underscores.

Most of the places using underscores() function might be converted to
alias_normalize(), but this is not done now.
2011-12-13 10:41:18 -02:00
Lucas De Marchi b148b8606a Add helper alias_normalize() 2011-12-13 10:41:18 -02:00
Lucas De Marchi 4308b176e9 Fix check for NULL variable 2011-12-13 10:41:18 -02:00
Lucas De Marchi 7d51d8bfe2 Fix "Dereference of null pointer" as reported by llvm 2011-12-12 18:43:04 -02:00
Lucas De Marchi 1c250ec150 Fix "Dead assignments" as reported by llvm 2011-12-12 18:36:27 -02:00
Gustavo Sverzut Barbieri 973c80ba7c handle case where modname was not detected. 2011-12-12 18:28:52 -02:00
Lucas De Marchi cb451f35d9 Change licenses
libkmod is under LGPL 2.1 or later
tools/* are under GPL
2011-12-12 18:24:35 -02:00
Lucas De Marchi 45f2778174 Remove warnings: ‘err’ may be used uninitialized in this function 2011-12-12 17:23:04 -02:00
Lucas De Marchi cb48c9b2e6 Rename project from libkmod to kmod 2011-12-12 16:54:18 -02:00
Lucas De Marchi 8f767e2dfa Use true/false for bool return 2011-12-12 15:27:57 -02:00
Lucas De Marchi 98c80f44c9 Directories inside config directories are not supported
This was failing silent, both in libkmod and module-init-tools. Give a
warning if we created a dir inside config directories.
2011-12-12 15:26:59 -02:00
Lucas De Marchi 4782396cc4 Do not stat() dir twice 2011-12-12 15:00:51 -02:00
Lucas De Marchi 016d619cd9 Fix leak of DIR 2011-12-12 14:39:35 -02:00
Lucas De Marchi 970ba8be9d Remove leftover comment
mod->path is always absolute: remove comment from previous behavior.
2011-12-12 14:01:39 -02:00
Lucas De Marchi 49ce6d0741 Remove libkmod-loaded.c and re-order functions in libkmod-module.c
It's not possible to move functions related to "live" modules to
libkmod-loaded.c because they depend on the definition of kmod_module.
Putting this structure in the private header is not a good idea, so let
all functions related to "live" information in the end of
libkmod-module.c, and move the sole function from libkmod-loaded.c to
this place. This way all functions get the right documentation
about their sections.
2011-12-12 13:56:47 -02:00
Lucas De Marchi a102e262e6 Rename kmod_loaded_get_list() to kmod_module_new_from_loaded()
Be consistent with other similar functions already present and improve
documentation.
2011-12-12 13:50:19 -02:00
Lucas De Marchi 28c175edd1 coding style: be consistent with blank lines 2011-12-12 11:52:59 -02:00
Lucas De Marchi c35347f15c coding style: fix lines over 80 chars
Lines should not go over 80 chars with a few exceptions:
	- headers
	- function definitions with only 1 argument
	- long strings, otherwise we break grep

This should go later in a coding-style file
2011-12-12 10:54:19 -02:00
Gustavo Sverzut Barbieri cb8d4d3e99 API-BREAK: kmod_new() takes a second parameter for configuration directory.
This is required by modprobe and also to help doing unit tests in future.
2011-12-11 20:58:22 -02:00
Gustavo Sverzut Barbieri d01c67e383 add missing newline to log messages. 2011-12-11 20:58:22 -02:00
Gustavo Sverzut Barbieri 926f67a6d6 be less verbose on initstate for unexistent modules.
the module may be unloaded, in this case -NOENT is returned but it
should not present an error message
2011-12-11 20:58:22 -02:00
Gustavo Sverzut Barbieri 3a721bbcf0 insmod: allows providing option to module. 2011-12-11 20:58:22 -02:00
Gustavo Sverzut Barbieri d917f2743e always normalize user-given alias. 2011-12-11 20:58:22 -02:00
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
Gustavo Sverzut Barbieri b6a534f72c parse_depline may be called from libkmod.c
allow parse_depline to be called when already initialized as it may be
called from libkmod.c and at that point there is no way to check
mod->init.dep
2011-12-11 20:58:21 -02:00
Gustavo Sverzut Barbieri bf8cf1483f fix string replace.
configure files with this would fail:

options wl x=1

were being handled as " =1".
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 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 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 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 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 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 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 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
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
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 ca491ca99c Drop configurations from /usr/local 2011-12-02 15:02:50 -02:00
Lucas De Marchi e71970ae44 index: follow libkmod coding style 2011-12-02 10:29:36 -02:00
Lucas De Marchi eb8bb32e42 Remove redundant comments 2011-12-02 10:25:17 -02:00
Lucas De Marchi 85078e6eef index: remove unused functions 2011-12-02 10:21:42 -02:00
Lucas De Marchi 1d152accf3 index: re-order functions so prototypes are not needed 2011-12-02 10:15:00 -02:00
Lucas De Marchi 3a61c84faa Remove trailing whitespace 2011-12-02 10:08:52 -02:00
Lucas De Marchi 963ca5586e Fix 'redundant redeclaration' warnings 2011-12-02 10:07:25 -02:00
Lucas De Marchi 93688880db Fix 'old style declaration' warnings 2011-12-02 10:05:31 -02:00
Lucas De Marchi 84f4220440 Fix missing return 2011-12-02 10:03:34 -02:00
Lucas De Marchi 6f1bc6e36e Clean 'unused variable' warnings 2011-12-02 10:02:05 -02:00
Lucas De Marchi 1fc1c9a06f Clean 'shadowed declaration' warnings 2011-12-02 10:00:03 -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 b418a82097 Use fstat() instead of stat() when possible 2011-12-01 23:13:27 -02:00
Lucas De Marchi 0835fc3bf9 Add fucntion to API to get dependencies 2011-12-01 20:06:08 -02:00
Lucas De Marchi c11e62bfd4 Use strtok_r insteat of strtok
strtok is not thread-safe because it uses a static pointer to keep track
of position in the string. Using strtok_r solves the problem.
2011-12-01 18:59:54 -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 7636e72b15 Add dependency list to kmod_module
Dependency list is created from line as defined in modules.dep.
2011-12-01 17:56:03 -02:00
Lucas De Marchi e915f92ad3 Add missing newlines 2011-12-01 17:47:49 -02:00
Lucas De Marchi 9eaad1f63a Allow path_to_modname to operate locally withou alloc 2011-12-01 17:19:24 -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 62be799554 Add kmod_list_remove_n_latest() 2011-12-01 15:34:12 -02:00
Lucas De Marchi 79d77111dc Add kmod_list_prev to exported functions 2011-12-01 14:47:44 -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 839d7dadf6 Remove dangling comment 2011-11-30 20:30:39 -02:00
Lucas De Marchi b14dcfdab3 Prepare lookup function for more files to look after 2011-11-30 20:29:51 -02:00
Lucas De Marchi 904c63aa96 Fix initialization of kernel modules dir 2011-11-30 20:27:50 -02:00
Lucas De Marchi 7e317da3c9 Add startswith() helper function 2011-11-30 19:20:19 -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 6e869df73d Add name() and path() getters for kmod_module 2011-11-30 19:01:01 -02:00
Lucas De Marchi 60aa4d8b48 Organize functions in private header 2011-11-30 18:57:38 -02:00
Lucas De Marchi b0ef19f7f5 Add getters for aliases 2011-11-30 18:18:13 -02:00
Lucas De Marchi 2043369e7e Fix misspellings by use of codespell 2011-11-30 16:02:08 -02:00
Lucas De Marchi a7be73b917 Remove trailing whitespaces 2011-11-30 15:59:47 -02:00
Lucas De Marchi e8847fd2fc Import index handling from module-init-tools
This effectively makes the combined work be GPL. All other parts of this
library are still LGPL and if this part in future becomes
double-licensed, we can switch back to LGPL.
2011-11-30 15:23:49 -02:00
Lucas De Marchi 44a5460fea Add streq() to prettify code
It's needed for importing index handling from module-init-tools, and may
be useful for the project, too.
2011-11-30 14:36:46 -02:00
Lucas De Marchi a507d803b4 Define temporary macros for importing index 2011-11-30 14:35:39 -02:00
Lucas De Marchi 30be7513c0 Use underscores() in module names and aliases 2011-11-30 02:14:57 -02:00
Lucas De Marchi 8185fc91e2 Add underscores() helper to replace - with _ 2011-11-30 02:14:33 -02:00
Lucas De Marchi 81cf2060e0 Parse blacklists in config files 2011-11-29 18:48:02 -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 4462c4ac60 Add getline_wrapped() to parse config files
Basically copied from module-init-tools
2011-11-29 18:05:43 -02:00
Lucas De Marchi aa1c3521de Add macro to safely derive the size of an array 2011-11-29 17:59:58 -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 2bd6299d2b Move down the ifdef for c++ 2011-11-28 12:03:17 -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 8f788d58c3 Add functions to operate on modules 2011-11-25 01:22:56 -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 423f856ad9 Format enum 2011-11-24 23:09:40 -02:00
Lucas De Marchi 4d1e689ada Format refcount handling 2011-11-24 23:09:39 -02:00
Lucas De Marchi 853b5fc52e Ref and unref ctx when kmod_loaded is created/destroyed 2011-11-24 23:09:39 -02:00
Lucas De Marchi cf9aadeb25 Fix refcount of loaded modules 2011-11-24 15:41:15 -02:00
Lucas De Marchi 6fc20bbfee Keep valgrind happy when mixing sscanf and strtok
When mixing sscanf() and strtok() Valgrind complaints like below:

==1641== Conditional jump or move depends on uninitialised value(s)

Use stroull() instead of sscanf().
2011-11-23 17:52:48 -02:00
Lucas De Marchi 6806a0437f Implement function to remove module 2011-11-23 17:14:22 -02:00
Lucas De Marchi 6ad9830731 Rename leftover libabc reference 2011-11-23 16:08:04 -02:00
Lucas De Marchi 88e9c12e4e Rename libkmod-util.h to macro.h 2011-11-23 16:08:04 -02:00
Lucas De Marchi f87081b4d1 Add some function attributes and use them 2011-11-23 16:08:04 -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 5369797d09 Add libkmod-loaded to handle live modules information
All the functions needed by a lsmod binary are in place.
test/test-loaded.c implements it with the same output of lsmod.
2011-11-23 11:44:17 -02:00
Lucas De Marchi 6924e47a8d Implement circular double-linked list 2011-11-23 05:15:21 -02:00
Lucas De Marchi 68b0d8e507 Don't use glob in version script 2011-11-22 05:37:21 -02:00
Lucas De Marchi c83a45ea87 Fix version to 0:0:0
Version is only incremented upon release
2011-11-22 05:36:50 -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