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

« back to all changes in this revision

Viewing changes to disk/host.c

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2011-02-08 11:39:26 UTC
  • mfrom: (17.6.26 experimental)
  • mto: (17.6.27 experimental)
  • mto: This revision was merged to the branch mainline in revision 104.
  • Revision ID: james.westby@ubuntu.com-20110208113926-clfs90haboyk9zip
Tags: 1.99~rc1-2
* Merge 1.98+20100804-13 and 1.98+20100804-14, updating translations:
  - Kazakh (Baurzhan Muftakhidinov / Timur Birsh).
* mkconfig_skip_dmcrypt.patch: Refer to GRUB_PRELOAD_MODULES rather than
  suggesting people write a /etc/grub.d/01_modules script (thanks, Jordan
  Uggla).
* Handle empty dir passed to grub_find_root_device_from_mountinfo; fixes
  grub-mkrelpath on btrfs subvolumes (LP: #712029).
* Add rootflags=subvol=<name> if / is on a btrfs subvolume (LP: #712029).
* Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* host.c - Dummy disk driver to provide access to the hosts filesystem  */
2
 
/*
3
 
 *  GRUB  --  GRand Unified Bootloader
4
 
 *  Copyright (C) 2007  Free Software Foundation, Inc.
5
 
 *
6
 
 *  GRUB is free software: you can redistribute it and/or modify
7
 
 *  it under the terms of the GNU General Public License as published by
8
 
 *  the Free Software Foundation, either version 3 of the License, or
9
 
 *  (at your option) any later version.
10
 
 *
11
 
 *  GRUB is distributed in the hope that it will be useful,
12
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
 *  GNU General Public License for more details.
15
 
 *
16
 
 *  You should have received a copy of the GNU General Public License
17
 
 *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
18
 
 */
19
 
 
20
 
/* When using the disk, make a reference to this module.  Otherwise
21
 
   the user will end up with a useless module :-).  */
22
 
 
23
 
#include <grub/dl.h>
24
 
#include <grub/disk.h>
25
 
#include <grub/misc.h>
26
 
 
27
 
int grub_disk_host_i_want_a_reference;
28
 
 
29
 
static int
30
 
grub_host_iterate (int (*hook) (const char *name))
31
 
{
32
 
  if (hook ("host"))
33
 
    return 1;
34
 
  return 0;
35
 
}
36
 
 
37
 
static grub_err_t
38
 
grub_host_open (const char *name, grub_disk_t disk)
39
 
{
40
 
  if (grub_strcmp (name, "host"))
41
 
      return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a host disk");
42
 
 
43
 
  disk->total_sectors = 0;
44
 
  disk->id = (unsigned long) "host";
45
 
 
46
 
  disk->has_partitions = 0;
47
 
  disk->data = 0;
48
 
 
49
 
  return GRUB_ERR_NONE;
50
 
}
51
 
 
52
 
static void
53
 
grub_host_close (grub_disk_t disk __attribute((unused)))
54
 
{
55
 
}
56
 
 
57
 
static grub_err_t
58
 
grub_host_read (grub_disk_t disk __attribute((unused)),
59
 
                grub_disk_addr_t sector __attribute((unused)),
60
 
                grub_size_t size __attribute((unused)),
61
 
                char *buf __attribute((unused)))
62
 
{
63
 
  return GRUB_ERR_OUT_OF_RANGE;
64
 
}
65
 
 
66
 
static grub_err_t
67
 
grub_host_write (grub_disk_t disk __attribute ((unused)),
68
 
                     grub_disk_addr_t sector __attribute ((unused)),
69
 
                     grub_size_t size __attribute ((unused)),
70
 
                     const char *buf __attribute ((unused)))
71
 
{
72
 
  return GRUB_ERR_OUT_OF_RANGE;
73
 
}
74
 
 
75
 
static struct grub_disk_dev grub_host_dev =
76
 
  {
77
 
    /* The only important line in this file :-) */
78
 
    .name = "host",
79
 
    .id = GRUB_DISK_DEVICE_HOST_ID,
80
 
    .iterate = grub_host_iterate,
81
 
    .open = grub_host_open,
82
 
    .close = grub_host_close,
83
 
    .read = grub_host_read,
84
 
    .write = grub_host_write,
85
 
    .next = 0
86
 
  };
87
 
 
88
 
GRUB_MOD_INIT(host)
89
 
{
90
 
  grub_disk_dev_register (&grub_host_dev);
91
 
}
92
 
 
93
 
GRUB_MOD_FINI(host)
94
 
{
95
 
  grub_disk_dev_unregister (&grub_host_dev);
96
 
}