opensuse:module-init-tools.git
8 years agomodprobe: change softdep --pre/--post to pre:/post:
Andreas Robinson [Mon, 12 Oct 2009 08:26:58 +0000 (10:26 +0200)]
modprobe: change softdep --pre/--post to pre:/post:

"--" is modified by underscores(). This would have made the
future implementation of softdep in .modinfo more complicated.

Signed-off-by: Andreas Robinson <andr345@gmail.com>
8 years agotest: add softdep test, modprobe: fix simple bugs in do_softdep
Andreas Robinson [Sat, 10 Oct 2009 14:56:28 +0000 (16:56 +0200)]
test: add softdep test, modprobe: fix simple bugs in do_softdep

Signed-off-by: Andreas Robinson <andr345@gmail.com>
8 years agomodprobe: add simple softdep loop detector
Andreas Robinson [Sun, 4 Oct 2009 15:18:38 +0000 (17:18 +0200)]
modprobe: add simple softdep loop detector

Signed-off-by: Andreas Robinson <andr345@gmail.com>
8 years agoelfops: remove errfn_t from load_strings
Andreas Robinson [Sun, 4 Oct 2009 15:00:43 +0000 (17:00 +0200)]
elfops: remove errfn_t from load_strings

Commit 528db92ab1dd0d75dba415b9f3dc81f5a34773ce added an errfn_t
parameter to elfops_core.c:load_strings. This was for the purpose
of detecting missing terminators at the end of ELF-sections with
strings in them, such as .modinfo.

