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.next, struct cake_pile, piles);
24 __cake_rd_stat(struct twimap* map)
26 struct cake_pile* pos = twimap_index(map, struct cake_pile*);
37 __cake_rd_psize(struct twimap* map)
39 struct cake_pile* pile = twimap_data(map, struct cake_pile*);
40 twimap_printf(map, "%u", pile->piece_size);
44 __cake_rd_ccount(struct twimap* map)
46 struct cake_pile* pile = twimap_data(map, struct cake_pile*);
47 twimap_printf(map, "%u", pile->cakes_count);
51 __cake_rd_alloced(struct twimap* map)
53 struct cake_pile* pile = twimap_data(map, struct cake_pile*);
54 twimap_printf(map, "%u", pile->alloced_pieces);
58 __cake_rd_ppc(struct twimap* map)
60 struct cake_pile* pile = twimap_data(map, struct cake_pile*);
61 twimap_printf(map, "%u", pile->pieces_per_cake);
65 __cake_rd_ppg(struct twimap* map)
67 struct cake_pile* pile = twimap_data(map, struct cake_pile*);
68 twimap_printf(map, "%u", pile->pg_per_cake);
72 cake_export_pile(struct twifs_node* root, struct cake_pile* pile)
74 struct twifs_node* pile_rt = twifs_dir_node(root, pile->pile_name);
76 struct twimap* map = twifs_mapping(pile_rt, pile, "piece_size");
77 map->read = __cake_rd_psize;
79 map = twifs_mapping(pile_rt, pile, "cake_count");
80 map->read = __cake_rd_ccount;
82 map = twifs_mapping(pile_rt, pile, "grabbed");
83 map->read = __cake_rd_alloced;
85 map = twifs_mapping(pile_rt, pile, "pieces_per_cake");
86 map->read = __cake_rd_ppc;
88 map = twifs_mapping(pile_rt, pile, "page_per_cake");
89 map->read = __cake_rd_ppg;
95 struct twifs_node* cake_root = twifs_dir_node(NULL, "cake");
97 struct twimap* map = twifs_mapping(cake_root, NULL, "pinkiepie");
98 map->reset = __cake_stat_reset;
99 map->go_next = __cake_stat_gonext;
100 map->read = __cake_rd_stat;
101 __cake_stat_reset(map);
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);