diff options
Diffstat (limited to '')
-rw-r--r-- | include/grub/osdep/hostfile.h | 7 | ||||
-rw-r--r-- | include/grub/osdep/hostfile_aros.h | 119 | ||||
-rw-r--r-- | include/grub/osdep/hostfile_unix.h | 118 | ||||
-rw-r--r-- | include/grub/osdep/hostfile_windows.h | 85 |
4 files changed, 329 insertions, 0 deletions
diff --git a/include/grub/osdep/hostfile.h b/include/grub/osdep/hostfile.h new file mode 100644 index 0000000..6d9f75b --- /dev/null +++ b/include/grub/osdep/hostfile.h @@ -0,0 +1,7 @@ +#if defined (__AROS__) +#include "hostfile_aros.h" +#elif defined (__CYGWIN__) || defined (__MINGW32__) +#include "hostfile_windows.h" +#else +#include "hostfile_unix.h" +#endif diff --git a/include/grub/osdep/hostfile_aros.h b/include/grub/osdep/hostfile_aros.h new file mode 100644 index 0000000..161fbb7 --- /dev/null +++ b/include/grub/osdep/hostfile_aros.h @@ -0,0 +1,119 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2010,2011,2012,2013 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef GRUB_EMU_HOSTFILE_H +#define GRUB_EMU_HOSTFILE_H 1 + +#include <config.h> +#include <stdarg.h> + +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <dirent.h> +#include <unistd.h> +#include <stdio.h> + +typedef struct dirent *grub_util_fd_dirent_t; +typedef DIR *grub_util_fd_dir_t; + +static inline grub_util_fd_dir_t +grub_util_fd_opendir (const char *name) +{ + return opendir (name); +} + +static inline void +grub_util_fd_closedir (grub_util_fd_dir_t dirp) +{ + closedir (dirp); +} + +static inline grub_util_fd_dirent_t +grub_util_fd_readdir (grub_util_fd_dir_t dirp) +{ + return readdir (dirp); +} + +static inline int +grub_util_rmdir (const char *pathname) +{ + return rmdir (pathname); +} + +static inline int +grub_util_unlink (const char *pathname) +{ + return unlink (pathname); +} + +static inline int +grub_util_rename (const char *from, const char *to) +{ + return rename (from, to); +} + +static inline ssize_t +grub_util_readlink (const char *name, char *buf, size_t bufsize) +{ + return readlink(name, buf, bufsize); +} + +#define grub_util_mkdir(a) mkdir ((a), 0755) + +struct grub_util_fd +{ + enum { GRUB_UTIL_FD_FILE, GRUB_UTIL_FD_DISK } type; + grub_uint64_t off; + union + { + int fd; + struct { + struct IOExtTD *ioreq; + struct MsgPort *mp; + unsigned int is_floppy:1; + unsigned int is_64:1; + }; + }; +}; +typedef struct grub_util_fd *grub_util_fd_t; + +enum grub_util_fd_open_flags_t + { + GRUB_UTIL_FD_O_RDONLY = O_RDONLY, + GRUB_UTIL_FD_O_WRONLY = O_WRONLY, + GRUB_UTIL_FD_O_RDWR = O_RDWR, + GRUB_UTIL_FD_O_CREATTRUNC = O_CREAT | O_TRUNC, + GRUB_UTIL_FD_O_SYNC = (0 +#ifdef O_SYNC + | O_SYNC +#endif +#ifdef O_FSYNC + | O_FSYNC +#endif + ) + }; + +#define GRUB_UTIL_FD_INVALID NULL +#define GRUB_UTIL_FD_IS_VALID(x) ((x) != GRUB_UTIL_FD_INVALID) +#define GRUB_UTIL_FD_STAT_IS_FUNCTIONAL 0 + +#define DEFAULT_DIRECTORY "SYS:" GRUB_BOOT_DIR_NAME "/" GRUB_DIR_NAME +#define DEFAULT_DEVICE_MAP DEFAULT_DIRECTORY "/device.map" + +#endif diff --git a/include/grub/osdep/hostfile_unix.h b/include/grub/osdep/hostfile_unix.h new file mode 100644 index 0000000..17cd3aa --- /dev/null +++ b/include/grub/osdep/hostfile_unix.h @@ -0,0 +1,118 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2010,2011,2012,2013 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef GRUB_EMU_HOSTFILE_H +#define GRUB_EMU_HOSTFILE_H 1 + +#include <config.h> +#include <stdarg.h> + +#include <grub/symbol.h> +#include <grub/types.h> + +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <dirent.h> +#include <unistd.h> +#include <stdio.h> + +typedef struct dirent *grub_util_fd_dirent_t; +typedef DIR *grub_util_fd_dir_t; + +static inline grub_util_fd_dir_t +grub_util_fd_opendir (const char *name) +{ + return opendir (name); +} + +static inline void +grub_util_fd_closedir (grub_util_fd_dir_t dirp) +{ + closedir (dirp); +} + +static inline grub_util_fd_dirent_t +grub_util_fd_readdir (grub_util_fd_dir_t dirp) +{ + return readdir (dirp); +} + +static inline int +grub_util_unlink (const char *pathname) +{ + return unlink (pathname); +} + +static inline int +grub_util_rmdir (const char *pathname) +{ + return rmdir (pathname); +} + +static inline int +grub_util_rename (const char *from, const char *to) +{ + return rename (from, to); +} + +static inline ssize_t +grub_util_readlink (const char *name, char *buf, size_t bufsize) +{ + return readlink(name, buf, bufsize); +} + +#define grub_util_mkdir(a) mkdir ((a), 0755) + +#if defined (__NetBSD__) +/* NetBSD uses /boot for its boot block. */ +# define DEFAULT_DIRECTORY "/"GRUB_DIR_NAME +#else +# define DEFAULT_DIRECTORY "/"GRUB_BOOT_DIR_NAME"/"GRUB_DIR_NAME +#endif + +enum grub_util_fd_open_flags_t + { + GRUB_UTIL_FD_O_RDONLY = O_RDONLY, + GRUB_UTIL_FD_O_WRONLY = O_WRONLY, + GRUB_UTIL_FD_O_RDWR = O_RDWR, + GRUB_UTIL_FD_O_CREATTRUNC = O_CREAT | O_TRUNC, + GRUB_UTIL_FD_O_SYNC = (0 +#ifdef O_SYNC + | O_SYNC +#endif +#ifdef O_FSYNC + | O_FSYNC +#endif + ) + }; + +#define DEFAULT_DEVICE_MAP DEFAULT_DIRECTORY "/device.map" + +typedef int grub_util_fd_t; +#define GRUB_UTIL_FD_INVALID -1 +#define GRUB_UTIL_FD_IS_VALID(x) ((x) >= 0) +#define GRUB_UTIL_FD_STAT_IS_FUNCTIONAL 1 + +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__APPLE__) || defined(__NetBSD__) || defined (__sun__) || defined(__OpenBSD__) || defined(__HAIKU__) +#define GRUB_DISK_DEVS_ARE_CHAR 1 +#else +#define GRUB_DISK_DEVS_ARE_CHAR 0 +#endif + +#endif diff --git a/include/grub/osdep/hostfile_windows.h b/include/grub/osdep/hostfile_windows.h new file mode 100644 index 0000000..bf6451b --- /dev/null +++ b/include/grub/osdep/hostfile_windows.h @@ -0,0 +1,85 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2010,2011,2012,2013 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef GRUB_EMU_HOSTFILE_H +#define GRUB_EMU_HOSTFILE_H 1 + +#include <config.h> +#include <stdarg.h> + +#include <windows.h> +typedef HANDLE grub_util_fd_t; +#define GRUB_UTIL_FD_INVALID INVALID_HANDLE_VALUE +#define GRUB_UTIL_FD_IS_VALID(x) ((x) != GRUB_UTIL_FD_INVALID) +#define GRUB_UTIL_FD_STAT_IS_FUNCTIONAL 0 + +#define DEFAULT_DIRECTORY "C:\\"GRUB_BOOT_DIR_NAME"\\"GRUB_DIR_NAME +#define DEFAULT_DEVICE_MAP DEFAULT_DIRECTORY "/device.map" + +struct grub_util_fd_dirent +{ + char d_name[0]; +}; +struct grub_util_fd_dir; +typedef struct grub_util_fd_dirent *grub_util_fd_dirent_t; +typedef struct grub_util_fd_dir *grub_util_fd_dir_t; + +int +grub_util_rename (const char *from, const char *to); +int +grub_util_unlink (const char *name); +void +grub_util_mkdir (const char *dir); + +grub_util_fd_dir_t +grub_util_fd_opendir (const char *name); + +void +grub_util_fd_closedir (grub_util_fd_dir_t dirp); + +grub_util_fd_dirent_t +grub_util_fd_readdir (grub_util_fd_dir_t dirp); + +int +grub_util_rmdir (const char *pathname); + +enum grub_util_fd_open_flags_t + { + GRUB_UTIL_FD_O_RDONLY = 1, + GRUB_UTIL_FD_O_WRONLY = 2, + GRUB_UTIL_FD_O_RDWR = 3, + GRUB_UTIL_FD_O_CREATTRUNC = 4, + GRUB_UTIL_FD_O_SYNC = 0, + }; + +#if defined (__MINGW32__) && !defined (__MINGW64__) + +/* 32 bit on Mingw-w64 already redefines them if _FILE_OFFSET_BITS=64 */ +#ifndef _W64 +#define fseeko fseeko64 +#define ftello ftello64 +#endif + +#endif + +LPTSTR +grub_util_utf8_to_tchar (const char *in); +char * +grub_util_tchar_to_utf8 (LPCTSTR in); + +#endif |