2008-06-19 Robert Millan <rmh@aybabtu.com>
* commands/search.c (search_label, search_fs_uuid, search_file): Print search result when not saving to variable, not the other way around. When saving to variable, abort iteration as soon as a match is found.
This commit is contained in:
parent
73940cec58
commit
6ce63911ab
2 changed files with 27 additions and 12 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2008-06-19 Robert Millan <rmh@aybabtu.com>
|
||||||
|
|
||||||
|
* commands/search.c (search_label, search_fs_uuid, search_file): Print
|
||||||
|
search result when not saving to variable, not the other way around.
|
||||||
|
When saving to variable, abort iteration as soon as a match is found.
|
||||||
|
|
||||||
2008-06-19 Robert Millan <rmh@aybabtu.com>
|
2008-06-19 Robert Millan <rmh@aybabtu.com>
|
||||||
|
|
||||||
* util/update-grub_lib.in (prepare_grub_to_access_device): Remove
|
* util/update-grub_lib.in (prepare_grub_to_access_device): Remove
|
||||||
|
|
|
@ -46,6 +46,7 @@ search_label (const char *key, const char *var)
|
||||||
int iterate_device (const char *name)
|
int iterate_device (const char *name)
|
||||||
{
|
{
|
||||||
grub_device_t dev;
|
grub_device_t dev;
|
||||||
|
int abort = 0;
|
||||||
|
|
||||||
dev = grub_device_open (name);
|
dev = grub_device_open (name);
|
||||||
if (dev)
|
if (dev)
|
||||||
|
@ -63,12 +64,14 @@ search_label (const char *key, const char *var)
|
||||||
if (grub_strcmp (label, key) == 0)
|
if (grub_strcmp (label, key) == 0)
|
||||||
{
|
{
|
||||||
/* Found! */
|
/* Found! */
|
||||||
|
count++;
|
||||||
if (var)
|
if (var)
|
||||||
{
|
{
|
||||||
grub_printf (" %s", name);
|
grub_env_set (var, name);
|
||||||
if (count++ == 0)
|
abort = 1;
|
||||||
grub_env_set (var, name);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
grub_printf (" %s", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
grub_free (label);
|
grub_free (label);
|
||||||
|
@ -79,7 +82,7 @@ search_label (const char *key, const char *var)
|
||||||
}
|
}
|
||||||
|
|
||||||
grub_errno = GRUB_ERR_NONE;
|
grub_errno = GRUB_ERR_NONE;
|
||||||
return 0;
|
return abort;
|
||||||
}
|
}
|
||||||
|
|
||||||
grub_device_iterate (iterate_device);
|
grub_device_iterate (iterate_device);
|
||||||
|
@ -97,6 +100,7 @@ search_fs_uuid (const char *key, const char *var)
|
||||||
int iterate_device (const char *name)
|
int iterate_device (const char *name)
|
||||||
{
|
{
|
||||||
grub_device_t dev;
|
grub_device_t dev;
|
||||||
|
int abort = 0;
|
||||||
|
|
||||||
dev = grub_device_open (name);
|
dev = grub_device_open (name);
|
||||||
if (dev)
|
if (dev)
|
||||||
|
@ -114,12 +118,14 @@ search_fs_uuid (const char *key, const char *var)
|
||||||
if (grub_strcmp (uuid, key) == 0)
|
if (grub_strcmp (uuid, key) == 0)
|
||||||
{
|
{
|
||||||
/* Found! */
|
/* Found! */
|
||||||
|
count++;
|
||||||
if (var)
|
if (var)
|
||||||
{
|
{
|
||||||
grub_printf (" %s", name);
|
grub_env_set (var, name);
|
||||||
if (count++ == 0)
|
abort = 1;
|
||||||
grub_env_set (var, name);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
grub_printf (" %s", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
grub_free (uuid);
|
grub_free (uuid);
|
||||||
|
@ -130,7 +136,7 @@ search_fs_uuid (const char *key, const char *var)
|
||||||
}
|
}
|
||||||
|
|
||||||
grub_errno = GRUB_ERR_NONE;
|
grub_errno = GRUB_ERR_NONE;
|
||||||
return 0;
|
return abort;
|
||||||
}
|
}
|
||||||
|
|
||||||
grub_device_iterate (iterate_device);
|
grub_device_iterate (iterate_device);
|
||||||
|
@ -151,6 +157,7 @@ search_file (const char *key, const char *var)
|
||||||
grub_size_t len;
|
grub_size_t len;
|
||||||
char *p;
|
char *p;
|
||||||
grub_file_t file;
|
grub_file_t file;
|
||||||
|
int abort = 0;
|
||||||
|
|
||||||
len = grub_strlen (name) + 2 + grub_strlen (key) + 1;
|
len = grub_strlen (name) + 2 + grub_strlen (key) + 1;
|
||||||
p = grub_realloc (buf, len);
|
p = grub_realloc (buf, len);
|
||||||
|
@ -164,18 +171,20 @@ search_file (const char *key, const char *var)
|
||||||
if (file)
|
if (file)
|
||||||
{
|
{
|
||||||
/* Found! */
|
/* Found! */
|
||||||
|
count++;
|
||||||
if (var)
|
if (var)
|
||||||
{
|
{
|
||||||
grub_printf (" %s", name);
|
grub_env_set (var, name);
|
||||||
if (count++ == 0)
|
abort = 1;
|
||||||
grub_env_set (var, name);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
grub_printf (" %s", name);
|
||||||
|
|
||||||
grub_file_close (file);
|
grub_file_close (file);
|
||||||
}
|
}
|
||||||
|
|
||||||
grub_errno = GRUB_ERR_NONE;
|
grub_errno = GRUB_ERR_NONE;
|
||||||
return 0;
|
return abort;
|
||||||
}
|
}
|
||||||
|
|
||||||
grub_device_iterate (iterate_device);
|
grub_device_iterate (iterate_device);
|
||||||
|
|
Loading…
Reference in a new issue