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 <sys/types.h>
32 typedef struct dirent
*grub_util_fd_dirent_t
;
33 typedef DIR *grub_util_fd_dir_t
;
35 static inline grub_util_fd_dir_t
36 grub_util_fd_opendir (const char *name
)
38 return opendir (name
);
42 grub_util_fd_closedir (grub_util_fd_dir_t dirp
)
47 static inline grub_util_fd_dirent_t
48 grub_util_fd_readdir (grub_util_fd_dir_t dirp
)
50 return readdir (dirp
);
54 grub_util_rmdir (const char *pathname
)
56 return rmdir (pathname
);
60 grub_util_unlink (const char *pathname
)
62 return unlink (pathname
);
66 grub_util_rename (const char *from
, const char *to
)
68 return rename (from
, to
);
71 #define grub_util_mkdir(a) mkdir ((a), 0755)
75 enum { GRUB_UTIL_FD_FILE
, GRUB_UTIL_FD_DISK
} type
;
81 struct IOExtTD
*ioreq
;
83 unsigned int is_floppy
:1;
88 typedef struct grub_util_fd
*grub_util_fd_t
;
90 enum grub_util_fd_open_flags_t
92 GRUB_UTIL_FD_O_RDONLY
= O_RDONLY
,
93 GRUB_UTIL_FD_O_WRONLY
= O_WRONLY
,
94 GRUB_UTIL_FD_O_RDWR
= O_RDWR
,
95 GRUB_UTIL_FD_O_CREATTRUNC
= O_CREAT
| O_TRUNC
,
96 GRUB_UTIL_FD_O_SYNC
= (0
106 #define GRUB_UTIL_FD_INVALID NULL
107 #define GRUB_UTIL_FD_IS_VALID(x) ((x) != GRUB_UTIL_FD_INVALID)
108 #define GRUB_UTIL_FD_STAT_IS_FUNCTIONAL 0
110 #define DEFAULT_DIRECTORY "SYS:" GRUB_BOOT_DIR_NAME "/" GRUB_DIR_NAME
111 #define DEFAULT_DEVICE_MAP DEFAULT_DIRECTORY "/device.map"