Red Hat ENTERPRISE LINUX 3 - DEVELOPER TOOLS GUIDE Especificações Página 62

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 110
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 61
Red Hat Enterprise Linux to Oracle Solaris Porting Guide
61
init_module() in Linux initializes a loadable module entry. In Oracle Solaris, _init() initializes a loadable module.
Within an _init() call, you need to call another function
called mod_install() that takes the modlinkage struct
as an argument.
delete_module() in Linux deletes a loadable module. mod_remove() is used to remove module in Oracle Solaris.
mod_remove() needs to be called from within _fini().
#include <sys/modctl.h>
int mod_remove(struct modlinkage *modlinkage);
int _fini(void)
{
int i;
if ((i = mod_remove(&modlinkage)) !=
0)
cmn_err(CE_NOTE,"Could not remove
module\n");
else
cmn_err(CE_NOTE,"flkm:
successfully removed");
return i;
}
Necessary Compiler Options, Linker Options, and Linked Libraries
TABLE 6-4. COMPILATION STEPS AND MAKEFILE CHANGES
RHEL ORACLE SOLARIS 11
A typical kernel module compilation command will look as
shown below:
gcc -O2 -DMODULE -D__KERNEL__ -W -Wall -
Wstrict-prototypes -Wmissing-prototypes -
isystem /lib/modules/`uname -r`/build/include
-c flkm.c -o flkm
Compiling a module is very simple. All you need to set are
some definitions that tell the included code this will be a kernel
module and not a normal executable. You should always link
your module's object file with the -r option; otherwise, the
module will not load, because the kernel module linker will not
be able to link the module.
gcc -D_KERNEL -DSVR4 -DSOL2 -O2 -c flkm.c ld -
o flkm -r flkm.o
Vista de página 61
1 2 ... 57 58 59 60 61 62 63 64 65 66 67 ... 109 110

Comentários a estes Manuais

Sem comentários