]> git.ipfire.org Git - thirdparty/kmod.git/commit - libkmod/libkmod-file.c
libkmod-file: refactor code to avoid ifdef mess.
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>
Tue, 3 Jan 2012 16:25:49 +0000 (14:25 -0200)
committerGustavo Sverzut Barbieri <barbieri@profusion.mobi>
Tue, 3 Jan 2012 16:25:49 +0000 (14:25 -0200)
commitdb5d14cf2422fec341c5bcfd3a74a8607884ea00
tree54ee76cc6bcafc61fe3eccc89235ace8e9943535
parent671799415717ee6d10df48ce03d60c5d75cded9f
libkmod-file: refactor code to avoid ifdef mess.

Refactor code to use pointer to functions, avoiding the previous

Now comp_types defines a magic header to be checked (size and bytes),
with the associated load() and unload() operations. If a header
matches, their operations are used. Otherwise the regular file
operations (mmap/munmap) are used.

File descriptor close is managed by the common code if it's valid
(>=0). If some code steals the file descriptor (eg: gzopen), then they
must change file->fd to -1.

This way the code should be easier to extend and avoid bugs.
libkmod/libkmod-file.c