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, n_cakes, pg/cake, slices/cake, n_slices\n");
25 __cake_rd_stat(struct twimap* map)
27 struct cake_pile* pos = twimap_index(map, struct cake_pile*);
38 __cake_rd_psize(struct twimap* map)
40 struct cake_pile* pile = twimap_data(map, struct cake_pile*);
41 twimap_printf(map, "%u", pile->piece_size);
45 __cake_rd_ccount(struct twimap* map)
47 struct cake_pile* pile = twimap_data(map, struct cake_pile*);
48 twimap_printf(map, "%u", pile->cakes_count);
52 __cake_rd_alloced(struct twimap* map)
54 struct cake_pile* pile = twimap_data(map, struct cake_pile*);
55 twimap_printf(map, "%u", pile->alloced_pieces);
59 __cake_rd_ppc(struct twimap* map)
61 struct cake_pile* pile = twimap_data(map, struct cake_pile*);
62 twimap_printf(map, "%u", pile->pieces_per_cake);
66 __cake_rd_ppg(struct twimap* map)
68 struct cake_pile* pile = twimap_data(map, struct cake_pile*);
69 twimap_printf(map, "%u", pile->pg_per_cake);
73 cake_export_pile(struct twifs_node* root, struct cake_pile* pile)
75 struct twifs_node* pile_rt = twifs_dir_node(root, pile->pile_name);
77 struct twimap* map = twifs_mapping(pile_rt, pile, "piece_size");
78 map->read = __cake_rd_psize;
80 map = twifs_mapping(pile_rt, pile, "cake_count");
81 map->read = __cake_rd_ccount;
83 map = twifs_mapping(pile_rt, pile, "grabbed");
84 map->read = __cake_rd_alloced;
86 map = twifs_mapping(pile_rt, pile, "pieces_per_cake");
87 map->read = __cake_rd_ppc;
89 map = twifs_mapping(pile_rt, pile, "page_per_cake");
90 map->read = __cake_rd_ppg;
96 struct twifs_node* cake_root = twifs_dir_node(NULL, "cake");
98 struct twimap* map = twifs_mapping(cake_root, NULL, "pinkiepie");
99 map->reset = __cake_stat_reset;
100 map->go_next = __cake_stat_gonext;
101 map->read = __cake_rd_stat;
103 struct cake_pile *pos, *n;
104 llist_for_each(pos, n, &piles, piles)
106 cake_export_pile(cake_root, pos);
109 EXPORT_TWIFS_PLUGIN(cake_alloc, cake_export);