Commit Graph

48 Commits

Author SHA1 Message Date
Lucas De Marchi
5b05c32725 libkmod-index: protect ourselves from corrupted indexes
If index is shorter than 12 bytes, we couldn't even read its header. Go
to error handling in this case.
2012-06-06 09:36:29 -03:00
Lucas De Marchi
5bbec8cdcb libkmod-index: use generic function for unaligned access 2012-05-23 19:32:58 -03:00
Lucas De Marchi
bfcd31def9 Fix wrong printf format string
This fixes build in 32 bits machines.
2012-03-02 21:28:11 -03:00
Lucas De Marchi
2e2e252bd4 libkmod-index: do not pre-populate mmap
If we tell mmap to populate all the indexes and they are big, this will
impact load time. Let them be mapped as they are used.
2012-03-02 20:33:26 -03:00
Lucas De Marchi
817f4e33de libkmod-index: free node when we have only partial match 2012-02-27 19:54:33 -03:00
Lucas De Marchi
ee1d188f70 libkmod-module: fill builtin's name
modules.builtin don't have any realname->value -- it follows the same
format of modules.dep, not the aliases ones.
2012-02-27 18:48:02 -03:00
Lucas De Marchi
73298175ea libkmod-index: don't print an error if index doesn't exist
It's ok not to have the index files, so just print a DBG message instead
of an ERR.
2012-02-13 21:58:36 -02:00
Gustavo Sverzut Barbieri
dfa96f1545 improve logging to mention context.
Just printing the errno string such as "%m\n" is not enough to help
debug or users understand the problem.

Change to provide more context on the failing operation.
2012-01-31 22:01:00 -02:00
Lucas De Marchi
6068aaaea8 Check if struct stat has mtim member
Not all libc's have a mtim member in struct stat (dietlibc doesn't).
Change ts_usec() to receive a struct stat as parameter and implement it
accordingly for both cases.
2012-01-17 12:22:55 -02:00
Lucas De Marchi
758428a75f libkmod: dump index files
Provide a function to dump the index files to a certain fd. It could be
more optimized (particularly the functions to dump the index that were
copied and pasted from m-i-t), but it seems like the only user of it is
'modprobe -c', used for debugging purposes. So, keep it as is.
2012-01-16 16:05:46 -02:00
Lucas De Marchi
a66a6a999f Update copyright 2012-01-09 00:41:07 -02:00
Lucas De Marchi
9fd58f30bf index: save timestamp of each loaded index 2012-01-01 06:18:16 -02:00
Cristian Rodríguez
4088b27e21 index_file_open: fix another fd leak on error path. 2011-12-26 09:55:15 -02:00
Cristian Rodríguez
67d94ad388 Fix leak on error path 2011-12-23 03:08:57 -02:00
Gustavo Sverzut Barbieri
c6824b62f2 Fix unaligned memory access
Bug found on sparc64. Thanks to "Jan Engelhardt <jengelh@medozas.de>"
for providing access to such a machine.
2011-12-21 18:37:46 -02:00
Gustavo Sverzut Barbieri
a5a92a613c fix error handling path. 2011-12-17 19:43:11 -02:00
Cristian Rodríguez
79e5ea91e0 Library must use O_CLOEXEC whenever it opens file descriptors 2011-12-16 04:16:09 -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
cb451f35d9 Change licenses
libkmod is under LGPL 2.1 or later
tools/* are under GPL
2011-12-12 18:24:35 -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
Lucas De Marchi
5109f2b422 index: mm: Add flag to open call to populate buffer 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
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
b471a6b494 index: mmap: open and close file 2011-12-03 04:06:16 -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
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
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