summaryrefslogtreecommitdiff
path: root/lists/lists.c
blob: 23d6e08a2f1d2c8b935525527e67ed06290eb21f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <linux/kernel.h>
#include <linux/module.h>

#define LENGTH 5

struct node {
	struct list_head l;
	int dato;
};

int init_module(void)
{
	int i;
	struct node head, aux[LENGTH], *aux2;
	struct list_head* iter;

	INIT_LIST_HEAD(&head.l);
	head.dato = 666;

	for (i = 0; i < LENGTH; i++) {
		aux[i].dato = i;

		list_add_tail(&aux[i].l, &head.l);
	}

	list_for_each(iter, &head.l) {
		aux2 = list_entry(iter, struct node, l);
		printk(KERN_INFO "%d", aux2->dato);
	}

	printk(KERN_INFO "Por cierto, en 0x0 hay: %d", ((struct node *)0)->dato);

	return 0;
}

void cleanup_module(void)
{
}

MODULE_LICENSE("GPL");
MODULE_AUTHOR("Guillermo Ramos");