mkboot.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 1992-1994, 2002-2003 Sun Microsystems, Inc.
* All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <strings.h>
static Elf32_Ehdr elfhdr;
static char buf[4096];
int
{
int count;
int text_written = 0;
int data_written = 0;
if (argc < 3) {
exit(1);
}
perror("open input");
exit(1);
}
perror("read elfhdr");
exit(1);
}
perror("open aout");
exit(1);
}
perror("elfmagic");
exit(1);
}
perror("lseek");
exit(1);
}
perror("read phdr");
exit(1);
}
perror("read dphdr");
exit(1);
}
/*
* Create an a.out header that will fool the PROM
*/
#ifdef sparc
#else
#error "unknown machine type!"
#endif
perror("write exec");
exit(1);
}
/*
* Text section
*/
perror("lseek text");
exit(1);
}
while (text_written < text &&
perror("write text file");
exit(1);
}
text_written += count;
}
/* Include a.out header in the accounting */
text_written += sizeof (exec);
/*
* Data section
*/
perror("lseek data");
exit(1);
}
while (data_written < data &&
perror("write data file");
exit(1);
}
data_written += count;
}
(void) printf("*** WARNING! ***\n"
"Do not install this bootblock!\n");
(void) printf("bootblock image is %d bytes too big.\n",
exit(1);
}
(void) printf("bootblock %d%% full - %d bytes to spare.\n",
return (0);
}