]> git.proxmox.com Git - grub2.git/blame - grub-core/commands/cacheinfo.c
* grub-core/commands/ls.c (grub_ls_list_devices): Disable
[grub2.git] / grub-core / commands / cacheinfo.c
CommitLineData
c5dc1690
SJ
1/* cacheinfo.c - disk cache statistics */
2/*
3 * GRUB -- GRand Unified Bootloader
4 * Copyright (C) 2008,2010 Free Software Foundation, Inc.
5 *
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.
10 *
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.
15 *
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/>.
18 */
19
20#include <grub/dl.h>
21#include <grub/misc.h>
22#include <grub/command.h>
23#include <grub/i18n.h>
24#include <grub/disk.h>
25
26static grub_err_t
27grub_rescue_cmd_info (struct grub_command *cmd __attribute__ ((unused)),
28 int argc __attribute__ ((unused)),
29 char *argv[] __attribute__ ((unused)))
30{
31 unsigned long hits, misses;
32
33 grub_disk_cache_get_performance (&hits, &misses);
c5dc1690
SJ
34 if (hits + misses)
35 {
36 unsigned long ratio = hits * 10000 / (hits + misses);
37 grub_printf ("(%lu.%lu%%)\n", ratio / 100, ratio % 100);
9c4b5c13
VS
38 grub_printf_ (N_("Disk cache statistics: hits = %lu (%lu.%02lu%%),"
39 " misses = %lu\n"), ratio / 100, ratio % 100,
40 hits, misses);
c5dc1690
SJ
41 }
42 else
9c4b5c13 43 grub_printf ("%s\n", _("No disk cache statistics available\n"));
c5dc1690
SJ
44
45 return 0;
46}
47
48static grub_command_t cmd_cacheinfo;
49
50GRUB_MOD_INIT(cacheinfo)
51{
52 cmd_cacheinfo =
53 grub_register_command ("cacheinfo", grub_rescue_cmd_info,
54 0, N_("Get disk cache info."));
55}
56
57GRUB_MOD_FINI(cacheinfo)
58{
59 grub_unregister_command (cmd_cacheinfo);
60}