~ubuntu-branches/ubuntu/trusty/grub2/trusty

« back to all changes in this revision

Viewing changes to include/grub/osdep/hostfile_unix.h

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2014-01-16 15:18:04 UTC
  • mfrom: (17.6.38 experimental)
  • Revision ID: package-import@ubuntu.com-20140116151804-3foouk7fpqcq3sxx
Tags: 2.02~beta2-2
* Convert patch handling to git-dpm.
* Add bi-endian support to ELF parser (Tomohiro B Berry).
* Adjust restore_mkdevicemap.patch to mark get_kfreebsd_version as static,
  to appease "gcc -Werror=missing-prototypes".
* Cherry-pick from upstream:
  - Change grub-macbless' manual page section to 8.
* Install grub-glue-efi, grub-macbless, grub-render-label, and
  grub-syslinux2cfg.
* grub-shell: Pass -no-pad to xorriso when building floppy images.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
19
#ifndef GRUB_EMU_HOSTFILE_H
 
20
#define GRUB_EMU_HOSTFILE_H 1
 
21
 
 
22
#include <config.h>
 
23
#include <stdarg.h>
 
24
 
 
25
#include <grub/symbol.h>
 
26
#include <grub/types.h>
 
27
 
 
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>
 
34
 
 
35
typedef struct dirent *grub_util_fd_dirent_t;
 
36
typedef DIR *grub_util_fd_dir_t;
 
37
 
 
38
static inline grub_util_fd_dir_t
 
39
grub_util_fd_opendir (const char *name)
 
40
{
 
41
  return opendir (name);
 
42
}
 
43
 
 
44
static inline void
 
45
grub_util_fd_closedir (grub_util_fd_dir_t dirp)
 
46
{
 
47
  closedir (dirp);
 
48
}
 
49
 
 
50
static inline grub_util_fd_dirent_t
 
51
grub_util_fd_readdir (grub_util_fd_dir_t dirp)
 
52
{
 
53
  return readdir (dirp);
 
54
}
 
55
 
 
56
static inline int
 
57
grub_util_unlink (const char *pathname)
 
58
{
 
59
  return unlink (pathname);
 
60
}
 
61
 
 
62
static inline int
 
63
grub_util_rmdir (const char *pathname)
 
64
{
 
65
  return rmdir (pathname);
 
66
}
 
67
 
 
68
static inline int
 
69
grub_util_rename (const char *from, const char *to)
 
70
{
 
71
  return rename (from, to);
 
72
}
 
73
 
 
74
#define grub_util_mkdir(a) mkdir ((a), 0755)
 
75
 
 
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
 
82
 
 
83
enum grub_util_fd_open_flags_t
 
84
  {
 
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
 
96
                           )
 
97
  };
 
98
 
 
99
#define DEFAULT_DEVICE_MAP      DEFAULT_DIRECTORY "/device.map"
 
100
 
 
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
 
105
 
 
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
 
111
 
 
112
#endif