~ubuntu-branches/debian/sid/grub2/sid-200907171838

« back to all changes in this revision

Viewing changes to disk/host.c

  • Committer: Bazaar Package Importer
  • Author(s): Robert Millan
  • Date: 2007-11-01 13:18:51 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20071101131851-tczt5tevrsnpt1tq
Tags: 1.95+20071101-1
* New CVS snapshot.
  - patches/linuxbios.diff: Remove (supported in upstream now).

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
 
 
26
int grub_disk_host_i_want_a_reference;
 
27
 
 
28
static int
 
29
grub_host_iterate (int (*hook) (const char *name))
 
30
{
 
31
  if (hook ("host"))
 
32
    return 1;
 
33
  return 0;
 
34
}
 
35
 
 
36
static grub_err_t
 
37
grub_host_open (const char *name __attribute((unused)), grub_disk_t disk)
 
38
{
 
39
  disk->total_sectors = 0;
 
40
  disk->id = (int) "host";
 
41
  
 
42
  disk->has_partitions = 0;
 
43
  disk->data = 0;
 
44
 
 
45
  return GRUB_ERR_NONE;
 
46
}
 
47
 
 
48
static void
 
49
grub_host_close (grub_disk_t disk __attribute((unused)))
 
50
{
 
51
}
 
52
 
 
53
static grub_err_t
 
54
grub_host_read (grub_disk_t disk __attribute((unused)),
 
55
                grub_disk_addr_t sector __attribute((unused)),
 
56
                grub_size_t size __attribute((unused)),
 
57
                char *buf __attribute((unused)))
 
58
{
 
59
  return GRUB_ERR_OUT_OF_RANGE;
 
60
}
 
61
 
 
62
static grub_err_t
 
63
grub_host_write (grub_disk_t disk __attribute ((unused)),
 
64
                     grub_disk_addr_t sector __attribute ((unused)),
 
65
                     grub_size_t size __attribute ((unused)),
 
66
                     const char *buf __attribute ((unused)))
 
67
{
 
68
  return GRUB_ERR_OUT_OF_RANGE;
 
69
}
 
70
 
 
71
static struct grub_disk_dev grub_host_dev =
 
72
  {
 
73
    /* The only important line in this file :-) */
 
74
    .name = "host",
 
75
    .id = GRUB_DISK_DEVICE_HOST_ID,
 
76
    .iterate = grub_host_iterate,
 
77
    .open = grub_host_open,
 
78
    .close = grub_host_close,
 
79
    .read = grub_host_read,
 
80
    .write = grub_host_write,
 
81
    .next = 0
 
82
  };
 
83
 
 
84
GRUB_MOD_INIT(host)
 
85
{
 
86
  (void) mod;                   /* To stop warning. */
 
87
  grub_disk_dev_register (&grub_host_dev);
 
88
}
 
89
 
 
90
GRUB_MOD_FINI(host)
 
91
{
 
92
  grub_disk_dev_unregister (&grub_host_dev);
 
93
}