1
/* autofs.c - support auto-loading from fs.lst */
3
* GRUB -- GRand Unified Bootloader
4
* Copyright (C) 2009 Free Software Foundation, Inc.
6
* GRUB is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
11
* GRUB is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
23
#include <grub/misc.h>
25
#include <grub/normal.h>
27
/* This is used to store the names of filesystem modules for auto-loading. */
28
static grub_named_list_t fs_module_list;
30
/* The auto-loading hook for filesystems. */
32
autoload_fs_module (void)
36
while ((p = fs_module_list) != NULL)
38
if (! grub_dl_get (p->name) && grub_dl_load (p->name))
44
fs_module_list = p->next;
52
/* Read the file fs.lst for auto-loading. */
54
read_fs_list (const char *prefix)
60
filename = grub_xasprintf ("%s/fs.lst", prefix);
64
grub_fs_autoload_hook_t tmp_autoload_hook;
66
/* This rules out the possibility that read_fs_list() is invoked
67
recursively when we call grub_file_open() below. */
68
tmp_autoload_hook = grub_fs_autoload_hook;
69
grub_fs_autoload_hook = NULL;
71
file = grub_file_open (filename);
74
/* Override previous fs.lst. */
75
while (fs_module_list)
77
grub_named_list_t tmp;
78
tmp = fs_module_list->next;
79
grub_free (fs_module_list);
88
grub_named_list_t fs_mod;
90
buf = grub_file_getline (file);
95
q = buf + grub_strlen (buf) - 1;
98
while (grub_isspace (*p))
101
while (p < q && grub_isspace (*q))
104
/* If the line is empty, skip it. */
108
fs_mod = grub_malloc (sizeof (*fs_mod));
112
fs_mod->name = grub_strdup (p);
119
fs_mod->next = fs_module_list;
120
fs_module_list = fs_mod;
123
grub_file_close (file);
124
grub_fs_autoload_hook = tmp_autoload_hook;
127
grub_free (filename);
132
grub_errno = GRUB_ERR_NONE;
135
grub_fs_autoload_hook = autoload_fs_module;