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
25
#include <grub/symbol.h>
26
#include <grub/types.h>
28
#include <sys/types.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);
45
grub_util_fd_closedir (grub_util_fd_dir_t dirp)
50
static inline grub_util_fd_dirent_t
51
grub_util_fd_readdir (grub_util_fd_dir_t dirp)
53
return readdir (dirp);
57
grub_util_unlink (const char *pathname)
59
return unlink (pathname);
63
grub_util_rmdir (const char *pathname)
65
return rmdir (pathname);
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
80
# define DEFAULT_DIRECTORY "/"GRUB_BOOT_DIR_NAME"/"GRUB_DIR_NAME
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
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
109
#define GRUB_DISK_DEVS_ARE_CHAR 0