allow specifiying access mode when creating twifs file node
[lunaix-os.git] / lunaix-os / kernel / mm / cake_export.c
index 956423b2a8eaf53e4b72c3a78bb8f776b692ff91..cde255c4fdc2201568b027bcb427cfaf2175b5b3 100644 (file)
@@ -3,8 +3,8 @@
 
 extern struct llist_header piles;
 
-int
-__cake_stat_gonext(struct twimap* map)
+static int
+__twimap_gonext_pinkiepie(struct twimap* map)
 {
     struct cake_pile* pile = twimap_index(map, struct cake_pile*);
     if (pile->piles.next == &piles) {
@@ -14,55 +14,57 @@ __cake_stat_gonext(struct twimap* map)
     return 1;
 }
 
-void
-__cake_stat_reset(struct twimap* map)
+static void
+__twimap_reset_pinkiepie(struct twimap* map)
 {
-    map->index = container_of(piles.next, struct cake_pile, piles);
+    map->index = container_of(&piles, struct cake_pile, piles);
+    twimap_printf(map, "name cakes pages size slices actives\n");
 }
 
-void
-__cake_rd_stat(struct twimap* map)
+static void
+__twimap_read_pinkiepie(struct twimap* map)
 {
     struct cake_pile* pos = twimap_index(map, struct cake_pile*);
     twimap_printf(map,
-                  "%s %d %d %d %d\n",
+                  "%s %d %d %d %d %d\n",
                   pos->pile_name,
                   pos->cakes_count,
                   pos->pg_per_cake,
+                  pos->piece_size,
                   pos->pieces_per_cake,
                   pos->alloced_pieces);
 }
 
-void
-__cake_rd_psize(struct twimap* map)
+static void
+__twimap_read_piece_size(struct twimap* map)
 {
     struct cake_pile* pile = twimap_data(map, struct cake_pile*);
     twimap_printf(map, "%u", pile->piece_size);
 }
 
-void
-__cake_rd_ccount(struct twimap* map)
+static void
+__twimap_read_cake_count(struct twimap* map)
 {
     struct cake_pile* pile = twimap_data(map, struct cake_pile*);
     twimap_printf(map, "%u", pile->cakes_count);
 }
 
-void
-__cake_rd_alloced(struct twimap* map)
+static void
+__twimap_read_grabbed(struct twimap* map)
 {
     struct cake_pile* pile = twimap_data(map, struct cake_pile*);
     twimap_printf(map, "%u", pile->alloced_pieces);
 }
 
-void
-__cake_rd_ppc(struct twimap* map)
+static void
+__twimap_read_pieces_per_cake(struct twimap* map)
 {
     struct cake_pile* pile = twimap_data(map, struct cake_pile*);
     twimap_printf(map, "%u", pile->pieces_per_cake);
 }
 
-void
-__cake_rd_ppg(struct twimap* map)
+static void
+__twimap_read_page_per_cake(struct twimap* map)
 {
     struct cake_pile* pile = twimap_data(map, struct cake_pile*);
     twimap_printf(map, "%u", pile->pg_per_cake);
@@ -71,38 +73,28 @@ __cake_rd_ppg(struct twimap* map)
 void
 cake_export_pile(struct twifs_node* root, struct cake_pile* pile)
 {
-    struct twifs_node* pile_rt = twifs_dir_node(root, pile->pile_name);
-
-    struct twimap* map = twifs_mapping(pile_rt, pile, "piece_size");
-    map->read = __cake_rd_psize;
-
-    map = twifs_mapping(pile_rt, pile, "cake_count");
-    map->read = __cake_rd_ccount;
-
-    map = twifs_mapping(pile_rt, pile, "grabbed");
-    map->read = __cake_rd_alloced;
-
-    map = twifs_mapping(pile_rt, pile, "pieces_per_cake");
-    map->read = __cake_rd_ppc;
-
-    map = twifs_mapping(pile_rt, pile, "page_per_cake");
-    map->read = __cake_rd_ppg;
+    struct twifs_node* pile_rt;
+    
+    pile_rt = twifs_dir_node(root, pile->pile_name);
+
+    twimap_export_value(pile_rt, piece_size,        FSACL_ugR, pile);
+    twimap_export_value(pile_rt, cake_count,        FSACL_ugR, pile);
+    twimap_export_value(pile_rt, grabbed,           FSACL_ugR, pile);
+    twimap_export_value(pile_rt, pieces_per_cake,   FSACL_ugR, pile);
+    twimap_export_value(pile_rt, page_per_cake,     FSACL_ugR, pile);
 }
 
 void
 cake_export()
 {
-    struct twifs_node* cake_root = twifs_dir_node(NULL, "cake");
+    struct cake_pile *pos, *n;
+    struct twifs_node* cake_root;
+    
+    cake_root = twifs_dir_node(NULL, "cake");
 
-    struct twimap* map = twifs_mapping(cake_root, NULL, "pinkiepie");
-    map->reset = __cake_stat_reset;
-    map->go_next = __cake_stat_gonext;
-    map->read = __cake_rd_stat;
-    __cake_stat_reset(map);
+    twimap_export_list(cake_root, pinkiepie, FSACL_ugR, NULL);
 
-    struct cake_pile *pos, *n;
-    llist_for_each(pos, n, &piles, piles)
-    {
+    llist_for_each(pos, n, &piles, piles) {
         cake_export_pile(cake_root, pos);
     }
 }