Commit Graph

66 Commits

Author SHA1 Message Date
Lucas De Marchi 3bd7187ff5 libkmod: fix return error when opening index
When calling kmod_load_resources() we could end up getting a bogus
return value -ENOMEM due to several other reasons, like the index not
existing. Change index_mm_open() to propagate the failure reason so we
can take actions on it or return to the caller.
2020-03-23 12:37:40 -07:00
Lucas De Marchi ebdac0005b Check return of fseek while reading index 2015-02-28 16:11:53 -03:00
Lucas De Marchi dea2dfee9b Remove FSF mailing address
It has changed in the past, and these days, anyone can get a copy of the
LGPL via the web rather than by post.

Like 657a122 (Remove FSF mailing address) in libabc by Josh Tripplet,
but let the FSF website in which the license can be found.
2014-12-25 23:41:34 -02:00
Lucas De Marchi bb72153d34 libkmod-index: move comment to include the includes 2014-11-15 11:18:54 -02:00
Lucas De Marchi a5852e3b36 libkmod-index: remove invalid comment 2014-11-15 11:18:54 -02:00
Lucas De Marchi c4cbdf8e17 libkmod-index: keep index and comments in .c
Just like other source files, keep the index and comments in the source
file rather than the header.

This also removes INDEX_PRIORITY_MIN that was never being used.
2014-10-29 11:58:12 -02:00
Lucas De Marchi 15a7ae30b3 shared: rename prefixes of strbuf functions
Use strbuf_ prefix instead of buf_.
2014-10-11 13:25:51 -03:00
Lucas De Marchi b4d1f44af1 Move strbuf implementation to shared/
Just move the strbuf-like implementation to shared/. No renames were
made yet to avoid cluttering the diff. It will come in a separate patch.
2014-10-11 13:09:42 -03:00
Lucas De Marchi c2e4286bb9 Reorder and reorganize header files
Let the includes in the following order:

< system headers >
< libkmod >
< tool >
< local headers >
2014-10-03 01:43:15 -03:00
Lucas De Marchi 96573a0220 Move generic util functions to shared directory 2014-10-03 00:33:25 -03:00
Lucas De Marchi 576dd4393d Move macro.h to shared directory
It's not really related to libkmod, so move it to a directory in which
we keep common stuff.
2014-10-02 22:03:19 -03:00
Holger Obermaier 1a4aa7e2cb libkmod-index.c: Fix error message 2014-09-04 16:29:47 -03:00
Leandro Pereira b6d985c61a Ensure read_long() reads the correct number of bytes from the index 2014-05-14 20:18:00 -03:00
Leandro Pereira d36c886aed Bail out of index_mm_open() if fstat() fails 2014-05-14 20:17:30 -03:00
Lucas De Marchi 83b855a6ed Use "-internal" suffix instead of "-private" 2013-07-04 16:13:11 -03:00
Lucas De Marchi 681bf89afd libkmod-index: Return early if readroot failed 2013-04-23 21:26:09 -03:00
Kees Cook c3e8d26946 libkmod: fix address argument to mmap calls
The first argument to mmap should be "NULL" instead of "0".
2013-02-19 19:19:51 -03:00
Lucas De Marchi e6b0e49b4e Update copyright notices 2013-01-16 11:27:45 -02:00
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