summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbcollins <tailor@grayson>2006-06-01 13:19:47 -0400
committerBen Collins <bcollins@ubuntu.com>2006-06-01 13:19:47 -0400
commitec7fd3b5657378fb484fbcc27de77ecec3fa164d (patch)
tree480b4fe6493aa26e9451a894884086cb307d2380
parent5836ca53ef54667af7908e32a27be02312b1e30e (diff)
downloadsilo-ec7fd3b5657378fb484fbcc27de77ecec3fa164d.tar.gz
[silo @ 160]
Ben, this patch is to work around some build problems with gcc-4.x that fabbione was running into. Somehow, some normal userland headers are getting fetched during the second stage bootloader build. (probably via some gcc internal header or something like that) And of course things go south because second/disk.c exports routines with names like "open()" and "close()", ie. not good for global namespace. I hit as much of the include/silo.h functions as I easily could, usually adding the "silo_" prefix to their names then fixing up the tree. xmit() wasn't used by anything, so I deleted it.#
-rw-r--r--first-isofs/isofs.c14
-rw-r--r--include/silo.h37
-rw-r--r--second/cmdline.c4
-rw-r--r--second/disk.c67
-rw-r--r--second/file.c12
-rw-r--r--second/fs/iom.c10
-rw-r--r--second/fs/ufs.c2
-rw-r--r--second/main.c131
-rw-r--r--second/misc.c24
-rw-r--r--silo/silo.c224
-rw-r--r--silo/silocheck.c32
11 files changed, 302 insertions, 255 deletions
diff --git a/first-isofs/isofs.c b/first-isofs/isofs.c
index 986e563..adc220d 100644
--- a/first-isofs/isofs.c
+++ b/first-isofs/isofs.c
@@ -56,8 +56,8 @@ static int open_namei(const char *pathname, struct isofs_inode *res_inode,
static int cd_init (void)
{
- char bootdevice[1024];
- char *s = bootdevice;
+ char iso_bootdevice[1024];
+ char *s = iso_bootdevice;
if (prom_vers == PROM_V0) {
struct linux_arguments_v0 *ap = *romvec->pv_v0bootargs;
@@ -74,12 +74,12 @@ static int cd_init (void)
*s++ = ')';
*s = 0;
- fd = (*romvec->pv_v0devops.v0_devopen) (bootdevice);
+ fd = (*romvec->pv_v0devops.v0_devopen) (iso_bootdevice);
} else {
if (prom_vers == PROM_P1275)
- prom_getproperty (prom_chosen, "bootpath", bootdevice, sizeof(bootdevice));
+ prom_getproperty (prom_chosen, "bootpath", iso_bootdevice, sizeof(iso_bootdevice));
else
- strcpy(bootdevice, *romvec->pv_v2bootargs.bootpath);
+ strcpy(iso_bootdevice, *romvec->pv_v2bootargs.bootpath);
for (; *s && *s != ':'; s++)
/* Do nothing */;
@@ -90,9 +90,9 @@ static int cd_init (void)
s[1] = 'a';
if (prom_vers == PROM_P1275)
- fd = p1275_cmd ("open", 1, bootdevice);
+ fd = p1275_cmd ("open", 1, iso_bootdevice);
else
- fd = (*romvec->pv_v2devops.v2_dev_open) (bootdevice);
+ fd = (*romvec->pv_v2devops.v2_dev_open) (iso_bootdevice);
}
if (fd == 0 || fd == -1)
diff --git a/include/silo.h b/include/silo.h
index f49be5f..0aa05dc 100644
--- a/include/silo.h
+++ b/include/silo.h
@@ -67,8 +67,8 @@ struct silo_inode {
#define LOADFILE_LS_MATCH (LOADFILE_MATCH | LOADFILE_MATCH)
/* cmdline.c */
-void cmdinit ();
-void cmdedit (void (*)(void),int);
+void silo_cmdinit(void);
+void silo_cmdedit(void (*)(void), int);
extern char cbuff[];
extern char passwdbuff[];
/* ls.c */
@@ -78,14 +78,13 @@ extern char passwdbuff[];
extern int ls_opt;
int do_ls (unsigned char *, int *);
/* disk.c */
-extern char bootdevice[];
-int diskinit (void);
-int read (char *, int, unsigned long long);
-int xmit (char *, int);
-int open (char *);
-int setdisk (char *);
-int partitionable (void);
-void close (void);
+char *silo_disk_get_bootdevice(void);
+int silo_diskinit(void);
+int silo_disk_read(char *, int, unsigned long long);
+int silo_disk_open(char *);
+int silo_disk_setdisk(char *);
+int silo_disk_partitionable(void);
+void silo_disk_close(void);
/* printf.c */
int vprintf (char *, va_list);
int putchar (int);
@@ -95,16 +94,16 @@ void free (void *);
void mark (void **);
void release (void *);
/* file.c */
-int load_file (char *, int, char *, char *, char *, int *, int, void (*)(int, char **, char **));
+int silo_load_file(char *, int, char *, char *, char *, int *, int, void (*)(int, char **, char **));
/* misc.c */
-void fatal (const char *);
-char *get_bootargs (int);
-void show_bootargs (void);
-void set_bootargs (char *, char *);
-void set_prollargs (char *, unsigned int, int);
-char *v0_device (char *);
-enum arch get_architecture();
-unsigned char *find_linux_HdrS (char *, int);
+void silo_fatal(const char *);
+char *silo_get_bootargs(int);
+void silo_show_bootargs(void);
+void silo_set_bootargs(char *, char *);
+void silo_set_prollargs(char *, unsigned int, int);
+char *silo_v0_device(char *);
+enum arch silo_get_architecture(void);
+unsigned char *silo_find_linux_HdrS(char *, int);
void print_message(char *);
void get_idprom(void);
char *get_syspackage(void);
diff --git a/second/cmdline.c b/second/cmdline.c
index 421cdc9..9ef0833 100644
--- a/second/cmdline.c
+++ b/second/cmdline.c
@@ -27,13 +27,13 @@ char passwdbuff[CMD_LENG];
extern int useconf;
extern int tab_ambiguous;
-void cmdinit ()
+void silo_cmdinit(void)
{
cbuff[0] = 0;
passwdbuff[0] = 0;
}
-void cmdedit (void (*tabfunc) (void), int password)
+void silo_cmdedit(void (*tabfunc)(void), int password)
{
int x, c;
char *buff = password ? passwdbuff : cbuff;
diff --git a/second/disk.c b/second/disk.c
index 74f05b7..40234b3 100644
--- a/second/disk.c
+++ b/second/disk.c
@@ -26,10 +26,15 @@ static int floppy = 0;
static unsigned int flash = 0;
static int fd;
static unsigned long long seekp;
-char bootdevice[4096];
+static char bootdevice[4096];
static char currentdevice[4096];
-int open (char *device)
+char *silo_disk_get_bootdevice(void)
+{
+ return bootdevice;
+}
+
+int silo_disk_open(char *device)
{
strcpy (currentdevice, device);
net = 0;
@@ -114,7 +119,7 @@ int get_boot_part(void)
return ret;
}
-int diskinit ()
+int silo_diskinit(void)
{
fd = 0;
if (prom_vers == PROM_V0) {
@@ -145,17 +150,17 @@ int diskinit ()
} else if (p[1] >= 'a' && p[1] <= 'z' && !p[2])
p[1] = get_boot_part() + 'a';
}
- return open (bootdevice);
+ return silo_disk_open(bootdevice);
}
-void reopen(void)
+static void silo_disk_reopen(void)
{
char c;
c = *currentdevice;
- close ();
+ silo_disk_close();
*currentdevice = c;
- open (currentdevice);
+ silo_disk_open(currentdevice);
}
static unsigned int flash_ld(unsigned int offset)
@@ -168,7 +173,7 @@ static unsigned int flash_ld(unsigned int offset)
return retval;
}
-int read (char *buff, int size, unsigned long long offset)
+int silo_disk_read(char *buff, int size, unsigned long long offset)
{
if (!size)
return 0;
@@ -187,7 +192,7 @@ int read (char *buff, int size, unsigned long long offset)
for (j = 0; j < 5; j++) {
rc = (*romvec->pv_v0devops.v0_rdblkdev) (fd, 1, (unsigned)(offset >> 9), buffer);
if (rc) break;
- reopen();
+ silo_disk_reopen();
}
if (rc != 1)
return -1;
@@ -201,7 +206,7 @@ int read (char *buff, int size, unsigned long long offset)
for (j = 0; j < 5; j++) {
rc = (*romvec->pv_v0devops.v0_rdblkdev) (fd, size >> 9, (unsigned)(offset >> 9), buff);
if (rc) break;
- reopen();
+ silo_disk_reopen();
}
if (rc != (size >> 9)) {
/* Lets try if the floppy is not happy because the read size is too large for it */
@@ -209,7 +214,7 @@ int read (char *buff, int size, unsigned long long offset)
for (j = 0; j < 5; j++) {
rc = (*romvec->pv_v0devops.v0_rdblkdev) (fd, 1, (unsigned)(offset >> 9) + k, buff + (k << 9));
if (rc) break;
- reopen();
+ silo_disk_reopen();
}
if (rc != 1)
return -1;
@@ -225,7 +230,7 @@ int read (char *buff, int size, unsigned long long offset)
for (j = 0; j < 5; j++) {
rc = (*romvec->pv_v0devops.v0_rdblkdev) (fd, 1, (unsigned)(offset >> 9), buffer);
if (rc) break;
- reopen();
+ silo_disk_reopen();
}
if (rc != 1)
return -1;
@@ -312,16 +317,16 @@ int read (char *buff, int size, unsigned long long offset)
for (i = 0; i < 2; i++) {
rc = (*romvec->pv_v2devops.v2_dev_read) (fd, buff, size);
if (rc == size) break;
- reopen();
+ silo_disk_reopen();
if ((*romvec->pv_v2devops.v2_dev_seek) (fd, (unsigned)(offset >> 32), (unsigned)offset) == -1)
return -1;
}
if (rc != size && size > 32768) {
int j, s = size;
- reopen();
+ silo_disk_reopen();
while (size) {
if (size < 32768) j = size; else j = 32768;
- if (read (buff, j, offset) != j)
+ if (silo_disk_read(buff, j, offset) != j)
return -1;
size -= j;
offset += j;
@@ -340,23 +345,7 @@ int read (char *buff, int size, unsigned long long offset)
return -1;
}
-int xmit (char *buff, int size)
-{
- if (!net) return -1;
- switch (prom_vers) {
- case PROM_V0:
- return (*romvec->pv_v0devops.v0_wrnetdev) (fd, size, buff);
- case PROM_V2:
- case PROM_V3:
- return (*romvec->pv_v2devops.v2_dev_write) (fd, buff, size);
- case PROM_P1275:
- return p1275_cmd ("write", 3, fd, buff, size);
- default:
- return -1;
- }
-}
-
-void close ()
+void silo_disk_close(void)
{
if (*currentdevice) {
switch (prom_vers) {
@@ -372,21 +361,21 @@ void close ()
*currentdevice = 0;
}
-int setdisk (char *device)
+int silo_disk_setdisk(char *device)
{
- if (!strcmp (currentdevice, device)) {
+ if (!strcmp(currentdevice, device))
return 0;
- }
- close ();
- return open (device);
+
+ silo_disk_close();
+ return silo_disk_open(device);
}
/*
* XXX Good thing would be to have an argument, perhaps some device name.
- * XXX Other option is to make open() to return partitionable flag.
+ * XXX Other option is to make silo_disk_open() to return partitionable flag.
* XXX Retrofit floppy ((flash == 0) && (floppy == 0) && (net == 0));
*/
-int partitionable()
+int silo_disk_partitionable(void)
{
return (flash == 0);
}
diff --git a/second/file.c b/second/file.c
index 849d493..f135345 100644
--- a/second/file.c
+++ b/second/file.c
@@ -187,13 +187,13 @@ int dump_block (blk_t * blocknr, int blockcnt)
block_no = *blocknr;
block_cnt = 1;
if (blockcnt) {
- fatal ("File cannot have a hole at beginning");
+ silo_fatal("File cannot have a hole at beginning");
return BLOCK_ABORT;
}
last_blockcnt = -1;
}
if (filebuffer + (block_cnt + ((*blocknr) ? (blockcnt - last_blockcnt - 1) : 0)) * bs > filelimit) {
- fatal ("Image too large to fit in destination");
+ silo_fatal("Image too large to fit in destination");
return BLOCK_ABORT;
}
if (block_cnt > 0 && io_channel_read_blk (fs->io, block_no, block_cnt, filebuffer))
@@ -321,7 +321,7 @@ static int dump_device_range (char *filename, char *bogusdev, int *len,
return 0;
}
-int load_file (char *device, int partno, char *filename, char *buffer,
+int silo_load_file(char *device, int partno, char *filename, char *buffer,
char *limit, int *len, int cmd,
void (*lenfunc)(int, char **, char **))
{
@@ -336,7 +336,7 @@ int load_file (char *device, int partno, char *filename, char *buffer,
mark (&mmark);
if (!device)
- device = bootdevice;
+ device = silo_disk_get_bootdevice();
bogdev = bogusdev;
@@ -349,7 +349,7 @@ int load_file (char *device, int partno, char *filename, char *buffer,
} else
bogusdev[8] = partno + '0';
- if (setdisk (device) < 0)
+ if (silo_disk_setdisk(device) < 0)
goto done_2;
do_gunzip = cmd & LOADFILE_GZIP;
@@ -379,7 +379,7 @@ int load_file (char *device, int partno, char *filename, char *buffer,
if (!silo_fs_ops[i]) {
if (!(cmd & LOADFILE_QUIET))
- fatal ("Unable to open filesystem");
+ silo_fatal("Unable to open filesystem");
goto done_2;
} else
cur_ops = silo_fs_ops[i];
diff --git a/second/fs/iom.c b/second/fs/iom.c
index d12d4ed..28dd4b2 100644
--- a/second/fs/iom.c
+++ b/second/fs/iom.c
@@ -32,13 +32,13 @@ static int read_sun_partition (int partno)
sun_partition sdl;
unsigned short csum, *ush;
- rc = read ((char *) &sdl, 512, 0);
+ rc = silo_disk_read((char *) &sdl, 512, 0);
if (rc != 512) {
- fatal ("Cannot read partition");
+ silo_fatal("Cannot read partition");
return 0;
}
if (sdl.magic != SUN_LABEL_MAGIC)
- fatal ("Wrong disklabel magic");
+ silo_fatal("Wrong disklabel magic");
for (csum = 0, ush = ((unsigned short *) ((&sdl) + 1)) - 1; ush >= (unsigned short *) &sdl;)
csum ^= *ush--;
if (csum)
@@ -66,7 +66,7 @@ static errcode_t silo_open (const char *name, int flags, io_channel * channel)
io->write_error = 0;
doff = 0LL;
- if (strncmp (name, "/dev/fd0", 8) && partitionable()) {
+ if (strncmp (name, "/dev/fd0", 8) && silo_disk_partitionable()) {
partno = *(name + strlen (name) - 1) - '0';
if (partno && !read_sun_partition (partno))
return EXT2_ET_BAD_DEVICE_NAME;
@@ -91,7 +91,7 @@ static errcode_t silo_read_blk (io_channel channel, unsigned long block, int cou
int size, got;
size = (count < 0) ? -count : count * bs;
- got = read (data, size, ((unsigned long long)block) * bs + doff);
+ got = silo_disk_read(data, size, ((unsigned long long)block) * bs + doff);
if (got != size) {
printf ("\nRead error on block %d (tried %d, got %d)\n", block, size, got);
return EXT2_ET_SHORT_READ;
diff --git a/second/fs/ufs.c b/second/fs/ufs.c
index 21a834a..8bcaf81 100644
--- a/second/fs/ufs.c
+++ b/second/fs/ufs.c
@@ -79,7 +79,7 @@ static char *get_archstr(void)
{
char *p = "sun4c";
- switch (get_architecture()) {
+ switch (silo_get_architecture()) {
case sun4: p = "sun4"; break;
case sun4c: p = "sun4c"; break;
case sun4m: p = "sun4m"; break;
diff --git a/second/main.c b/second/main.c
index 5e78112..9609d89 100644
--- a/second/main.c
+++ b/second/main.c
@@ -113,7 +113,7 @@ static int tab_complete(void) {
if (p && *p >= '1' && *p <= '8' && !p[1])
defpart = *p - '0';
else {
- fatal("\nDefault partition could not be found");
+ silo_fatal("\nDefault partition could not be found");
free(r);
return 1;
}
@@ -167,8 +167,9 @@ static int tab_complete(void) {
} else {
if (!device) device = cfg_get_strg (0, "device");
- if (load_file(device, part, kname, (unsigned char *) 0x4000,
- (unsigned char *) &_start, &image_len, LOADFILE_LS_MATCH|LOADFILE_QUIET, 0))
+ if (silo_load_file(device, part, kname, (unsigned char *) 0x4000,
+ (unsigned char *) &_start, &image_len,
+ LOADFILE_LS_MATCH|LOADFILE_QUIET, 0))
if (do_ls((unsigned char *)0x4000, &tab_ambiguous))
ret = 1;
}
@@ -204,7 +205,7 @@ static void parse_name (char *imagename, int defpart, char **device,
*kname = 0;
if (prom_vers == PROM_V0) {
static char v0_buffer[20];
- *kname = v0_device (imagename);
+ *kname = silo_v0_device(imagename);
if (*kname) {
memcpy (v0_buffer, imagename, *kname - imagename + 1);
v0_buffer [*kname - imagename + 1] = 0;
@@ -328,7 +329,7 @@ static void check_password(char *str)
for (i = 0; i < 3; i++) {
printf ("\n%sassword: ", str);
passwdbuff[0] = 0;
- cmdedit ((void (*)(void)) 0, 1);
+ silo_cmdedit((void (*)(void)) 0, 1);
printf ("\n");
if (!strcmp (password, passwdbuff))
return;
@@ -391,7 +392,7 @@ static int get_params (char **device, int *part, char **kname, char **proll,
pause_after = 0;
reboot = 0;
*proll = 0;
- cmdinit ();
+ silo_cmdinit();
*params = "";
if (useconf) {
defdevice = cfg_get_strg (0, "device");
@@ -408,7 +409,7 @@ static int get_params (char **device, int *part, char **kname, char **proll,
if (p && *p)
timeout = atoi (p);
if (no_prom_args) p = 0;
- else p = get_bootargs (0);
+ else p = silo_get_bootargs(0);
if (p) while (*p == ' ') p++;
if (p && *p) {
for (q = p; *q && *q != ' '; q++);
@@ -483,7 +484,7 @@ static int get_params (char **device, int *part, char **kname, char **proll,
if (!imagename) {
if ((!*cbuff || (timeout > 0 && timer_status < 0)) && !tabbedout)
printf ("boot: ");
- cmdedit (maintabfunc, 0);
+ silo_cmdedit(maintabfunc, 0);
if (*cbuff == ' ') {
for (p = cbuff; *p == ' '; p++);
q = cbuff;
@@ -608,7 +609,7 @@ static int get_params (char **device, int *part, char **kname, char **proll,
if (defdevice)
oth_device = defdevice;
else
- oth_device = bootdevice;
+ oth_device = silo_disk_get_bootdevice();
}
strcpy (other_device, oth_device);
p = cfg_get_strg (label, "bootblock");
@@ -634,7 +635,7 @@ static int get_params (char **device, int *part, char **kname, char **proll,
if (first) {
first = 0;
if (no_prom_args) p = 0;
- else p = get_bootargs (0);
+ else p = silo_get_bootargs(0);
if (p) while (*p == ' ') p++;
if (p && *p) {
for (q = p; *q && *q != ' '; q++);
@@ -650,7 +651,7 @@ static int get_params (char **device, int *part, char **kname, char **proll,
}
if (!imagename) {
printf ("boot: ");
- cmdedit ((void (*)(void)) 0, 0);
+ silo_cmdedit((void (*)(void)) 0, 0);
if (*cbuff == ' ') {
for (p = cbuff; *p == ' '; p++);
q = cbuff;
@@ -755,7 +756,7 @@ static int get_params (char **device, int *part, char **kname, char **proll,
if (*part != -2) {
other_part = *part;
if (!*device)
- strcpy (other_device, bootdevice);
+ strcpy (other_device, silo_disk_get_bootdevice());
else
strcpy (other_device, *device);
p = strstr (*params, "bootblock=");
@@ -859,7 +860,8 @@ static void initrd_lenfunc (int len, char **filebuffer, char **filelimit)
initrd_start = memory_find ((len + 16383) & ~16383);
if (!initrd_start) {
- fatal ("You do not have enough continuous available memory for such initial ramdisk.");
+ silo_fatal("You do not have enough continuous available memory "
+ "for such initial ramdisk.");
prom_halt ();
}
initrd_size = len;
@@ -905,7 +907,7 @@ static int parse_executable (char *base, int image_len, unsigned int *poff,
hp.e->e_ident[EI_MAG3] == ELFMAG3) {
if (hp.e->e_ident[EI_DATA] != ELFDATA2MSB) {
- fatal ("Image is not a MSB ELF");
+ silo_fatal("Image is not a MSB ELF");
prom_halt ();
}
if (hp.e->e_ident[EI_CLASS] == ELFCLASS32) {
@@ -913,7 +915,8 @@ static int parse_executable (char *base, int image_len, unsigned int *poff,
p = (Elf32_Phdr *) (hp.b + hp.e->e_phoff);
if (p->p_type != PT_LOAD) {
- fatal ("Cannot find a loadable segment in your ELF image");
+ silo_fatal("Cannot find a loadable segment in your "
+ "ELF image");
prom_halt ();
}
if (solaris) {
@@ -923,7 +926,8 @@ static int parse_executable (char *base, int image_len, unsigned int *poff,
for (i = 0; i < hp.e->e_phnum; i++, p++) {
if (p->p_vaddr < 0x4000 + image_len ||
p->p_vaddr + p->p_memsz >= sa) {
- fatal("Unable to handle your Solaris `ufsboot' bootloader.");
+ silo_fatal("Unable to handle your "
+ "Solaris `ufsboot' bootloader.");
prom_halt ();
}
memcpy ((char *)p->p_vaddr,
@@ -951,7 +955,8 @@ static int parse_executable (char *base, int image_len, unsigned int *poff,
p->p_filesz = n + q->p_filesz;
p->p_memsz = n + q->p_memsz;
} else {
- fatal("Multiple loadable segments in your ELF image");
+ silo_fatal("Multiple loadable segments in "
+ "your ELF image");
prom_halt();
}
}
@@ -968,7 +973,8 @@ static int parse_executable (char *base, int image_len, unsigned int *poff,
p = (Elf64_Phdr *) (hp.b + hp.f->e_phoff);
if (p->p_type != PT_LOAD) {
- fatal ("Cannot find a loadable segment in your ELF image");
+ silo_fatal("Cannot find a loadable segment in your "
+ "ELF image");
prom_halt ();
}
if (solaris) {
@@ -979,7 +985,8 @@ static int parse_executable (char *base, int image_len, unsigned int *poff,
if (p->p_vaddr < 0x4000 + image_len ||
p->p_vaddr + p->p_memsz >= sa) {
- fatal("Unable to handle your Solaris `ufsboot' bootloader.");
+ silo_fatal("Unable to handle your "
+ "Solaris `ufsboot' bootloader.");
prom_halt ();
}
memcpy ((Elf64_Addr *)(long)(p->p_vaddr),
@@ -1005,7 +1012,8 @@ static int parse_executable (char *base, int image_len, unsigned int *poff,
p->p_filesz = n + q->p_filesz;
p->p_memsz = n + q->p_memsz;
} else {
- fatal("Multiple loadable segments in your ELF image");
+ silo_fatal("Multiple loadable segments "
+ "in your ELF image");
prom_halt();
}
}
@@ -1045,12 +1053,12 @@ int bootmain (void)
prom_ranges_init ();
get_idprom();
- architecture = get_architecture ();
- strcpy (given_bootargs, get_bootargs (1));
- strcpy (my_bootargs, get_bootargs (0));
+ architecture = silo_get_architecture();
+ strcpy (given_bootargs, silo_get_bootargs(1));
+ strcpy (my_bootargs, silo_get_bootargs(0));
#ifndef TFTP
- if (diskinit () == -1)
+ if (silo_diskinit() == -1)
prom_halt ();
#endif
@@ -1080,9 +1088,10 @@ int bootmain (void)
if (*silo_conf && silo_conf_partition >= 1 && silo_conf_partition <= 8) {
int len;
solaris = 0;
- fileok = load_file (0, silo_conf_partition, silo_conf,
- (unsigned char *) 0x4000, (unsigned char *) &_start,
- &len, LOADFILE_GZIP | LOADFILE_NO_ROTATE, 0);
+ fileok = silo_load_file(0, silo_conf_partition, silo_conf,
+ (unsigned char *) 0x4000,
+ (unsigned char *) &_start,
+ &len, LOADFILE_GZIP | LOADFILE_NO_ROTATE, 0);
if (!fileok || (unsigned) len >= 65535)
printf ("\nCouldn't load %s\n", silo_conf);
else {
@@ -1104,7 +1113,10 @@ int bootmain (void)
if (!device)
device = cfg_get_strg (0, "device");
solaris = 0;
- if (load_file (device, part, kname, (unsigned char *) 0x4000, (unsigned char *) &_start, &len, LOADFILE_GZIP, 0)) {
+ if (silo_load_file(device, part, kname,
+ (unsigned char *) 0x4000,
+ (unsigned char *) &_start, &len,
+ LOADFILE_GZIP, 0)) {
*(unsigned char *) (0x4000 + len) = 0;
printf ("\n");
print_message ((char *) 0x4000);
@@ -1147,7 +1159,7 @@ try_again:
break;
if (solaris) {
- char *p = seed_part_into_device ((!device || !*device) ? bootdevice : device, part);
+ char *p = seed_part_into_device ((!device || !*device) ? silo_disk_get_bootdevice() : device, part);
strcpy (sol_params, p);
params_device = strchr (sol_params, 0) + 1;
strcpy (params_device, kname);
@@ -1162,8 +1174,9 @@ try_again:
printf ("\nNeither \"other\" nor \"solaris\" are compatible with proll\n");
continue;
}
- if (!load_file (device, part, proll, (unsigned char *) 0x4000,
- (unsigned char *) 0x40000, &image_len, LOADFILE_GZIP, 0)) {
+ if (!silo_load_file(device, part, proll, (unsigned char *) 0x4000,
+ (unsigned char *) 0x40000, &image_len,
+ LOADFILE_GZIP, 0)) {
printf ("\nProll not found.... try again\n");
continue;
}
@@ -1172,8 +1185,9 @@ try_again:
memcpy ((char *) 0x4000, ((char *) 0x4000) + off, len);
image_base = (char *) 0x40000;
- if (!load_file (device, part, kname, image_base,
- (unsigned char *) &_start, &image_len, LOADFILE_GZIP, 0)) {
+ if (!silo_load_file(device, part, kname, image_base,
+ (unsigned char *) &_start, &image_len,
+ LOADFILE_GZIP, 0)) {
printf ("\nImage not found.... try again\n");
continue;
}
@@ -1206,8 +1220,10 @@ try_again:
}
}
- if (!load_file (device, part, kname, image_base, image_end,
- &image_len, load_cmd == CMD_LS ? LOADFILE_LS : LOADFILE_GZIP, 0)) {
+ if (!silo_load_file(device, part, kname, image_base, image_end,
+ &image_len, ((load_cmd == CMD_LS) ?
+ LOADFILE_LS :
+ LOADFILE_GZIP), 0)) {
printf ("\nImage not found.... try again\n");
if (!load_cmd)
@@ -1243,7 +1259,8 @@ try_again:
memcpy (image_base, image_base + off, len);
- hdrs = (struct HdrS_struct *)find_linux_HdrS (image_base, image_len);
+ hdrs = (struct HdrS_struct *)
+ silo_find_linux_HdrS(image_base, image_len);
if (hdrs && hdrs->ver < 0x300 && image_base != (char *)0x4000) {
/* Kernel doesn't support being loaded to other than
@@ -1266,7 +1283,8 @@ try_again:
/* Readjust some things */
ret_offset = 0x4000;
- hdrs = (struct HdrS_struct *)find_linux_HdrS (image_base, image_len);
+ hdrs = (struct HdrS_struct *)
+ silo_find_linux_HdrS(image_base, image_len);
printf("done.\n");
}
@@ -1280,7 +1298,6 @@ try_again:
if (fill_reboot_cmd && hdrs->ver >= 0x201) { /* ie. uses reboot_command */
char *q = (char *)hdrs->reboot_cmd_ptr_high;
char *r;
- extern char bootdevice[];
/* On Ultra there is xword there, this hack makes
* it work...
@@ -1290,8 +1307,8 @@ try_again:
q = (char *)(((unsigned long)q)& 0x003fffff);
if (q >= (char *)0x4000 && q <= (char *)0x300000) {
if (given_bootargs_by_user) {
- if (strlen (bootdevice) <= 254) {
- strcpy (q, bootdevice);
+ if (strlen (silo_disk_get_bootdevice()) <= 254) {
+ strcpy (q, silo_disk_get_bootdevice());
r = strchr (q, 0);
if (strlen (given_bootargs) < 255 - (r - q)) {
*r++ = ' ';
@@ -1341,15 +1358,19 @@ try_again:
q = strchr (initrd_string, '|');
if (q && !initrd_size) {
- fatal ("When more than one initial ramdisk piece is specified, you have to give\n"
- "a non-zero initrd-size option which is no shorter than sum of all pieces\n"
- "lengths. Try again...\n");
+ silo_fatal("When more than one initial ramdisk piece "
+ "is specified, you have to give\n"
+ "a non-zero initrd-size option which is no "
+ "shorter than sum of all pieces\n"
+ "lengths. Try again...\n");
prom_halt ();
}
if (q) {
initrd_start = memory_find ((initrd_size + 16383) & ~16383);
if (!initrd_start) {
- fatal ("You do not have enough continuous available memory for such initial ramdisk.");
+ silo_fatal("You do not have enough continuous "
+ "available memory for such initial "
+ "ramdisk.");
prom_halt ();
}
string = strdup (initrd_string);
@@ -1364,7 +1385,10 @@ try_again:
parse_name (r, initrd_defpart, &initrd_device, &initrd_partno, &initrd_kname);
if (!initrd_kname) break;
if (!initrd_device) initrd_device = initrd_defdevice;
- if (!load_file (initrd_device, initrd_partno, initrd_kname, initrd_cur, initrd_limit, &len, 0, 0)) break;
+ if (!silo_load_file(initrd_device, initrd_partno,
+ initrd_kname, initrd_cur,
+ initrd_limit, &len, 0, 0))
+ break;
initrd_cur += len;
if (!c) {
statusok = 1;
@@ -1374,7 +1398,7 @@ try_again:
q = strchr (r, '|');
if (!q) q = strchr (r, 0);
if (initrd_prompt) {
- close ();
+ silo_disk_close();
printf ("Insert next media and press ENTER");
prom_getchar ();
printf ("\n");
@@ -1407,9 +1431,10 @@ try_again:
parse_name (initrd_string, initrd_defpart, &initrd_device, &initrd_partno, &initrd_kname);
if (initrd_kname) {
if (!initrd_device) initrd_device = initrd_defdevice;
- if (load_file (initrd_device, initrd_partno, initrd_kname,
- (char *) 0x300000, (unsigned char *) LARGE_RELOC,
- 0, 0, initrd_lenfunc)) {
+ if (silo_load_file(initrd_device, initrd_partno,
+ initrd_kname, (char *) 0x300000,
+ (unsigned char *) LARGE_RELOC,
+ 0, 0, initrd_lenfunc)) {
extern unsigned long long sun4u_initrd_phys;
extern unsigned long sun4m_initrd_pa;
@@ -1443,17 +1468,17 @@ try_again:
params_device = other_device;
}
- close ();
+ silo_disk_close();
if (timer_status >= 1)
close_timer ();
if (proll) {
- set_prollargs (params, (unsigned int)image_base, len);
+ silo_set_prollargs(params, (unsigned int)image_base, len);
if (show_arguments) {
printf ("Arguments: \"%s\"\n");
pause_after = 1;
}
} else {
- set_bootargs (params, params_device);
+ silo_set_bootargs(params, params_device);
if (kernel_params) {
extern char barg_out[];
@@ -1465,7 +1490,7 @@ try_again:
}
if (show_arguments) {
- show_bootargs ();
+ silo_show_bootargs();
pause_after = 1;
}
}
diff --git a/second/misc.c b/second/misc.c
index 898be1d..895c584 100644
--- a/second/misc.c
+++ b/second/misc.c
@@ -24,12 +24,12 @@
#include <asm/machines.h>
#include <stringops.h>
-void fatal (const char *msg)
+void silo_fatal(const char *msg)
{
- printf ("\nFatal error: %s\n", msg);
+ printf("\nFatal error: %s\n", msg);
}
-char *v0_device (char *imagename)
+char *silo_v0_device(char *imagename)
{
if (((imagename[0] == 's' && strchr ("dt", imagename[1])) ||
(imagename[0] == 'x' && strchr ("dy", imagename[1])) ||
@@ -92,7 +92,7 @@ char *seed_part_into_device (char *device, int part)
static char barg_buf[1024];
char barg_out[1024];
-void set_bootargs (char *params, char *device)
+void silo_set_bootargs(char *params, char *device)
{
char *q, *r;
char **p;
@@ -219,7 +219,7 @@ void set_bootargs (char *params, char *device)
}
}
-char *get_bootargs (int full)
+char *silo_get_bootargs(int full)
{
int iter;
char *cp, *q;
@@ -235,7 +235,7 @@ char *get_bootargs (int full)
q = p [iter];
if (q) {
if (!iter && !full) {
- q = v0_device (q);
+ q = silo_v0_device(q);
if (q && !q[1])
continue;
@@ -296,12 +296,12 @@ char *get_bootargs (int full)
return barg_buf;
}
-void show_bootargs ()
+void silo_show_bootargs(void)
{
- printf ("Kernel args: %s\n", get_bootargs (0));
+ printf("Kernel args: %s\n", silo_get_bootargs(0));
}
-unsigned char *find_linux_HdrS (char *base, int len)
+unsigned char *silo_find_linux_HdrS(char *base, int len)
{
/* Ugly magic to find HdrS, we dig into first jmp gokernel */
char *p = base + ((*(unsigned short *) (base+2)) << 2) - 512;
@@ -409,7 +409,7 @@ void print_message (char *msg)
if (curly)
p++;
if (!strncmp (p, "ARCH", 4)) {
- switch (get_architecture ()) {
+ switch (silo_get_architecture()) {
case sun4: q = "SUN4"; break;
case sun4c: q = "SUN4C"; break;
case sun4d: q = "SUN4D"; break;
@@ -448,7 +448,7 @@ void print_message (char *msg)
}
}
-void set_prollargs (char *params, unsigned int kbase, int ksize)
+void silo_set_prollargs(char *params, unsigned int kbase, int ksize)
{
struct silo_to_proll {
char magic[4]; /* SiPR */
@@ -486,7 +486,7 @@ void set_prollargs (char *params, unsigned int kbase, int ksize)
strcpy(p->kern_args, params);
}
-enum arch get_architecture ()
+enum arch silo_get_architecture(void)
{
char *buffer = "sun4c ";
int i;
diff --git a/silo/silo.c b/silo/silo.c
index be8ab37..ea45dab 100644
--- a/silo/silo.c
+++ b/silo/silo.c
@@ -176,7 +176,7 @@ int promver = -1;
int oldroot = -1;
enum fs_type { unknownfs, ext2fs, ufsfs, romfs } fstype = unknownfs;
-void fatal (char *fmt,...)
+static void silo_fatal(char *fmt,...)
{
va_list ap;
va_start (ap, fmt);
@@ -213,7 +213,7 @@ int check_fs (int fd)
} rsd;
if (lseek (fd, 1024, 0) != 1024 || read (fd, &sb, sizeof (sb)) != sizeof (sb))
- fatal ("Cannot read Super Block!");
+ silo_fatal("Cannot read Super Block!");
if (swab16 (sb.s_magic) == EXT2_SUPER_MAGIC) {
if (fstype == unknownfs) fstype = ext2fs;
return 1024 << swab32 (sb.s_log_block_size);
@@ -243,19 +243,20 @@ void read_sb (struct hwdevice *hwdev)
hwdev->partat0 = 0;
if ((fd = devopen (hwdev->dev, O_RDONLY)) == -1)
- fatal ("Cannot open superblock on %s", hwdev->dev);
+ silo_fatal("Cannot open superblock on %s", hwdev->dev);
hwdev->bs = check_fs (fd);
if (hwdev->bs == (unsigned short)-1)
- fatal ("File systems other than ext2, ext3, ufs and romfs not yet supported", hwdev->dev);
+ silo_fatal("File systems other than ext2, ext3, ufs and romfs "
+ "not yet supported", hwdev->dev);
close (fd);
hwdev->nsect = hwdev->bs / 512;
if (hwdev->part == -1)
return;
sdl = (struct sun_disklabel *) &buff;
if ((fd = devopen (hwdev->wholedev, O_RDONLY)) == -1)
- fatal ("Error opening %s", hwdev->wholedev);
+ silo_fatal("Error opening %s", hwdev->wholedev);
if (read (fd, buff, sizeof (buff)) != sizeof (buff))
- fatal ("Error reading %s's label", hwdev->wholedev);
+ silo_fatal("Error reading %s's label", hwdev->wholedev);
for (i = 0; i < 8; i++) {
if (i == 2) continue;
if (!sdl->partitions[i].start_cylinder && sdl->partitions[i].num_sectors) {
@@ -286,9 +287,12 @@ void read_sb (struct hwdevice *hwdev)
}
}
if (i == 8) {
- fatal ("In order to install SILO you must start at least one partition on cylinder\n"
- "0. Consider setting %s3 as WHOLE_DISK (starting at 0 and ending at disk end)\n"
- "and %s1 starting on cylinder 0 (both will make your life easier)\n", hwdev->wholedev, hwdev->wholedev);
+ silo_fatal("In order to install SILO you must start at least "
+ "one partition on cylinder\n"
+ "0. Consider setting %s3 as WHOLE_DISK (starting at 0 "
+ "and ending at disk end)\n"
+ "and %s1 starting on cylinder 0 (both will make your "
+ "life easier)\n", hwdev->wholedev, hwdev->wholedev);
}
hwdev->doff = bswab16(sdl->ntrks) * bswab16(sdl->nsect) * bswab32(sdl->partitions[hwdev->part].start_cylinder);
close (fd);
@@ -317,26 +321,26 @@ void make_room_for_raid1 (struct hwdevice *hwdev, char *name)
if (raid1 <= 1)
return;
if ((fd = open (name, O_RDWR)) == -1)
- fatal ("Cannot open %s", name);
+ silo_fatal("Cannot open %s", name);
if (fstat (fd, &st) < 0)
- fatal ("Couldn't stat %s", name);
+ silo_fatal("Couldn't stat %s", name);
if (lseek (fd, 0x90c, 0) != 0x90c || read(fd, buf, 12) != 12)
- fatal ("Could not read %s version and length header", name);
+ silo_fatal("Could not read %s version and length header", name);
if (memcmp (buf, "SILO", 4))
- fatal ("Second stage %s too old", name);
+ silo_fatal("Second stage %s too old", name);
len = *(int *)&buf[8];
if (len % 512 || st.st_size < len || (st.st_size - len) % 2048)
- fatal ("Second stage %s has wrong size", name);
+ silo_fatal("Second stage %s has wrong size", name);
i = raid1 - 1 - (st.st_size - len) / 2048;
if (i > 0) {
if (lseek (fd, len, 0) != len)
- fatal ("Could not seek in %s", name);
+ silo_fatal("Could not seek in %s", name);
memset(buf, 0, 512);
/* Should not use ftruncate here, because we cannot have fs
holes in */
for (i = 4 * i; i > 0; i--) {
if (write (fd, buf, 512) != 512)
- fatal ("Could not write to %s", name);
+ silo_fatal("Could not write to %s", name);
}
}
second_b_len = len;
@@ -357,11 +361,11 @@ int get_partition_blocks (struct hwdevice *hwdev, char *filename)
again:
if ((fd = open (name, O_RDONLY)) == -1) {
gpb_cleanup(filename, movecount);
- fatal ("Cannot find %s", name);
+ silo_fatal("Cannot find %s", name);
}
if (fstat (fd, &st) < 0) {
gpb_cleanup(filename, movecount);
- fatal ("Couldn't stat %s", name);
+ silo_fatal("Couldn't stat %s", name);
}
#ifdef __linux__
if (!movecount)
@@ -372,7 +376,8 @@ again:
if (p) p++; else p = name;
start = (long)st.st_ino + 16 + ((strlen(p) + 16) & ~15);
if (start & 511)
- fatal ("File %s on romfs not aligned on 512B boundary. Use genromfs -a to generate the image", name);
+ silo_fatal("File %s on romfs not aligned on 512B boundary. "
+ "Use genromfs -a to generate the image", name);
start = hwdev->doff + start / 512;
if (flash_image) start += 1024 / 512; /* make room for ieee32 */
for (j = 0; j * 512 < size; j++)
@@ -387,7 +392,9 @@ again:
break;
if (!block) {
if ((j << 9) < size)
- fatal ("Filesystem holes are not yet supported for second stage loader. Mail silo-general@lists.sparc-boot.org");
+ silo_fatal("Filesystem holes are not yet supported for "
+ "second stage loader. Mail "
+ "silo-general@lists.sparc-boot.org");
else
break;
}
@@ -395,14 +402,18 @@ again:
if (movecount < 5) {
if (!movecount) {
if (hwdev->id)
- fatal ("Your %s is located above the magic %dGB boundary from the start of the disk\n"
- "on one of the RAID1 mirrors. Please make sure it is below the limit on all\n"
- "mirrors.", filename, prombug);
+ silo_fatal("Your %s is located above the "
+ "magic %dGB boundary from the "
+ "start of the disk\n"
+ "on one of the RAID1 mirrors. "
+ "Please make sure it is below the "
+ "limit on all\n"
+ "mirrors.", filename, prombug);
buf = malloc (size);
if (!buf)
- fatal ("Not enough memory");
+ silo_fatal("Not enough memory");
if (read (fd, buf, size) != size)
- fatal ("Cannot read from %s", filename);
+ silo_fatal("Cannot read from %s", filename);
}
close (fd);
movecount++;
@@ -411,14 +422,18 @@ again:
fd = creat (name, 0644);
if (!fd || write (fd, buf, size) != size) {
gpb_cleanup(filename, movecount);
- fatal ("Your %s is located above the magic %dGB boundary from the start of the disk.\n"
- "Please move it down, so that SILO first stage loader can load it.", filename, prombug);
+ silo_fatal("Your %s is located above the magic %dGB "
+ "boundary from the start of the disk.\n"
+ "Please move it down, so that SILO first "
+ "stage loader can load it.",
+ filename, prombug);
}
close (fd);
goto again;
}
gpb_cleanup(filename, movecount);
- fatal ("Your %s is located above the magic %dGB boundary from the start of the disk.\n"
+ silo_fatal("Your %s is located above the magic %dGB boundary "
+ "from the start of the disk.\n"
"Please move it down, so that SILO first stage loader can load it.", filename, prombug);
}
for (k = 0; k < hwdev->nsect; k++)
@@ -432,8 +447,9 @@ again:
would resync away the bootblock unless second.b starts on exactly the same
offsets in each device */
if (memcmp (hwdevs->blocks, hwdev->blocks, sizeof(hwdev->blocks)))
- fatal ("With silo -t on RAID1 all mirrors must start at the same offset\n"
- "from the start of the disk.");
+ silo_fatal("With silo -t on RAID1 all mirrors must "
+ "start at the same offset\n"
+ "from the start of the disk.");
} else
for (i = 0; i < 4; i++)
hwdev->blocks[i] = hwdev->blocks[second_b_len / 512 + (hwdev->id - 1) * 4 + i];
@@ -443,8 +459,9 @@ again:
if (movecount) {
if (rename (name, filename) < 0) {
gpb_cleanup(filename, movecount - 1);
- fatal ("Cannot rename a suitably located copy (below 1GB from start of disk) of %s to it's old position.\n"
- "Please check %s\n", filename, filename);
+ silo_fatal("Cannot rename a suitably located copy (below 1GB "
+ "from start of disk) of %s to it's old position.\n"
+ "Please check %s\n", filename, filename);
}
gpb_cleanup(filename, movecount - 1);
}
@@ -465,12 +482,12 @@ void write_block_device (struct hwdevice *hwdev)
unsigned char part;
if ((fd = devopen (masterboot ? hwdev->wholedev : hwdev->dev, O_RDWR)) == -1)
- fatal ("Cannot open %s", hwdev->dev);
+ silo_fatal("Cannot open %s", hwdev->dev);
if (flash_image) off = IEEE32_OFFSET;
else if (floppy_image) off = 1020 + 512 - 4;
else off = 1020;
if (lseek (fd, off, SEEK_SET) != off)
- fatal ("Seek error on %s", hwdev->dev);
+ silo_fatal("Seek error on %s", hwdev->dev);
if (floppy_image) {
int j;
for (j = 0; j < 512 && hwdev->blocks[j]; j++);
@@ -478,12 +495,12 @@ void write_block_device (struct hwdevice *hwdev)
tmp = bswab32 (j);
rc = write (fd, &tmp, 4);
if (rc != 4)
- fatal ("Couldn't write to %s", hwdev->dev);
+ silo_fatal("Couldn't write to %s", hwdev->dev);
}
tmp = bswab32 (hwdev->blocks[0]);
rc = write (fd, &tmp, 4);
if (rc != 4)
- fatal ("Couldn't write to %s", hwdev->dev);
+ silo_fatal("Couldn't write to %s", hwdev->dev);
if (!flash_image) {
if (!ultra || floppy_image) {
if (floppy_image)
@@ -491,11 +508,11 @@ void write_block_device (struct hwdevice *hwdev)
else
offset = DIGIT_OFFSET;
if (lseek (fd, offset, SEEK_SET) != offset)
- fatal ("Seek error on %s", hwdev->dev);
+ silo_fatal("Seek error on %s", hwdev->dev);
part = hwdev->partat0 + '0';
rc = write (fd, &part, 1);
if (rc != 1)
- fatal ("Couldn't write to %s", hwdev->dev);
+ silo_fatal("Couldn't write to %s", hwdev->dev);
}
if (floppy_image)
offset = FD_LETTER_OFFSET;
@@ -504,24 +521,24 @@ void write_block_device (struct hwdevice *hwdev)
else
offset = LETTER_OFFSET;
if (lseek (fd, offset, SEEK_SET) != offset)
- fatal ("Seek error on %s", hwdev->dev);
+ silo_fatal("Seek error on %s", hwdev->dev);
part = hwdev->partat0 + 'a';
rc = write (fd, &part, 1);
if (rc != 1)
- fatal ("Couldn't write to %s", hwdev->dev);
+ silo_fatal("Couldn't write to %s", hwdev->dev);
if (!floppy_image) {
if (ultra)
offset = ULTRA_NUMBER_OFFSET;
else
offset = NUMBER_OFFSET;
if (lseek (fd, offset, SEEK_SET) != offset)
- fatal ("Seek error on %s", hwdev->dev);
+ silo_fatal("Seek error on %s", hwdev->dev);
part = 0;
if (raid1)
part = hwdev->id + 1;
rc = write (fd, &part, 1);
if (rc != 1)
- fatal ("Couldn't write to %s", hwdev->dev);
+ silo_fatal("Couldn't write to %s", hwdev->dev);
}
}
close (fd);
@@ -546,50 +563,53 @@ void write_block_tables (struct hwdevice *hwdev, char *filename, char *config_fi
if ((fd = open (filename, O_RDWR)) == -1) {
if (raid1)
- fatal ("Cannot open %s", filename);
+ silo_fatal("Cannot open %s", filename);
if ((fd = open (filename, O_RDONLY)) >= 0) {
close (fd); /* Maybe it is romfs */
if ((fd = devopen (hwdev->wholedev, O_RDWR)) == -1)
- fatal ("Cannot open %s", hwdev->wholedev);
+ silo_fatal("Cannot open %s", hwdev->wholedev);
tordonly = 1;
} else
- fatal ("Cannot open %s", filename);
+ silo_fatal("Cannot open %s", filename);
}
if (tordonly) {
char *p = (char *)hwdev->blocks, *pend = p + sizeof (hwdev->blocks);
if (raid1)
- fatal ("RAID1 not supported with read-only filesystems");
+ silo_fatal("RAID1 not supported with read-only filesystems");
for (i = 0, rc = 0; p < pend; i++, p+=512) {
if (lseek (fd, hwdev->blocks [i] * 512, SEEK_SET) != hwdev->blocks [i] * 512)
- fatal ("Cannot seek in %s", filename);
+ silo_fatal("Cannot seek in %s", filename);
rc += write (fd, p, 512);
}
} else {
if (lseek (fd, 0, SEEK_SET) != 0)
- fatal ("Cannot seek in %s", filename);
+ silo_fatal("Cannot seek in %s", filename);
rc = write (fd, hwdev->blocks, sizeof (hwdev->blocks));
if (raid1 > 1) {
- if (rc != sizeof (hwdev->blocks)) fatal ("Couldn't write to %s", filename);
+ if (rc != sizeof (hwdev->blocks))
+ silo_fatal("Couldn't write to %s", filename);
if (lseek (fd, second_b_len, SEEK_SET) != second_b_len)
- fatal ("Cannot seek in %s", filename);
+ silo_fatal("Cannot seek in %s", filename);
for (d = hwdev->next; d; d = d->next)
rc = write (fd, d->blocks, sizeof (d->blocks));
}
}
- if (rc != sizeof (hwdev->blocks)) fatal ("Couldn't write to %s", filename);
+ if (rc != sizeof (hwdev->blocks))
+ silo_fatal("Couldn't write to %s", filename);
if (tordonly)
i = hwdev->blocks [0x808/512] * 512 + 0x808 % 512;
else
i = 0x808;
if (lseek (fd, i, SEEK_SET) != i)
- fatal ("Cannot seek in %s", filename);
+ silo_fatal("Cannot seek in %s", filename);
if (read (fd, &buffer, sizeof(buffer)) != sizeof(buffer))
- fatal ("Couldn't read from %s", filename);
+ silo_fatal("Couldn't read from %s", filename);
if (lseek (fd, i, SEEK_SET) != i)
- fatal ("Cannot seek in %s", filename);
+ silo_fatal("Cannot seek in %s", filename);
if (buffer.l != 'L' || memcmp(buffer.silover, "SILO", 4))
- fatal ("Corrupted %s or second stage with incorrect version", filename);
+ silo_fatal("Corrupted %s or second stage with incorrect version",
+ filename);
buffer.partno = partno;
buffer.partat0 = hwdev->partat0;
buffer.raid_dsk_number = 0;
@@ -602,7 +622,7 @@ void write_block_tables (struct hwdevice *hwdev, char *filename, char *config_fi
}
}
if (write (fd, &buffer, sizeof(buffer)) != sizeof(buffer))
- fatal ("Couldn't write to %s", filename);
+ silo_fatal("Couldn't write to %s", filename);
close (fd);
for (d = hwdev; d; d = d->next)
write_block_device (d);
@@ -650,11 +670,11 @@ int examine_bootblock (char *device, char *filename, int do_backup)
int ret = 0;
if ((fd = devopen (device, O_RDONLY)) == -1)
- fatal ("Cannot open %s", device);
+ silo_fatal("Cannot open %s", device);
if (lseek (fd, 512, 0) != 512)
- fatal ("Couldn't seek on %s", device);
+ silo_fatal("Couldn't seek on %s", device);
if (read (fd, buffer, sizeof (buffer)) != sizeof(buffer))
- fatal ("Couldn't read your old bootblock");
+ silo_fatal("Couldn't read your old bootblock");
close (fd);
if (memcmp (buffer + 24, "SILO" IMGVERSION, 8))
ret = 1;
@@ -663,10 +683,11 @@ int examine_bootblock (char *device, char *filename, int do_backup)
if ((fp = fopen (filename, "w")) == NULL) {
if (do_backup >= 2)
return ret;
- fatal ("Cannot open file for saving backup of your bootblock");
+ silo_fatal("Cannot open file for saving backup of your bootblock");
}
if ((rc = fwrite (buffer, 1, sizeof (buffer), fp)) != sizeof (buffer))
- fatal ("Couldn't write to %s backup of your bootblock", filename);
+ silo_fatal("Couldn't write to %s backup of your bootblock",
+ filename);
fclose (fp);
}
return ret;
@@ -694,12 +715,12 @@ void install_first_stage (char *device, char *filename)
struct sun_disklabel sdl;
if ((fd = devopen (device, floppy_image ? O_RDWR : O_WRONLY)) == -1)
- fatal ("Couldn't open device %s for writing", device);
+ silo_fatal("Couldn't open device %s for writing", device);
if ((fp = fopen (filename, "r")) == NULL)
- fatal ("Couldn't open file %s", filename);
+ silo_fatal("Couldn't open file %s", filename);
rc = fread (buff, 1, (floppy_image || flash_image) ? 1024 : 512, fp);
if (rc <= 0)
- fatal ("Couldn't read new silo bootblock from %s", filename);
+ silo_fatal("Couldn't read new silo bootblock from %s", filename);
if (floppy_image) {
unsigned short *ush;
unsigned short x;
@@ -707,13 +728,13 @@ void install_first_stage (char *device, char *filename)
int i;
if (lseek (fd, 0, 0))
- fatal ("Couldn't seek on %s", device);
+ silo_fatal("Couldn't seek on %s", device);
if (read(fd, (char *)&sdl, 512) != 512)
- fatal ("Couldn't read on %s", device);
+ silo_fatal("Couldn't read on %s", device);
if (lseek (fd, 0, 0))
- fatal ("Couldn't seek on %s", device);
+ silo_fatal("Couldn't seek on %s", device);
if (strncmp ((char *)&sdl, "-rom1fs-", 8))
- fatal ("Couldn't find romfs image on %s", device);
+ silo_fatal("Couldn't find romfs image on %s", device);
memcpy (((char *)&sdl) + 128, floppy_label + 128, 512 - 128);
ush = (unsigned short *)&sdl;
@@ -738,13 +759,13 @@ void install_first_stage (char *device, char *filename)
*(unsigned int *)(ush + 62) = (-d/2);
if (write (fd, &sdl, 512) != 512)
- fatal ("Couldn't write new partition table to %s", device);
+ silo_fatal("Couldn't write new partition table to %s", device);
} else if (flash_image) {
/*
* Make sure that both block table address and checksum fit.
*/
if (rc > 1016)
- fatal ("Flash bootblock is too large");
+ silo_fatal("Flash bootblock is too large");
/*
* Here we do an assumption which is not quite safe.
* PROM gets the size looking at section headers,
@@ -754,9 +775,9 @@ void install_first_stage (char *device, char *filename)
flash_check_sum (buff, rc);
rc += 4;
} else if (lseek (fd, 512, 0) != 512)
- fatal ("Couldn't seek on %s", device);
+ silo_fatal("Couldn't seek on %s", device);
if (write (fd, buff, rc) != rc)
- fatal ("Couldn't write new silo bootblock to %s", device);
+ silo_fatal("Couldn't write new silo bootblock to %s", device);
close (fd);
fclose (fp);
}
@@ -989,13 +1010,15 @@ struct hwdevice *get_device(int majno, int minno)
sprintf (dev, "/dev/md%d", minno);
md_fd = devopen (dev, O_RDONLY);
- if (md_fd < 0) fatal ("Could not open RAID device");
+ if (md_fd < 0)
+ silo_fatal("Could not open RAID device");
if (ioctl (md_fd, GET_ARRAY_INFO, &md_array_info) < 0)
- fatal ("Could not get RAID array info");
+ silo_fatal("Could not get RAID array info");
if (md_array_info.major_version == 0 && md_array_info.minor_version < 90)
- fatal ("Raid versions < 0.90 are not supported");
+ silo_fatal("Raid versions < 0.90 are not "
+ "supported");
if (md_array_info.level != 1)
- fatal ("Only RAID1 supported");
+ silo_fatal("Only RAID1 supported");
hwdev = NULL;
last = NULL;
for (i = 0; i < md_array_info.nr_disks; i++) {
@@ -1004,7 +1027,8 @@ struct hwdevice *get_device(int majno, int minno)
break; // That's all folks
md_disk_info.number = i;
if (ioctl (md_fd, GET_DISK_INFO, &md_disk_info) < 0)
- fatal ("Could not get RAID disk info for disk %d\n", i);
+ silo_fatal("Could not get RAID disk "
+ "info for disk %d\n", i);
if(md_disk_info.majorno != 0 && md_disk_info.minorno != 0) {
d = get_device (md_disk_info.majorno, md_disk_info.minorno);
if (md_disk_info.state == MD_DISK_FAULTY) {
@@ -1020,7 +1044,8 @@ struct hwdevice *get_device(int majno, int minno)
}
}
if (!hwdev)
- fatal ("No non-faulty disks found in RAID1");
+ silo_fatal("No non-faulty disks found "
+ "in RAID1");
for (d = hwdev; d; d = d->next)
d->id = id++;
raid1 = id;
@@ -1031,7 +1056,9 @@ struct hwdevice *get_device(int majno, int minno)
default: {
char *p = find_dev (makedev (majno, minno));
- if (!p) fatal ("Couldn't find out what device is second stage on");
+ if (!p)
+ silo_fatal("Couldn't find out what device is second "
+ "stage on");
strcpy (dev, p);
strcpy (wholedev, p);
#ifdef __sun__
@@ -1049,7 +1076,8 @@ struct hwdevice *get_device(int majno, int minno)
break;
}
hwdev = malloc(sizeof(struct hwdevice) + strlen(dev) + strlen(wholedev) + 4);
- if (!hwdev) fatal("Not enough memory");
+ if (!hwdev)
+ silo_fatal("Not enough memory");
memset(hwdev, 0, sizeof(*hwdev));
hwdev->dev = (char *)(hwdev + 1);
strcpy (hwdev->dev, dev);
@@ -1215,7 +1243,7 @@ int main(int argc,char **argv)
if (new_root && strcmp("/", new_root)) {
if (stat (new_root, &st1) < 0 || !S_ISDIR(st1.st_mode)) {
- fatal ("New root %s is not a directory", new_root);
+ silo_fatal("New root %s is not a directory", new_root);
}
oldroot = open("/", O_RDONLY);
chroot(new_root);
@@ -1239,10 +1267,10 @@ int main(int argc,char **argv)
secondary = strdup (secondary);
if (stat (secondary, &st1) < 0)
- fatal ("Cannot open second stage loader %s", secondary);
+ silo_fatal("Cannot open second stage loader %s", secondary);
hwdevs = get_device (mmajor(st1.st_dev), mminor(st1.st_dev));
if (raid1 > 32)
- fatal ("SILO supports at most 32 disks in the RAID1 array");
+ silo_fatal("SILO supports at most 32 disks in the RAID1 array");
if (raid1 && masterboot) {
struct hwdevice *d, *d1;
/* Check if we have to remove some RAID1 mirrors, because
@@ -1266,7 +1294,7 @@ int main(int argc,char **argv)
* So we do not bother trying.
*/
if (raid1)
- fatal ("-J cannot be used with RAID1");
+ silo_fatal("-J cannot be used with RAID1");
hwdevs->wholedev = flash_image;
}
p = backup;
@@ -1274,12 +1302,14 @@ int main(int argc,char **argv)
config_file = strdup (config_file);
strcpy (backup, p);
if (!backup || !config_file)
- fatal ("Not enough memory");
+ silo_fatal("Not enough memory");
if (stat (config_file, &st2) >= 0) {
if (raid1 && st1.st_dev != st2.st_dev)
- fatal ("Config file %s has to be on the same RAID1 device as second stage bootblock", config_file);
+ silo_fatal("Config file %s has to be on the same RAID1 device "
+ "as second stage bootblock", config_file);
else if (hwdevs->type == TYPE_UNKNOWN && st1.st_dev != st2.st_dev)
- fatal ("Config file %s has to be on the %s device", config_file, hwdevs->dev);
+ silo_fatal("Config file %s has to be on the %s device",
+ config_file, hwdevs->dev);
#ifdef __linux__
else if ((hwdevs->type == TYPE_SCSI && (mmajor(st2.st_dev) != mmajor(st1.st_dev) || (mminor(st2.st_dev) & (~0xf)) != (mminor(st1.st_dev) & (~0xf)))) ||
(hwdevs->type == TYPE_IDE && (mmajor(st2.st_dev) != mmajor(st1.st_dev) || (mminor(st2.st_dev) & (~0x3f)) != (mminor(st1.st_dev) & (~0x3f)))))
@@ -1288,7 +1318,9 @@ int main(int argc,char **argv)
#else
# error "Unknown system"
#endif
- fatal ("Config file %s has to be on the %s device (on any partition there)", config_file, hwdevs->wholedev);
+ silo_fatal("Config file %s has to be on the %s device "
+ "(on any partition there)", config_file,
+ hwdevs->wholedev);
else {
char *p, *q, *r, c;
char readlinkbuf[2048];
@@ -1303,7 +1335,7 @@ int main(int argc,char **argv)
*q = 0;
} else c = 0;
if (lstat (*buffer ? buffer : "/", &st3) < 0)
- fatal ("Couldn't stat %s\n", config_file);
+ silo_fatal("Couldn't stat %s\n", config_file);
if (st3.st_dev == st2.st_dev) {
*q = c;
config_file = q;
@@ -1312,7 +1344,7 @@ int main(int argc,char **argv)
if (S_ISLNK(st3.st_mode)) {
len = readlink (buffer, readlinkbuf, 2048);
if (len < 0)
- fatal ("Couldn't readlink %s\n", config_file);
+ silo_fatal("Couldn't readlink %s\n", config_file);
readlinkbuf[len] = 0;
if (*readlinkbuf == '/') {
if (c) {
@@ -1340,7 +1372,7 @@ int main(int argc,char **argv)
*q = c;
p = q + 1;
if (!c)
- fatal ("Internal error\n");
+ silo_fatal("Internal error\n");
}
}
}
@@ -1434,7 +1466,7 @@ static errcode_t std_open (const char *name, int flags, io_channel * channel)
return EXT2_ET_BAD_DEVICE_NAME;
std_fd = devopen (name, O_RDONLY);
if (std_fd < 0)
- fatal ("Cannot open %s", name);
+ silo_fatal("Cannot open %s", name);
memset (io, 0, sizeof (struct struct_io_channel));
io->magic = EXT2_ET_MAGIC_IO_CHANNEL;
io->manager = std_io_manager;
@@ -1464,9 +1496,9 @@ static errcode_t std_read_blk (io_channel channel, unsigned long block, int coun
size = (count < 0) ? -count : count * cbs;
if (lseek (std_fd, block * cbs, SEEK_SET) != block * cbs)
- fatal ("Cannot seek");
+ silo_fatal("Cannot seek");
if (read (std_fd, data, size) != size)
- fatal ("Read error on block %d", block);
+ silo_fatal("Read error on block %d", block);
return 0;
}
@@ -1491,10 +1523,10 @@ static int ufs_blocks_dump (ufs_filsys fs, blk_t *block, int i, void *private)
static int ufs_blocks (struct hwdevice *hwdev, ino_t inode)
{
if (ufs_open (hwdev->dev, std_io_manager, &fs))
- fatal ("Cannot open ufs filesystem containing second stage");
+ silo_fatal("Cannot open ufs filesystem containing second stage");
hwdev->nsect = cbs / 512;
if (ufs_block_iterate (fs, inode, ufs_blocks_dump, hwdev))
- fatal ("Block iterating error on second stage");
+ silo_fatal("Block iterating error on second stage");
blocks [ufs_block_idx] = 0;
return 0;
}
diff --git a/silo/silocheck.c b/silo/silocheck.c
index 0257438..c8edb95 100644
--- a/silo/silocheck.c
+++ b/silo/silocheck.c
@@ -141,7 +141,7 @@ unsigned long doff;
int nblocks = 0;
__u32 blocks[16384];
-void fatal (char *fmt,...)
+static void silo_fatal(char *fmt,...)
{
va_list ap;
va_start (ap, fmt);
@@ -158,7 +158,7 @@ int check_fs (int fd)
struct ext2_super_block sb; /* Super Block Info */
if (lseek (fd, 1024, 0) != 1024 || read (fd, &sb, sizeof (sb)) != sizeof (sb))
- fatal ("Cannot read Super Block!");
+ silo_fatal("Cannot read Super Block!");
if (swab16 (sb.s_magic) == EXT2_SUPER_MAGIC)
return 1024 << swab32 (sb.s_log_block_size);
if (lseek (fd, 8192, 0) != 8192 || read (fd, &ufs, sizeof (ufs)) != sizeof (ufs))
@@ -176,10 +176,11 @@ void read_sb (char *device, char *bootdev)
int offset;
if ((fd = open (device, O_RDONLY)) == -1)
- fatal ("Cannot open superblock on %s", device);
+ silo_fatal("Cannot open superblock on %s", device);
bs = check_fs (fd);
if (bs == (unsigned short)-1)
- fatal ("File systems other than ext2, ext3, ufs and romfs not yet supported", device);
+ silo_fatal("File systems other than ext2, ext3, ufs and romfs "
+ "not yet supported", device);
close (fd);
nsect = bs / 512;
doff = 0;
@@ -190,9 +191,9 @@ void read_sb (char *device, char *bootdev)
#endif
sdl = (struct sun_disklabel *) &buff;
if ((fd = open (bootdev, O_RDONLY)) == -1)
- fatal ("Error opening %s", bootdev);
+ silo_fatal("Error opening %s", bootdev);
if (read (fd, buff, sizeof (buff)) != sizeof (buff))
- fatal ("Error reading %s's label", bootdev);
+ silo_fatal("Error reading %s's label", bootdev);
doff = bswab16(sdl->ntrks) * bswab16(sdl->nsect) * bswab32(sdl->partitions[partno].start_cylinder);
offset = bswab16(sdl->ntrks) * bswab16(sdl->nsect) * bswab32(sdl->partitions[0].start_cylinder);
close (fd);
@@ -206,10 +207,10 @@ int get_partition_blocks (char *device, char *filename)
int size;
if ((fd = open (filename, O_RDONLY)) == -1) {
- fatal ("Cannot find %s", filename);
+ silo_fatal("Cannot find %s", filename);
}
if (fstat (fd, &st) < 0) {
- fatal ("Couldn't stat %s", filename);
+ silo_fatal("Couldn't stat %s", filename);
}
#ifdef __linux__
size = st.st_size;
@@ -298,7 +299,7 @@ int main(int argc,char **argv)
if (argc != 1) usage(name);
filename = *argv;
if (stat (filename, &st1) < 0)
- fatal ("Cannot open %s", filename);
+ silo_fatal("Cannot open %s", filename);
#ifdef __linux__
if (mmajor(st1.st_dev) == 8) {
sprintf (bootdev2, "/dev/sd%c%c", (mminor(st1.st_dev) >> 4) + 'a', (mminor(st1.st_dev) & 0xf) + '0');
@@ -308,7 +309,8 @@ int main(int argc,char **argv)
{
char *p = find_dev (st1.st_dev);
- if (!p) fatal ("Couldn't find out what device is %s on", filename);
+ if (!p)
+ silo_fatal("Couldn't find out what device is %s on", filename);
strcpy (bootdev, p);
strcpy (bootdev2, p);
#ifdef __sun__
@@ -393,7 +395,7 @@ static errcode_t std_open (const char *name, int flags, io_channel * channel)
return EXT2_ET_BAD_DEVICE_NAME;
std_fd = open (name, O_RDONLY);
if (std_fd < 0)
- fatal ("Cannot open %s", name);
+ silo_fatal("Cannot open %s", name);
memset (io, 0, sizeof (struct struct_io_channel));
io->magic = EXT2_ET_MAGIC_IO_CHANNEL;
io->manager = std_io_manager;
@@ -423,9 +425,9 @@ static errcode_t std_read_blk (io_channel channel, unsigned long block, int coun
size = (count < 0) ? -count : count * cbs;
if (lseek (std_fd, block * cbs, SEEK_SET) != block * cbs)
- fatal ("Cannot seek");
+ silo_fatal("Cannot seek");
if (read (std_fd, data, size) != size)
- fatal ("Read error on block %d", block);
+ silo_fatal("Read error on block %d", block);
return 0;
}
@@ -449,10 +451,10 @@ static int ufs_blocks_dump (ufs_filsys fs, blk_t *block, int i, void *private)
static int ufs_blocks (char *device, ino_t inode)
{
if (ufs_open (device, std_io_manager, &fs))
- fatal ("Cannot open ufs filesystem containing second stage");
+ silo_fatal("Cannot open ufs filesystem containing second stage");
nsect = cbs / 512;
if (ufs_block_iterate (fs, inode, ufs_blocks_dump, 0))
- fatal ("Block iterating error on second stage");
+ silo_fatal("Block iterating error on second stage");
blocks [ufs_block_idx] = 0;
nblocks = ufs_block_idx;
return 0;