1 #include <lunaix/fs/twifs.h>
2 #include <lunaix/mm/cake.h>
4 extern struct llist_header piles;
7 __cake_stat_gonext(struct twimap* map)
9 struct cake_pile* pile = twimap_index(map, struct cake_pile*);
10 if (pile->piles.next == &piles) {
13 map->index = list_entry(pile->piles.next, struct cake_pile, piles);
18 __cake_stat_reset(struct twimap* map)
20 map->index = container_of(&piles, struct cake_pile, piles);
21 twimap_printf(map, "name cakes pages size slices actives\n");
25 __cake_rd_stat(struct twimap* map)
27 struct cake_pile* pos = twimap_index(map, struct cake_pile*);
29 "%s %d %d %d %d %d\n",
39 __cake_rd_psize(struct twimap* map)
41 struct cake_pile* pile = twimap_data(map, struct cake_pile*);
42 twimap_printf(map, "%u", pile->piece_size);
46 __cake_rd_ccount(struct twimap* map)
48 struct cake_pile* pile = twimap_data(map, struct cake_pile*);
49 twimap_printf(map, "%u", pile->cakes_count);
53 __cake_rd_alloced(struct twimap* map)
55 struct cake_pile* pile = twimap_data(map, struct cake_pile*);
56 twimap_printf(map, "%u", pile->alloced_pieces);
60 __cake_rd_ppc(struct twimap* map)
62 struct cake_pile* pile = twimap_data(map, struct cake_pile*);
63 twimap_printf(map, "%u", pile->pieces_per_cake);
67 __cake_rd_ppg(struct twimap* map)
69 struct cake_pile* pile = twimap_data(map, struct cake_pile*);
70 twimap_printf(map, "%u", pile->pg_per_cake);
74 cake_export_pile(struct twifs_node* root, struct cake_pile* pile)
76 struct twifs_node* pile_rt = twifs_dir_node(root, pile->pile_name);
78 struct twimap* map = twifs_mapping(pile_rt, pile, "piece_size");
79 map->read = __cake_rd_psize;
81 map = twifs_mapping(pile_rt, pile, "cake_count");
82 map->read = __cake_rd_ccount;
84 map = twifs_mapping(pile_rt, pile, "grabbed");
85 map->read = __cake_rd_alloced;
87 map = twifs_mapping(pile_rt, pile, "pieces_per_cake");
88 map->read = __cake_rd_ppc;
90 map = twifs_mapping(pile_rt, pile, "page_per_cake");
91 map->read = __cake_rd_ppg;
97 struct twifs_node* cake_root = twifs_dir_node(NULL, "cake");
99 struct twimap* map = twifs_mapping(cake_root, NULL, "pinkiepie");
100 map->reset = __cake_stat_reset;
101 map->go_next = __cake_stat_gonext;
102 map->read = __cake_rd_stat;
104 struct cake_pile *pos, *n;
105 llist_for_each(pos, n, &piles, piles)
107 cake_export_pile(cake_root, pos);
110 EXPORT_TWIFS_PLUGIN(cake_alloc, cake_export);