Getting ready for 0.5.1

This commit is contained in:
gord 1999-02-22 03:20:36 +00:00
parent 6b874486ce
commit 553fec6022
21 changed files with 379 additions and 208 deletions

View file

@ -1,3 +1,60 @@
1999-02-21 Gordon Matzigkeit <gord@trick.fig.org>
* debian: Add to the distribution, since we maintain the GRUB
Debian package ourselves.
* grub/asmstub.c: New file to implement stubbed assembly functions
under Unix.
* stage1/Makefile: Delete spurious dependencies on Makefile.
* stage2/Makefile: Likewise.
* stage2_debug/Makefile: Likewise.
* grub/Makefile: Likewise.
* shared_src/fsys_ext2fs.c (ext2fs_dir): Follow symbolic links
rather than giving an error.
* shared_src/common.c (err_list): Use labeled elements to
associate messages with error codes.
* shared_src/shared.h: Make error codes into an enumerated type.
* shared_src/common.c (err_list): Add ERR_SYMLINK_LOOP.
* shared_src/shared.h: Likewise.
* shared_src/char_io.c (bcopy): Don't make any assumptions about
the length of an unsigned long.
* grub/Makefile: Treat CFLAGS, CPPFLAGS, LDFLAGS according to
GNU standards.
* stage2/Makefile: Likewise.
* e2fs_stage1_5/Makefile: Likewise.
* fat_stage1_5/Makefile: Likewise.
* ffs_stage1_5/Makefile: Likewise.
1999-02-20 Gordon Matzigkeit <gord@trick.fig.org>
* docs/index.html: Rename to grub.html, so that we don't hide
files in this directory from a web browser.
1999-02-15 Gordon Matzigkeit <gord@trick.fig.org>
* Makefile.end (PROGS): Add grub.
* grub/main.c: New file.
* grub/Makefile: New directory to contain the stage2 Unix program.
* shared_src/cmdline.c: Use substring.
* shared_src/fsys_ext2fs.c: Likewise.
* shared_src/fsys_fat.c: Likewise.
* shared_src/fsys_ffs.c: Likewise.
* shared_src/stage2.c: Likewise.
* shared_src/shared.h: Delete strcmp, declare substring.
* shared_src/char_io.c (strcmp): Rename to `substring', because
this function doesn't behave the same as libc's strcmp.
1999-02-14 Gordon Matzigkeit <gord@trick.fig.org>
* shared_src/shared.h: (addr32, data32): Delete definitions.

View file

@ -3,7 +3,7 @@
# part created by configure.
#
PROGS= stage1 e2fs_stage1_5 fat_stage1_5 ffs_stage1_5 \
PROGS= grub stage1 e2fs_stage1_5 fat_stage1_5 ffs_stage1_5 \
stage2 stage2_debug
all:

3
configure vendored
View file

@ -391,7 +391,8 @@ for tool_var in $tool_vars ; do
done
cat << EOF >> Makefile
export SHARED_FLAGS = -pipe -fno-builtin -nostdinc -O2 -DEXT_C\(x\)="$munge_func1"
export CFLAGS = -O2
export SHARED_FLAGS = -pipe -fno-builtin -nostdinc -DEXT_C\(x\)="$munge_func1"
# (END OF AUTOMATICALLY GENERATED PORTION)
#

6
debian/changelog vendored
View file

@ -1,3 +1,9 @@
grub (0.5-3) unstable; urgency=low
* GRUB now understands symbolic links (fixes: #17306).
-- Gordon Matzigkeit <gord@debian.org> Sun, 21 Feb 1999 05:13:25 -0600
grub (0.5-2) unstable; urgency=low
* Assembly source cleanups.

4
debian/rules vendored
View file

@ -41,8 +41,8 @@ binary-arch: checkroot build
cp -r docs debian/tmp/usr/doc/grub
rm -f debian/tmp/usr/doc/grub/docs/COPYING
$(INSTALL_DATA) ChangeLog debian/tmp/usr/doc/grub/
gzip -f9 debian/tmp/usr/doc/grub/ChangeLog
$(INSTALL_DATA) ChangeLog debian/tmp/usr/doc/grub/changelog
gzip -f9 debian/tmp/usr/doc/grub/changelog
$(INSTALL_DATA) debian/changelog debian/tmp/usr/doc/grub/changelog.Debian
gzip -f9 debian/tmp/usr/doc/grub/changelog.Debian
$(INSTALL_DATA) debian/copyright debian/tmp/usr/doc/grub/

View file

@ -2,13 +2,15 @@
# GRUB e2fs_stage1_5 makefile
#
SHARED_FLAGS += -DFSYS_EXT2FS -DNO_DECOMPRESSION -DNO_FANCY_STUFF \
COMPILE = $(CC) $(CFLAGS) $(CPPFLAGS) $(SHARED_FLAGS) \
-DFSYS_EXT2FS -DNO_DECOMPRESSION -DNO_FANCY_STUFF \
-DNO_BLOCK_FILES -DCONFIG_FILE_ASM=".string \"/boot/grub/stage2\"" \
-I../shared_src
# FIXME: is this really true?
# There are problems inheriting flags that work fine with stage1 and stage2
# so... don't use them at all!
CFLAGS= $(SHARED_FLAGS)
#CFLAGS= $(SHARED_FLAGS)
# "asm.o" absolutely has to come first in the link line!
SHARED_OBJS= asm.o char_io.o common.o disk_io.o stage1_5.o fsys_ext2fs.o
@ -16,24 +18,24 @@ SHARED_OBJS= asm.o char_io.o common.o disk_io.o stage1_5.o fsys_ext2fs.o
all: ../bin/e2fs_stage1_5
asm.o: ../shared_src/asm.S ../shared_src/shared.h
$(CC) $(CFLAGS) -c ../shared_src/asm.S
$(COMPILE) -c ../shared_src/asm.S
char_io.o: ../shared_src/char_io.c ../shared_src/shared.h
$(CC) $(CFLAGS) -c ../shared_src/char_io.c
$(COMPILE) -c ../shared_src/char_io.c
common.o: ../shared_src/common.c ../shared_src/shared.h
$(CC) $(CFLAGS) -c ../shared_src/common.c
$(COMPILE) -c ../shared_src/common.c
disk_io.o: ../shared_src/disk_io.c ../shared_src/filesys.h \
../shared_src/pc_slice.h ../shared_src/shared.h
$(CC) $(CFLAGS) -c ../shared_src/disk_io.c
$(COMPILE) -c ../shared_src/disk_io.c
stage1_5.o: ../shared_src/stage1_5.c ../shared_src/shared.h
$(CC) $(CFLAGS) -c ../shared_src/stage1_5.c
$(COMPILE) -c ../shared_src/stage1_5.c
fsys_ext2fs.o: ../shared_src/fsys_ext2fs.c ../shared_src/filesys.h \
../shared_src/pc_slice.h ../shared_src/shared.h
$(CC) $(CFLAGS) -c ../shared_src/fsys_ext2fs.c
$(COMPILE) -c ../shared_src/fsys_ext2fs.c
# "asm.o" absolutely has to come first in the link line!
e2fs_stage1_5.exec: $(SHARED_OBJS)

View file

@ -2,13 +2,15 @@
# GRUB fat_stage1_5 makefile
#
SHARED_FLAGS += -DFSYS_FAT -DNO_DECOMPRESSION -DNO_FANCY_STUFF \
COMPILE = $(CC) $(CFLAGS) $(CPPFLAGS) $(SHARED_FLAGS) \
-DFSYS_FAT -DNO_DECOMPRESSION -DNO_FANCY_STUFF \
-DCONFIG_FILE_ASM=".string \"/boot/grub/stage2\"" \
-I../shared_src
# FIXME: Is this really true?
# There are problems inheriting flags that work fine with stage1 and stage2
# so... don't use them at all!
CFLAGS= $(SHARED_FLAGS)
#CFLAGS= $(SHARED_FLAGS)
# "asm.o" absolutely has to come first in the link line!
SHARED_OBJS= asm.o char_io.o common.o disk_io.o stage1_5.o fsys_fat.o
@ -16,24 +18,24 @@ SHARED_OBJS= asm.o char_io.o common.o disk_io.o stage1_5.o fsys_fat.o
all: ../bin/fat_stage1_5
asm.o: ../shared_src/asm.S ../shared_src/shared.h
$(CC) $(CFLAGS) -c ../shared_src/asm.S
$(COMPILE) -c ../shared_src/asm.S
char_io.o: ../shared_src/char_io.c ../shared_src/shared.h
$(CC) $(CFLAGS) -c ../shared_src/char_io.c
$(COMPILE) -c ../shared_src/char_io.c
common.o: ../shared_src/common.c ../shared_src/shared.h
$(CC) $(CFLAGS) -c ../shared_src/common.c
$(COMPILE) -c ../shared_src/common.c
disk_io.o: ../shared_src/disk_io.c ../shared_src/filesys.h \
../shared_src/pc_slice.h ../shared_src/shared.h
$(CC) $(CFLAGS) -c ../shared_src/disk_io.c
$(COMPILE) -c ../shared_src/disk_io.c
stage1_5.o: ../shared_src/stage1_5.c ../shared_src/shared.h
$(CC) $(CFLAGS) -c ../shared_src/stage1_5.c
$(COMPILE) -c ../shared_src/stage1_5.c
fsys_fat.o: ../shared_src/fsys_fat.c ../shared_src/filesys.h \
../shared_src/pc_slice.h ../shared_src/shared.h
$(CC) $(CFLAGS) -c ../shared_src/fsys_fat.c
$(COMPILE) -c ../shared_src/fsys_fat.c
# "asm.o" absolutely has to come first in the link line!
fat_stage1_5.exec: $(SHARED_OBJS)

View file

@ -3,8 +3,9 @@
#
IMPORTANT_SIZE_LIMIT = 7168
CFLAGS= $(SHARED_FLAGS) -DFSYS_FFS -DNO_DECOMPRESSION -DNO_FANCY_STUFF \
-DNO_BLOCK_FILES -DCONFIG_FILE_ASM=".string \"/boot/grub/stage2\"" \
COMPILE= $(CC) $(CFLAGS) $(CPPFLAGS) $(SHARED_FLAGS) -DFSYS_FFS \
-DNO_DECOMPRESSION -DNO_FANCY_STUFF -DNO_BLOCK_FILES \
-DCONFIG_FILE_ASM=".string \"/boot/grub/stage2\"" \
-I../shared_src
# "asm.o" absolutely has to come first in the link line!
@ -13,27 +14,27 @@ SHARED_OBJS= asm.o char_io.o common.o disk_io.o stage1_5.o fsys_ffs.o
all: ../bin/ffs_stage1_5
asm.o: ../shared_src/asm.S ../shared_src/shared.h
$(CC) $(CFLAGS) -c ../shared_src/asm.S
$(COMPILE) -c ../shared_src/asm.S
char_io.o: ../shared_src/char_io.c ../shared_src/shared.h
$(CC) $(CFLAGS) -c ../shared_src/char_io.c
$(COMPILE) -c ../shared_src/char_io.c
common.o: ../shared_src/common.c ../shared_src/shared.h
$(CC) $(CFLAGS) -c ../shared_src/common.c
$(COMPILE) -c ../shared_src/common.c
disk_io.o: ../shared_src/disk_io.c ../shared_src/filesys.h \
../shared_src/pc_slice.h ../shared_src/shared.h
$(CC) $(CFLAGS) -c ../shared_src/disk_io.c
$(COMPILE) -c ../shared_src/disk_io.c
stage1_5.o: ../shared_src/stage1_5.c ../shared_src/shared.h
$(CC) $(CFLAGS) -c ../shared_src/stage1_5.c
$(COMPILE) -c ../shared_src/stage1_5.c
fsys_ffs.o: ../shared_src/fsys_ffs.c ../shared_src/filesys.h \
../shared_src/pc_slice.h ../shared_src/shared.h \
../shared_src/defs.h ../shared_src/disk_inode.h \
../shared_src/disk_inode_ffs.h ../shared_src/dir.h \
../shared_src/fs.h
$(CC) $(CFLAGS) -c ../shared_src/fsys_ffs.c
$(COMPILE) -c ../shared_src/fsys_ffs.c
# "asm.o" absolutely has to come first in the link line!
ffs_stage1_5.exec: $(SHARED_OBJS)

43
mail
View file

@ -153,3 +153,46 @@ Comments?
Gordon Matzigkeit <gord@fig.org> //\ I'm a FIG (http://www.fig.org/)
Lovers of freedom, unite! \// I use GNU (http://www.gnu.org/)
[Unfortunately, www.fig.org is broken. Please stay tuned for details.]
From nobody Sun Feb 21 01:59:03 1999
X-From-Line: dunham@cse.msu.edu Sat Feb 20 17:43:34 1999
Return-Path: <dunham@cse.msu.edu>
Delivered-To: gord@trick.fig.org
Received: (qmail 16082 invoked from network); 20 Feb 1999 17:43:34 -0000
Received: from sargasso.cse.msu.edu (35.9.20.14)
by ip223.net247210.cr.sk.ca with SMTP; 20 Feb 1999 17:43:34 -0000
Received: from fatneck.cse.msu.edu (dunham@fatneck.cse.msu.edu [35.9.20.47])
by sargasso.cse.msu.edu (8.8.8/8.8.8) with ESMTP id MAA25678
for <gord@trick.fig.org>; Sat, 20 Feb 1999 12:43:26 -0500 (EST)
Received: (from dunham@localhost)
by fatneck.cse.msu.edu (8.9.2/8.9.2/Debian/GNU) id MAA19662;
Sat, 20 Feb 1999 12:45:10 -0500 (EST)
To: Gordon Matzigkeit <gord@trick.fig.org>
Subject: GRUB
Mime-Version: 1.0 (generated by tm-edit 7.108)
Content-Type: text/plain; charset=US-ASCII
From: Steve Dunham <dunham@cse.msu.edu>
Date: 20 Feb 1999 12:45:09 -0500
In-Reply-To: Gordon Matzigkeit's message of "18 Feb 1999 09:12:49 -0600"
Message-ID: <m9bemnl6kbe.fsf_-_@fatneck.cse.msu.edu>
X-Mailer: Gnus v5.5/XEmacs 20.4 - "Emerald"
Lines: 18
Xref: trick.fig.org misc:2354
IIRC, you took over the Grub package and upstream Grub.
You might be interested in the work by the "Fiasco" (aka L4) people at
tu-dresden - they taken Grub 0.4.1 and added network booting to it.
You can get their code at:
ftp://ftp.inf.tu-dresden.de/pub/os/L4/devel/
or grab a local copy of it that I put up at:
http://www.cse.msu.edu/~dunham/out/grub-l4-981207.tar.gz
Steve
dunham@cse.msu.edu

View file

@ -521,18 +521,21 @@ strncat(char *s1, char *s2, int n)
int
strcmp(char *s1, char *s2)
substring(char *s1, char *s2)
{
while (*s1 == *s2)
{
/* The strings match, so return 0. */
if (!*(s1++))
return 0;
s2++;
}
/* S1 is shorter than S2. */
if (*s1 == 0)
return -1;
/* S1 is a substring of S2. */
return 1;
}
@ -577,9 +580,9 @@ bcopy(char *from, char *to, int len)
{
if ((to >= from+len) || (to <= from))
{
while (len > 3)
while (len >= sizeof (unsigned long))
{
len -= 4;
len -= sizeof (unsigned long);
*(((unsigned long *)to)++) = *(((unsigned long *)from)++);
}
while (len-- > 0)
@ -587,6 +590,8 @@ bcopy(char *from, char *to, int len)
}
else
{
/* We have a region that overlaps, but would be overwritten
if we copied it forward. */
while (len-- > 0)
to[len] = from[len];
}
@ -607,5 +612,3 @@ bzero(char *start, int len)
return (!errnum);
}

View file

@ -214,7 +214,7 @@ returnit:
if (run_cmdline && get_cmdline("command> ", commands, cur_heap, 2048))
return 1;
if (strcmp("boot", cur_heap) == 0 || (script && !*cur_heap))
if (substring("boot", cur_heap) == 0 || (script && !*cur_heap))
{
if ((type == 'f') | (type == 'n'))
bsd_boot(type, bootdev);
@ -245,7 +245,7 @@ returnit:
cmd_len = 0;
while (cur_cmdline[cmd_len++]);
if (strcmp("chainloader", cur_heap) < 1)
if (substring("chainloader", cur_heap) < 1)
{
if (open(cur_cmdline) && (read(BOOTSEC_LOCATION, SECTOR_SIZE)
== SECTOR_SIZE)
@ -258,17 +258,17 @@ returnit:
type = 0;
}
}
else if (strcmp("pause", cur_heap) < 1)
else if (substring("pause", cur_heap) < 1)
{
if (getc() == 27)
return 1;
}
else if (strcmp("uppermem", cur_heap) < 1)
else if (substring("uppermem", cur_heap) < 1)
{
if (safe_parse_maxint(&cur_cmdline, (int *)&(mbi.mem_upper)))
mbi.flags &= ~MB_INFO_MEM_MAP;
}
else if (strcmp("root", cur_heap) < 1)
else if (substring("root", cur_heap) < 1)
{
int hdbias = 0;
char *biasptr = skip_to(0, set_device(cur_cmdline));
@ -295,7 +295,7 @@ returnit:
current_drive = -1;
}
}
else if (strcmp("kernel", cur_heap) < 1)
else if (substring("kernel", cur_heap) < 1)
{
/* make sure it's at the beginning of the boot heap area */
bcopy(cur_heap, heap, cmd_len + (((int)cur_cmdline) - ((int)cur_heap)));
@ -304,7 +304,7 @@ returnit:
if (type = load_image())
cur_heap = cur_cmdline + cmd_len;
}
else if (strcmp("module", cur_heap) < 1)
else if (substring("module", cur_heap) < 1)
{
if (type == 'm')
{
@ -329,7 +329,7 @@ returnit:
else
errnum = ERR_NEED_MB_KERNEL;
}
else if (strcmp("initrd", cur_heap) < 1)
else if (substring("initrd", cur_heap) < 1)
{
if (type == 'L' || type == 'l')
{
@ -338,7 +338,7 @@ returnit:
else
errnum = ERR_NEED_LX_KERNEL;
}
else if (strcmp("install", cur_heap) < 1)
else if (substring("install", cur_heap) < 1)
{
char *stage1_file = cur_cmdline, *dest_dev, *file, *addr, *config_file;
char buffer[SECTOR_SIZE], old_sect[SECTOR_SIZE];
@ -470,7 +470,7 @@ returnit:
}
}
#ifdef DEBUG
else if (strcmp("testload", cur_heap) < 1)
else if (substring("testload", cur_heap) < 1)
{
type = 0;
if (open(cur_cmdline))
@ -534,13 +534,13 @@ returnit:
debug_fs = NULL;
}
}
else if (strcmp("read", cur_heap) < 1)
else if (substring("read", cur_heap) < 1)
{
int myaddr;
if (safe_parse_maxint(&cur_cmdline, &myaddr))
printf("Address 0x%x: Value 0x%x", myaddr, *((unsigned *)myaddr));
}
else if (strcmp("fstest", cur_heap) == 0)
else if (substring("fstest", cur_heap) == 0)
{
if (debug_fs)
{
@ -553,12 +553,12 @@ returnit:
printf(" Filesystem tracing is now on\n");
}
}
else if (strcmp("impsprobe", cur_heap) == 0)
else if (substring("impsprobe", cur_heap) == 0)
{
if (!imps_probe())
printf(" No MPS information found or probe failed\n");
}
else if (strcmp("displaymem", cur_heap) == 0)
else if (substring("displaymem", cur_heap) == 0)
{
if (get_eisamemsize() != -1)
printf(" EISA Memory BIOS Interface is present\n");
@ -592,11 +592,10 @@ returnit:
}
}
#endif /* DEBUG */
else if (strcmp("makeactive", cur_heap) == 0)
else if (substring("makeactive", cur_heap) == 0)
make_saved_active();
else if (*cur_heap && *cur_heap != ' ')
errnum = ERR_UNRECOGNIZED;
goto restart;
}

View file

@ -41,36 +41,36 @@ int errnum = 0;
char *err_list[] =
{
0,
"Selected item won\'t fit into memory",
"Selected disk doesn\'t exist",
"Disk read error",
"Disk write error",
"Disk geometry error",
"Attempt to access block outside partition",
"Partition table invalid or corrupt",
"No such partition",
"Bad filename (must be absolute pathname or blocklist)",
"Bad file or directory type",
"File not found",
"Cannot mount selected partition",
"Inconsistent filesystem structure",
"Filesystem compatibility error, can\'t read whole file",
"Error while parsing number",
"Device string unrecognizable",
"Invalid device requested",
"Invalid or unsupported executable format",
"Loading below 1MB is not supported",
"Unsupported Multiboot features requested",
"Unknown boot failure",
"Must load Multiboot kernel before modules",
"Must load Linux kernel before initrd",
"Cannot boot without kernel loaded",
"Unrecognized command",
"Bad or incompatible header on compressed file",
"Bad or corrupt data while decompressing file",
"Bad or corrupt version of stage1/stage2",
0
[ERR_NONE] = 0,
[ERR_BAD_FILENAME] = "Bad filename (must be absolute pathname or blocklist)",
[ERR_BAD_FILETYPE] = "Bad file or directory type",
[ERR_BAD_GZIP_DATA] = "Bad or corrupt data while decompressing file",
[ERR_BAD_GZIP_HEADER] = "Bad or incompatible header on compressed file",
[ERR_BAD_PART_TABLE] = "Partition table invalid or corrupt",
[ERR_BAD_VERSION] = "Bad or corrupt version of stage1/stage2",
[ERR_BELOW_1MB] = "Loading below 1MB is not supported",
[ERR_BOOT_COMMAND] = "Cannot boot without kernel loaded",
[ERR_BOOT_FAILURE] = "Unknown boot failure",
[ERR_BOOT_FEATURES] = "Unsupported Multiboot features requested",
[ERR_DEV_FORMAT] = "Device string unrecognizable",
[ERR_DEV_VALUES] = "Invalid device requested",
[ERR_EXEC_FORMAT] = "Invalid or unsupported executable format",
[ERR_FILELENGTH] = "Filesystem compatibility error, cannot read whole file",
[ERR_FILE_NOT_FOUND] = "File not found",
[ERR_FSYS_CORRUPT] = "Inconsistent filesystem structure",
[ERR_FSYS_MOUNT] = "Cannot mount selected partition",
[ERR_GEOM] = "Disk geometry error",
[ERR_NEED_LX_KERNEL] = "Must load Linux kernel before initrd",
[ERR_NEED_MB_KERNEL] = "Must load Multiboot kernel before modules",
[ERR_NO_DISK] = "Selected disk does not exist",
[ERR_NO_PART] = "No such partition",
[ERR_NUMBER_PARSING] = "Error while parsing number",
[ERR_OUTSIDE_PART] = "Attempt to access block outside partition",
[ERR_READ] = "Disk read error",
[ERR_SYMLINK_LOOP] = "Too many symbolic links",
[ERR_UNRECOGNIZED] = "Unrecognized command",
[ERR_WONT_FIT] = "Selected item cannot fit into memory",
[ERR_WRITE] = "Disk write error",
};
@ -212,4 +212,3 @@ init_bios_info(void)
cmain();
}

View file

@ -1,6 +1,7 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 1996 Erich Boleyn <erich@uruk.org>
* Copyright (C) 1999 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -19,12 +20,7 @@
#include "shared.h"
#ifdef E2DEBUG
#include "pc_slice.h"
#else
#include "filesys.h"
#endif
static int mapblock1, mapblock2;
@ -181,6 +177,8 @@ struct ext2_dir_entry {
#define EXT2_SUPER_MAGIC 0xEF53 /* include/linux/ext2_fs.h */
#define EXT2_ROOT_INO 2 /* include/linux/ext2_fs.h */
#define PATH_MAX 1024 /* include/linux/limits.h */
#define MAX_LINK_COUNT 5 /* number of symbolic links to follow */
/* made up, these are pointers into FSYS_BUF */
/* read once, always stays there: */
@ -209,8 +207,10 @@ struct ext2_dir_entry {
(EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_group_desc))
/* linux/stat.h */
#define S_IFMT 00170000
#define S_IFLNK 0120000
#define S_IFREG 0100000
#define S_IFDIR 0040000
#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
@ -358,12 +358,13 @@ ext2fs_read(int addr, int len)
int size = 0;
#ifdef E2DEBUG
static char hexdigit[] = "0123456789abcdef";
unsigned char * i;
for (i = (unsigned char *)INODE;
i < ((unsigned char *)INODE + sizeof(struct ext2_inode));
i++) {
printf("%c", "0123456789abcdef"[*i >> 4]);
printf("%c", "0123456789abcdef"[*i % 16]);
printf("%c", hexdigit[*i >> 4]);
printf("%c", hexdigit[*i % 16]);
if (!((i + 1 - (unsigned char *)INODE) % 16)) { printf("\n"); }
else { printf(" "); }
}
@ -442,6 +443,7 @@ int
ext2fs_dir(char *dirname)
{
int current_ino = EXT2_ROOT_INO; /* start at the root */
int updir_ino = current_ino; /* the parent of the current directory */
int group_id; /* which group the inode is in */
int group_desc; /* fs pointer to that group */
int desc; /* index within that group */
@ -450,6 +452,9 @@ ext2fs_dir(char *dirname)
struct ext2_group_desc * gdp;
struct ext2_inode * raw_inode; /* inode info corresponding to current_ino */
char linkbuf[PATH_MAX]; /* buffer for following symbolic links */
int link_count = 0;
char *rest;
char ch; /* temp char holder */
@ -527,6 +532,74 @@ ext2fs_dir(char *dirname)
printf("first word=%x\n", *((int *)INODE));
#endif /* E2DEBUG */
/* If we've got a symbolic link, then chase it. */
if (S_ISLNK(INODE->i_mode))
{
int len, remaining;
if (++ link_count > MAX_LINK_COUNT)
{
errnum = ERR_SYMLINK_LOOP;
return 0;
}
/* Find out how long our remaining name is. */
len = 0;
while (dirname[len] && !isspace (dirname[len]))
len ++;
/* Get the symlink size. */
filemax = (INODE->i_size);
if (filemax + len > sizeof (linkbuf) - 2)
{
errnum = ERR_FILELENGTH;
return 0;
}
if (len)
{
/* Copy the remaining name to the end of the symlink data.
Note that DIRNAME and LINKBUF may overlap! */
bcopy (dirname, linkbuf + filemax, len);
}
linkbuf[filemax + len] = '\0';
/* Read the symlink data. */
if (INODE->i_blocks)
{
/* Read the necessary blocks, and reset the file pointer. */
len = read ((int) linkbuf, filemax);
filepos = 0;
if (!len)
return 0;
}
else
{
/* Copy the data directly from the inode. */
len = filemax;
bcopy ((char *) INODE->i_block, linkbuf, len);
}
#if E2DEBUG
printf ("symlink=%s\n", linkbuf);
#endif
dirname = linkbuf;
if (*dirname == '/')
{
/* It's an absolute link, so look it up in root. */
current_ino = EXT2_ROOT_INO;
updir_ino = current_ino;
}
else
{
/* Relative, so look it up in our parent directory. */
current_ino = updir_ino;
}
/* Try again using the new name. */
continue;
}
/* if end of filename, INODE points to the file's inode */
if (!*dirname || isspace(*dirname))
{
@ -541,6 +614,7 @@ ext2fs_dir(char *dirname)
}
/* else we have to traverse a directory */
updir_ino = current_ino;
/* skip over slashes */
while (*dirname == '/')
@ -583,7 +657,7 @@ ext2fs_dir(char *dirname)
/* else, find the (logical) block component of our location */
blk = loc >> EXT2_BLOCK_SIZE_BITS(SUPERBLOCK);
/* now we know which logical block of the directory entry we are looking
/* we know which logical block of the directory entry we are looking
for, now we have to translate that to the physical (fs) block on
the disk */
map = ext2fs_block_map(blk);
@ -614,7 +688,7 @@ ext2fs_dir(char *dirname)
int saved_c = dp->name[dp->name_len];
dp->name[dp->name_len] = 0;
str_chk = strcmp(dirname, dp->name);
str_chk = substring(dirname, dp->name);
if (print_possibilities && ch != '/'
&& (!*dirname || str_chk <= 0))

View file

@ -234,14 +234,15 @@ loop:
}
if (print_possibilities && ch != '/'
&& (!*dirname || strcmp(dirname, filename) <= 0))
&& (!*dirname || substring(dirname, filename) <= 0))
{
if (print_possibilities > 0)
print_possibilities = -print_possibilities;
printf(" %s", filename);
}
}
while (strcmp(dirname, filename) != 0 || (print_possibilities && ch != '/'));
while (substring(dirname, filename) != 0 ||
(print_possibilities && ch != '/'));
*(dirname = rest) = ch;
@ -252,5 +253,3 @@ loop:
/* go back to main loop at top of function */
goto loop;
}

View file

@ -244,7 +244,7 @@ loop:
loc += dp->d_reclen;
if (dp->d_ino && print_possibilities && ch != '/'
&& (!*dirname || strcmp(dirname, dp->d_name) <= 0))
&& (!*dirname || substring(dirname, dp->d_name) <= 0))
{
if (print_possibilities > 0)
print_possibilities = -print_possibilities;
@ -252,7 +252,7 @@ loop:
printf(" %s", dp->d_name);
}
}
while (!dp->d_ino || (strcmp(dirname, dp->d_name) != 0
while (!dp->d_ino || (substring(dirname, dp->d_name) != 0
|| (print_possibilities && ch != '/')) );
/* only get here if we have a matching directory entry */
@ -263,5 +263,3 @@ loop:
/* go back to main loop at top of function */
goto loop;
}

View file

@ -316,36 +316,40 @@ int special_attribute;
#endif /* _CHAR_IO_C */
#define ERR_NONE 0
#define ERR_WONT_FIT (ERR_NONE + 1)
#define ERR_NO_DISK (ERR_WONT_FIT + 1)
#define ERR_READ (ERR_NO_DISK + 1)
#define ERR_WRITE (ERR_READ + 1)
#define ERR_GEOM (ERR_WRITE + 1)
#define ERR_OUTSIDE_PART (ERR_GEOM + 1)
#define ERR_BAD_PART_TABLE (ERR_OUTSIDE_PART + 1)
#define ERR_NO_PART (ERR_BAD_PART_TABLE + 1)
#define ERR_BAD_FILENAME (ERR_NO_PART + 1)
#define ERR_BAD_FILETYPE (ERR_BAD_FILENAME + 1)
#define ERR_FILE_NOT_FOUND (ERR_BAD_FILETYPE + 1)
#define ERR_FSYS_MOUNT (ERR_FILE_NOT_FOUND + 1)
#define ERR_FSYS_CORRUPT (ERR_FSYS_MOUNT + 1)
#define ERR_FILELENGTH (ERR_FSYS_CORRUPT + 1)
#define ERR_NUMBER_PARSING (ERR_FILELENGTH + 1)
#define ERR_DEV_FORMAT (ERR_NUMBER_PARSING + 1)
#define ERR_DEV_VALUES (ERR_DEV_FORMAT + 1)
#define ERR_EXEC_FORMAT (ERR_DEV_VALUES + 1)
#define ERR_BELOW_1MB (ERR_EXEC_FORMAT + 1)
#define ERR_BOOT_FEATURES (ERR_BELOW_1MB + 1)
#define ERR_BOOT_FAILURE (ERR_BOOT_FEATURES + 1)
#define ERR_NEED_MB_KERNEL (ERR_BOOT_FAILURE + 1)
#define ERR_NEED_LX_KERNEL (ERR_NEED_MB_KERNEL + 1)
#define ERR_BOOT_COMMAND (ERR_NEED_LX_KERNEL + 1)
#define ERR_UNRECOGNIZED (ERR_BOOT_COMMAND + 1)
#define ERR_BAD_GZIP_HEADER (ERR_UNRECOGNIZED + 1)
#define ERR_BAD_GZIP_DATA (ERR_BAD_GZIP_HEADER + 1)
#define ERR_BAD_VERSION (ERR_BAD_GZIP_DATA + 1)
#define MAX_ERR_NUM (ERR_BAD_VERSION + 1)
enum grub_error_t {
ERR_NONE = 0,
ERR_BAD_FILENAME,
ERR_BAD_FILETYPE,
ERR_BAD_GZIP_DATA,
ERR_BAD_GZIP_HEADER,
ERR_BAD_PART_TABLE,
ERR_BAD_VERSION,
ERR_BELOW_1MB,
ERR_BOOT_COMMAND,
ERR_BOOT_FAILURE,
ERR_BOOT_FEATURES,
ERR_DEV_FORMAT,
ERR_DEV_VALUES,
ERR_EXEC_FORMAT,
ERR_FILELENGTH,
ERR_FILE_NOT_FOUND,
ERR_FSYS_CORRUPT,
ERR_FSYS_MOUNT,
ERR_GEOM,
ERR_NEED_LX_KERNEL,
ERR_NEED_MB_KERNEL,
ERR_NO_DISK,
ERR_NO_PART,
ERR_NUMBER_PARSING,
ERR_OUTSIDE_PART,
ERR_READ,
ERR_SYMLINK_LOOP,
ERR_UNRECOGNIZED,
ERR_WONT_FIT,
ERR_WRITE,
MAX_ERR_NUM
};
/* returns packed BIOS/ASCII code */
#define BIOS_CODE(x) ((x) >> 8)
@ -371,7 +375,7 @@ int get_cmdline(char *prompt, char *commands, char *cmdline, int maxlen);
int tolower(int c);
int isspace(int c);
int strncat(char *s1, char *s2, int n);
int strcmp(char *s1, char *s2);
int substring(char *s1, char *s2);
char *strstr(char *s1, char *s2);
int bcopy(char *from, char *to, int len);
int bzero(char *start, int len);

View file

@ -529,7 +529,7 @@ cmain(void)
{
ptr = skip_to(1, cmdline);
if (strcmp("title", cmdline) < 1)
if (substring("title", cmdline) < 1)
{
if (state > 1)
{
@ -551,13 +551,13 @@ cmain(void)
}
else if (!state)
{
if (strcmp("timeout", cmdline) < 1)
if (substring("timeout", cmdline) < 1)
safe_parse_maxint(&ptr, &timeout);
if (strcmp("fallback", cmdline) < 1)
if (substring("fallback", cmdline) < 1)
safe_parse_maxint(&ptr, &fallback);
if (strcmp("default", cmdline) < 1)
if (substring("default", cmdline) < 1)
safe_parse_maxint(&ptr, &default_entry);
if (strcmp("password", cmdline) < 1)
if (substring("password", cmdline) < 1)
{
char *ptrend = ptr;
password = config_entries;

View file

@ -6,15 +6,14 @@ CFLAGS= $(SHARED_FLAGS)
all: ../bin/stage1
stage1.o: stage1.S Makefile ../Makefile
stage1.o: stage1.S
$(CC) $(CFLAGS) -c -o stage1.o stage1.S
stage1.exec: stage1.o Makefile ../Makefile
stage1.exec: stage1.o
$(LD) -N -Ttext 7C00 -o stage1.exec stage1.o
../bin/stage1: stage1.exec Makefile ../Makefile
../bin/stage1: stage1.exec
$(OBJCOPY) -O binary stage1.exec ../bin/stage1
clean:
rm -f stage1.o stage1.exec

View file

@ -1,8 +1,8 @@
#
# GRUB stage2 makefile
# GRUB program makefile
#
CFLAGS= $(SHARED_FLAGS) -I../shared_src
COMPILE = $(CC) $(CPPFLAGS) $(CFLAGS) $(SHARED_FLAGS) -I../shared_src
# "asm.o" absolutely must come first!!!
SHARED_OBJS= asm.o common.o char_io.o boot.o cmdline.o gunzip.o \
@ -10,61 +10,53 @@ SHARED_OBJS= asm.o common.o char_io.o boot.o cmdline.o gunzip.o \
all: ../bin/stage2
asm.o: ../shared_src/asm.S ../shared_src/shared.h Makefile ../Makefile
$(CC) $(CFLAGS) -c ../shared_src/asm.S
asm.o: ../shared_src/asm.S ../shared_src/shared.h
$(COMPILE) -c ../shared_src/asm.S
boot.o: ../shared_src/boot.c ../shared_src/shared.h Makefile ../Makefile
$(CC) $(CFLAGS) -c ../shared_src/boot.c
boot.o: ../shared_src/boot.c ../shared_src/shared.h
$(COMPILE) -c ../shared_src/boot.c
char_io.o: ../shared_src/char_io.c ../shared_src/shared.h Makefile \
../Makefile
$(CC) $(CFLAGS) -c ../shared_src/char_io.c
char_io.o: ../shared_src/char_io.c ../shared_src/shared.h
$(COMPILE) -c ../shared_src/char_io.c
cmdline.o: ../shared_src/cmdline.c ../shared_src/shared.h Makefile \
../Makefile
$(CC) $(CFLAGS) -c ../shared_src/cmdline.c
cmdline.o: ../shared_src/cmdline.c ../shared_src/shared.h
$(COMPILE) -c ../shared_src/cmdline.c
common.o: ../shared_src/common.c ../shared_src/shared.h Makefile \
../Makefile
$(CC) $(CFLAGS) -c ../shared_src/common.c
common.o: ../shared_src/common.c ../shared_src/shared.h
$(COMPILE) -c ../shared_src/common.c
gunzip.o: ../shared_src/gunzip.c ../shared_src/shared.h Makefile \
../Makefile
$(CC) $(CFLAGS) -c ../shared_src/gunzip.c
gunzip.o: ../shared_src/gunzip.c ../shared_src/shared.h
$(COMPILE) -c ../shared_src/gunzip.c
disk_io.o: ../shared_src/disk_io.c ../shared_src/filesys.h \
../shared_src/pc_slice.h ../shared_src/shared.h Makefile \
../Makefile
$(CC) $(CFLAGS) -c ../shared_src/disk_io.c
../shared_src/pc_slice.h ../shared_src/shared.h
$(COMPILE) -c ../shared_src/disk_io.c
stage2.o: ../shared_src/stage2.c ../shared_src/shared.h Makefile \
../Makefile
$(CC) $(CFLAGS) -c ../shared_src/stage2.c
stage2.o: ../shared_src/stage2.c ../shared_src/shared.h
$(COMPILE) -c ../shared_src/stage2.c
fsys_ffs.o: ../shared_src/fsys_ffs.c ../shared_src/filesys.h \
../shared_src/pc_slice.h ../shared_src/shared.h \
../shared_src/defs.h ../shared_src/disk_inode.h \
../shared_src/disk_inode_ffs.h ../shared_src/dir.h \
../shared_src/fs.h Makefile ../Makefile
$(CC) $(CFLAGS) -c ../shared_src/fsys_ffs.c
../shared_src/fs.h
$(COMPILE) -c ../shared_src/fsys_ffs.c
fsys_ext2fs.o: ../shared_src/fsys_ext2fs.c ../shared_src/filesys.h \
../shared_src/pc_slice.h ../shared_src/shared.h Makefile \
../Makefile
$(CC) $(CFLAGS) -c ../shared_src/fsys_ext2fs.c
../shared_src/pc_slice.h ../shared_src/shared.h
$(COMPILE) -c ../shared_src/fsys_ext2fs.c
fsys_fat.o: ../shared_src/fsys_fat.c ../shared_src/filesys.h \
../shared_src/pc_slice.h ../shared_src/shared.h \
../shared_src/fat.h Makefile ../Makefile
$(CC) $(CFLAGS) -c ../shared_src/fsys_fat.c
../shared_src/fat.h
$(COMPILE) -c ../shared_src/fsys_fat.c
# "asm.o" absolutely has to come first in the link line!
stage2.exec: $(SHARED_OBJS) Makefile ../Makefile
stage2.exec: $(SHARED_OBJS)
$(LD) -N -Ttext 8000 -o stage2.exec $(SHARED_OBJS)
../bin/stage2: stage2.exec Makefile ../Makefile
../bin/stage2: stage2.exec
$(OBJCOPY) -O binary stage2.exec ../bin/stage2
clean:
rm -f $(SHARED_OBJS) stage2.exec

View file

@ -10,61 +10,53 @@ SHARED_OBJS= asm.o common.o char_io.o boot.o cmdline.o gunzip.o \
all: ../bin/stage2_debug
asm.o: ../shared_src/asm.S ../shared_src/shared.h Makefile ../Makefile
asm.o: ../shared_src/asm.S ../shared_src/shared.h
$(CC) $(CFLAGS) -c ../shared_src/asm.S
boot.o: ../shared_src/boot.c ../shared_src/shared.h Makefile ../Makefile
boot.o: ../shared_src/boot.c ../shared_src/shared.h
$(CC) $(CFLAGS) -c ../shared_src/boot.c
char_io.o: ../shared_src/char_io.c ../shared_src/shared.h Makefile \
../Makefile
char_io.o: ../shared_src/char_io.c ../shared_src/shared.h
$(CC) $(CFLAGS) -c ../shared_src/char_io.c
cmdline.o: ../shared_src/cmdline.c ../shared_src/shared.h Makefile \
../Makefile
cmdline.o: ../shared_src/cmdline.c ../shared_src/shared.h
$(CC) $(CFLAGS) -c ../shared_src/cmdline.c
common.o: ../shared_src/common.c ../shared_src/shared.h Makefile \
../Makefile
common.o: ../shared_src/common.c ../shared_src/shared.h
$(CC) $(CFLAGS) -c ../shared_src/common.c
gunzip.o: ../shared_src/gunzip.c ../shared_src/shared.h Makefile \
../Makefile
gunzip.o: ../shared_src/gunzip.c ../shared_src/shared.h
$(CC) $(CFLAGS) -c ../shared_src/gunzip.c
disk_io.o: ../shared_src/disk_io.c ../shared_src/filesys.h \
../shared_src/pc_slice.h ../shared_src/shared.h Makefile \
../Makefile
../shared_src/pc_slice.h ../shared_src/shared.h
$(CC) $(CFLAGS) -c ../shared_src/disk_io.c
stage2.o: ../shared_src/stage2.c ../shared_src/shared.h Makefile \
../Makefile
stage2.o: ../shared_src/stage2.c ../shared_src/shared.h
$(CC) $(CFLAGS) -c ../shared_src/stage2.c
fsys_ffs.o: ../shared_src/fsys_ffs.c ../shared_src/filesys.h \
../shared_src/pc_slice.h ../shared_src/shared.h \
../shared_src/defs.h ../shared_src/disk_inode.h \
../shared_src/disk_inode_ffs.h ../shared_src/dir.h \
../shared_src/fs.h Makefile ../Makefile
../shared_src/fs.h
$(CC) $(CFLAGS) -c ../shared_src/fsys_ffs.c
fsys_ext2fs.o: ../shared_src/fsys_ext2fs.c ../shared_src/filesys.h \
../shared_src/pc_slice.h ../shared_src/shared.h Makefile \
../Makefile
../shared_src/pc_slice.h ../shared_src/shared.h
$(CC) $(CFLAGS) -c ../shared_src/fsys_ext2fs.c
fsys_fat.o: ../shared_src/fsys_fat.c ../shared_src/filesys.h \
../shared_src/pc_slice.h ../shared_src/shared.h \
../shared_src/fat.h Makefile ../Makefile
../shared_src/fat.h
$(CC) $(CFLAGS) -c ../shared_src/fsys_fat.c
# "asm.o" absolutely has to come first in the link line!
stage2.exec: $(SHARED_OBJS) Makefile ../Makefile
stage2.exec: $(SHARED_OBJS)
$(LD) -N -Ttext 8000 -o stage2.exec $(SHARED_OBJS)
../bin/stage2_debug: stage2.exec Makefile ../Makefile
../bin/stage2_debug: stage2.exec
$(OBJCOPY) -O binary stage2.exec ../bin/stage2_debug
clean:
rm -f $(SHARED_OBJS) stage2.exec