]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
Remove grub_fs_iterate
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Fri, 26 Mar 2010 23:27:42 +0000 (00:27 +0100)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Fri, 26 Mar 2010 23:27:42 +0000 (00:27 +0100)
include/grub/fs.h
kern/fs.c

index 45f515768a4738d9d427eb3a21391e571a517170..3368eb553430d5d000f8353061842227d5670df5 100644 (file)
@@ -24,6 +24,8 @@
 #include <grub/symbol.h>
 #include <grub/types.h>
 
+#include <grub/list.h>
+
 /* Forward declaration is required, because of mutual reference.  */
 struct grub_file;
 
@@ -38,6 +40,9 @@ struct grub_dirhook_info
 /* Filesystem descriptor.  */
 struct grub_fs
 {
+  /* The next filesystem.  */
+  struct grub_fs *next;
+
   /* My name.  */
   const char *name;
 
@@ -72,9 +77,6 @@ struct grub_fs
   /* Whether this filesystem reserves first sector for DOS-style boot.  */
   int reserved_first_sector;
 #endif
-
-  /* The next filesystem.  */
-  struct grub_fs *next;
 };
 typedef struct grub_fs *grub_fs_t;
 
@@ -87,10 +89,22 @@ extern struct grub_fs grub_fs_blocklist;
    the linked list GRUB_FS_LIST through the function grub_fs_register.  */
 typedef int (*grub_fs_autoload_hook_t) (void);
 extern grub_fs_autoload_hook_t EXPORT_VAR(grub_fs_autoload_hook);
+extern grub_fs_t EXPORT_VAR (grub_fs_list);
+
+static inline void
+grub_fs_register (grub_fs_t fs)
+{
+  grub_list_push (GRUB_AS_LIST_P (&grub_fs_list), GRUB_AS_LIST (fs));
+}
+
+static inline void
+grub_fs_unregister (grub_fs_t fs)
+{
+  grub_list_remove (GRUB_AS_LIST_P (&grub_fs_list), GRUB_AS_LIST (fs));
+}
+
+#define FOR_FILESYSTEMS(var) FOR_LIST_ELEMENTS((var), (grub_fs_list))
 
-void EXPORT_FUNC(grub_fs_register) (grub_fs_t fs);
-void EXPORT_FUNC(grub_fs_unregister) (grub_fs_t fs);
-void EXPORT_FUNC(grub_fs_iterate) (int (*hook) (const grub_fs_t fs));
 grub_fs_t EXPORT_FUNC(grub_fs_probe) (grub_device_t device);
 
 #endif /* ! GRUB_FS_HEADER */
index 0c456377f3a0cdf0dabaf069ebd693fa809209a1..cf800f4cc4c92ae89f04478bba2ec16dad0b67e4 100644 (file)
--- a/kern/fs.c
+++ b/kern/fs.c
 #include <grub/mm.h>
 #include <grub/term.h>
 
-static grub_fs_t grub_fs_list;
+grub_fs_t grub_fs_list = 0;
 
 grub_fs_autoload_hook_t grub_fs_autoload_hook = 0;
 
-void
-grub_fs_register (grub_fs_t fs)
-{
-  fs->next = grub_fs_list;
-  grub_fs_list = fs;
-}
-
-void
-grub_fs_unregister (grub_fs_t fs)
-{
-  grub_fs_t *p, q;
-
-  for (p = &grub_fs_list, q = *p; q; p = &(q->next), q = q->next)
-    if (q == fs)
-      {
-       *p = q->next;
-       break;
-      }
-}
-
-void
-grub_fs_iterate (int (*hook) (const grub_fs_t fs))
-{
-  grub_fs_t p;
-
-  for (p = grub_fs_list; p; p = p->next)
-    if (hook (p))
-      break;
-}
-
 grub_fs_t
 grub_fs_probe (grub_device_t device)
 {