Uczę się pisać moduły jądra dla Linuksa jako początkujący. Próbuję napisać każde zadanie i jego proces potomny do dziennika jądra za pomocą algorytmu DFS. Ale kiedy mogę skompilować kod za pomocą Makefile
, pokazuje powyższy błąd:Deklaracja funkcji nie jest prototypem w C
function declaration isn’t a prototype [-Werror=strict-prototypes]
struct task_struct *current;
Wskazuje ona słowa kluczowego w funkcji DFS task_struct
. Oto mój kod:
# include <linux/init.h>
# include <linux/kernel.h>
# include <linux/module.h>
# include <linux/sched.h>
# include <linux/list.h>
void DFS (struct task_struct *task)
{
struct task_struct *current;
struct list_head *list;
list_for_each (list, &task->children)
{
current = list_entry(list, struct task_struct, sibling);
printk(KERN_INFO "%d\t%d\t%s \n", (int)current->state, current->pid, current->comm);
if (current != NULL)
{
DFS(current);
}
}
}
int DFS_init(void)
{
printk(KERN_INFO "Loading the Second Module...\n");
printk(KERN_INFO "State\tPID\tName\n");
DFS(&init_task);
return 0;
}
void DFS_exit(void)
{
printk(KERN_INFO "Removing the Second Module...\n");
}
Ktoś wie jak to naprawić ??
Dlaczego _votedown_ ?? Możesz wytłumaczyć ?? –
C dopuszcza 'current'. Być może jest coś w nagłówkach, które zawierasz? –
W kernelu 'current' jest globalnie widoczną zmienną (wskaźnik) wskazującą bieżący wpis w tabeli procesu. – wildplasser