hostfile_aros.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * GRUB -- GRand Unified Bootloader
  3. * Copyright (C) 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. #ifndef GRUB_EMU_HOSTFILE_H
  19. #define GRUB_EMU_HOSTFILE_H 1
  20. #include <config.h>
  21. #include <stdarg.h>
  22. #include <sys/types.h>
  23. #include <sys/stat.h>
  24. #include <fcntl.h>
  25. #include <dirent.h>
  26. #include <unistd.h>
  27. #include <stdio.h>
  28. typedef struct dirent *grub_util_fd_dirent_t;
  29. typedef DIR *grub_util_fd_dir_t;
  30. static inline grub_util_fd_dir_t
  31. grub_util_fd_opendir (const char *name)
  32. {
  33. return opendir (name);
  34. }
  35. static inline void
  36. grub_util_fd_closedir (grub_util_fd_dir_t dirp)
  37. {
  38. closedir (dirp);
  39. }
  40. static inline grub_util_fd_dirent_t
  41. grub_util_fd_readdir (grub_util_fd_dir_t dirp)
  42. {
  43. return readdir (dirp);
  44. }
  45. static inline int
  46. grub_util_rmdir (const char *pathname)
  47. {
  48. return rmdir (pathname);
  49. }
  50. static inline int
  51. grub_util_unlink (const char *pathname)
  52. {
  53. return unlink (pathname);
  54. }
  55. static inline int
  56. grub_util_rename (const char *from, const char *to)
  57. {
  58. return rename (from, to);
  59. }
  60. #define grub_util_mkdir(a) mkdir ((a), 0755)
  61. struct grub_util_fd
  62. {
  63. enum { GRUB_UTIL_FD_FILE, GRUB_UTIL_FD_DISK } type;
  64. grub_uint64_t off;
  65. union
  66. {
  67. int fd;
  68. struct {
  69. struct IOExtTD *ioreq;
  70. struct MsgPort *mp;
  71. unsigned int is_floppy:1;
  72. unsigned int is_64:1;
  73. };
  74. };
  75. };
  76. typedef struct grub_util_fd *grub_util_fd_t;
  77. enum grub_util_fd_open_flags_t
  78. {
  79. GRUB_UTIL_FD_O_RDONLY = O_RDONLY,
  80. GRUB_UTIL_FD_O_WRONLY = O_WRONLY,
  81. GRUB_UTIL_FD_O_RDWR = O_RDWR,
  82. GRUB_UTIL_FD_O_CREATTRUNC = O_CREAT | O_TRUNC,
  83. GRUB_UTIL_FD_O_SYNC = (0
  84. #ifdef O_SYNC
  85. | O_SYNC
  86. #endif
  87. #ifdef O_FSYNC
  88. | O_FSYNC
  89. #endif
  90. )
  91. };
  92. #define GRUB_UTIL_FD_INVALID NULL
  93. #define GRUB_UTIL_FD_IS_VALID(x) ((x) != GRUB_UTIL_FD_INVALID)
  94. #define GRUB_UTIL_FD_STAT_IS_FUNCTIONAL 0
  95. #define DEFAULT_DIRECTORY "SYS:" GRUB_BOOT_DIR_NAME "/" GRUB_DIR_NAME
  96. #define DEFAULT_DEVICE_MAP DEFAULT_DIRECTORY "/device.map"
  97. #endif