hostdisk.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * GRUB -- GRand Unified Bootloader
  3. * Copyright (C) 1999,2000,2001,2002,2003,2004,2006,2007,2008,2009,2010,2011,2012,2013 Free Software Foundation, Inc.
  4. *
  5. * GRUB is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * GRUB is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #include <config-util.h>
  19. #include <grub/disk.h>
  20. #include <grub/partition.h>
  21. #include <grub/msdos_partition.h>
  22. #include <grub/types.h>
  23. #include <grub/err.h>
  24. #include <grub/emu/misc.h>
  25. #include <grub/emu/hostdisk.h>
  26. #include <grub/emu/getroot.h>
  27. #include <grub/misc.h>
  28. #include <grub/i18n.h>
  29. #include <grub/list.h>
  30. #include <stdio.h>
  31. #include <stdlib.h>
  32. #include <string.h>
  33. #include <ctype.h>
  34. #include <assert.h>
  35. #include <unistd.h>
  36. #include <sys/types.h>
  37. #include <sys/stat.h>
  38. #include <fcntl.h>
  39. #include <errno.h>
  40. #include <limits.h>
  41. #include <sys/ioctl.h>
  42. #include <Drivers.h>
  43. #include <StorageDefs.h>
  44. grub_int64_t
  45. grub_util_get_fd_size_os (grub_util_fd_t fd,
  46. const char *name __attribute__ ((unused)),
  47. unsigned *log_secsize)
  48. {
  49. device_geometry part;
  50. unsigned lg;
  51. if (ioctl (fd, B_GET_GEOMETRY, &part, sizeof (part)) < 0)
  52. return -1;
  53. for (lg = 0; (1 << lg) < part.bytes_per_sector; lg++);
  54. if (log_secsize)
  55. *log_secsize= lg;
  56. return ((grub_uint64_t) part.cylinder_count
  57. * (grub_uint64_t) part.head_count
  58. * (grub_uint64_t) part.sectors_per_track
  59. * (grub_uint64_t) part.bytes_per_sector);
  60. }
  61. void
  62. grub_hostdisk_flush_initial_buffer (const char *os_dev __attribute__ ((unused)))
  63. {
  64. }