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

Re: [Minios-devel] [UNIKRAFT PATCH v4 11/22] lib/vfscore: introduce UK_FS_REGISTER



Hello Yuri,

This patch seems fine.

Reviewed-by: Sharan Santhanam <sharan.santhanam@xxxxxxxxx>

There is a checkpatch warning we can fix while upstreaming.

Thanks & Regards
Sharan

On 2/18/19 3:54 PM, Yuri Volchkov wrote:
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..5a1957fb 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 */
  };

WARNING: macros should not use a trailing semicolon
#52: FILE: lib/vfscore/include/vfscore/mount.h:109:
+#define UK_FS_REGISTER(fssw) static struct vfscore_fs_type     \
+       __attribute((__section__(".uk_fs_list")))               \
+       *__ptr_##fssw __used = &fssw;                           \
+
+#define UK_FS_REGISTER(fssw) static struct vfscore_fs_type     \
+       __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 71c876d2..95eb907b 100644
--- a/lib/vfscore/mount.c
+++ b/lib/vfscore/mount.c
@@ -62,20 +62,32 @@ UK_LIST_HEAD(mount_list);
   */
  static struct uk_mutex mount_lock = UK_MUTEX_INITIALIZER(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;


_______________________________________________
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®.