X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/c50398ab4cb09658b3b3fff74804d2f26df785e7..4b6190b935dd75d8ddd514a05c7c7343e32c0cdc:/lunaix-os/kernel/fs/fs_export.c diff --git a/lunaix-os/kernel/fs/fs_export.c b/lunaix-os/kernel/fs/fs_export.c new file mode 100644 index 0000000..13d6557 --- /dev/null +++ b/lunaix-os/kernel/fs/fs_export.c @@ -0,0 +1,47 @@ +#include +#include +#include + +extern struct llist_header all_mnts; + +void +__mount_read(struct twimap* map) +{ + char path[512]; + struct v_mount* mnt = twimap_index(map, struct v_mount*); + size_t len = vfs_get_path(mnt->mnt_point, path, 511, 0); + path[len] = '\0'; + twimap_printf(map, "%s at %s", mnt->super_block->fs->fs_name.value, path); + if ((mnt->flags & MNT_RO)) { + twimap_printf(map, ", ro"); + } else { + twimap_printf(map, ", rw"); + } + twimap_printf(map, "\n"); +} + +int +__mount_next(struct twimap* map) +{ + struct v_mount* mnt = twimap_index(map, struct v_mount*); + if (mnt->list.next == &all_mnts) { + return 0; + } + map->index = container_of(mnt->list.next, struct v_mount, list); + return 1; +} + +void +__mount_reset(struct twimap* map) +{ + map->index = container_of(all_mnts.next, struct v_mount, list); +} + +void +vfs_export_attributes() +{ + struct twimap* map = twifs_mapping(NULL, NULL, "mounts"); + map->read = __mount_read; + map->go_next = __mount_next; + map->reset = __mount_reset; +} \ No newline at end of file