However, the committer (that'd be me) forgot to add any actual code to
load_strings() and now the errfn_t parameter complicates the error
handling when softdep is used.

This commit removes that parameter and adds a non-fatal warning message.

Signed-off-by: Andreas Robinson <andr345@gmail.com>
8 years agomodprobe: add softdep command
Andreas Robinson [Sat, 3 Oct 2009 19:30:18 +0000 (21:30 +0200)]
modprobe: add softdep command

Imlementation notes
-------------------

* find_softdep()/do_softdep() mirrors find_command()/do_command()
  precisely. (And if they don't, that's a bug.)

* Failures in the indirect modprobes, ie. those run by the softdep
  command, are ignored. This seems correct for removing, but I'm
  unsure what the proper action is when installing.

An example - or how it's supposed to work
-----------------------------------------

Configuration:
softdep foo --pre pre1 pre2 --post post1 post2

Installing a module:

$modprobe foo <CMDLINE_OPTS>

yields

modprobe pre1
modprobe pre2
modprobe --ignore-install foo <CMDLINE_OPTS>
modprobe post1
modprobe post2

Likewiese, removing a module:

$modprobe -r foo

yields

modprobe -r post2
modprobe -r post1
modprobe --ignore-remove -r foo
modprobe -r pre2
modprobe -r pre1

Signed-off-by: Andreas Robinson <andr345@gmail.com>
8 years agomodprobe: don't modify the modname string passed to do_modprobe
Andreas Robinson [Sat, 3 Oct 2009 19:20:23 +0000 (21:20 +0200)]
modprobe: don't modify the modname string passed to do_modprobe

The function will work on a copy instead.

Signed-off-by: Andreas Robinson <andr345@gmail.com>
8 years agomodprobe: enable calling do_modprobe from within handle_module,insmod,rmmod
Andreas Robinson [Sat, 3 Oct 2009 18:39:21 +0000 (20:39 +0200)]
modprobe: enable calling do_modprobe from within handle_module,insmod,rmmod

A new function, do_softdep(), will be invoked from the same locations
as do_command() as it eventually will replace it. do_softdep() in turn
needs to call do_modprobe().

This commit adds some parameters to do_modprobe, handle_module,
insmod and rmmod, needed to make this possible.

The pathnames for "module.symbols" and "modules.alias" are now
generated wherever they're needed, rather than in main().

Signed-off-by: Andreas Robinson <andr345@gmail.com>
8 years agomodprobe: put configuration objects in a struct
Andreas Robinson [Sat, 3 Oct 2009 18:22:48 +0000 (20:22 +0200)]
modprobe: put configuration objects in a struct

It is now possible to add or remove conf commands without rewriting
the function declarations of e.g parse_config_*() every time.

Signed-off-by: Andreas Robinson <andr345@gmail.com>
8 years agomodprobe: cleanup indentation change in conf parser
Andreas Robinson [Sat, 3 Oct 2009 18:18:35 +0000 (20:18 +0200)]
modprobe: cleanup indentation change in conf parser

Follow up to the previous commit.

Signed-off-by: Andreas Robinson <andr345@gmail.com>
8 years agomodprobe: reduce nesting in conf parser
Andreas Robinson [Sat, 3 Oct 2009 18:07:15 +0000 (20:07 +0200)]
modprobe: reduce nesting in conf parser

Helps readability and will simplify the softdep command parser.

Signed-off-by: Andreas Robinson <andr345@gmail.com>
8 years agomodule-init-tools v3.11-rc1 v3.11-rc1
Jon Masters [Thu, 1 Oct 2009 06:29:21 +0000 (02:29 -0400)]
module-init-tools v3.11-rc1

An initial round of patches for the 3.11 release, including support for
"builtin" modules (those pre-compiled into the kernel image for which we
have sysfs entries and perform module initcalls just like loadable ones).

Signed-off-by: Jon Masters <jcm@jonmasters.org>
8 years agomodprobe: handle built-in modules (v4, this time tested...)
Michal Marek [Thu, 10 Sep 2009 14:26:34 +0000 (16:26 +0200)]
modprobe: handle built-in modules (v4, this time tested...)

The kernel installs a modules.builtin file listing all builtin
modules. Let depmod generate a modules.builtin.bin file and use
this in modprobe: If a module is not found in modules.dep or
modules.alias, check if the module is builtin and either do nothing,
or print "builtin <module>" if --show-depends was given. Trying to
remove a builtin module returns an error, as does inserting a builtin
module with --first-time.

Signed-off-by: Michal Marek <mmarek@suse.cz>
Signed-off-by: Jon Masters <jcm@jonmasters.org>
8 years agodepmod: change depfile functions to return int
Michal Marek [Thu, 10 Sep 2009 07:33:54 +0000 (09:33 +0200)]
depmod: change depfile functions to return int

If a function returns zero, the file won't be generated

Signed-off-by: Michal Marek <mmarek@suse.cz>
Signed-off-by: Jon Masters <jcm@jonmasters.org>
8 years agomodprobe: add --resolve-alias option
Thomas Bächler [Wed, 26 Aug 2009 17:12:05 +0000 (19:12 +0200)]
modprobe: add --resolve-alias option

The --resolve-alias option prints all module names that match the
alias given on the commandline and exits. If no valid alias is specified,
it does nothing.

8 years agologging: tell GCC to check calls to error() etc
Alan Jenkins [Fri, 7 Aug 2009 09:17:12 +0000 (10:17 +0100)]
logging: tell GCC to check calls to error() etc

This warns about the modinfo segfault which Ozan found.  It doesn't
find any other problems, which is good to know.  It may also help
avoid future errors.

Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
8 years agomodinfo: Fix segmentation fault due to the wrong parameter
Ozan Çağlayan [Fri, 7 Aug 2009 07:37:11 +0000 (10:37 +0300)]
modinfo: Fix segmentation fault due to the wrong parameter

modinfo segfaults when called with a module which is just deleted from
the filesystem without re-running depmod.

Pass filename instead of the address of it to the error() function to
fix the problem.

Tested-by: Ozan Çağlayan <ozan@pardus.org.tr>
Signed-off-by: Ozan Çağlayan <ozan@pardus.org.tr>
9 years agorelease: module-init-tools version 3.10 v3.10
Jon Masters [Thu, 16 Jul 2009 07:42:25 +0000 (03:42 -0400)]
release: module-init-tools version 3.10

9 years agotestsuite: rebuild all module data files
Jon Masters [Sat, 27 Jun 2009 08:25:21 +0000 (04:25 -0400)]
testsuite: rebuild all module data files

Rebuild all module data files using hornet (ppc64) and tonnant (x86_64).

Signed-off-by: Jon Masters <jcm@jonmasters.org>
9 years agoFrom: Michal Marek <mmarek@suse.cz>
Jon Masters [Sat, 27 Jun 2009 08:07:46 +0000 (04:07 -0400)]
From: Michal Marek <mmarek@suse.cz>

testsuite: stop testing the old style EXPORT_SYMBOL macro

The "new style" macro has been in use long enough (since 2.5.59 or so),
so stop testing the old one. The next patch will remove support for the
old macro.

The modules were rebuilt on a x86 and ppc machine, using gcc 4.3.2.

Signed-off-by: Michal Marek <mmarek@suse.cz>
9 years agotestsuite: add a Makefile to rebuild the test modules
Michal Marek [Sat, 27 Jun 2009 08:04:13 +0000 (04:04 -0400)]
testsuite: add a Makefile to rebuild the test modules

I haven't found a Makefile or script in the tree to do this, so I wrote
one.

jcm: Indeed, there was no such Makefile - these are rebuilt infrequently
     and I last time just did it by hand, but a Makefile is cleaner.

Signed-off-by: Michal Marek <mmarek@suse.cz>
Signed-off-by: Jon Masters <jcm@jonmasters.org>
9 years agotestsuite: add option to only test a given endianess / bitness
Michal Marek [Sat, 27 Jun 2009 08:02:22 +0000 (04:02 -0400)]
testsuite: add option to only test a given endianess / bitness

To make it easier to test changes to the testsuite without a
cross-compiler, add environment variables TEST_ENDIAN and TEST_BITS
controlling which environment / bitness will be tested. All test run in
all four modes.

jcm: removed bad options handling test since it's no longer in testsuite.

Signed-off-by: Michal Marek <mmarek@suse.cz>
Signed-off-by: Jon Masters <jcm@jonmasters.org>
9 years agogit: ignore libmodtools.a
Jon Masters [Tue, 23 Jun 2009 08:10:19 +0000 (04:10 -0400)]
git: ignore libmodtools.a

Michal Marek pointed out that (following his previous .gitignore patch) that
we were also not ignoring the output from building the new libmodtools.a.

Signed-off-by: Jon Masters <jcm@jonmasters.org>
9 years agoAdd cscope/ctags/etags files to .gitignore
Michal Marek [Mon, 15 Jun 2009 14:08:06 +0000 (16:08 +0200)]
Add cscope/ctags/etags files to .gitignore

Signed-off-by: Michal Marek <mmarek@suse.cz>
Signed-off-by: Jon Masters <jcm@jonmasters.org>
9 years agodepmod: add ability to check symbol versions
Jon Masters [Tue, 23 Jun 2009 08:07:06 +0000 (04:07 -0400)]
depmod: add ability to check symbol versions

Add a new option -E Module.symvers to read symbol versions from a
Module.symvers files and modules and warn about mismatches if -e is
given.

Signed-off-by: Michal Marek <mmarek@suse.cz>
Signed-off-by: Jon Masters <jcm@jonmasters.org>
9 years agoelfops: kill first argument of load_dep_syms()
Michal Marek [Thu, 18 Jun 2009 14:38:55 +0000 (16:38 +0200)]
elfops: kill first argument of load_dep_syms()

The pathname is already in the elf_file struct.

Signed-off-by: Michal Marek <mmarek@suse.cz>
Signed-off-by: Jon Masters <jcm@jonmasters.org>
9 years agoelfops: clean up load_symbols()
Michal Marek [Thu, 18 Jun 2009 14:38:59 +0000 (16:38 +0200)]
elfops: clean up load_symbols()

__ksymtab_strings_gpl must have been a mistake, there has never been such
section. __ksymtab_strings is present since 2.5.59, so get rid of the
compatibility code.

Signed-off-by: Michal Marek <mmarek@suse.cz>
Signed-off-by: Jon Masters <jcm@jonmasters.org>
9 years agodoc: link depmod.d to depmod.conf also
Jon Masters [Tue, 23 Jun 2009 07:53:17 +0000 (03:53 -0400)]
doc: link depmod.d to depmod.conf also

We created a link previously from depmod.conf to depmod.d (and it has to be
done the way it is for now due to the XML utilities not handling the actual
multiple file names we specify right in the source), so let's do the same
for depmod.d documentation.

Signed-off-by: Jon Masters <jcm@jonmasters.org>
9 years agoMerge branch 'modprobe_main' of ../module_init_tools_andr345
Jon Masters [Tue, 23 Jun 2009 07:49:09 +0000 (03:49 -0400)]
Merge branch 'modprobe_main' of ../module_init_tools_andr345

9 years agoMerge branch 'modprobe_main' of git://github.com/andr345/module-init-tools into modpr...
Jon Masters [Tue, 23 Jun 2009 07:43:42 +0000 (03:43 -0400)]
Merge branch 'modprobe_main' of git://github.com/andr345/module-init-tools into modprobe_main

9 years agomodprobe: fix various simple style issues related to the option flags
Andreas Robinson [Mon, 15 Jun 2009 17:45:02 +0000 (19:45 +0200)]
modprobe: fix various simple style issues related to the option flags

Changes suggested by Alan:

* Rename ignore_inuse => ignore_loaded
* Put the flags parameter last in handle_module/insmod/rmmod/do_modprobe
  function declarations.
  (The errfn was moved too, to just before the flags.)
* Don't change more than one flag per statement,
  i.e flags |= (foo | bar); => flags |= foo; flags |= bar;

Signed-off-by: Andreas Robinson <andr345@gmail.com>
9 years agodoc: delete modprobe -w option documentation
Andreas Robinson [Mon, 15 Jun 2009 17:40:15 +0000 (19:40 +0200)]
doc: delete modprobe -w option documentation

Signed-off-by: Andreas Robinson <andr345@gmail.com>
9 years agotests: remove depmod --unknown option test
Alan Jenkins [Mon, 15 Jun 2009 08:15:28 +0000 (09:15 +0100)]
tests: remove depmod --unknown option test

depmod no longer handles unknown or malformed options itself.  The error
message is now generated by getopt, so we don't need to test for it.
It turns out that different versions of getopt can generate slightly
different error messages, so the test will do more harm than good.

Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
9 years agomodprobe: move modprobing from main() into separate function.
Andreas Robinson [Sat, 13 Jun 2009 13:36:25 +0000 (15:36 +0200)]
modprobe: move modprobing from main() into separate function.

Signed-off-by: Andreas Robinson <andr345@gmail.com>
9 years agomodprobe: merge option flags into a single parameter
Andreas Robinson [Sat, 13 Jun 2009 13:25:08 +0000 (15:25 +0200)]
modprobe: merge option flags into a single parameter

Also simplify how handle_module()'s return code is handled in main():
Before: if (handle_module()) failed = 1;
After: failed |= handle_module();

Signed-off-by: Andreas Robinson <andr345@gmail.com>
9 years agomodprobe: remove broken -w option
Andreas Robinson [Sat, 13 Jun 2009 13:12:13 +0000 (15:12 +0200)]
modprobe: remove broken -w option

This reverts commit 5a402b77821e76f318beffff3f544ad3c7250c21
dated 5 Sep 2007.

The call to delete_module() is unaffected by the -w option and
delete_module() (in 2.6.29) itself can not be made to block
the way that is intended.

Signed-off-by: Andreas Robinson <andr345@gmail.com>
9 years agomodprobe: rename some option variables
Andreas Robinson [Sat, 13 Jun 2009 13:07:06 +0000 (15:07 +0200)]
modprobe: rename some option variables

ignore_proc => ignore_inuse
optstring => cmdline_opts
config => configname
dump_only => dump_config
modulearg => modname

Signed-off-by: Andreas Robinson <andr345@gmail.com>
9 years agotest-depmod: Fix error message mismatch
Andreas Robinson [Sat, 13 Jun 2009 12:56:47 +0000 (14:56 +0200)]
test-depmod: Fix error message mismatch

Did a glibc version change or something cause this?

9 years agomodprobe: trivial code reorganization
Andreas Robinson [Sat, 13 Jun 2009 12:41:42 +0000 (14:41 +0200)]
modprobe: trivial code reorganization

Move do_command, insmod and rmmod closer to handle_module.

Signed-off-by: Andreas Robinson <andr345@gmail.com>
9 years agomodindex: simplify option handling
Alan Jenkins [Thu, 11 Jun 2009 15:20:39 +0000 (16:20 +0100)]
modindex: simplify option handling

Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
9 years agodoc: modprobe --dumpversions needs a full filename, as opposed to a module name
Alan Jenkins [Thu, 11 Jun 2009 13:11:12 +0000 (14:11 +0100)]
doc: modprobe --dumpversions needs a full filename, as opposed to a module name

Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
9 years agodepmod: simplify option error handling
Alan Jenkins [Thu, 11 Jun 2009 14:43:48 +0000 (15:43 +0100)]
depmod: simplify option error handling

Backcompat is removed, so we can exit immediately if we don't recognise
an option.

Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
9 years agomodprobe: --remove requires at least one module name
Alan Jenkins [Thu, 11 Jun 2009 14:08:58 +0000 (15:08 +0100)]
modprobe: --remove requires at least one module name

This makes it consistent with --all.

Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
9 years agomodprobe: don't ignore --set-version when preceded by --dirname
Alan Jenkins [Thu, 11 Jun 2009 14:26:11 +0000 (15:26 +0100)]
modprobe: don't ignore --set-version when preceded by --dirname

Fix this:

strace -e trace=file build/modprobe --dirname / --set-version 2.6.99 foo
...
open("///lib/modules/2.6.30-rc7/modules.alias", O_RDONLY) = 5
FATAL: Module foo not found.

Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
9 years agodepmod --warn doesn't has_arg
Alan Jenkins [Thu, 11 Jun 2009 14:24:17 +0000 (15:24 +0100)]
depmod --warn doesn't has_arg

Fix this:

$ depmod --warn
depmod: malformed/unrecognized option '--warn'
...

$ depmod --warn dummy-arg
$

Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
9 years agoClean up missing options
Alan Jenkins [Thu, 11 Jun 2009 14:24:23 +0000 (15:24 +0100)]
Clean up missing options

modprobe -D (short version of --show-deps) doesn't work, remove it from
the manpage.  Don't try to pass "-D" to commands either ("--show-deps"
sets dry_run, so we won't run any commands).

modprobe -Q is not valid, remove 'Q' from the getopt string.

In depmod, "r" was listed twice in the getopt string.

Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
9 years agoRe-order options to make the code easier to check
Alan Jenkins [Thu, 11 Jun 2009 11:42:42 +0000 (12:42 +0100)]
Re-order options to make the code easier to check

options are listed in three places:
 1. getopt (long) option array
 2. getopt (short) option string
 3. the switch statement which handles the options

It's easier to check these lists for inconsistencies if all three lists
are in the same order.

Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
9 years agotestsuite: rebuild all the 64-be|le data files
Jon Masters [Thu, 28 May 2009 02:26:11 +0000 (22:26 -0400)]
testsuite: rebuild all the 64-be|le data files

Rebuild all the test modules to make sure there's no bitrot. We haven't done
this for big endian in a while, but I now have configured my home ppc64 box.

Signed-off-by: Jon Masters <jcm@jonmasters.org>
9 years agodoc: make a link from modprobe.d.sgml to modprobe.conf.sgml v3.9
Jon Masters [Wed, 27 May 2009 18:36:27 +0000 (14:36 -0400)]
doc: make a link from modprobe.d.sgml to modprobe.conf.sgml

The previous hack for modprobe.d.5 happens because 'docbook2man' as shipped
in at least one major distribution does not support '--solinks' to create
automatic links for each of the refentrytitle entries. It will actually only
make links for the last one. This is the other piece - for now, link sources.

Signed-off-by: Jon Masters <jcm@jonmasters.org>
9 years agobuild: remove elf_core.c from source dependencies
Jon Masters [Wed, 27 May 2009 18:33:41 +0000 (14:33 -0400)]
build: remove elf_core.c from source dependencies

We killed elf_core.c. Don't use it any more e.g. during "make dist".

Signed-off-by: Jon Masters <jcm@jonmasters.org>
9 years agorelease: module-init-tools v3.9
Jon Masters [Wed, 27 May 2009 16:57:47 +0000 (12:57 -0400)]
release: module-init-tools v3.9

9 years agoadd configure option to disable creation of .static utils
Mike Frysinger [Sun, 24 May 2009 19:19:16 +0000 (15:19 -0400)]
add configure option to disable creation of .static utils

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Jon Masters <jcm@jonmasters.org>
9 years agolink modprobe.d(5) to modprobe.conf(5)
Mike Frysinger [Sun, 24 May 2009 19:09:07 +0000 (15:09 -0400)]
link modprobe.d(5) to modprobe.conf(5)

Some people expect to be able to do `man modprobe.d` and see the relevant
content.  Not surprising considering modprobe.conf(5) already documents
that.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Jon Masters <jcm@jonmasters.org>
9 years agologging: remove unused warning counter
Alan Jenkins [Thu, 21 May 2009 17:03:57 +0000 (18:03 +0100)]
logging: remove unused warning counter

Signed-off-by: Jon Masters <jcm@jonmasters.org>
9 years agoMerge branch 'elf_cleanup3' of ../module_init_tools_andr345
Jon Masters [Wed, 27 May 2009 16:49:59 +0000 (12:49 -0400)]
Merge branch 'elf_cleanup3' of ../module_init_tools_andr345

9 years agomodindex: getopt_long returns int not char (fix ppc64 bug)
Jon Masters [Wed, 27 May 2009 22:27:46 +0000 (18:27 -0400)]
modindex: getopt_long returns int not char (fix ppc64 bug)

getopt_long returns an int and not a char. The existing code will fail a return
test on ppc64 where the -1 comparison will never succeed, so instead garbage
will exist in 'opt' at the end of the main while loop.

Signed-off-by: Jon Masters <jcm@jonmasters.org>
9 years agomodprobe, tests: make modprobe fail noisily on non-ELF files
Andreas Robinson [Thu, 21 May 2009 20:29:52 +0000 (22:29 +0200)]
modprobe, tests: make modprobe fail noisily on non-ELF files

Also remove fake placeholder modules in the test suite
e.g "echo Test > foo.ko && modprobe foo".
They don't work anymore.

Signed-off-by: Andreas Robinson <andr345@gmail.com>
9 years agoread string sections such as .modinfo with load_strings()
Andreas Robinson [Thu, 21 May 2009 20:10:38 +0000 (22:10 +0200)]
read string sections such as .modinfo with load_strings()

Changes to load_strings():
* export in struct module_ops
* avoid buffer overruns by looking for a string terminator
  at the end of a section.
* new errfn_t parameter selects error message type.
  If load_strings fails on a missing string terminator, the module
  is probably broken.
  Therefore, modprobe and depmod sets errfn_t error = fatal.
  Modinfo on the other hand sets errfn_t error = error.

Signed-off-by: Andreas Robinson <andr345@gmail.com>
9 years agologging, modprobe: move errfn_t to logging.h
Andreas Robinson [Thu, 21 May 2009 19:04:25 +0000 (21:04 +0200)]
logging, modprobe: move errfn_t to logging.h

Signed-off-by: Andreas Robinson <andr345@gmail.com>
9 years agoelfops: clear struct module_tables with memset()
Andreas Robinson [Wed, 20 May 2009 15:57:54 +0000 (17:57 +0200)]
elfops: clear struct module_tables with memset()

Signed-off-by: Andreas Robinson <andr345@gmail.com>
9 years agoelfops: fix potential crashing bug in load_symbols()
Andreas Robinson [Tue, 19 May 2009 16:18:18 +0000 (18:18 +0200)]
elfops: fix potential crashing bug in load_symbols()

get_section() returned an undefined section size on failure,
which could cause load_symbols() to crash if kernel symtables
were missing from the module.

get_section() will now return secsize == 0 if it fails.

Signed-off-by: Andreas Robinson <andr345@gmail.com>
9 years agofix minor strtbl_free and strtbl_add problems
Andreas Robinson [Tue, 19 May 2009 16:50:31 +0000 (18:50 +0200)]
fix minor strtbl_free and strtbl_add problems

- add missing NOFAIL to strtbl_add() in load_dep_syms()
- export strtbl_free()
- free string tables with strtbl_free()
- documentation fix

Signed-off-by: Andreas Robinson <andr345@gmail.com>
9 years agomodprobe: fix tab formatting of return statement
Jon Masters [Thu, 21 May 2009 02:58:43 +0000 (22:58 -0400)]
modprobe: fix tab formatting of return statement

Correct a problem with tabulation so the rc doesn't look like it's part
of the "if" statement above it.

Signed-off-by: Jon Masters <jcm@jonmasters.org>
9 years agodepmod: fix uninitialized value error in "depmod --warn" code
Alan Jenkins [Tue, 12 May 2009 11:01:07 +0000 (12:01 +0100)]
depmod: fix uninitialized value error in "depmod --warn" code

==12690== Conditional jump or move depends on uninitialised value(s)
==12690==    at 0x804A095: output_deps_bin (depmod.c:473)
==12690==    by 0x804CD85: main (depmod.c:1364)
==12690==  Uninitialised value was created by a stack allocation
==12690==    at 0x80517D3: add_value (index.c:86)

Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
Signed-off-by: Jon Masters <jcm@jonmasters.org>
9 years agotestsuite: add --valgrind
Alan Jenkins [Mon, 11 May 2009 08:22:58 +0000 (09:22 +0100)]
testsuite: add --valgrind

"valgrindme.sh" has been hanging around for a while without doing
anything. The original idea seems to have been to run under valgrind
automatically. But it is very slow, which discourages one from running
the testsuite. Implement it as an option instead.

In particular, this was useful while writing the binary index code.

Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
Signed-off-by: Jon Masters <jcm@jonmasters.org>
9 years agoMerge branch 'elf_cleanup2' of ../module_init_tools_andr345
Jon Masters [Tue, 19 May 2009 08:50:10 +0000 (04:50 -0400)]
Merge branch 'elf_cleanup2' of ../module_init_tools_andr345

9 years agoMerge branch 'elf_cleanup' of ../module_init_tools_andr345
Jon Masters [Tue, 19 May 2009 08:50:08 +0000 (04:50 -0400)]
Merge branch 'elf_cleanup' of ../module_init_tools_andr345

9 years agoelfops: hide elf_ident(), no users outside elfops
Andreas Robinson [Thu, 14 May 2009 16:54:46 +0000 (18:54 +0200)]
elfops: hide elf_ident(), no users outside elfops

Signed-off-by: Andreas Robinson <andr345@gmail.com>
9 years agomodprobe, elfops: move most of dump_modversions() to elfops
Andreas Robinson [Fri, 15 May 2009 13:56:02 +0000 (15:56 +0200)]
modprobe, elfops: move most of dump_modversions() to elfops

Signed-off-by: Andreas Robinson <andr345@gmail.com>
9 years agomodprobe, elfops: move strip_section() to elfops and refactor it
Andreas Robinson [Thu, 14 May 2009 16:22:23 +0000 (18:22 +0200)]
modprobe, elfops: move strip_section() to elfops and refactor it

strip_section() now finds the section flags with get_section()
and handles files of opposite endianness.

Signed-off-by: Andreas Robinson <andr345@gmail.com>
9 years agoelfops: use elf_file in, and return section header from, get_module()
Andreas Robinson [Fri, 15 May 2009 13:34:47 +0000 (15:34 +0200)]
elfops: use elf_file in, and return section header from, get_module()

Returning the section header allows invalidate/strip_section() to
use get_section(). get_module() is more robust than strip_section()'s
own section lookup.

Signed-off-by: Andreas Robinson <andr345@gmail.com>
9 years agoelfops: hide get_section() and rename its parameters
Andreas Robinson [Fri, 15 May 2009 13:22:03 +0000 (15:22 +0200)]
elfops: hide get_section() and rename its parameters

load_section() has replaced get_section() outside elfops.

The new parameter names match the fields in struct elf_file.

Signed-off-by: Andreas Robinson <andr345@gmail.com>
9 years agomodprobe: use elf_file in ELF-related functions
Andreas Robinson [Fri, 15 May 2009 13:07:07 +0000 (15:07 +0200)]
modprobe: use elf_file in ELF-related functions

The affected functions are

replace_modname()
rename_module()
invalidate_section()
strip_section()
clear_magic()
dump_modversions()

Signed-off-by: Andreas Robinson <andr345@gmail.com>
9 years agomodprobe: trivial indentation fix in dump_modversions()
Andreas Robinson [Thu, 14 May 2009 14:52:20 +0000 (16:52 +0200)]
modprobe: trivial indentation fix in dump_modversions()

Signed-off-by: Andreas Robinson <andr345@gmail.com>
9 years agomodprobe: load modules with grab_elf_file_fd()
Andreas Robinson [Thu, 14 May 2009 12:07:37 +0000 (14:07 +0200)]
modprobe: load modules with grab_elf_file_fd()

In the old implementation, the loader didn't care about whether
a file is an ELF-file or not, and let init_module() sort it out.

In the new implementation, the loading fails with errno = ENOEXEC
if the file isn't an ELF-file.

However, the new logic does not pass the testing, specifically
test-modprobe/10alias.sh. To work around this, the commit adds a
hack that replicates the old way, when grab_elf_file_fd() does
return errno = ENOEXEC.

Obviously, this needs to be fixed. To replicate the problem,
simply remove the hack.

Signed-off-by: Andreas Robinson <andr345@gmail.com>
9 years agomodinfo: load modules with grab_elf_file()
Andreas Robinson [Thu, 14 May 2009 09:42:57 +0000 (11:42 +0200)]
modinfo: load modules with grab_elf_file()

Also, load module info with ops->get_modinfo() instead of get_section()
This hides struct elf_file fields.

load_strings() was originally planned to replace get_section(),
but the code ended up less clear, so that idea is put on hold.

Signed-off-by: Andreas Robinson <andr345@gmail.com>
9 years agomodinfo: use logging facility for oom-checks and error messages
Andreas Robinson [Thu, 14 May 2009 08:15:59 +0000 (10:15 +0200)]
modinfo: use logging facility for oom-checks and error messages

Also fix slightly broken nofail_asprintf()

Side effects:
Errors are printed with the "ERROR:" prefix.
Testing for oom, quiets asprintf return-value warning.

Signed-off-by: Andreas Robinson <andr345@gmail.com>
9 years agomodinfo: clean up grab_module()
Andreas Robinson [Thu, 14 May 2009 07:50:28 +0000 (09:50 +0200)]
modinfo: clean up grab_module()

Reorganize pathname building and use asprintf and strndup instead
of malloc, sprintf and memcpy.

Module file names are now truncated *after* copying.
It wastes a few bytes, but makes the code much easier to read.

Signed-off-by: Andreas Robinson <andr345@gmail.com>
9 years agoelfops, depmod: add elf_file grab/release functions
Andreas Robinson [Thu, 14 May 2009 08:34:24 +0000 (10:34 +0200)]
elfops, depmod: add elf_file grab/release functions

This introduces constructor and destructor for struct elf_file,
following the grab/release naming pattern used elsewhere. Care is
taken to ensure the constructor returns a valid errno on failure.

The first user is grab_module() in depmod.c

Signed-off-by: Andreas Robinson <andr345@gmail.com>
9 years agoelfops: add strict bounds checking to get/load_section()
Andreas Robinson [Thu, 14 May 2009 08:28:22 +0000 (10:28 +0200)]
elfops: add strict bounds checking to get/load_section()

get_section() and load_section() now return NULL if a section header
is corrupt and points to a block that lies partially or entirely
outside the file data buffer.

Signed-off-by: Andreas Robinson <andr345@gmail.com>
9 years agoelfops: export load_section(), hide load_strings()
Andreas Robinson [Fri, 15 May 2009 12:33:17 +0000 (14:33 +0200)]
elfops: export load_section(), hide load_strings()

load_strings() was planned to replace get_section() + next_string()
e.g in modinfo. However it turns out there are no advantages in style
and few in function. As it won't be used outside elfops, the export
is removed.

load_section() OTOH, will replace get_section() so we export it now.

Signed-off-by: Andreas Robinson <andr345@gmail.com>
9 years agoinstall-with-care: Replace backticks with braces
Robby Workman [Wed, 13 May 2009 19:05:56 +0000 (14:05 -0500)]
install-with-care: Replace backticks with braces

  This seems to be the current "standard" (which is probably
    not the best word to use and will cause whining), so here's
    a patch.  Feel free to ignore this one :-)

