[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Minios-devel] [UNIKRAFT PATCH 10/22] lib/vfscore: introduce UK_FS_REGISTER



The macro registers the filesystem in the static array

Signed-off-by: Yuri Volchkov <yuri.volchkov@xxxxxxxxx>
---
 lib/vfscore/Makefile.uk             |  2 ++
 lib/vfscore/extra.ld                |  9 +++++++++
 lib/vfscore/include/vfscore/mount.h |  6 +++++-
 lib/vfscore/mount.c                 | 24 ++++++++++++++++++------
 4 files changed, 34 insertions(+), 7 deletions(-)
 create mode 100644 lib/vfscore/extra.ld

diff --git a/lib/vfscore/Makefile.uk b/lib/vfscore/Makefile.uk
index 1246ae53..06933d96 100644
--- a/lib/vfscore/Makefile.uk
+++ b/lib/vfscore/Makefile.uk
@@ -5,3 +5,5 @@ CINCLUDES-y += -I$(LIBVFSCORE_BASE)/include
 LIBVFSCORE_SRCS-y += $(LIBVFSCORE_BASE)/fd.c
 LIBVFSCORE_SRCS-y += $(LIBVFSCORE_BASE)/file.c
 LIBVFSCORE_SRCS-y += $(LIBVFSCORE_BASE)/stdio.c
+
+EXTRA_LD_SCRIPT-$(CONFIG_LIBVFSCORE) += $(LIBVFSCORE_BASE)/extra.ld
\ No newline at end of file
diff --git a/lib/vfscore/extra.ld b/lib/vfscore/extra.ld
new file mode 100644
index 00000000..173b2350
--- /dev/null
+++ b/lib/vfscore/extra.ld
@@ -0,0 +1,9 @@
+SECTIONS
+{
+       .uk_fs_list : {
+               PROVIDE(uk_fslist_start = .);
+               KEEP (*(.uk_fs_list))
+                PROVIDE(uk_fslist_end = .);
+       }
+}
+INSERT AFTER .text;
diff --git a/lib/vfscore/include/vfscore/mount.h 
b/lib/vfscore/include/vfscore/mount.h
index 7a638dbe..b4a07323 100644
--- a/lib/vfscore/include/vfscore/mount.h
+++ b/lib/vfscore/include/vfscore/mount.h
@@ -100,12 +100,16 @@ struct mount {
 /*
  * Filesystem type switch table.
  */
-struct vfssw {
+struct vfscore_fs_type {
        const char      *vs_name;       /* name of file system */
        int             (*vs_init)(void); /* initialize routine */
        struct vfsops   *vs_op;         /* pointer to vfs operation */
 };
 
+#define UK_FS_REGISTER(fssw)                                   \
+       static void __attribute((__section__(".uk_fs_list")))   \
+               *__ptr_##fssw __used = &fssw;                           \
+
 /*
  * Operations supported on virtual file system.
  */
diff --git a/lib/vfscore/mount.c b/lib/vfscore/mount.c
index 04f96c4c..9158b5d9 100644
--- a/lib/vfscore/mount.c
+++ b/lib/vfscore/mount.c
@@ -59,20 +59,32 @@ UK_LIST_HEAD(mount_list);
  */
 static struct uk_mutex mount_lock;
 
+extern const struct vfscore_fs_type *uk_fslist_start;
+extern const struct vfscore_fs_type *uk_fslist_end;
+
+#define for_each_fs(iter)                      \
+       for (iter = &uk_fslist_start;   \
+            iter < &uk_fslist_end;             \
+            iter++)
+
 /*
  * Lookup file system.
  */
-static const struct vfssw *
+static const struct vfscore_fs_type *
 fs_getfs(const char *name)
 {
-       const struct vfssw *fs;
+       const struct vfscore_fs_type *fs = NULL, **__fs;
+
+       for_each_fs(__fs) {
+               fs = *__fs;
+               if (fs == NULL)
+                       continue;
 
-       for (fs = vfssw; fs->vs_name; fs++) {
                if (!strncmp(name, fs->vs_name, FSMAXNAMES))
                        break;
        }
-       if (!fs->vs_name)
-               return nullptr;
+       if (!fs || !fs->vs_name)
+               return NULL;
        return fs;
 }
 
@@ -96,7 +108,7 @@ int device_close(struct device *dev)
 int
 sys_mount(const char *dev, const char *dir, const char *fsname, int flags, 
const void *data)
 {
-       const struct vfssw *fs;
+       const struct vfscore_fs_type *fs;
        struct mount *mp;
        struct device *device;
        struct dentry *dp_covered = NULL;
-- 
2.19.2


_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.