Commit yaboot 1.3.4-pre3.
git-archimport-id: erbenson@alaska.net--public/yaboot--devel--1.3--patch-7
# tag: automatic-ChangeLog--erbenson@alaska.net--public/yaboot--devel--1.3
#
+2002-03-26 15:00:49 GMT Ethan Benson <erbenson@alaska.net> patch-7
+
+ Summary:
+ Commit yaboot 1.3.4-pre3
+ Revision:
+ yaboot--devel--1.3--patch-7
+
+ Commit yaboot 1.3.4-pre3.
+
+ new files:
+ include/.arch-ids/debug.h.id include/debug.h
+
+ modified files:
+ ChangeLog Makefile changelog include/errors.h include/file.h
+ include/fs.h include/partition.h include/prom.h second/cfg.c
+ second/file.c second/fs_ext2.c second/fs_of.c
+ second/fs_reiserfs.c second/fs_xfs.c second/partition.c
+ second/prom.c second/yaboot.c ybin/ybin
+
+
2002-03-26 14:42:58 GMT Ethan Benson <erbenson@alaska.net> patch-6
Summary:
include Config
-VERSION = 1.3.4pre2
+VERSION = 1.3.4pre3
# Debug mode (spam/verbose)
DEBUG = 0
# make install vars
+2001-10-12 Ethan Benson <erbenson@alaska.net>
+
+ * Version 1.3.4pre3
+
+ * ybin: Correct a verbosity message.
+
+ * yaboot:
+ - Add non-fatal warning when bootstrap partition has wrong type (pmac only).
+ - Minor code rearrangment.
+
2001-10-10 Ethan Benson <erbenson@alaska.net>
* Version 1.3.4pre2
--- /dev/null
+/*
+ * Debug defines
+ *
+ * Copyright (C) 2001 Ethan Benson
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#if DEBUG
+# define DEBUG_ENTER prom_printf( "--> %s\n", __PRETTY_FUNCTION__ )
+# define DEBUG_LEAVE(str) \
+ prom_printf( "<-- %s - %s\n", __PRETTY_FUNCTION__, #str )
+# define DEBUG_LEAVE_F(args...)\
+{\
+ prom_printf( "<-- %s - %d\n", __PRETTY_FUNCTION__, ## args );\
+}
+# define DEBUG_F(fmt, args...)\
+{\
+ prom_printf( " %s - ", __PRETTY_FUNCTION__ );\
+ prom_printf( fmt, ## args );\
+}
+# define DEBUG_OPEN DEBUG_F( "dev=%s, part=0x%p (%d), file_name=%s\n",\
+ dev_name, part, part ? part->part_number : -1,\
+ file_name)
+# define DEBUG_SLEEP prom_sleep(3)
+#else
+#define DEBUG_ENTER
+#define DEBUG_LEAVE(x)
+#define DEBUG_LEAVE_F(args...)
+#define DEBUG_F(fmt, args...)
+#define DEBUG_OPEN
+#define DEBUG_SLEEP
+#endif
#define FILE_ERR_LENGTH -10
#define FILE_ERR_FSBUSY -11
#define FILE_ERR_BADDEV -12
+
+/* Device kind */
+#define FILE_DEVICE_BLOCK 1
+#define FILE_DEVICE_NET 2
#define FILE_MAX_PATH 1024
-/* Device kind */
-#define FILE_DEVICE_BLOCK 1
-#define FILE_DEVICE_NET 2
-
struct boot_fspec_t {
char* dev; /* OF device path */
int part; /* Partition number or -1 */
const struct fs_t *fs_open(struct boot_file_t *file, const char *dev_name,
struct partition_t *part, const char *file_name);
-#if DEBUG
-# define DEBUG_ENTER prom_printf( "--> %s\n", __PRETTY_FUNCTION__ )
-# define DEBUG_LEAVE(str) \
- prom_printf( "<-- %s - %s\n", __PRETTY_FUNCTION__, #str )
-# define DEBUG_LEAVE_F(args...)\
-{\
- prom_printf( "<-- %s - %d\n", __PRETTY_FUNCTION__, ## args );\
-}
-# define DEBUG_F(fmt, args...)\
-{\
- prom_printf( " %s - ", __PRETTY_FUNCTION__ );\
- prom_printf( fmt, ## args );\
-}
-# define DEBUG_OPEN DEBUG_F( "dev=%s, part=0x%p (%d), file_name=%s\n",\
- dev_name, part, part ? part->part_number : -1,\
- file_name)
-# define DEBUG_SLEEP prom_sleep(3)
-#else
-#define DEBUG_ENTER
-#define DEBUG_LEAVE(x)
-#define DEBUG_LEAVE_F(args...)
-#define DEBUG_F(fmt, args...)
-#define DEBUG_OPEN
-#define DEBUG_SLEEP
-#endif
-
#endif
struct partition_t {
struct partition_t* next;
int part_number;
- char part_name[MAX_PART_NAME];
+ char part_type[MAX_PART_NAME];
+ char part_name[MAX_PART_NAME];
unsigned long part_start; /* In blocks */
unsigned long part_size; /* In blocks */
unsigned short blocksize;
};
extern struct partition_t* partitions_lookup(const char *device);
+extern char *get_part_type(char *device, int partition);
extern void partitions_free(struct partition_t* list);
-
-
#endif
prom_handle prom_finddevice (char *name);
prom_handle prom_findpackage (char *path);
int prom_getprop (prom_handle dev, char *name, void *buf, int len);
+int prom_get_devtype (char *device);
/* misc */
{cft_strg, "init-message", NULL},
{cft_strg, "fgcolor", NULL},
{cft_strg, "bgcolor", NULL},
+ {cft_strg, "ptypewarning", NULL},
{cft_end, NULL, NULL}};
CONFIG cf_image[] =
#include "partition.h"
#include "fs.h"
#include "errors.h"
+#include "debug.h"
extern char bootdevice[1024];
return 1;
}
-#if 0
-char *
-parse_device_path(char *of_device, char **file_spec, int *partition)
-{
- char *p, *last;
-
- if (file_spec)
- *file_spec = NULL;
- if (partition)
- *partition = -1;
-
- DEBUG_F("of_device before parsing: %s\n", of_device);
- p = strchr(of_device, ':');
- DEBUG_F("of_device after parsing: %s\n", p);
-
- if (!p) { /* if null terminated we are finished */
- DEBUG_F("of_device: %s\n", of_device);
- return of_device;
- }
-#if 0 /* this is broken crap, breaks netboot entirely */
- else if (strstr(of_device, "ethernet") != NULL)
- p = strchr(of_device, ','); /* skip over ip all the way to the ',' */
- else if (strstr(of_device, "enet") != NULL)
- p = strchr(of_device, ','); /* skip over ip all the way to the ',' */
-#endif
- *p = 0;
- last = ++p; /* sets to start of second part */
- while(*p && *p != ',') {
- if (!isdigit (*p)) {
- p = last;
- break;
- }
- ++p;
- }
- if (p != last) {
- *(p++) = 0;
- if (partition)
- *partition = simple_strtol(last, NULL, 10);
- }
- if (*p && file_spec)
- *file_spec = p;
-
- DEBUG_F("of_device: %s\n", of_device);
- strcat(of_device, ":");
- DEBUG_F("of_device after strcat: %s\n", of_device);
- return of_device;
-}
-
-int
-validate_fspec( struct boot_fspec_t* spec,
- char* default_device,
- int default_part)
-{
- if (!spec->file) {
- spec->file = spec->dev;
- spec->dev = NULL;
- }
- if (spec->part == -1)
- spec->part = default_part;
- if (!spec->dev)
- spec->dev = default_device;
- if (!spec->file)
- return FILE_BAD_PATH;
- else if (spec->file[0] == ',')
- spec->file++;
-
- return FILE_ERR_OK;
-}
-
-#endif
static int
file_block_open( struct boot_file_t* file,
};
-int open_file( const struct boot_fspec_t* spec,
- struct boot_file_t* file)
+int open_file(const struct boot_fspec_t* spec, struct boot_file_t* file)
{
-// static char temp[1024];
- static char temps[64];
-// char *dev_name;
-// char *file_name = NULL;
- phandle dev;
int result;
- int partition;
memset(file, 0, sizeof(struct boot_file_t*));
file->fs = &fs_default;
- /* Lookup the OF device path */
- /* First, see if a device was specified for the kernel
- * if not, we hope that the user wants a kernel on the same
- * drive and partition as yaboot itself */
-#if 0 /* this is crap */
- if (!spec->dev)
- strcpy(spec->dev, bootdevice);
- strncpy(temp,spec->dev,1024);
- dev_name = parse_device_path(temp, &file_name, &partition);
- if (file_name == NULL)
- file_name = (char *)spec->file;
- if (file_name == NULL) {
- prom_printf("Configuration error: null filename\n");
- return FILE_ERR_NOTFOUND;
- }
- if (partition == -1)
-#endif
- partition = spec->part;
-
-
DEBUG_F("dev_path = %s\nfile_name = %s\npartition = %d\n",
- spec->dev, spec->file, partition);
-
- /* Find OF device phandle */
- dev = prom_finddevice(spec->dev);
- if (dev == PROM_INVALID_HANDLE) {
- return FILE_ERR_BADDEV;
- }
-
- DEBUG_F("dev_phandle = %p\n", dev);
+ spec->dev, spec->file, spec->part);
- /* Check the kind of device */
- result = prom_getprop(dev, "device_type", temps, 63);
- if (result == -1) {
- prom_printf("can't get <device_type> for device\n");
- return FILE_ERR_BADDEV;
- }
- temps[result] = 0;
- if (!strcmp(temps, "block"))
- file->device_kind = FILE_DEVICE_BLOCK;
- else if (!strcmp(temps, "network"))
- file->device_kind = FILE_DEVICE_NET;
- else {
- prom_printf("Unkown device type <%s>\n", temps);
- return FILE_ERR_BADDEV;
- }
+ result = prom_get_devtype(spec->dev);
+ if (result > 0)
+ file->device_kind = result;
+ else
+ return result;
switch(file->device_kind) {
case FILE_DEVICE_BLOCK:
DEBUG_F("device is a block device\n");
- return file_block_open(file, spec->dev, spec->file, partition);
+ return file_block_open(file, spec->dev, spec->file, spec->part);
case FILE_DEVICE_NET:
DEBUG_F("device is a network device\n");
return file_net_open(file, spec->dev, spec->file);
#include "partition.h"
#include "fs.h"
#include "errors.h"
+#include "debug.h"
#define FAST_VERSION
#define MAX_READ_RANGE 256
#include "partition.h"
#include "fs.h"
#include "errors.h"
+#include "debug.h"
#define LOAD_BUFFER_POS 0x600000
#define LOAD_BUFFER_SIZE 0x400000
#include "stdlib.h"
#include "fs.h"
#include "errors.h"
+#include "debug.h"
#include "reiserfs/reiserfs.h"
-
/* Exported in struct fs_t */
static int reiserfs_open( struct boot_file_t *file, const char *dev_name,
struct partition_t *part, const char *file_name );
#include "fs.h"
#include "xfs/xfs.h"
#include "errors.h"
+#include "debug.h"
#define SECTOR_BITS 9
#include "prom.h"
#include "string.h"
#include "linux/iso_fs.h"
+#include "debug.h"
+#include "errors.h"
/* We currently don't check the partition type, some users
* are putting crap there and still expect it to work...
static unsigned char block_buffer[MAX_BLOCK_SIZE];
static void
-add_new_partition( struct partition_t** list, int part_number,
- unsigned long part_start, unsigned long part_size,
- unsigned short part_blocksize )
+add_new_partition(struct partition_t** list, int part_number, const char *part_type,
+ const char *part_name, unsigned long part_start, unsigned long part_size,
+ unsigned short part_blocksize)
{
struct partition_t* part;
part = (struct partition_t*)malloc(sizeof(struct partition_t));
part->part_number = part_number;
+ strncpy(part->part_type, part_type, MAX_PART_NAME);
+ strncpy(part->part_name, part_name, MAX_PART_NAME);
part->part_start = part_start;
part->part_size = part_size;
part->blocksize = part_blocksize;
add_new_partition(
list, /* partition list */
block, /* partition number */
+ part->type, /* type */
+ part->name, /* name */
part->start_block + part->data_start, /* start */
part->data_count, /* size */
ptable_block_size );
if (part->sys_ind == LINUX_NATIVE) {
add_new_partition( list,
partition,
+ "Linux", /* type */
+ '\0', /* name */
swab32(*(unsigned int *)(part->start4)),
swab32(*(unsigned int *)(part->size4)),
512 /*blksize*/ );
goto bail;
}
prom_blksize = prom_getblksize(disk);
-#if DEBUG
- prom_printf("block size of device is %d\n", prom_blksize);
-#endif
+ DEBUG_F("block size of device is %d\n", prom_blksize);
+
if (prom_blksize <= 1)
prom_blksize = 512;
if (prom_blksize > MAX_BLOCK_SIZE) {
/* Read boot blocs */
if (prom_readblocks(disk, 0, 1, block_buffer) != 1) {
- prom_printf("Can't read boot blocs\n");
+ prom_printf("Can't read boot blocks\n");
goto bail;
}
if (desc->signature == MAC_DRIVER_MAGIC) {
/* fdisk partition format */
partition_fdisk_lookup(device, disk, prom_blksize, &list);
} else if (prom_blksize == 2048 && identify_iso_fs(disk, &iso_root_block)) {
- add_new_partition( &list,
- 0,
- iso_root_block,
- 0,
- prom_blksize);
+ add_new_partition(&list,
+ 0,
+ '\0',
+ '\0',
+ iso_root_block,
+ 0,
+ prom_blksize);
prom_printf("ISO9660 disk\n");
} else {
prom_printf("No supported partition table detected\n");
return list;
}
+char *
+get_part_type(char *device, int partition)
+{
+ struct partition_t* parts;
+ struct partition_t* p;
+ struct partition_t* found;
+ char *type = NULL;
+
+ if (prom_get_devtype(device) != FILE_DEVICE_BLOCK)
+ return NULL;
+
+ parts = partitions_lookup(device);
+ found = NULL;
+
+ if (!parts)
+ return '\0';
+
+ for (p = parts; p && !found; p=p->next) {
+ DEBUG_F("number: %02d, start: 0x%08lx, length: 0x%08lx, type: %s, name: %s\n",
+ p->part_number, p->part_start, p->part_size, p->part_type, p->part_name);
+ if ((partition >= 0) && (partition == p->part_number)) {
+ type = strdup(p->part_type);
+ break;
+ }
+ }
+ if (parts)
+ partitions_free(parts);
+ return type;
+}
+
/* Freed in reverse order of allocation to help malloc'ator */
void
partitions_free(struct partition_t* list)
}
+/*
+ * Local variables:
+ * c-file-style: "K&R"
+ * c-basic-offset: 5
+ * End:
+ */
return prom_getprop (prom_options, name, mem, len);
}
+int
+prom_get_devtype (char *device)
+{
+ phandle dev;
+ int result;
+ char tmp[64];
+
+ /* Find OF device phandle */
+ dev = prom_finddevice(device);
+ if (dev == PROM_INVALID_HANDLE) {
+ return FILE_ERR_BADDEV;
+ }
+
+ /* Check the kind of device */
+ result = prom_getprop(dev, "device_type", tmp, 63);
+ if (result == -1) {
+ prom_printf("can't get <device_type> for device: %s\n", device);
+ return FILE_ERR_BADDEV;
+ }
+ tmp[result] = 0;
+ if (!strcmp(tmp, "block"))
+ return FILE_DEVICE_BLOCK;
+ else if (!strcmp(tmp, "network"))
+ return FILE_DEVICE_NET;
+ else {
+ prom_printf("Unkown device type <%s>\n", tmp);
+ return FILE_ERR_BADDEV;
+ }
+}
+
void
prom_init (prom_entry pp)
{
Because this program is derived from the corresponding file in the
silo-0.64 distribution, it is also
-sys
+
Copyright (C) 1996 Pete A. Zaitcev
1996 Maurizio Plaza
1996 David S. Miller
#include "yaboot.h"
#include "linux/elf.h"
#include "bootinfo.h"
+#include "debug.h"
#define CONFIG_FILE_NAME "yaboot.conf"
#define CONFIG_FILE_MAX 0x8000 /* 32k */
int useconf = 0;
char bootdevice[1024];
-//char *bootpath = NULL;
char *password = NULL;
-//int bootpartition = -1;
struct boot_fspec_t boot;
int _machine = _MACH_Pmac;
fspec.part = partition;
result = open_file(&fspec, &file);
if (result != FILE_ERR_OK) {
- prom_printf("%s:%d", fspec.dev, fspec.part);
+ prom_printf("%s:%d,", fspec.dev, fspec.part);
prom_perror(result, fspec.file);
prom_printf("Can't open config file\n");
goto bail;
int
yaboot_main(void)
{
- if (_machine == _MACH_Pmac)
- setup_display();
-
- prom_get_chosen("bootpath", bootdevice, sizeof(bootdevice));
- DEBUG_F("/chosen/bootpath = %s\n", bootdevice);
- if (bootdevice[0] == 0)
- prom_get_options("boot-device", bootdevice, sizeof(bootdevice));
- if (bootdevice[0] == 0) {
- prom_printf("Couldn't determine boot device\n");
- return -1;
- }
-
- if (!parse_device_path(bootdevice, (_machine == _MACH_Pmac) ? "hd" : "disc",
- -1, "", &boot)) {
- prom_printf("%s: Unable to parse\n", bootdevice);
- return -1;
- }
- DEBUG_F("After parse_device_path: dev=%s, part=%d, file=%s\n",
- boot.dev, boot.part, boot.file);
+ char *ptype;
- if (strlen(boot.file)) {
- if (!strncmp(boot.file, "\\\\", 2))
- boot.file = "\\\\";
- else {
- char *p, *last;
- p = last = boot.file;
- while(*p) {
- if (*p == '\\')
- last = p;
- p++;
- }
- if (p)
- *(last) = 0;
- else
- boot.file = "";
- if (strlen(boot.file))
- strcat(boot.file, "\\");
- }
- }
- DEBUG_F("After path fixup: dev=%s, part=%d, file=%s\n",
- boot.dev, boot.part, boot.file);
-
- useconf = load_config_file(boot.dev, boot.file, boot.part);
-
- prom_printf("Welcome to yaboot version " VERSION "\n");
- prom_printf("Enter \"help\" to get some basic usage information\n");
+ if (_machine == _MACH_Pmac)
+ setup_display();
- yaboot_text_ui();
+ prom_get_chosen("bootpath", bootdevice, sizeof(bootdevice));
+ DEBUG_F("/chosen/bootpath = %s\n", bootdevice);
+ if (bootdevice[0] == 0)
+ prom_get_options("boot-device", bootdevice, sizeof(bootdevice));
+ if (bootdevice[0] == 0) {
+ prom_printf("Couldn't determine boot device\n");
+ return -1;
+ }
+
+ if (!parse_device_path(bootdevice, (_machine == _MACH_Pmac) ? "hd" : "disc",
+ -1, "", &boot)) {
+ prom_printf("%s: Unable to parse\n", bootdevice);
+ return -1;
+ }
+ DEBUG_F("After parse_device_path: dev=%s, part=%d, file=%s\n",
+ boot.dev, boot.part, boot.file);
+
+ if (strlen(boot.file)) {
+ if (!strncmp(boot.file, "\\\\", 2))
+ boot.file = "\\\\";
+ else {
+ char *p, *last;
+ p = last = boot.file;
+ while(*p) {
+ if (*p == '\\')
+ last = p;
+ p++;
+ }
+ if (p)
+ *(last) = 0;
+ else
+ boot.file = "";
+ if (strlen(boot.file))
+ strcat(boot.file, "\\");
+ }
+ }
+ DEBUG_F("After path fixup: dev=%s, part=%d, file=%s\n",
+ boot.dev, boot.part, boot.file);
+
+ useconf = load_config_file(boot.dev, boot.file, boot.part);
+
+ prom_printf("Welcome to yaboot version " VERSION "\n");
+ prom_printf("Enter \"help\" to get some basic usage information\n");
+
+ /* I am fed up with lusers using the wrong partition type and
+ mailing me *when* it breaks */
+
+ if (_machine == _MACH_Pmac) {
+ char *entry = cfg_get_strg(0, "ptypewarning");
+ int warn = 1;
+ if (entry)
+ warn = strcmp(entry,
+ "I_know_the_partition_type_is_wrong_and_will_NOT_send_mail_when_booting_breaks");
+ if (warn) {
+ ptype = get_part_type(boot.dev, boot.part);
+ if ((ptype != NULL) && (strcmp(ptype, "Apple_Bootstrap")))
+ prom_printf("\nWARNING: Bootstrap partition type is wrong: \"%s\"\n"
+ " type should be: \"Apple_Bootstrap\"\n\n", ptype);
+ }
+ }
+
+ yaboot_text_ui();
- prom_printf("Bye.\n");
- return 0;
+ prom_printf("Bye.\n");
+ return 0;
}
+
/*
* Local variables:
* c-file-style: "K&R"
fi
PRG="${0##*/}"
SIGINT="$PRG: Interrupt caught ... exiting"
-VERSION=1.3.4pre2
+VERSION=1.3.4pre3
DEBUG=0
VERBOSE=0
TMP="${TMPDIR:-/tmp}"
fi
fi
- [ "$VERBOSE" = 1 ] && echo "$INSTALLFIRST"
+ [ "$VERBOSE" = 1 ] && echo "$INSTALLPRIMARY"
cp -f "$install" "$TARGET/$BTFILE"
if [ $? != 0 ] ; then
echo 1>&2 "$PRG: An error occured while writing to $boot"