9 years agodocs/support files: remove deprecated/obsolete back-compat stuff
Robby Workman [Wed, 13 May 2009 19:01:37 +0000 (14:01 -0500)]
docs/support files: remove deprecated/obsolete back-compat stuff

  FAQ
    - removed references to modprobe.conf, as it should not be
      needed in that context
    - used /etc/modprobe.d/sound.conf for the alsa example (perhaps
      this can go away completely now; I think alsa handles this
      automatically if needed)
    - trivial typo fix
  Makefile.am
    - removed references to modprobe.devfs (obsolete)
  NEWS
    - noted release of 3.7 and 3.8, but Jon will need to clarify
      their status with respect to maintenance and such
    - noted the deprecation of generate-modprobe.conf and the
      fact that it is no longer installed by default
  README
    - clarified note about backwards compatibility (requires a
      2.6.x kernel, and no support at all for older modutils)
    - updated instructions to remove note about generate-modprobe.conf
  modprobe.defvs
    - removed completely from the repo; this is obsolete now

9 years agomanpages: general cleanup and removal of backwards-compat notes
Robby Workman [Wed, 13 May 2009 18:53:21 +0000 (13:53 -0500)]
manpages: general cleanup and removal of backwards-compat notes

  depmod.conf.sgml:
    -trivial cleanups
    -removed the deprecated "include" mentions
  depmod.sgml
    -trivial cleanups
    -removed the backward-compatibility mentions (will add a global
     note to the toplevel README in another commit)
  insmod.sgml
    -trivial cleanups
    -removed the backward-compatibility mentions
  lsmod.sgml
    -removed the backward-compatibility mentions
  modinfo.sgml
    -removed the backward-compatibility mentions
    -I left the old -{a,d,l,p,n} options untouched, even though they
     are documented as being for old modutils compatibility
  modprobe.conf.sgml
    -trivial cleanups
    -noted preference for /etc/modprobe.d/ over /etc/modprobe.conf
     (as modprobe.conf is deprecated and will be removed)
    -removed the deprecated "include" mentions
    -removed the backward-compatibility mentions
  modprobe.sgml
    -trivial cleanups
    -clarified the -C and -c options; perhaps they should go away later
    -removed the backward-compatibility mentions
  modules.dep.sgml
    -trivial cleanups
    -bring kernel version used in examples more up to date
  rmmod.sgml
    -trivial cleanups
    -removed the backward-compatibility mentions

