Enviado em 27/04/2023 - 14:11h
Estou tentando executar uma funcao de um modulo pra linux que eu construi, mas nao obtenho sucesso.
void fp_printk(int number, int decimal_places, char* destination)
{
printk(KERN_INFO "um test no inicio");
static char buffer[32] = { 0 };
int buf_index = 30;
int count_decimal_place = 0;
int point_include = 0;
for (; number && buf_index; --buf_index, number /= 10) {
count_decimal_place++;
if (!point_include && count_decimal_place > decimal_places) {
buffer[buf_index] = '.';
buf_index--;
point_include = 1;
}
buffer[buf_index] = "0123456789"[number % 10];
}
strcpy(destination, &buffer[buf_index + 1]);
}
EXPORT_SYMBOL(fp_printk);
static int __init fp_printk_init(void)
{
printk(KERN_INFO "%s: initial execute module", OURMODNAME);
char *dest = kmalloc(sizeof("12.34"), GFP_KERNEL);
fp_printk(1243, 2, dest);
printk(KERN_INFO, "%s", dest);
return 0;
}
printk(KERN_INFO, "before exec\n");
char *r = kmalloc(sizeof("12.34"), GFP_KERNEL);
extern __visible void fp_printk(number, decimal_places, r);
printk(KERN_INFO, "%s: %s\n", "test_fp_printk", r);
printk(KERN_INFO, "after exec\n");
[1210228.128703] test_fp_printk: before exec
[1210228.128712] test_fp_printk: after exec
Crie alias para as tarefas que possuam longas linhas de comando - bash e zsh
Criando um gateway de internet com o Debian
Configuração básica do Conky para mostrar informações sobre a sua máquina no Desktop
Aprenda a criar músicas com Inteligência Artificial usando Suno AI
Entendendo o que é URI, URL, URN e conhecendo as diferenças entre POST e GET
Instalando Grub Customizer no Ubuntu 24.04
Preparando pendrive com GNU/Linux [Corretamente!]
Instalando Google Chrome no Fedora 40
Habilitando a importação de senhas no Firefox
Como corrigir o erro do VirtualBox travar a máquina virtual em tela cheia
Som continua saindo no auto-falante mesmo com headphone, como conserto... (3)
Como adicionar módulo de saúde da bateria dos notebooks Acer ao kernel... (39)