Upgraded GRUB2 to 2.00 release.
[AROS.git] / arch / all-pc / boot / grub2-aros / grub-core / commands / cacheinfo.c
blobead6ff82cfcb046932f8d00eeabc02a1eff25c3e
1 /* cacheinfo.c - disk cache statistics */
2 /*
3 * GRUB -- GRand Unified Bootloader
4 * Copyright (C) 2008,2010 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/>.
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>
26 static grub_err_t
27 grub_rescue_cmd_info (struct grub_command *cmd __attribute__ ((unused)),
28 int argc __attribute__ ((unused)),
29 char *argv[] __attribute__ ((unused)))
31 unsigned long hits, misses;
33 grub_disk_cache_get_performance (&hits, &misses);
34 if (hits + misses)
36 unsigned long ratio = hits * 10000 / (hits + misses);
37 grub_printf ("(%lu.%lu%%)\n", ratio / 100, ratio % 100);
38 grub_printf_ (N_("Disk cache statistics: hits = %lu (%lu.%02lu%%),"
39 " misses = %lu\n"), ratio / 100, ratio % 100,
40 hits, misses);
42 else
43 grub_printf ("%s\n", _("No disk cache statistics available\n"));
45 return 0;
48 static grub_command_t cmd_cacheinfo;
50 GRUB_MOD_INIT(cacheinfo)
52 cmd_cacheinfo =
53 grub_register_command ("cacheinfo", grub_rescue_cmd_info,
54 0, N_("Get disk cache info."));
57 GRUB_MOD_FINI(cacheinfo)
59 grub_unregister_command (cmd_cacheinfo);