9 years agoutil: document the rationale for the string table
Andreas Robinson [Tue, 12 May 2009 10:36:36 +0000 (12:36 +0200)]
util: document the rationale for the string table

Signed-off-by: Andreas Robinson <andr345@gmail.com>
9 years agoelfops: Fix symbol type (weak, undef) definitions
Andreas Robinson [Tue, 12 May 2009 07:01:50 +0000 (09:01 +0200)]
elfops: Fix symbol type (weak, undef) definitions

Inline string literals might not have static lifetimes (C99 6.4.5).
This corrects the assumption that they do, that was introduced
in e35f9df6c1aa02a2f7aa0e319af4d0e70181a9ca

Signed-off-by: Andreas Robinson <andr345@gmail.com>
9 years agomove ELF-related code into elfops
Andreas Robinson [Sun, 10 May 2009 09:38:11 +0000 (11:38 +0200)]
move ELF-related code into elfops

Specifically

depmod.h   => elfops.h:      struct module_tables and struct elf_file
elfops.c   => elfops_core.c: X-macros (eg PERBIT)
elf_core.c => elfops_core.c: get_section()
util.[ch]  => elfops.[ch]:   elf_ident() and get_section()

Additionally, elf_core.c is deleted, being replaced by elfops_core.c

Signed-off-by: Andreas Robinson <andr345@gmail.com>
9 years agomoduleops: rename to elfops and move to static lib
Andreas Robinson [Sun, 10 May 2009 09:31:58 +0000 (11:31 +0200)]
moduleops: rename to elfops and move to static lib

