merge mainline into net
This commit is contained in:
commit
03a0046581
45 changed files with 682 additions and 233 deletions
|
@ -94,10 +94,8 @@ grub_cmd_cmp (grub_command_t cmd __attribute__ ((unused)),
|
|||
|
||||
cleanup:
|
||||
|
||||
if (buf1)
|
||||
grub_free (buf1);
|
||||
if (buf2)
|
||||
grub_free (buf2);
|
||||
grub_free (buf1);
|
||||
grub_free (buf2);
|
||||
if (file1)
|
||||
grub_file_close (file1);
|
||||
if (file2)
|
||||
|
|
|
@ -192,7 +192,7 @@ grub_cmd_play (grub_command_t cmd __attribute__ ((unused)),
|
|||
file = grub_file_open (args[0]);
|
||||
|
||||
if (! file)
|
||||
return grub_error (GRUB_ERR_FILE_NOT_FOUND, "file not found");
|
||||
return grub_error (GRUB_ERR_FILE_NOT_FOUND, "file `%s' not found", args[0]);
|
||||
|
||||
if (grub_file_read (file, &tempo, sizeof (tempo)) != sizeof (tempo))
|
||||
{
|
||||
|
@ -227,7 +227,7 @@ grub_cmd_play (grub_command_t cmd __attribute__ ((unused)),
|
|||
|
||||
if (*end)
|
||||
/* Was not a number either, assume it was supposed to be a file name. */
|
||||
return grub_error (GRUB_ERR_FILE_NOT_FOUND, "file not found");
|
||||
return grub_error (GRUB_ERR_FILE_NOT_FOUND, "file `%s' not found", args[0]);
|
||||
|
||||
grub_dprintf ("play","tempo = %d\n", tempo);
|
||||
|
||||
|
|
68
grub-core/commands/time.c
Normal file
68
grub-core/commands/time.c
Normal file
|
@ -0,0 +1,68 @@
|
|||
/* echo.c - Command to display a line of text */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2011 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/time.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/command.h>
|
||||
#include <grub/i18n.h>
|
||||
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_time (grub_command_t ctxt __attribute__ ((unused)),
|
||||
int argc, char **args)
|
||||
{
|
||||
grub_command_t cmd;
|
||||
grub_uint32_t start;
|
||||
grub_uint32_t end;
|
||||
|
||||
if (argc == 0)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "command expected");
|
||||
|
||||
cmd = grub_command_find (args[0]);
|
||||
|
||||
if (!cmd)
|
||||
return grub_error (GRUB_ERR_UNKNOWN_COMMAND, "Unknown command `%s'\n",
|
||||
args[0]);
|
||||
|
||||
start = grub_get_time_ms ();
|
||||
(cmd->func) (cmd, argc - 1, &args[1]);
|
||||
end = grub_get_time_ms ();
|
||||
|
||||
grub_printf ("Elapsed time: %d.%03d seconds \n", (end - start) / 1000,
|
||||
(end - start) % 1000);
|
||||
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
static grub_command_t cmd;
|
||||
|
||||
GRUB_MOD_INIT(time)
|
||||
{
|
||||
cmd = grub_register_command ("time", grub_cmd_time,
|
||||
N_("COMMAND [ARGS]"),
|
||||
N_("Measure time used by COMMAND"));
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(time)
|
||||
{
|
||||
grub_unregister_command (cmd);
|
||||
}
|
|
@ -28,6 +28,7 @@
|
|||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
static unsigned height, width, depth;
|
||||
static struct grub_video_mode_info *current_mode;
|
||||
|
||||
static int
|
||||
hook (const struct grub_video_mode_info *info)
|
||||
|
@ -41,7 +42,13 @@ hook (const struct grub_video_mode_info *info)
|
|||
if (info->mode_number == GRUB_VIDEO_MODE_NUMBER_INVALID)
|
||||
grub_printf (" ");
|
||||
else
|
||||
grub_printf (" 0x%03x ", info->mode_number);
|
||||
{
|
||||
if (current_mode && info->mode_number == current_mode->mode_number)
|
||||
grub_printf ("*");
|
||||
else
|
||||
grub_printf (" ");
|
||||
grub_printf (" 0x%03x ", info->mode_number);
|
||||
}
|
||||
grub_printf ("%4d x %4d x %2d ", info->width, info->height, info->bpp);
|
||||
|
||||
if (info->mode_type & GRUB_VIDEO_MODE_TYPE_PURE_TEXT)
|
||||
|
@ -122,6 +129,8 @@ grub_cmd_videoinfo (grub_command_t cmd __attribute__ ((unused)),
|
|||
|
||||
FOR_VIDEO_ADAPTERS (adapter)
|
||||
{
|
||||
struct grub_video_mode_info info;
|
||||
|
||||
grub_printf ("Adapter '%s':\n", adapter->name);
|
||||
|
||||
if (!adapter->iterate)
|
||||
|
@ -130,7 +139,17 @@ grub_cmd_videoinfo (grub_command_t cmd __attribute__ ((unused)),
|
|||
continue;
|
||||
}
|
||||
|
||||
if (adapter->id != id)
|
||||
current_mode = NULL;
|
||||
|
||||
if (adapter->id == id)
|
||||
{
|
||||
if (grub_video_get_info (&info) == GRUB_ERR_NONE)
|
||||
current_mode = &info;
|
||||
else
|
||||
/* Don't worry about errors. */
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (adapter->init ())
|
||||
{
|
||||
|
@ -145,6 +164,8 @@ grub_cmd_videoinfo (grub_command_t cmd __attribute__ ((unused)),
|
|||
|
||||
adapter->iterate (hook);
|
||||
|
||||
current_mode = NULL;
|
||||
|
||||
if (adapter->id != id)
|
||||
{
|
||||
if (adapter->fini ())
|
||||
|
|
|
@ -255,8 +255,7 @@ match_devices (const regex_t *regexp, int noparts)
|
|||
for (i = 0; devs && devs[i]; i++)
|
||||
grub_free (devs[i]);
|
||||
|
||||
if (devs)
|
||||
grub_free (devs);
|
||||
grub_free (devs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -342,20 +341,17 @@ match_files (const char *prefix, const char *suffix, const char *end,
|
|||
|
||||
fail:
|
||||
|
||||
if (dir)
|
||||
grub_free (dir);
|
||||
grub_free (dir);
|
||||
|
||||
for (i = 0; files && files[i]; i++)
|
||||
grub_free (files[i]);
|
||||
|
||||
if (files)
|
||||
grub_free (files);
|
||||
grub_free (files);
|
||||
|
||||
if (dev)
|
||||
grub_device_close (dev);
|
||||
|
||||
if (device_name)
|
||||
grub_free (device_name);
|
||||
grub_free (device_name);
|
||||
|
||||
grub_error_pop ();
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue