Commit Graph

189 Commits

Author SHA1 Message Date
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