Signed-off-by: Andreas Robinson <andr345@gmail.com>
9 years agodepmod: Introduce struct elf_file
Andreas Robinson [Sat, 9 May 2009 23:35:16 +0000 (01:35 +0200)]
depmod: Introduce struct elf_file

Remove the last remnants of struct module from moduleops*.[ch]

Signed-off-by: Andreas Robinson <andr345@gmail.com>
9 years agomoduleops: Trivial code cleanups
Andreas Robinson [Sat, 9 May 2009 23:25:33 +0000 (01:25 +0200)]
moduleops: Trivial code cleanups

load_section():
* Pass struct module rather than module->data and module->conv.

load_dep_syms() and fetch_tables()
* Assign local variable conv = module->conv when used in many places.

fetch_tables():
* Treat handle_register_symbols like the boolean it is.

Signed-off-by: Andreas Robinson <andr345@gmail.com>
9 years agodepmod: move tables from struct module into separate struct
Andreas Robinson [Sat, 9 May 2009 11:54:52 +0000 (13:54 +0200)]
depmod: move tables from struct module into separate struct

This is part of the work separating depmod and moduleops.

Signed-off-by: Andreas Robinson <andr345@gmail.com>
9 years agomoduleops: add load_strings() operation
Andreas Robinson [Sat, 9 May 2009 11:01:50 +0000 (13:01 +0200)]
moduleops: add load_strings() operation

