5a79f472c7
Migrate to GNU General Public License Version 3. * COPYING: Replaced with the plain text version of GPLv3. * config.guess: Updated from gnulib. * config.sub: Likewise. * geninit.sh: Output a GPLv3 copyright notice. * geninitheader.sh: Likewise. * genmodsrc.sh: Likewise. * gensymlist.sh.in: Likewise. * boot/i386/pc/boot.S: Upgraded to GPLv3. * boot/i386/pc/diskboot.S: Likewise. * boot/i386/pc/pxeboot.S: Likewise. * commands/blocklist.c: Likewise. * commands/boot.c: Likewise. * commands/cat.c: Likewise. * commands/cmp.c: Likewise. * commands/configfile.c: Likewise. * commands/echo.c: Likewise. * commands/help.c: Likewise. * commands/ls.c: Likewise. * commands/search.c: Likewise. * commands/terminal.c: Likewise. * commands/test.c: Likewise. * commands/videotest.c: Likewise. * commands/i386/cpuid.c: Likewise. * commands/i386/pc/halt.c: Likewise. * commands/i386/pc/play.c: Likewise. * commands/i386/pc/reboot.c: Likewise. * commands/i386/pc/vbeinfo.c: Likewise. * commands/i386/pc/vbetest.c: Likewise. * commands/ieee1275/halt.c: Likewise. * commands/ieee1275/reboot.c: Likewise. * commands/ieee1275/suspend.c: Likewise. * disk/loopback.c: Likewise. * disk/lvm.c: Likewise. * disk/raid.c: Likewise. * disk/efi/efidisk.c: Likewise. * disk/i386/pc/biosdisk.c: Likewise. * disk/ieee1275/ofdisk.c: Likewise. * font/manager.c: Likewise. * fs/affs.c: Likewise. * fs/ext2.c: Likewise. * fs/fat.c: Likewise. * fs/fshelp.c: Likewise. * fs/hfs.c: Likewise. * fs/hfsplus.c: Likewise. * fs/iso9660.c: Likewise. * fs/jfs.c: Likewise. * fs/minix.c: Likewise. * fs/sfs.c: Likewise. * fs/ufs.c: Likewise. * fs/xfs.c: Likewise. * hello/hello.c: Likewise. * include/grub/acorn_filecore.h: Likewise. * include/grub/arg.h: Likewise. * include/grub/bitmap.h: Likewise. * include/grub/boot.h: Likewise. * include/grub/cache.h: Likewise. * include/grub/device.h: Likewise. * include/grub/disk.h: Likewise. * include/grub/dl.h: Likewise. * include/grub/elfload.h: Likewise. * include/grub/env.h: Likewise. * include/grub/err.h: Likewise. * include/grub/file.h: Likewise. * include/grub/font.h: Likewise. * include/grub/fs.h: Likewise. * include/grub/fshelp.h: Likewise. * include/grub/gzio.h: Likewise. * include/grub/hfs.h: Likewise. * include/grub/kernel.h: Likewise. * include/grub/loader.h: Likewise. * include/grub/lvm.h: Likewise. * include/grub/misc.h: Likewise. * include/grub/mm.h: Likewise. * include/grub/net.h: Likewise. * include/grub/normal.h: Likewise. * include/grub/parser.h: Likewise. * include/grub/partition.h: Likewise. * include/grub/pc_partition.h: Likewise. * include/grub/raid.h: Likewise. * include/grub/rescue.h: Likewise. * include/grub/script.h: Likewise. * include/grub/setjmp.h: Likewise. * include/grub/symbol.h: Likewise. * include/grub/term.h: Likewise. * include/grub/terminfo.h: Likewise. * include/grub/tparm.h: Likewise. * include/grub/types.h: Likewise. * include/grub/video.h: Likewise. * include/grub/efi/api.h: Likewise. * include/grub/efi/chainloader.h: Likewise. * include/grub/efi/console.h: Likewise. * include/grub/efi/console_control.h: Likewise. * include/grub/efi/disk.h: Likewise. * include/grub/efi/efi.h: Likewise. * include/grub/efi/pe32.h: Likewise. * include/grub/efi/time.h: Likewise. * include/grub/i386/linux.h: Likewise. * include/grub/i386/setjmp.h: Likewise. * include/grub/i386/types.h: Likewise. * include/grub/i386/efi/kernel.h: Likewise. * include/grub/i386/efi/loader.h: Likewise. * include/grub/i386/efi/time.h: Likewise. * include/grub/i386/pc/biosdisk.h: Likewise. * include/grub/i386/pc/boot.h: Likewise. * include/grub/i386/pc/chainloader.h: Likewise. * include/grub/i386/pc/console.h: Likewise. * include/grub/i386/pc/init.h: Likewise. * include/grub/i386/pc/kernel.h: Likewise. * include/grub/i386/pc/loader.h: Likewise. * include/grub/i386/pc/memory.h: Likewise. * include/grub/i386/pc/multiboot.h: Likewise. * include/grub/i386/pc/serial.h: Likewise. * include/grub/i386/pc/time.h: Likewise. * include/grub/i386/pc/vbe.h: Likewise. * include/grub/i386/pc/vbeblit.h: Likewise. * include/grub/i386/pc/vbefill.h: Likewise. * include/grub/i386/pc/vbeutil.h: Likewise. * include/grub/i386/pc/vga.h: Likewise. * include/grub/ieee1275/ieee1275.h: Likewise. * include/grub/ieee1275/ofdisk.h: Likewise. * include/grub/powerpc/libgcc.h: Likewise. * include/grub/powerpc/setjmp.h: Likewise. * include/grub/powerpc/types.h: Likewise. * include/grub/powerpc/ieee1275/biosdisk.h: Likewise. * include/grub/powerpc/ieee1275/console.h: Likewise. * include/grub/powerpc/ieee1275/ieee1275.h: Likewise. * include/grub/powerpc/ieee1275/kernel.h: Likewise. * include/grub/powerpc/ieee1275/loader.h: Likewise. * include/grub/powerpc/ieee1275/multiboot.h: Likewise. * include/grub/powerpc/ieee1275/time.h: Likewise. * include/grub/powerpc/ieee1275/util/biosdisk.h: Likewise. * include/grub/sparc64/libgcc.h: Likewise. * include/grub/sparc64/setjmp.h: Likewise. * include/grub/sparc64/types.h: Likewise. * include/grub/sparc64/ieee1275/console.h: Likewise. * include/grub/sparc64/ieee1275/ieee1275.h: Likewise. * include/grub/sparc64/ieee1275/kernel.h: Likewise. * include/grub/sparc64/ieee1275/time.h: Likewise. * include/grub/util/biosdisk.h: Likewise. * include/grub/util/getroot.h: Likewise. * include/grub/util/lvm.h: Likewise. * include/grub/util/misc.h: Likewise. * include/grub/util/raid.h: Likewise. * include/grub/util/resolve.h: Likewise. * io/gzio.c: Likewise. * kern/device.c: Likewise. * kern/disk.c: Likewise. * kern/dl.c: Likewise. * kern/elf.c: Likewise. * kern/env.c: Likewise. * kern/err.c: Likewise. * kern/file.c: Likewise. * kern/fs.c: Likewise. * kern/loader.c: Likewise. * kern/main.c: Likewise. * kern/misc.c: Likewise. * kern/mm.c: Likewise. * kern/parser.c: Likewise. * kern/partition.c: Likewise. * kern/rescue.c: Likewise. * kern/term.c: Likewise. * kern/efi/efi.c: Likewise. * kern/efi/init.c: Likewise. * kern/efi/mm.c: Likewise. * kern/i386/dl.c: Likewise. * kern/i386/efi/init.c: Likewise. * kern/i386/efi/startup.S: Likewise. * kern/i386/pc/init.c: Likewise. * kern/i386/pc/lzo1x.S: Likewise. * kern/i386/pc/startup.S: Likewise. * kern/ieee1275/ieee1275.c: Likewise. * kern/powerpc/cache.S: Likewise. * kern/powerpc/dl.c: Likewise. * kern/powerpc/ieee1275/cmain.c: Likewise. * kern/powerpc/ieee1275/crt0.S: Likewise. * kern/powerpc/ieee1275/init.c: Likewise. * kern/powerpc/ieee1275/openfw.c: Likewise. * kern/sparc64/cache.S: Likewise. * kern/sparc64/dl.c: Likewise. * kern/sparc64/ieee1275/init.c: Likewise. * kern/sparc64/ieee1275/openfw.c: Likewise. * loader/efi/chainloader.c: Likewise. * loader/efi/chainloader_normal.c: Likewise. * loader/i386/efi/linux.c: Likewise. * loader/i386/efi/linux_normal.c: Likewise. * loader/i386/pc/chainloader.c: Likewise. * loader/i386/pc/chainloader_normal.c: Likewise. * loader/i386/pc/linux.c: Likewise. * loader/i386/pc/linux_normal.c: Likewise. * loader/i386/pc/multiboot.c: Likewise. * loader/i386/pc/multiboot_normal.c: Likewise. * loader/powerpc/ieee1275/linux.c: Likewise. * loader/powerpc/ieee1275/linux_normal.c: Likewise. * normal/arg.c: Likewise. * normal/cmdline.c: Likewise. * normal/command.c: Likewise. * normal/completion.c: Likewise. * normal/execute.c: Likewise. * normal/function.c: Likewise. * normal/lexer.c: Likewise. * normal/main.c: Likewise. * normal/menu.c: Likewise. * normal/menu_entry.c: Likewise. * normal/misc.c: Likewise. * normal/parser.y: Likewise. * normal/script.c: Likewise. * normal/i386/setjmp.S: Likewise. * normal/powerpc/setjmp.S: Likewise. * normal/sparc64/setjmp.S: Likewise. * partmap/acorn.c: Likewise. * partmap/amiga.c: Likewise. * partmap/apple.c: Likewise. * partmap/gpt.c: Likewise. * partmap/pc.c: Likewise. * partmap/sun.c: Likewise. * term/gfxterm.c: Likewise. * term/terminfo.c: Likewise. * term/efi/console.c: Likewise. * term/i386/pc/console.c: Likewise. * term/i386/pc/serial.c: Likewise. * term/i386/pc/vesafb.c: Likewise. * term/i386/pc/vga.c: Likewise. * term/ieee1275/ofconsole.c: Likewise. * util/biosdisk.c: Likewise. * util/console.c: Likewise. * util/genmoddep.c: Likewise. * util/getroot.c: Likewise. * util/grub-emu.c: Likewise. * util/grub-mkdevicemap.c: Likewise. * util/grub-probe.c: Likewise. * util/lvm.c: Likewise. * util/misc.c: Likewise. * util/raid.c: Likewise. * util/resolve.c: Likewise. * util/update-grub.in: Likewise. * util/update-grub_lib.in: Likewise. * util/grub.d/00_header.in: Likewise. * util/grub.d/10_hurd.in: Likewise. * util/grub.d/10_linux.in: Likewise. * util/i386/efi/grub-install.in: Likewise. * util/i386/efi/grub-mkimage.c: Likewise. * util/i386/pc/grub-install.in: Likewise. * util/i386/pc/grub-mkimage.c: Likewise. * util/i386/pc/grub-mkrescue.in: Likewise. * util/i386/pc/grub-setup.c: Likewise. * util/i386/pc/misc.c: Likewise. * util/powerpc/ieee1275/grub-install.in: Likewise. * util/powerpc/ieee1275/grub-mkimage.c: Likewise. * util/powerpc/ieee1275/misc.c: Likewise. * video/bitmap.c: Likewise. * video/video.c: Likewise. * video/i386/pc/vbe.c: Likewise. * video/i386/pc/vbeblit.c: Likewise. * video/i386/pc/vbefill.c: Likewise. * video/i386/pc/vbeutil.c: Likewise. * video/readers/tga.c: Likewise.
359 lines
10 KiB
C
359 lines
10 KiB
C
/*
|
|
* GRUB -- GRand Unified Bootloader
|
|
* Copyright (C) 2004,2005,2006,2007 Free Software Foundation, Inc.
|
|
*
|
|
* GRUB is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* GRUB is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include <config.h>
|
|
|
|
#include <stdio.h>
|
|
#include <stdint.h>
|
|
#include <unistd.h>
|
|
#include <fcntl.h>
|
|
#include <getopt.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <grub/elf.h>
|
|
#include <grub/misc.h>
|
|
#include <grub/util/misc.h>
|
|
#include <grub/util/resolve.h>
|
|
#include <grub/kernel.h>
|
|
#include <grub/machine/kernel.h>
|
|
|
|
#define GRUB_IEEE1275_NOTE_NAME "PowerPC"
|
|
#define GRUB_IEEE1275_NOTE_TYPE 0x1275
|
|
|
|
/* These structures are defined according to the CHRP binding to IEEE1275,
|
|
"Client Program Format" section. */
|
|
|
|
struct grub_ieee1275_note_hdr
|
|
{
|
|
grub_uint32_t namesz;
|
|
grub_uint32_t descsz;
|
|
grub_uint32_t type;
|
|
char name[sizeof (GRUB_IEEE1275_NOTE_NAME)];
|
|
};
|
|
|
|
struct grub_ieee1275_note_desc
|
|
{
|
|
grub_uint32_t real_mode;
|
|
grub_uint32_t real_base;
|
|
grub_uint32_t real_size;
|
|
grub_uint32_t virt_base;
|
|
grub_uint32_t virt_size;
|
|
grub_uint32_t load_base;
|
|
};
|
|
|
|
struct grub_ieee1275_note
|
|
{
|
|
struct grub_ieee1275_note_hdr header;
|
|
struct grub_ieee1275_note_desc descriptor;
|
|
};
|
|
|
|
void
|
|
load_note (Elf32_Phdr *phdr, FILE *out)
|
|
{
|
|
struct grub_ieee1275_note note;
|
|
int note_size = sizeof (struct grub_ieee1275_note);
|
|
|
|
grub_util_info ("adding CHRP NOTE segment");
|
|
|
|
note.header.namesz = grub_cpu_to_be32 (sizeof (GRUB_IEEE1275_NOTE_NAME));
|
|
note.header.descsz = grub_cpu_to_be32 (note_size);
|
|
note.header.type = grub_cpu_to_be32 (GRUB_IEEE1275_NOTE_TYPE);
|
|
strcpy (note.header.name, GRUB_IEEE1275_NOTE_NAME);
|
|
note.descriptor.real_mode = grub_cpu_to_be32 (0xffffffff);
|
|
note.descriptor.real_base = grub_cpu_to_be32 (0x00c00000);
|
|
note.descriptor.real_size = grub_cpu_to_be32 (0xffffffff);
|
|
note.descriptor.virt_base = grub_cpu_to_be32 (0xffffffff);
|
|
note.descriptor.virt_size = grub_cpu_to_be32 (0xffffffff);
|
|
note.descriptor.load_base = grub_cpu_to_be32 (0x00004000);
|
|
|
|
/* Write the note data to the new segment. */
|
|
grub_util_write_image_at (¬e, note_size,
|
|
grub_be_to_cpu32 (phdr->p_offset), out);
|
|
|
|
/* Fill in the rest of the segment header. */
|
|
phdr->p_type = grub_cpu_to_be32 (PT_NOTE);
|
|
phdr->p_flags = grub_cpu_to_be32 (PF_R);
|
|
phdr->p_align = grub_cpu_to_be32 (sizeof (long));
|
|
phdr->p_vaddr = 0;
|
|
phdr->p_paddr = 0;
|
|
phdr->p_filesz = grub_cpu_to_be32 (note_size);
|
|
phdr->p_memsz = 0;
|
|
}
|
|
|
|
void
|
|
load_modules (grub_addr_t modbase, Elf32_Phdr *phdr, const char *dir,
|
|
char *mods[], FILE *out)
|
|
{
|
|
char *module_img;
|
|
struct grub_util_path_list *path_list;
|
|
struct grub_util_path_list *p;
|
|
struct grub_module_info *modinfo;
|
|
size_t offset;
|
|
size_t total_module_size;
|
|
|
|
path_list = grub_util_resolve_dependencies (dir, "moddep.lst", mods);
|
|
|
|
offset = sizeof (struct grub_module_info);
|
|
total_module_size = sizeof (struct grub_module_info);
|
|
for (p = path_list; p; p = p->next)
|
|
{
|
|
total_module_size += (grub_util_get_image_size (p->name)
|
|
+ sizeof (struct grub_module_header));
|
|
}
|
|
|
|
grub_util_info ("the total module size is 0x%x", total_module_size);
|
|
|
|
module_img = xmalloc (total_module_size);
|
|
modinfo = (struct grub_module_info *) module_img;
|
|
modinfo->magic = grub_cpu_to_be32 (GRUB_MODULE_MAGIC);
|
|
modinfo->offset = grub_cpu_to_be32 (sizeof (struct grub_module_info));
|
|
modinfo->size = grub_cpu_to_be32 (total_module_size);
|
|
|
|
/* Load all the modules, with headers, into module_img. */
|
|
for (p = path_list; p; p = p->next)
|
|
{
|
|
struct grub_module_header *header;
|
|
size_t mod_size;
|
|
|
|
grub_util_info ("adding module %s", p->name);
|
|
|
|
mod_size = grub_util_get_image_size (p->name);
|
|
|
|
header = (struct grub_module_header *) (module_img + offset);
|
|
header->offset = grub_cpu_to_be32 (sizeof (*header));
|
|
header->size = grub_cpu_to_be32 (mod_size + sizeof (*header));
|
|
|
|
grub_util_load_image (p->name, module_img + offset + sizeof (*header));
|
|
|
|
offset += sizeof (*header) + mod_size;
|
|
}
|
|
|
|
/* Write the module data to the new segment. */
|
|
grub_util_write_image_at (module_img, total_module_size,
|
|
grub_cpu_to_be32 (phdr->p_offset), out);
|
|
|
|
/* Fill in the rest of the segment header. */
|
|
phdr->p_type = grub_cpu_to_be32 (PT_LOAD);
|
|
phdr->p_flags = grub_cpu_to_be32 (PF_R | PF_W | PF_X);
|
|
phdr->p_align = grub_cpu_to_be32 (sizeof (long));
|
|
phdr->p_vaddr = grub_cpu_to_be32 (modbase);
|
|
phdr->p_paddr = grub_cpu_to_be32 (modbase);
|
|
phdr->p_filesz = grub_cpu_to_be32 (total_module_size);
|
|
phdr->p_memsz = grub_cpu_to_be32 (total_module_size);
|
|
}
|
|
|
|
void
|
|
add_segments (char *dir, FILE *out, int chrp, char *mods[])
|
|
{
|
|
Elf32_Ehdr ehdr;
|
|
Elf32_Phdr *phdrs = NULL;
|
|
Elf32_Phdr *phdr;
|
|
FILE *in;
|
|
char *kernel_path;
|
|
grub_addr_t grub_end = 0;
|
|
off_t phdroff;
|
|
int i;
|
|
|
|
/* Read ELF header. */
|
|
kernel_path = grub_util_get_path (dir, "kernel.elf");
|
|
in = fopen (kernel_path, "rb");
|
|
if (! in)
|
|
grub_util_error ("cannot open %s", kernel_path);
|
|
|
|
grub_util_read_at (&ehdr, sizeof (ehdr), 0, in);
|
|
|
|
phdrs = xmalloc (grub_be_to_cpu16 (ehdr.e_phentsize)
|
|
* (grub_be_to_cpu16 (ehdr.e_phnum) + 2));
|
|
/* Copy all existing segments. */
|
|
for (i = 0; i < grub_be_to_cpu16 (ehdr.e_phnum); i++)
|
|
{
|
|
char *segment_img;
|
|
grub_size_t segment_end;
|
|
|
|
phdr = phdrs + i;
|
|
|
|
/* Read segment header. */
|
|
grub_util_read_at (phdr, sizeof (Elf32_Phdr),
|
|
(grub_be_to_cpu32 (ehdr.e_phoff)
|
|
+ (i * grub_be_to_cpu16 (ehdr.e_phentsize))),
|
|
in);
|
|
grub_util_info ("copying segment %d, type %d", i,
|
|
grub_be_to_cpu32 (phdr->p_type));
|
|
|
|
/* Locate _end. */
|
|
segment_end = grub_be_to_cpu32 (phdr->p_paddr)
|
|
+ grub_be_to_cpu32 (phdr->p_memsz);
|
|
grub_util_info ("segment %u end 0x%lx", i, segment_end);
|
|
if (segment_end > grub_end)
|
|
grub_end = segment_end;
|
|
|
|
/* Read segment data and write it to new file. */
|
|
segment_img = xmalloc (grub_be_to_cpu32 (phdr->p_filesz));
|
|
|
|
grub_util_read_at (segment_img, grub_be_to_cpu32 (phdr->p_filesz),
|
|
grub_be_to_cpu32 (phdr->p_offset), in);
|
|
grub_util_write_image_at (segment_img, grub_be_to_cpu32 (phdr->p_filesz),
|
|
grub_be_to_cpu32 (phdr->p_offset), out);
|
|
|
|
free (segment_img);
|
|
}
|
|
|
|
if (mods[0] != NULL)
|
|
{
|
|
grub_addr_t modbase;
|
|
|
|
/* Place modules just after grub segment. */
|
|
modbase = ALIGN_UP(grub_end, GRUB_IEEE1275_MOD_ALIGN);
|
|
|
|
/* Construct new segment header for modules. */
|
|
phdr = phdrs + grub_be_to_cpu16 (ehdr.e_phnum);
|
|
ehdr.e_phnum = grub_cpu_to_be16 (grub_be_to_cpu16 (ehdr.e_phnum) + 1);
|
|
|
|
/* Fill in p_offset so the callees know where to write. */
|
|
phdr->p_offset = grub_cpu_to_be32 (ALIGN_UP (grub_util_get_fp_size (out),
|
|
sizeof (long)));
|
|
|
|
load_modules (modbase, phdr, dir, mods, out);
|
|
}
|
|
|
|
if (chrp)
|
|
{
|
|
/* Construct new segment header for the CHRP note. */
|
|
phdr = phdrs + grub_be_to_cpu16 (ehdr.e_phnum);
|
|
ehdr.e_phnum = grub_cpu_to_be16 (grub_be_to_cpu16 (ehdr.e_phnum) + 1);
|
|
|
|
/* Fill in p_offset so the callees know where to write. */
|
|
phdr->p_offset = grub_cpu_to_be32 (ALIGN_UP (grub_util_get_fp_size (out),
|
|
sizeof (long)));
|
|
|
|
load_note (phdr, out);
|
|
}
|
|
|
|
/* Don't bother preserving the section headers. */
|
|
ehdr.e_shoff = 0;
|
|
ehdr.e_shnum = 0;
|
|
ehdr.e_shstrndx = 0;
|
|
|
|
/* Append entire segment table to the file. */
|
|
phdroff = ALIGN_UP (grub_util_get_fp_size (out), sizeof (long));
|
|
grub_util_write_image_at (phdrs, grub_be_to_cpu16 (ehdr.e_phentsize)
|
|
* grub_be_to_cpu16 (ehdr.e_phnum), phdroff,
|
|
out);
|
|
|
|
/* Write ELF header. */
|
|
ehdr.e_phoff = grub_cpu_to_be32 (phdroff);
|
|
grub_util_write_image_at (&ehdr, sizeof (ehdr), 0, out);
|
|
|
|
free (phdrs);
|
|
free (kernel_path);
|
|
}
|
|
|
|
static struct option options[] =
|
|
{
|
|
{"directory", required_argument, 0, 'd'},
|
|
{"output", required_argument, 0, 'o'},
|
|
{"help", no_argument, 0, 'h'},
|
|
{"note", no_argument, 0, 'n'},
|
|
{"version", no_argument, 0, 'V'},
|
|
{"verbose", no_argument, 0, 'v'},
|
|
{ 0, 0, 0, 0 },
|
|
};
|
|
|
|
static void
|
|
usage (int status)
|
|
{
|
|
if (status)
|
|
fprintf (stderr, "Try ``grub-mkimage --help'' for more information.\n");
|
|
else
|
|
printf ("\
|
|
Usage: grub-mkimage -o FILE [OPTION]... [MODULES]\n\
|
|
\n\
|
|
Make a bootable image of GRUB.\n\
|
|
\n\
|
|
-d, --directory=DIR use images and modules under DIR [default=%s]\n\
|
|
-o, --output=FILE output a generated image to FILE\n\
|
|
-h, --help display this message and exit\n\
|
|
-n, --note add NOTE segment for CHRP Open Firmware\n\
|
|
-V, --version print version information and exit\n\
|
|
-v, --verbose print verbose messages\n\
|
|
\n\
|
|
Report bugs to <%s>.\n\
|
|
", GRUB_LIBDIR, PACKAGE_BUGREPORT);
|
|
|
|
exit (status);
|
|
}
|
|
|
|
int
|
|
main (int argc, char *argv[])
|
|
{
|
|
FILE *fp;
|
|
char *output = NULL;
|
|
char *dir = NULL;
|
|
int chrp = 0;
|
|
|
|
progname = "grub-mkimage";
|
|
|
|
while (1)
|
|
{
|
|
int c = getopt_long (argc, argv, "d:o:hVvn", options, 0);
|
|
if (c == -1)
|
|
break;
|
|
|
|
switch (c)
|
|
{
|
|
case 'd':
|
|
if (dir)
|
|
free (dir);
|
|
dir = xstrdup (optarg);
|
|
break;
|
|
case 'h':
|
|
usage (0);
|
|
break;
|
|
case 'n':
|
|
chrp = 1;
|
|
break;
|
|
case 'o':
|
|
if (output)
|
|
free (output);
|
|
output = xstrdup (optarg);
|
|
break;
|
|
case 'V':
|
|
printf ("grub-mkimage (%s) %s\n", PACKAGE_NAME, PACKAGE_VERSION);
|
|
return 0;
|
|
case 'v':
|
|
verbosity++;
|
|
break;
|
|
default:
|
|
usage (1);
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (!output)
|
|
usage (1);
|
|
|
|
fp = fopen (output, "wb");
|
|
if (! fp)
|
|
grub_util_error ("cannot open %s", output);
|
|
|
|
add_segments (dir ? : GRUB_LIBDIR, fp, chrp, argv + optind);
|
|
|
|
fclose (fp);
|
|
|
|
return 0;
|
|
}
|