Fix cross compilation (e.g. on Darwin). Following changes to make.tmpl,
[AROS.git] / arch / all-pc / boot / grub2-aros / include / grub / osdep / hostfile_unix.h
blob9ffe46fa3ca50f68e3dd4853d09cf555523bc14a
1 /*
2 * GRUB -- GRand Unified Bootloader
3 * Copyright (C) 2010,2011,2012,2013 Free Software Foundation, Inc.
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.
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.
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/>.
19 #ifndef GRUB_EMU_HOSTFILE_H
20 #define GRUB_EMU_HOSTFILE_H 1
22 #include <config.h>
23 #include <stdarg.h>
25 #include <grub/symbol.h>
26 #include <grub/types.h>
28 #include <sys/types.h>
29 #include <sys/stat.h>
30 #include <fcntl.h>
31 #include <dirent.h>
32 #include <unistd.h>
33 #include <stdio.h>
35 typedef struct dirent *grub_util_fd_dirent_t;
36 typedef DIR *grub_util_fd_dir_t;
38 static inline grub_util_fd_dir_t
39 grub_util_fd_opendir (const char *name)
41 return opendir (name);
44 static inline void
45 grub_util_fd_closedir (grub_util_fd_dir_t dirp)
47 closedir (dirp);
50 static inline grub_util_fd_dirent_t
51 grub_util_fd_readdir (grub_util_fd_dir_t dirp)
53 return readdir (dirp);
56 static inline int
57 grub_util_unlink (const char *pathname)
59 return unlink (pathname);
62 static inline int
63 grub_util_rmdir (const char *pathname)
65 return rmdir (pathname);
68 static inline int
69 grub_util_rename (const char *from, const char *to)
71 return rename (from, to);
74 #define grub_util_mkdir(a) mkdir ((a), 0755)
76 #if defined (__NetBSD__)
77 /* NetBSD uses /boot for its boot block. */
78 # define DEFAULT_DIRECTORY "/"GRUB_DIR_NAME
79 #else
80 # define DEFAULT_DIRECTORY "/"GRUB_BOOT_DIR_NAME"/"GRUB_DIR_NAME
81 #endif
83 enum grub_util_fd_open_flags_t
85 GRUB_UTIL_FD_O_RDONLY = O_RDONLY,
86 GRUB_UTIL_FD_O_WRONLY = O_WRONLY,
87 GRUB_UTIL_FD_O_RDWR = O_RDWR,
88 GRUB_UTIL_FD_O_CREATTRUNC = O_CREAT | O_TRUNC,
89 GRUB_UTIL_FD_O_SYNC = (0
90 #ifdef O_SYNC
91 | O_SYNC
92 #endif
93 #ifdef O_FSYNC
94 | O_FSYNC
95 #endif
99 #define DEFAULT_DEVICE_MAP DEFAULT_DIRECTORY "/device.map"
101 typedef int grub_util_fd_t;
102 #define GRUB_UTIL_FD_INVALID -1
103 #define GRUB_UTIL_FD_IS_VALID(x) ((x) >= 0)
104 #define GRUB_UTIL_FD_STAT_IS_FUNCTIONAL 1
106 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__APPLE__) || defined(__NetBSD__) || defined (__sun__) || defined(__OpenBSD__) || defined(__HAIKU__)
107 #define GRUB_DISK_DEVS_ARE_CHAR 1
108 #else
109 #define GRUB_DISK_DEVS_ARE_CHAR 0
110 #endif
112 #endif