load_string() treats the data in an ELF-file section as a collection
of strings and builds a string table from those. It can be used to
read .modinfo, __ksymtab_strings and similar sections.

load_symbols() is updated to take advantage of the new function.

Signed-off-by: Andreas Robinson <andr345@gmail.com>
9 years agodepmod: separate symbol lookup and dependency calculation
Andreas Robinson [Sat, 9 May 2009 10:55:10 +0000 (12:55 +0200)]
depmod: separate symbol lookup and dependency calculation

The new load_dep_syms() operation in moduleops returns a string table of
symbols on which a module depends. calculate_deps() is moved to depmod.

Remaining depmod callbacks in moduleops are removed.

Signed-off-by: Andreas Robinson <andr345@gmail.com>
9 years agodepmod: rewrite load_symbols() to not use callback
Andreas Robinson [Sat, 9 May 2009 10:44:30 +0000 (12:44 +0200)]
depmod: rewrite load_symbols() to not use callback

load_symbols() in moduleops no longer has to call add_symbol()
in depmod. Data is now returned in a string table.

Signed-off-by: Andreas Robinson <andr345@gmail.com>
9 years agoutil: introduce new string table object
Andreas Robinson [Sat, 9 May 2009 10:43:11 +0000 (12:43 +0200)]
util: introduce new string table object

