dffff0ae70f50b4042084be127a51f32c132fa8b
[lunaix-os.git] / lunaix-os / kernel / fs / fs_export.c
1 #include <lunaix/foptions.h>
2 #include <lunaix/fs.h>
3 #include <lunaix/fs/twifs.h>
4
5 extern struct llist_header all_mnts;
6
7 void
8 __mount_read(struct twimap* map)
9 {
10     char path[512];
11     struct v_mount* mnt = twimap_index(map, struct v_mount*);
12     size_t len = vfs_get_path(mnt->mnt_point, path, 511, 0);
13     path[len] = '\0';
14     twimap_printf(map, "%s at %s", mnt->super_block->fs->fs_name.value, path);
15     if ((mnt->flags & MNT_RO)) {
16         twimap_printf(map, ", ro");
17     } else {
18         twimap_printf(map, ", rw");
19     }
20     twimap_printf(map, "\n");
21 }
22
23 int
24 __mount_next(struct twimap* map)
25 {
26     struct v_mount* mnt = twimap_index(map, struct v_mount*);
27     if (mnt->list.next == &all_mnts) {
28         return 0;
29     }
30     map->index = container_of(mnt->list.next, struct v_mount, list);
31     return 1;
32 }
33
34 void
35 __mount_reset(struct twimap* map)
36 {
37     map->index = container_of(all_mnts.next, struct v_mount, list);
38 }
39
40 void
41 __version_rd(struct twimap* map)
42 {
43     twimap_printf(map,
44                   "LunaixOS version %s (gnu-cc %s) %s %s",
45                   CONFIG_LUNAIX_VER,
46                   __VERSION__,
47                   __DATE__,
48                   __TIME__);
49 }
50
51 void
52 vfs_export_attributes()
53 {
54     struct twimap* map = twifs_mapping(NULL, NULL, "mounts");
55     map->read = __mount_read;
56     map->go_next = __mount_next;
57     map->reset = __mount_reset;
58
59     map = twifs_mapping(NULL, NULL, "version");
60     map->read = __version_rd;
61 }
62 EXPORT_TWIFS_PLUGIN(vfs_general, vfs_export_attributes);