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
Atualizando o Passado: Linux no Lenovo G460 em 2025
aaPanel - Um Painel de Hospedagem Gratuito e Poderoso
O macete do Warsaw no Linux Mint e cia
Visualizar arquivos em formato markdown (ex.: README.md) pelo terminal
Dando - teoricamente - um gás no Gnome-Shell do Arch Linux
Como instalar o Google Cloud CLI no Ubuntu/Debian
Mantenha seu Sistema Leve e Rápido com a Limpeza do APT!
Procurando vídeos de YouTube pelo terminal e assistindo via mpv (2025)
Pastas da raiz foram para a área de trabalho [RESOLVIDO] (11)
Será que eu deveria apreender C/C++ para desenvolver para Linux? (4)