load_symbols() and calculate_deps() in moduleops call functions in
depmod as a way of passing multiple symbols back to depmod.

This adds a string table to replace those callbacks.

Signed-off-by: Andreas Robinson <andr345@gmail.com>
9 years agoAdd elf_core.c into the EXTRA_SOURCES for the static library v3.8
Jon Masters [Thu, 30 Apr 2009 20:34:27 +0000 (16:34 -0400)]
Add elf_core.c into the EXTRA_SOURCES for the static library

We need this additional inclusion for "make dist" to work correctly.

Signed-off-by: Jon Masters <jcm@jonmasters.org>
9 years agorelease: bump release to v3.8
Jon Masters [Thu, 30 Apr 2009 19:45:31 +0000 (15:45 -0400)]
release: bump release to v3.8

Signed-off-by: Jon Masters <jcm@jonmasters.org>
9 years agoDon't abort the build if docbook2man is missing
Michal Marek [Mon, 9 Mar 2009 18:48:59 +0000 (19:48 +0100)]
Don't abort the build if docbook2man is missing

Instead of aborting the build, print a warning if neither
docbook2man nor docbook-to-man is found.

Signed-off-by: Michal Marek <mmarek@suse.cz>
Signed-off-by: Jon Masters <jcm@jonmasters.org>
9 years agoAllow to link zlib dynamically
Michal Marek [Thu, 30 Apr 2009 19:41:44 +0000 (15:41 -0400)]
Allow to link zlib dynamically

