2N/A/* host.c - Dummy disk driver to provide access to the hosts filesystem */
2N/A/*
2N/A * GRUB -- GRand Unified Bootloader
2N/A * Copyright (C) 2007 Free Software Foundation, Inc.
2N/A *
2N/A * GRUB is free software: you can redistribute it and/or modify
2N/A * it under the terms of the GNU General Public License as published by
2N/A * the Free Software Foundation, either version 3 of the License, or
2N/A * (at your option) any later version.
2N/A *
2N/A * GRUB is distributed in the hope that it will be useful,
2N/A * but WITHOUT ANY WARRANTY; without even the implied warranty of
2N/A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2N/A * GNU General Public License for more details.
2N/A *
2N/A * You should have received a copy of the GNU General Public License
2N/A * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
2N/A */
2N/A
2N/A/* When using the disk, make a reference to this module. Otherwise
2N/A the user will end up with a useless module :-). */
2N/A
2N/A#include <grub/dl.h>
2N/A#include <grub/disk.h>
2N/A#include <grub/misc.h>
2N/A
2N/Aint grub_disk_host_i_want_a_reference;
2N/A
2N/Astatic int
2N/Agrub_host_iterate (int (*hook) (const char *name),
2N/A grub_disk_pull_t pull)
2N/A{
2N/A if (pull != GRUB_DISK_PULL_NONE)
2N/A return 0;
2N/A
2N/A if (hook ("host"))
2N/A return 1;
2N/A return 0;
2N/A}
2N/A
2N/Astatic grub_err_t
2N/Agrub_host_open (const char *name, grub_disk_t disk)
2N/A{
2N/A if (grub_strcmp (name, "host"))
2N/A return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a host disk");
2N/A
2N/A disk->total_sectors = 0;
2N/A disk->id = (unsigned long) "host";
2N/A
2N/A disk->data = 0;
2N/A
2N/A return GRUB_ERR_NONE;
2N/A}
2N/A
2N/Astatic void
2N/Agrub_host_close (grub_disk_t disk __attribute((unused)))
2N/A{
2N/A}
2N/A
2N/Astatic grub_err_t
2N/Agrub_host_read (grub_disk_t disk __attribute((unused)),
2N/A grub_disk_addr_t sector __attribute((unused)),
2N/A grub_size_t size __attribute((unused)),
2N/A char *buf __attribute((unused)))
2N/A{
2N/A return GRUB_ERR_OUT_OF_RANGE;
2N/A}
2N/A
2N/Astatic grub_err_t
2N/Agrub_host_write (grub_disk_t disk __attribute ((unused)),
2N/A grub_disk_addr_t sector __attribute ((unused)),
2N/A grub_size_t size __attribute ((unused)),
2N/A const char *buf __attribute ((unused)))
2N/A{
2N/A return GRUB_ERR_OUT_OF_RANGE;
2N/A}
2N/A
2N/Astatic struct grub_disk_dev grub_host_dev =
2N/A {
2N/A /* The only important line in this file :-) */
2N/A .name = "host",
2N/A .id = GRUB_DISK_DEVICE_HOST_ID,
2N/A .iterate = grub_host_iterate,
2N/A .open = grub_host_open,
2N/A .close = grub_host_close,
2N/A .read = grub_host_read,
2N/A .write = grub_host_write,
2N/A .next = 0
2N/A };
2N/A
2N/AGRUB_MOD_INIT(host)
2N/A{
2N/A grub_disk_dev_register (&grub_host_dev);
2N/A}
2N/A
2N/AGRUB_MOD_FINI(host)
2N/A{
2N/A grub_disk_dev_unregister (&grub_host_dev);
2N/A}