Add new configure option --enable-zlib-dynamic to allow linking zlib
dynamically (e.g. opensuse installs libz.so.1 in /lib, so it's safe to
do it there).

Signed-off-by: Jon Masters <jcm@jonmasters.org>
9 years agobuild: put shared functions in static library
Andreas Robinson [Sat, 25 Apr 2009 13:16:38 +0000 (15:16 +0200)]
build: put shared functions in static library

This helps eliminating unused functions, shrinking the binaries
a little bit.

Signed-off-by: Andreas Robinson <andr345@gmail.com>
Signed-off-by: Jon Masters <jcm@jonmasters.org>
9 years agoRewrite my_basename() as inline function
Andreas Robinson [Thu, 23 Apr 2009 17:52:09 +0000 (19:52 +0200)]
Rewrite my_basename() as inline function

On Thu, 2009-04-23 at 18:15 +0100, Alan Jenkins wrote:

> Sorry, I didn't explain myself very well.  When I objected to the
> macro, what I really disliked was the way it was compressed into one
> line.  I think the original 3-line my_basename() function was much
> clearer.

Ah, ok. I need to kill some of my darlings it seems...
Is this patch better?

>From 8f80cd791a9008387c1c457d551bca73277c18e9 Mon Sep 17 00:00:00 2001
From: Andreas Robinson <andr345@gmail.com>
Date: Thu, 23 Apr 2009 19:49:16 +0200
Subject: [PATCH] Rewrite my_basename() for clarity

Signed-off-by: Jon Masters <jcm@jonmasters.org>