mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-16 05:53:00 +02:00
Rudimentaere ISDN-Erkennung erstellt.
ProbeHW optimiert weges des via-rhine-Problem. Grubs gfx-Menue entfernt wegen der Kompatibilitaet. git-svn-id: http://svn.ipfire.org/svn/ipfire/trunk@785 ea5c0bd1-69bd-2848-81d8-4f18e57aeed8
This commit is contained in:
@@ -2,7 +2,8 @@ timeout 10
|
||||
default saved
|
||||
foreground = 16064e
|
||||
background = ffffff
|
||||
gfxmenu /grub/message
|
||||
#hiddenmenu
|
||||
splashimage (hd0,0)/grub/ipfire.xpm.gz
|
||||
title IPFire (1024x768)
|
||||
root (hd0,0)
|
||||
kernel /vmlinuz-ipfire root=ROOT panic=10 vga=791 MOUNT
|
||||
|
||||
Binary file not shown.
@@ -3,7 +3,6 @@ boot/grub/default
|
||||
boot/grub/grub.conf
|
||||
boot/grub/grubbatch
|
||||
boot/grub/ipfire.xpm.gz
|
||||
boot/grub/message
|
||||
boot/grub/stage1
|
||||
boot/grub/stage2
|
||||
#usr/bin/mbchk
|
||||
|
||||
@@ -107,7 +107,6 @@
|
||||
* httpd-2.2.2
|
||||
* hwdata
|
||||
* iana-etc-2.10
|
||||
* ibod-1.4
|
||||
* icecast-2.3.1
|
||||
* ices-2.0.1
|
||||
* iftop-0.17
|
||||
|
||||
@@ -141,9 +141,10 @@ print <<END
|
||||
<td width='100%' class='base'>$Lang::tr{'ssh keys'}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align='center'><hr /><input type='submit' name='ACTION' value='$Lang::tr{'ssh tempstart15'}' /></td>
|
||||
<td align='center'><hr /><input type='submit' name='ACTION' value='$Lang::tr{'ssh tempstart30'}' /></td>
|
||||
<td align='center'><hr /><input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td>
|
||||
<td align='center' colspan='3'><hr />
|
||||
<input type='submit' name='ACTION' value='$Lang::tr{'ssh tempstart15'}' />
|
||||
<input type='submit' name='ACTION' value='$Lang::tr{'ssh tempstart30'}' />
|
||||
<input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td>
|
||||
</tr>
|
||||
</table>
|
||||
END
|
||||
|
||||
@@ -29,13 +29,21 @@
|
||||
|
||||
char *de_tr[] = {
|
||||
|
||||
/* TR_ISDN */
|
||||
"ISDN",
|
||||
/* TR_ERROR_PROBING_ISDN */
|
||||
"Konnte ISDN Scan nicht durchf<68>hren.",
|
||||
/* TR_PROBING_ISDN */
|
||||
"Suche und konfiguriere ISDN Ger<65>te.",
|
||||
/* TR_MISSING_GREEN_IP */
|
||||
"Fehlende IP auf der gr<67>nen Schnittstelle!",
|
||||
/* TR_CHOOSE_FILESYSTEM */
|
||||
"Bitte wählen Sie ihr Dateisystem aus:",
|
||||
/* TR_NOT_ENOUGH_INTERFACES */
|
||||
"Nicht genügend Netzwerkkarten für diese Auswahl gefunden.\n\nBenötigt: %d - Gefunden: %d\n",
|
||||
/* TR_INTERFACE_CHANGE */
|
||||
"Bitte wählen Sie das Interface aus das geändert werden soll.\n\n",
|
||||
/* TR_METCARD_COLOR */
|
||||
/* TR_NETCARD_COLOR */
|
||||
"Zugewiesene Karten",
|
||||
/* TR_REMOVE */
|
||||
"Entfernen",
|
||||
@@ -52,7 +60,7 @@ char *de_tr[] = {
|
||||
/* TR_ERROR_INTERFACES */
|
||||
"Es wurden leider keine freien Netzwerkkarten für die Schnittstelle in ihrem System gefunden.",
|
||||
/* TR_REMOVE_CARD */
|
||||
"Soll die Zuordnung der folgende Netzwerkkarte entfernt werden?",
|
||||
"Soll die Zuordnung der folgende Netzwerkkarte entfernt werden? - %s",
|
||||
/* TR_JOURNAL_ERROR */
|
||||
"Konnte das Journal nicht erstelle, verwende ext2 Fallback.",
|
||||
/* TR_FILESYSTEM */
|
||||
|
||||
@@ -25,13 +25,21 @@
|
||||
|
||||
char *en_tr[] = {
|
||||
|
||||
/* TR_ISDN */
|
||||
"ISDN",
|
||||
/* TR_ERROR_PROBING_ISDN */
|
||||
"Unable to scan for ISDN devices.",
|
||||
/* TR_PROBING_ISDN */
|
||||
"Scanning and configuring ISDN devices.",
|
||||
/* TR_MISSING_GREEN_IP */
|
||||
"Missing Green IP!",
|
||||
/* TR_CHOOSE_FILESYSTEM */
|
||||
"Please choose your filesystem:",
|
||||
/* TR_NOT_ENOUGH_INTERFACES */
|
||||
"Not enough netcards for your choice.\n\nNeeded: %d - Available: %d\n",
|
||||
/* TR_INTERFACE_CHANGE */
|
||||
"Please choose the interface you wish to change.\n\n",
|
||||
/* TR_METCARD_COLOR */
|
||||
/* TR_NETCARD_COLOR */
|
||||
"Assigned Cards",
|
||||
/* TR_REMOVE */
|
||||
"Remove",
|
||||
@@ -48,7 +56,7 @@ char *en_tr[] = {
|
||||
/* TR_ERROR_INTERFACES */
|
||||
"There are no free interfaces on your system.",
|
||||
/* TR_REMOVE_CARD */
|
||||
"Should the allocation for the networkcard be deleted?",
|
||||
"Should the allocation for the networkcard be deleted? - %s",
|
||||
/* TR_JOURNAL_ERROR */
|
||||
"Could not create the journal, using fallback to ext2.",
|
||||
/* TR_FILESYSTEM */
|
||||
|
||||
5
lfs/grub
5
lfs/grub
@@ -74,10 +74,7 @@ $(subst %,%_MD5,$(objects)) :
|
||||
$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
|
||||
@$(PREBUILD)
|
||||
@rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar zxf $(DIR_DL)/$(DL_FILE)
|
||||
|
||||
# This fails, but doesn't matter
|
||||
-cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/grub-0.97-disk_geometry-1.patch
|
||||
cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/grub-gfxmenu-v8.diff
|
||||
cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/grub-0.97-disk_geometry-1.patch
|
||||
|
||||
cd $(DIR_APP) && perl -pi -e 's,/usr/lib/grub/i386-pc,/usr/share/grub/i386-pc,' docs/grub.texi
|
||||
cd $(DIR_APP) && sed -i 's/AM_INIT_AUTOMAKE/&\nAM_PROG_AS/' configure.ac
|
||||
|
||||
@@ -142,28 +142,27 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
fprintf(flog, "Couldn't open commandline: /proc/cmdline\n");
|
||||
} else {
|
||||
mysystem("/sbin/modprobe ide-generic");
|
||||
mysystem("/sbin/modprobe generic");
|
||||
mysystem("/sbin/modprobe ide-cd");
|
||||
mysystem("/sbin/modprobe ide-disk");
|
||||
mysystem("/sbin/modprobe sd_mod");
|
||||
mysystem("/sbin/modprobe sr_mod");
|
||||
mysystem("/sbin/modprobe usb-storage");
|
||||
|
||||
fgets(line, STRING_SIZE, cmdfile);
|
||||
|
||||
// check if we have to make an unattended install
|
||||
if (strstr (line, "unattended") != NULL) {
|
||||
unattended = 1;
|
||||
}
|
||||
mysystem("/sbin/modprobe iso9660"); // CDROM
|
||||
mysystem("/sbin/modprobe ext2"); // Boot patition
|
||||
mysystem("/sbin/modprobe vfat"); // USB key
|
||||
runcommandwithstatus("/bin/sleep 10", "WARNING: Unattended installation will start in 10 seconds...");
|
||||
}
|
||||
}
|
||||
|
||||
mysystem("/sbin/modprobe ide-generic");
|
||||
mysystem("/sbin/modprobe generic");
|
||||
mysystem("/sbin/modprobe ide-cd");
|
||||
mysystem("/sbin/modprobe ide-disk");
|
||||
mysystem("/sbin/modprobe sd_mod");
|
||||
mysystem("/sbin/modprobe sr_mod");
|
||||
mysystem("/sbin/modprobe usb-storage");
|
||||
mysystem("/sbin/modprobe usbhid");
|
||||
|
||||
if (unattended) {
|
||||
runcommandwithstatus("/bin/sleep 10", "WARNING: Unattended installation will start in 10 seconds...");
|
||||
}
|
||||
mysystem("/sbin/modprobe iso9660"); // CDROM
|
||||
mysystem("/sbin/modprobe ext2"); // Boot patition
|
||||
mysystem("/sbin/modprobe vfat"); // USB key
|
||||
|
||||
/* German is the default */
|
||||
for (choice = 0; langnames[choice]; choice++)
|
||||
@@ -181,7 +180,6 @@ int main(int argc, char *argv[])
|
||||
|
||||
ctr = langtrs[choice];
|
||||
strcpy(shortlangname, shortlangnames[choice]);
|
||||
fprintf(flog, "Selected language: %s\n", shortlangname);
|
||||
|
||||
newtDrawRootText(14, 0, NAME " " VERSION " - " SLOGAN );
|
||||
newtPushHelpLine(ctr[TR_HELPLINE]);
|
||||
|
||||
@@ -6,6 +6,8 @@ for MODULE in $(kudzu -qps -t 30 | grep driver: | cut -d ' ' -f 2 | sort | uniq
|
||||
[ "${MODULE}" = "ignore" ]; then
|
||||
continue
|
||||
fi
|
||||
MODULE=$(basename $(find /lib/modules -name $(echo $MODULE | sed -e 's/[_-]/*/g')* ) | cut -d. -f1 | head -1)
|
||||
|
||||
if grep -Eqe "^${MODULE} " /proc/modules; then
|
||||
continue
|
||||
fi
|
||||
|
||||
@@ -335,37 +335,6 @@ int probecards(char *driver, char *driveroptions )
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ### alter strupper ###
|
||||
char *strupper(char *s)
|
||||
{
|
||||
int n;
|
||||
for (n=0;s[n];n++) s[n]=toupper(s[n]);
|
||||
return s;
|
||||
}
|
||||
*/
|
||||
|
||||
/* neuer StringUpper, wird zur Zeit nicht benutzt da UTF-8 nicht geht.
|
||||
void strupper(unsigned char *string)
|
||||
{
|
||||
unsigned char *str;
|
||||
for (str = string; *str != '\0'; str++)
|
||||
if (!(*str & 0x80) && islower(*str))
|
||||
*str = toupper(*str);
|
||||
}
|
||||
*/
|
||||
|
||||
/* int ismacaddr(char *ismac)
|
||||
{
|
||||
char *a;
|
||||
fprintf(flog,"Check is MAC true\n"); // #### Debug ####
|
||||
for (a = ismac; *a; a++) {
|
||||
sprintf(flog,"%c\n", *a); // #### Debug ####
|
||||
if (*a != ':' && !isxdigit(*a)) return 0; // is int != ':' or not hexdigit then exit
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
*/
|
||||
|
||||
int get_knic(int card) //returns "0" for zero cards or error and "1" card is found.
|
||||
{
|
||||
struct keyvalue *kv = initkeyvalues();
|
||||
@@ -412,13 +381,13 @@ int init_knics(void)
|
||||
return found;
|
||||
}
|
||||
|
||||
int fmt_exists(const char *fname) { /* Check it's any File or Directory */
|
||||
int fmt_exists(const char *fname) { /* Check if it is any file or directory */
|
||||
struct stat st;
|
||||
if (stat(fname, &st) == -1) return 0;
|
||||
else return 1;
|
||||
}
|
||||
|
||||
int is_interface_up(char *card) { /* Check is interface UP */
|
||||
int is_interface_up(char *card) { /* Check if the interface is UP */
|
||||
char temp[STRING_SIZE];
|
||||
|
||||
sprintf(temp,"ip link show dev %s | grep -q UP", card);
|
||||
@@ -433,7 +402,6 @@ int rename_device(char *old_name, char *new_name) {
|
||||
fprintf(flog,"Device not found: %s\n",old_name);
|
||||
return 0;
|
||||
}
|
||||
// fprintf(flog,"NIC: %s wurde in %s umbenannt.\n", old_name, new_name); // #### Debug ####
|
||||
sprintf(temp,"/sbin/ip link set dev %s name %s",old_name ,new_name );
|
||||
mysystem(temp);
|
||||
|
||||
@@ -442,7 +410,6 @@ int rename_device(char *old_name, char *new_name) {
|
||||
|
||||
char g_temp[STRING_SIZE]="";
|
||||
char* readmac(char *card) {
|
||||
// fprintf(flog,"Enter readmac... NIC: %s\n", card); // #### Debug ####
|
||||
FILE *fp;
|
||||
char temp[STRING_SIZE], mac[20];
|
||||
|
||||
@@ -459,8 +426,6 @@ char* readmac(char *card) {
|
||||
}
|
||||
|
||||
char* find_nic4mac(char *findmac) {
|
||||
fprintf(flog,"Enter find_name4nic... Search for %s\n", findmac); // #### Debug ####
|
||||
|
||||
DIR *dir;
|
||||
struct dirent *dirzeiger;
|
||||
char temp[STRING_SIZE], temp2[STRING_SIZE];
|
||||
@@ -476,7 +441,6 @@ char* find_nic4mac(char *findmac) {
|
||||
sprintf(temp2, "%s", readmac((*dirzeiger).d_name) );
|
||||
if (strcmp(findmac, temp2) == 0) {
|
||||
sprintf(temp,"%s", (*dirzeiger).d_name);
|
||||
// fprintf(flog,"MAC: %s is NIC: %s\n", findmac, temp); // #### Debug ####
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -507,43 +471,27 @@ int rename_nics(void) {
|
||||
int fnics = scan_network_cards();
|
||||
char nic2find[STRING_SIZE], temp[STRING_SIZE];
|
||||
|
||||
fprintf(flog,"Renaming Nics\n"); // #### Debug ####
|
||||
|
||||
for(i=0; i<4; i++)
|
||||
if (strcmp(knics[i].macaddr, "")) // Wird das Interface benutzt ?
|
||||
if (strcmp(knics[i].macaddr, ""))
|
||||
for(j=0; j<fnics; j++)
|
||||
if(strcmp(knics[i].macaddr, nics[j].macaddr) == 0) { // suche den aktuellen Namen
|
||||
if(strcmp(knics[i].macaddr, nics[j].macaddr) == 0) {
|
||||
sprintf(nic2find,"%s0",lcolourcard[i]);
|
||||
// fprintf(flog,"search4: %s\n", nic2find); // #### Debug ####
|
||||
if(strcmp(nic2find, nics[j].nic)) { // hat das Interface nicht den Namen ?
|
||||
// fprintf(flog,"cmp nic2find false\n"); // #### Debug ####
|
||||
// fprintf(flog,"is nic( %s ) up ?\n",nics[j].nic); // #### Debug ####
|
||||
|
||||
if(is_interface_up(nics[j].nic)) { // wurde das Interface gestartet ?
|
||||
// fprintf(flog,"%s is UP, shutting down...\n",nics[j].nic); // #### Debug ####
|
||||
if(strcmp(nic2find, nics[j].nic)) {
|
||||
if(is_interface_up(nics[j].nic)) {
|
||||
nic_shutdown(nics[j].nic);
|
||||
}
|
||||
sprintf(temp,SYSDIR "/%s", nic2find);
|
||||
// fprintf(flog,"exists ?--> %s\n", temp); // #### Debug ####
|
||||
if(fmt_exists(temp)) { // Ist der Name schon in Benutzung ?
|
||||
// fprintf(flog,"is exists %s\n", nic2find); // #### Debug ####
|
||||
for(k=0; k<fnics; k++) // Suche das Interface
|
||||
if(fmt_exists(temp)) {
|
||||
for(k=0; k<fnics; k++)
|
||||
if (strcmp(nics[k].nic, nic2find) == 0 ) {
|
||||
if(is_interface_up(nics[k].nic)) { // wurde das Interface gestartet ?
|
||||
// fprintf(flog,"%s is UP, shutting down...\n",nics[k].nic); // #### Debug ####
|
||||
if(is_interface_up(nics[k].nic)) {
|
||||
nic_shutdown(nics[k].nic);
|
||||
}
|
||||
sprintf(temp,"dummy%i",k); // Benenne NIC nach "dummy[k]" um.
|
||||
// fprintf(flog,"set dummy%i\n", k); // #### Debug ####
|
||||
sprintf(temp,"dummy%i",k);
|
||||
if (rename_device(nics[k].nic, temp)) strcpy(nics[k].nic, temp);
|
||||
}
|
||||
}
|
||||
if (rename_device(nics[j].nic, nic2find)) strcpy(nics[j].nic, nic2find); // Benenne NIC um.
|
||||
|
||||
// if(strncmp(nics[j].nic,"dummy",5)) {
|
||||
// fprintf(flog,"%s is down, start up...\n",nics[j].nic); // #### Debug ####
|
||||
// nic_startup(nics[j].nic);
|
||||
// }
|
||||
if (rename_device(nics[j].nic, nic2find)) strcpy(nics[j].nic, nic2find);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -554,7 +502,6 @@ int create_udev(void)
|
||||
FILE *fp;
|
||||
int i;
|
||||
|
||||
fprintf(flog,"Enter create_udev: "UDEV_NET_CONF"\n"); // #### Debug ####
|
||||
if ( (fp = fopen(UDEV_NET_CONF, "w")) == NULL ) {
|
||||
fprintf(stderr,"Couldn't open" UDEV_NET_CONF);
|
||||
return 1;
|
||||
@@ -564,7 +511,6 @@ int create_udev(void)
|
||||
{
|
||||
if (strcmp(knics[i].macaddr, "")) {
|
||||
fprintf(fp,"ACTION==\"add\", SUBSYSTEM==\"net\", SYSFS{address}==\"%s\", NAME=\"%s0\" # %s\n", knics[i].macaddr, lcolourcard[i], knics[i].description);
|
||||
fprintf(flog,"Write %s\n",lcolourcard[i]); // #### Debug ####
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
@@ -617,9 +563,7 @@ int scan_network_cards(void)
|
||||
|
||||
if (!(scanned_nics_read_done))
|
||||
{
|
||||
fprintf(flog,"Enter scan_network_cards\n"); // #### Debug ####
|
||||
mysystem("/bin/probenic.sh");
|
||||
// Read our scanned nics
|
||||
if( (fp = fopen(SCANNED_NICS, "r")) == NULL )
|
||||
{
|
||||
fprintf(stderr,"Couldn't open "SCANNED_NICS);
|
||||
@@ -654,16 +598,8 @@ int nicmenu(int colour)
|
||||
char MenuInhalt[20][180];
|
||||
char *pMenuInhalt[20];
|
||||
|
||||
// strcpy( message , pnics[count].macaddr);
|
||||
// while (strcmp(message, "")) {
|
||||
// count++;
|
||||
// strcpy( message , pnics[count].macaddr);
|
||||
// }
|
||||
|
||||
while (strcmp(nics[count].macaddr, "")) count++; // 2 find how many nics in system
|
||||
for ( i=0 ; i<4;i++) if (strcmp(knics[i].macaddr, "")) kcount++; // loop to find all knowing nics
|
||||
fprintf(flog, "Enter NicMenu\n"); // #### Debug ####
|
||||
fprintf(flog, "count nics %i\ncount knics %i\n", count, kcount); // #### Debug ####
|
||||
|
||||
// If new nics are found...
|
||||
if (count > kcount) {
|
||||
@@ -673,12 +609,10 @@ int nicmenu(int colour)
|
||||
for (j=0 ; j <= kcount ; j++) {
|
||||
if (strcmp(nics[ i ].macaddr, knics[ j ].macaddr) == 0 ) {
|
||||
nic_in_use = 1;
|
||||
fprintf(flog,"NIC \"%s\" is in use.\n", nics[ i ].macaddr); // #### Debug ####
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!(nic_in_use)) {
|
||||
fprintf(flog,"NIC \"%s\" is free.\n", nics[ i ].macaddr); // #### Debug ####
|
||||
if ( strlen(nics[i].description) < 55 )
|
||||
sprintf(MenuInhalt[mcount], "%.*s", strlen(nics[i].description)-2, nics[i].description+1);
|
||||
else {
|
||||
@@ -700,17 +634,12 @@ int nicmenu(int colour)
|
||||
|
||||
pMenuInhalt[mcount] = NULL;
|
||||
|
||||
// sprintf(message, "Es wurde(n) %d freie Netzwerkkarte(n) in Ihrem System gefunden.\nBitte waehlen Sie im naechsten Dialog eine davon aus.\n", count);
|
||||
// newtWinMessage("NetcardMenu", ctr[TR_OK], message);
|
||||
|
||||
sprintf(message, ctr[TR_CHOOSE_NETCARD], ucolourcard[colour]);
|
||||
rc = newtWinMenu( ctr[TR_NETCARDMENU2], message, 50, 5, 5, 6, pMenuInhalt, &choise, ctr[TR_OK], ctr[TR_SELECT], ctr[TR_CANCEL], NULL);
|
||||
|
||||
if ( rc == 0 || rc == 1) {
|
||||
write_configs_netudev(found_NIC_as_Card[choise], colour);
|
||||
} else if (rc == 2) {
|
||||
// manualdriver("pcnet32","");
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
} else {
|
||||
// We have to add here that you can manually add a device
|
||||
@@ -747,7 +676,6 @@ int clear_card_entry(int card)
|
||||
writekeyvalues(kv, CONFIG_ROOT "/ethernet/settings");
|
||||
freekeyvalues(kv);
|
||||
|
||||
fprintf(flog,"Card \"%s\" cleared\n",ucolourcard[card]); // #### Debug ####
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -756,19 +684,11 @@ int ask_clear_card_entry(int card)
|
||||
char message[STRING_SIZE];
|
||||
int rc;
|
||||
|
||||
sprintf(message, ctr[TR_REMOVE_CARD] "%s \n", ucolourcard[card]);
|
||||
sprintf(message, ctr[TR_REMOVE_CARD], ucolourcard[card]);
|
||||
rc = newtWinChoice(ctr[TR_WARNING], ctr[TR_OK], ctr[TR_CANCEL], message);
|
||||
|
||||
if ( rc = 0 || rc == 1) {
|
||||
clear_card_entry(card);
|
||||
// sprintf(temp1, "%s_DEV", ucolour);
|
||||
// sprintf(temp2, "%s_MACADDR", ucolour);
|
||||
// replacekeyvalue(kv, temp1, "");
|
||||
// replacekeyvalue(kv, temp2, "");
|
||||
// sprintf(temp1, "%s_DESCRIPTION", ucolour);
|
||||
// replacekeyvalue(kv, temp1, "");
|
||||
|
||||
// writekeyvalues(kv, CONFIG_ROOT "/ethernet/settings");
|
||||
} else return 1;
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -95,9 +95,10 @@ int main(int argc, char *argv[])
|
||||
sections[2] = ctr[TR_HOSTNAME];
|
||||
sections[3] = ctr[TR_DOMAINNAME];
|
||||
sections[4] = ctr[TR_NETWORKING];
|
||||
sections[5] = ctr[TR_ROOT_PASSWORD];
|
||||
sections[6] = ctr[TR_ADMIN_PASSWORD];
|
||||
sections[7] = NULL;
|
||||
sections[5] = ctr[TR_ISDN];
|
||||
sections[6] = ctr[TR_ROOT_PASSWORD];
|
||||
sections[7] = ctr[TR_ADMIN_PASSWORD];
|
||||
sections[8] = NULL;
|
||||
|
||||
newtInit();
|
||||
newtCls();
|
||||
@@ -147,12 +148,16 @@ int main(int argc, char *argv[])
|
||||
case 4:
|
||||
handlenetworking();
|
||||
break;
|
||||
|
||||
|
||||
case 5:
|
||||
handleisdn();
|
||||
break;
|
||||
|
||||
case 6:
|
||||
handlerootpassword();
|
||||
break;
|
||||
|
||||
case 6:
|
||||
case 7:
|
||||
handleadminpassword();
|
||||
break;
|
||||
|
||||
@@ -173,6 +178,8 @@ int main(int argc, char *argv[])
|
||||
goto EXIT;
|
||||
if (!(handlenetworking()))
|
||||
goto EXIT;
|
||||
if (!(handleisdn()))
|
||||
goto EXIT;
|
||||
if (!(handledhcp()))
|
||||
goto EXIT;
|
||||
if (!(handlerootpassword()))
|
||||
|
||||
@@ -1,141 +1,149 @@
|
||||
/* SmoothWall setup program.
|
||||
*
|
||||
* This program is distributed under the terms of the GNU General Public
|
||||
* Licence. See the file COPYING for details.
|
||||
*
|
||||
* (c) Lawrence Manning, 2001
|
||||
* Misc. stuff for the lib.
|
||||
*
|
||||
* $Id: misc.c,v 1.5.2.3 2005/08/25 17:51:42 gespinasse Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
#include "setup.h"
|
||||
|
||||
extern FILE *flog;
|
||||
extern char *mylog;
|
||||
|
||||
extern char **ctr;
|
||||
|
||||
extern int automode;
|
||||
|
||||
/* This will rewrite /etc/hosts, /etc/hosts.*, and the apache ServerName file. */
|
||||
int writehostsfiles(void)
|
||||
{
|
||||
char address[STRING_SIZE] = "";
|
||||
char netaddress[STRING_SIZE] = "";
|
||||
char netmask[STRING_SIZE] = "";
|
||||
char message[1000];
|
||||
FILE *file, *hosts;
|
||||
struct keyvalue *kv;
|
||||
char hostname[STRING_SIZE];
|
||||
char domainname[STRING_SIZE] = "";
|
||||
char commandstring[STRING_SIZE];
|
||||
char buffer[STRING_SIZE];
|
||||
|
||||
kv = initkeyvalues();
|
||||
if (!(readkeyvalues(kv, CONFIG_ROOT "/ethernet/settings")))
|
||||
{
|
||||
freekeyvalues(kv);
|
||||
errorbox(ctr[TR_UNABLE_TO_OPEN_SETTINGS_FILE]);
|
||||
return 0;
|
||||
}
|
||||
findkey(kv, "GREEN_ADDRESS", address);
|
||||
findkey(kv, "GREEN_NETADDRESS", netaddress);
|
||||
findkey(kv, "GREEN_NETMASK", netmask);
|
||||
freekeyvalues(kv);
|
||||
|
||||
kv = initkeyvalues();
|
||||
if (!(readkeyvalues(kv, CONFIG_ROOT "/main/settings")))
|
||||
{
|
||||
freekeyvalues(kv);
|
||||
errorbox(ctr[TR_UNABLE_TO_OPEN_SETTINGS_FILE]);
|
||||
return 0;
|
||||
}
|
||||
strcpy(hostname, SNAME );
|
||||
findkey(kv, "HOSTNAME", hostname);
|
||||
findkey(kv, "DOMAINNAME", domainname);
|
||||
freekeyvalues(kv);
|
||||
|
||||
if (!(file = fopen(CONFIG_ROOT "/main/hostname.conf", "w")))
|
||||
{
|
||||
sprintf (message, ctr[TR_UNABLE_TO_WRITE_VAR_SMOOTHWALL_MAIN_HOSTNAMECONF], CONFIG_ROOT);
|
||||
errorbox(message);
|
||||
return 0;
|
||||
}
|
||||
fprintf(file, "ServerName %s.%s\n", hostname,domainname);
|
||||
fclose(file);
|
||||
|
||||
if (!(file = fopen(CONFIG_ROOT "/main/hosts", "r")))
|
||||
{
|
||||
errorbox(ctr[TR_UNABLE_TO_OPEN_HOSTS_FILE]);
|
||||
return 0;
|
||||
}
|
||||
if (!(hosts = fopen("/etc/hosts", "w")))
|
||||
{
|
||||
errorbox(ctr[TR_UNABLE_TO_WRITE_ETC_HOSTS]);
|
||||
return 0;
|
||||
}
|
||||
fprintf(hosts, "127.0.0.1\tlocalhost\n");
|
||||
if (strlen(domainname))
|
||||
fprintf(hosts, "%s\t%s.%s\t%s\n",address,hostname,domainname,hostname);
|
||||
else
|
||||
fprintf(hosts, "%s\t%s\n",address,hostname);
|
||||
while (fgets(buffer, STRING_SIZE, file))
|
||||
{
|
||||
char *token, *ip, *host, *domain;
|
||||
|
||||
buffer[strlen(buffer) - 1] = 0;
|
||||
|
||||
token = strtok(buffer, ",");
|
||||
|
||||
ip = strtok(NULL, ",");
|
||||
host = strtok(NULL, ",");
|
||||
domain = strtok(NULL, ",");
|
||||
|
||||
if (!(ip && host))
|
||||
break;
|
||||
|
||||
if (strlen(ip) < 7 || strlen(ip) > 15
|
||||
|| strspn(ip, "0123456789.") != strlen(ip))
|
||||
break;
|
||||
|
||||
if (strspn(host, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-") != strlen(host))
|
||||
break;
|
||||
|
||||
if (domain)
|
||||
fprintf(hosts, "%s\t%s.%s\t%s\n",ip,host,domain,host);
|
||||
else
|
||||
fprintf(hosts, "%s\t%s\n",ip,host);
|
||||
}
|
||||
fclose(file);
|
||||
fclose(hosts);
|
||||
|
||||
/* TCP wrappers stuff. */
|
||||
if (!(file = fopen("/etc/hosts.deny", "w")))
|
||||
{
|
||||
errorbox(ctr[TR_UNABLE_TO_WRITE_ETC_HOSTS_DENY]);
|
||||
return 0;
|
||||
}
|
||||
fprintf(file, "ALL : ALL\n");
|
||||
fclose(file);
|
||||
|
||||
if (!(file = fopen("/etc/hosts.allow", "w")))
|
||||
{
|
||||
errorbox(ctr[TR_UNABLE_TO_WRITE_ETC_HOSTS_ALLOW]);
|
||||
return 0;
|
||||
}
|
||||
fprintf(file, "sshd : ALL\n");
|
||||
fprintf(file, "ALL : localhost\n");
|
||||
fprintf(file, "ALL : %s/%s\n", netaddress, netmask);
|
||||
fclose(file);
|
||||
|
||||
sprintf(commandstring, "/bin/hostname %s.%s", hostname, domainname);
|
||||
if (mysystem(commandstring))
|
||||
{
|
||||
errorbox(ctr[TR_UNABLE_TO_SET_HOSTNAME]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
/* SmoothWall setup program.
|
||||
*
|
||||
* This program is distributed under the terms of the GNU General Public
|
||||
* Licence. See the file COPYING for details.
|
||||
*
|
||||
* (c) Lawrence Manning, 2001
|
||||
* Misc. stuff for the lib.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "setup.h"
|
||||
|
||||
extern FILE *flog;
|
||||
extern char *mylog;
|
||||
|
||||
extern char **ctr;
|
||||
|
||||
extern int automode;
|
||||
|
||||
/* This will rewrite /etc/hosts, /etc/hosts.*, and the apache ServerName file. */
|
||||
int writehostsfiles(void)
|
||||
{
|
||||
char address[STRING_SIZE] = "";
|
||||
char netaddress[STRING_SIZE] = "";
|
||||
char netmask[STRING_SIZE] = "";
|
||||
char message[1000];
|
||||
FILE *file, *hosts;
|
||||
struct keyvalue *kv;
|
||||
char hostname[STRING_SIZE];
|
||||
char domainname[STRING_SIZE] = "";
|
||||
char commandstring[STRING_SIZE];
|
||||
char buffer[STRING_SIZE];
|
||||
|
||||
kv = initkeyvalues();
|
||||
if (!(readkeyvalues(kv, CONFIG_ROOT "/ethernet/settings")))
|
||||
{
|
||||
freekeyvalues(kv);
|
||||
errorbox(ctr[TR_UNABLE_TO_OPEN_SETTINGS_FILE]);
|
||||
return 0;
|
||||
}
|
||||
findkey(kv, "GREEN_ADDRESS", address);
|
||||
findkey(kv, "GREEN_NETADDRESS", netaddress);
|
||||
findkey(kv, "GREEN_NETMASK", netmask);
|
||||
freekeyvalues(kv);
|
||||
|
||||
kv = initkeyvalues();
|
||||
if (!(readkeyvalues(kv, CONFIG_ROOT "/main/settings")))
|
||||
{
|
||||
freekeyvalues(kv);
|
||||
errorbox(ctr[TR_UNABLE_TO_OPEN_SETTINGS_FILE]);
|
||||
return 0;
|
||||
}
|
||||
strcpy(hostname, SNAME );
|
||||
findkey(kv, "HOSTNAME", hostname);
|
||||
findkey(kv, "DOMAINNAME", domainname);
|
||||
freekeyvalues(kv);
|
||||
|
||||
if (!(file = fopen(CONFIG_ROOT "/main/hostname.conf", "w")))
|
||||
{
|
||||
sprintf (message, ctr[TR_UNABLE_TO_WRITE_VAR_SMOOTHWALL_MAIN_HOSTNAMECONF], CONFIG_ROOT);
|
||||
errorbox(message);
|
||||
return 0;
|
||||
}
|
||||
fprintf(file, "ServerName %s.%s\n", hostname,domainname);
|
||||
fclose(file);
|
||||
|
||||
if (!(file = fopen(CONFIG_ROOT "/main/hosts", "r")))
|
||||
{
|
||||
errorbox(ctr[TR_UNABLE_TO_OPEN_HOSTS_FILE]);
|
||||
return 0;
|
||||
}
|
||||
if (!(hosts = fopen("/etc/hosts", "w")))
|
||||
{
|
||||
errorbox(ctr[TR_UNABLE_TO_WRITE_ETC_HOSTS]);
|
||||
return 0;
|
||||
}
|
||||
fprintf(hosts, "127.0.0.1\tlocalhost\n");
|
||||
if (strlen(domainname))
|
||||
fprintf(hosts, "%s\t%s.%s\t%s\n",address,hostname,domainname,hostname);
|
||||
else
|
||||
fprintf(hosts, "%s\t%s\n",address,hostname);
|
||||
while (fgets(buffer, STRING_SIZE, file))
|
||||
{
|
||||
char *token, *ip, *host, *domain;
|
||||
|
||||
buffer[strlen(buffer) - 1] = 0;
|
||||
|
||||
token = strtok(buffer, ",");
|
||||
|
||||
ip = strtok(NULL, ",");
|
||||
host = strtok(NULL, ",");
|
||||
domain = strtok(NULL, ",");
|
||||
|
||||
if (!(ip && host))
|
||||
break;
|
||||
|
||||
if (strlen(ip) < 7 || strlen(ip) > 15
|
||||
|| strspn(ip, "0123456789.") != strlen(ip))
|
||||
break;
|
||||
|
||||
if (strspn(host, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-") != strlen(host))
|
||||
break;
|
||||
|
||||
if (domain)
|
||||
fprintf(hosts, "%s\t%s.%s\t%s\n",ip,host,domain,host);
|
||||
else
|
||||
fprintf(hosts, "%s\t%s\n",ip,host);
|
||||
}
|
||||
fclose(file);
|
||||
fclose(hosts);
|
||||
|
||||
/* TCP wrappers stuff. */
|
||||
if (!(file = fopen("/etc/hosts.deny", "w")))
|
||||
{
|
||||
errorbox(ctr[TR_UNABLE_TO_WRITE_ETC_HOSTS_DENY]);
|
||||
return 0;
|
||||
}
|
||||
fprintf(file, "ALL : ALL\n");
|
||||
fclose(file);
|
||||
|
||||
if (!(file = fopen("/etc/hosts.allow", "w")))
|
||||
{
|
||||
errorbox(ctr[TR_UNABLE_TO_WRITE_ETC_HOSTS_ALLOW]);
|
||||
return 0;
|
||||
}
|
||||
fprintf(file, "sshd : ALL\n");
|
||||
fprintf(file, "ALL : localhost\n");
|
||||
fprintf(file, "ALL : %s/%s\n", netaddress, netmask);
|
||||
fclose(file);
|
||||
|
||||
sprintf(commandstring, "/bin/hostname %s.%s", hostname, domainname);
|
||||
if (mysystem(commandstring))
|
||||
{
|
||||
errorbox(ctr[TR_UNABLE_TO_SET_HOSTNAME]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int handleisdn(void)
|
||||
{
|
||||
char command[STRING_SIZE];
|
||||
sprintf(command, "/etc/rc.d/init.d/mISDN config");
|
||||
if (!runcommandwithstatus(command, ctr[TR_PROBING_ISDN]))
|
||||
errorbox(ctr[TR_ERROR_PROBING_ISDN]);
|
||||
// Need to write some lines that count the cards and say the names...
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ int handleadminpassword(void);
|
||||
|
||||
/* misc.c */
|
||||
int writehostsfiles(void);
|
||||
int handleisdn(void);
|
||||
|
||||
/* keymap.c */
|
||||
int handlekeymap(void);
|
||||
|
||||
892
src/patches/grub-0.97-disk_geometry-1.patch
Normal file
892
src/patches/grub-0.97-disk_geometry-1.patch
Normal file
@@ -0,0 +1,892 @@
|
||||
Submitted By: Jim Gifford <jim@linuxfromscratch.org>
|
||||
Date: 05-28-2006
|
||||
Initial Package Version: 0.97
|
||||
Upstream Status: Unknown
|
||||
Origin: Fedora and Mandriva
|
||||
Description: This patch fixes issues with disk geometry not being
|
||||
detected properly. Part of this patch also fixes
|
||||
gcc 4 compile errors, which are a part of the issue.
|
||||
|
||||
diff -Naur grub-0.97.orig/configure grub-0.97/configure
|
||||
--- grub-0.97.orig/configure 2005-05-07 19:48:12.000000000 -0700
|
||||
+++ grub-0.97/configure 2006-05-28 20:29:36.025466751 -0700
|
||||
@@ -3485,9 +3485,9 @@
|
||||
echo "$as_me:$LINENO: result: $size_flag" >&5
|
||||
echo "${ECHO_T}$size_flag" >&6
|
||||
if test "x$size_flag" = xyes; then
|
||||
- STAGE2_CFLAGS="-Os"
|
||||
+ STAGE2_CFLAGS="-Os -fno-strict-aliasing"
|
||||
else
|
||||
- STAGE2_CFLAGS="-O2 -fno-strength-reduce -fno-unroll-loops"
|
||||
+ STAGE2_CFLAGS="-O2 -fno-strict-aliasing -fno-strength-reduce -fno-unroll-loops"
|
||||
fi
|
||||
# OpenBSD has a GCC extension for protecting applications from
|
||||
# stack smashing attacks, but GRUB doesn't want this feature.
|
||||
diff -Naur grub-0.97.orig/configure.ac grub-0.97/configure.ac
|
||||
--- grub-0.97.orig/configure.ac 2005-05-07 19:36:03.000000000 -0700
|
||||
+++ grub-0.97/configure.ac 2006-05-28 20:28:41.538819726 -0700
|
||||
@@ -93,9 +93,9 @@
|
||||
CFLAGS=$saved_CFLAGS
|
||||
])
|
||||
if test "x$size_flag" = xyes; then
|
||||
- STAGE2_CFLAGS="-Os"
|
||||
+ STAGE2_CFLAGS="-Os -fno-strict-aliasing"
|
||||
else
|
||||
- STAGE2_CFLAGS="-O2 -fno-strength-reduce -fno-unroll-loops"
|
||||
+ STAGE2_CFLAGS="-O2 -fno-strict-aliasing -fno-strength-reduce -fno-unroll-loops"
|
||||
fi
|
||||
# OpenBSD has a GCC extension for protecting applications from
|
||||
# stack smashing attacks, but GRUB doesn't want this feature.
|
||||
diff -Naur grub-0.97.orig/lib/device.c grub-0.97/lib/device.c
|
||||
--- grub-0.97.orig/lib/device.c 2005-03-27 15:14:25.000000000 -0800
|
||||
+++ grub-0.97/lib/device.c 2006-05-28 20:34:03.546804777 -0700
|
||||
@@ -131,6 +131,152 @@
|
||||
#include <shared.h>
|
||||
#include <device.h>
|
||||
|
||||
+#if defined(__linux__)
|
||||
+/* The 2.6 kernel has removed all of the geometry handling for IDE drives
|
||||
+ * that did fixups for LBA, etc. This means that the geometry we get
|
||||
+ * with the ioctl has a good chance of being wrong. So, we get to
|
||||
+ * also know about partition tables and try to read what the geometry
|
||||
+ * is there. *grumble* Very closely based on code from cfdisk
|
||||
+ */
|
||||
+static void get_kernel_geometry(int fd, long long *cyl, int *heads, int *sectors) {
|
||||
+ struct hd_geometry hdg;
|
||||
+
|
||||
+ if (ioctl (fd, HDIO_GETGEO, &hdg))
|
||||
+ return;
|
||||
+
|
||||
+ *cyl = hdg.cylinders;
|
||||
+ *heads = hdg.heads;
|
||||
+ *sectors = hdg.sectors;
|
||||
+}
|
||||
+
|
||||
+struct partition {
|
||||
+ unsigned char boot_ind; /* 0x80 - active */
|
||||
+ unsigned char head; /* starting head */
|
||||
+ unsigned char sector; /* starting sector */
|
||||
+ unsigned char cyl; /* starting cylinder */
|
||||
+ unsigned char sys_ind; /* What partition type */
|
||||
+ unsigned char end_head; /* end head */
|
||||
+ unsigned char end_sector; /* end sector */
|
||||
+ unsigned char end_cyl; /* end cylinder */
|
||||
+ unsigned char start4[4]; /* starting sector counting from 0 */
|
||||
+ unsigned char size4[4]; /* nr of sectors in partition */
|
||||
+};
|
||||
+
|
||||
+#define ALIGNMENT 2
|
||||
+typedef union {
|
||||
+ struct {
|
||||
+ unsigned char align[ALIGNMENT];
|
||||
+ unsigned char b[SECTOR_SIZE];
|
||||
+ } c;
|
||||
+ struct {
|
||||
+ unsigned char align[ALIGNMENT];
|
||||
+ unsigned char buffer[0x1BE];
|
||||
+ struct partition part[4];
|
||||
+ unsigned char magicflag[2];
|
||||
+ } p;
|
||||
+} partition_table;
|
||||
+
|
||||
+#define PART_TABLE_FLAG0 0x55
|
||||
+#define PART_TABLE_FLAG1 0xAA
|
||||
+
|
||||
+static void
|
||||
+get_partition_table_geometry(partition_table *bufp, long long *cyl, int *heads,
|
||||
+ int *sectors) {
|
||||
+ struct partition *p;
|
||||
+ int i,h,s,hh,ss;
|
||||
+ int first = 1;
|
||||
+ int bad = 0;
|
||||
+
|
||||
+ if (bufp->p.magicflag[0] != PART_TABLE_FLAG0 ||
|
||||
+ bufp->p.magicflag[1] != PART_TABLE_FLAG1) {
|
||||
+ /* Matthew Wilcox: slightly friendlier version of
|
||||
+ fatal(_("Bad signature on partition table"), 3);
|
||||
+ */
|
||||
+ fprintf(stderr, "Unknown partition table signature\n");
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ hh = ss = 0;
|
||||
+ for (i=0; i<4; i++) {
|
||||
+ p = &(bufp->p.part[i]);
|
||||
+ if (p->sys_ind != 0) {
|
||||
+ h = p->end_head + 1;
|
||||
+ s = (p->end_sector & 077);
|
||||
+ if (first) {
|
||||
+ hh = h;
|
||||
+ ss = s;
|
||||
+ first = 0;
|
||||
+ } else if (hh != h || ss != s)
|
||||
+ bad = 1;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (!first && !bad) {
|
||||
+ *heads = hh;
|
||||
+ *sectors = ss;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static long long my_lseek (unsigned int fd, long long offset,
|
||||
+ unsigned int origin)
|
||||
+{
|
||||
+#if defined(__linux__) && (!defined(__GLIBC__) || \
|
||||
+ ((__GLIBC__ < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ < 1))))
|
||||
+ /* Maybe libc doesn't have large file support. */
|
||||
+ loff_t offset, result;
|
||||
+ static int _llseek (uint filedes, ulong hi, ulong lo,
|
||||
+ loff_t *res, uint wh);
|
||||
+ _syscall5 (int, _llseek, uint, filedes, ulong, hi, ulong, lo,
|
||||
+ loff_t *, res, uint, wh);
|
||||
+
|
||||
+ if (_llseek (fd, offset >> 32, offset & 0xffffffff, &result, SEEK_SET) < 0)
|
||||
+ return (long long) -1;
|
||||
+ return result;
|
||||
+#else
|
||||
+ return lseek(fd, offset, SEEK_SET);
|
||||
+#endif
|
||||
+}
|
||||
+
|
||||
+static void get_linux_geometry (int fd, struct geometry *geom) {
|
||||
+ long long kern_cyl = 0; int kern_head = 0, kern_sectors = 0;
|
||||
+ long long pt_cyl = 0; int pt_head = 0, pt_sectors = 0;
|
||||
+ partition_table bufp;
|
||||
+ char *buff, *buf_unaligned;
|
||||
+
|
||||
+ buf_unaligned = malloc(sizeof(partition_table) + 4095);
|
||||
+ buff = (char *) (((unsigned long)buf_unaligned + 4096 - 1) &
|
||||
+ (~(4096-1)));
|
||||
+
|
||||
+ get_kernel_geometry(fd, &kern_cyl, &kern_head, &kern_sectors);
|
||||
+
|
||||
+ if (my_lseek (fd, 0*SECTOR_SIZE, SEEK_SET) < 0) {
|
||||
+ fprintf(stderr, "Unable to seek");
|
||||
+ }
|
||||
+
|
||||
+ if (read(fd, buff, SECTOR_SIZE) == SECTOR_SIZE) {
|
||||
+ memcpy(bufp.c.b, buff, SECTOR_SIZE);
|
||||
+ get_partition_table_geometry(&bufp, &pt_cyl, &pt_head, &pt_sectors);
|
||||
+ } else {
|
||||
+ fprintf(stderr, "Unable to read partition table: %s\n", strerror(errno));
|
||||
+ }
|
||||
+
|
||||
+ if (pt_head && pt_sectors) {
|
||||
+ int cyl_size;
|
||||
+
|
||||
+ geom->heads = pt_head;
|
||||
+ geom->sectors = pt_sectors;
|
||||
+ cyl_size = pt_head * pt_sectors;
|
||||
+ geom->cylinders = geom->total_sectors/cyl_size;
|
||||
+ } else {
|
||||
+ geom->heads = kern_head;
|
||||
+ geom->sectors = kern_sectors;
|
||||
+ geom->cylinders = kern_cyl;
|
||||
+ }
|
||||
+
|
||||
+ return;
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
/* Get the geometry of a drive DRIVE. */
|
||||
void
|
||||
get_drive_geometry (struct geometry *geom, char **map, int drive)
|
||||
@@ -151,21 +297,16 @@
|
||||
#if defined(__linux__)
|
||||
/* Linux */
|
||||
{
|
||||
- struct hd_geometry hdg;
|
||||
unsigned long nr;
|
||||
-
|
||||
- if (ioctl (fd, HDIO_GETGEO, &hdg))
|
||||
- goto fail;
|
||||
|
||||
if (ioctl (fd, BLKGETSIZE, &nr))
|
||||
goto fail;
|
||||
|
||||
/* Got the geometry, so save it. */
|
||||
- geom->cylinders = hdg.cylinders;
|
||||
- geom->heads = hdg.heads;
|
||||
- geom->sectors = hdg.sectors;
|
||||
geom->total_sectors = nr;
|
||||
-
|
||||
+ get_linux_geometry(fd, geom);
|
||||
+ if (!geom->heads && !geom->cylinders && !geom->sectors)
|
||||
+ goto fail;
|
||||
goto success;
|
||||
}
|
||||
|
||||
@@ -844,6 +985,7 @@
|
||||
{
|
||||
char dev[PATH_MAX]; /* XXX */
|
||||
int fd;
|
||||
+ off_t offset = (off_t) sector * (off_t) SECTOR_SIZE;
|
||||
|
||||
if ((partition & 0x00FF00) != 0x00FF00)
|
||||
{
|
||||
@@ -870,35 +1012,13 @@
|
||||
errnum = ERR_NO_PART;
|
||||
return 0;
|
||||
}
|
||||
-
|
||||
-#if defined(__linux__) && (!defined(__GLIBC__) || \
|
||||
- ((__GLIBC__ < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ < 1))))
|
||||
- /* Maybe libc doesn't have large file support. */
|
||||
- {
|
||||
- loff_t offset, result;
|
||||
- static int _llseek (uint filedes, ulong hi, ulong lo,
|
||||
- loff_t *res, uint wh);
|
||||
- _syscall5 (int, _llseek, uint, filedes, ulong, hi, ulong, lo,
|
||||
- loff_t *, res, uint, wh);
|
||||
|
||||
- offset = (loff_t) sector * (loff_t) SECTOR_SIZE;
|
||||
- if (_llseek (fd, offset >> 32, offset & 0xffffffff, &result, SEEK_SET))
|
||||
- {
|
||||
- errnum = ERR_DEV_VALUES;
|
||||
- return 0;
|
||||
- }
|
||||
- }
|
||||
-#else
|
||||
- {
|
||||
- off_t offset = (off_t) sector * (off_t) SECTOR_SIZE;
|
||||
|
||||
- if (lseek (fd, offset, SEEK_SET) != offset)
|
||||
- {
|
||||
- errnum = ERR_DEV_VALUES;
|
||||
- return 0;
|
||||
- }
|
||||
- }
|
||||
-#endif
|
||||
+ if (my_lseek(fd, offset, SEEK_SET) != offset)
|
||||
+ {
|
||||
+ errnum = ERR_DEV_VALUES;
|
||||
+ return 0;
|
||||
+ }
|
||||
|
||||
if (write (fd, buf, size * SECTOR_SIZE) != (size * SECTOR_SIZE))
|
||||
{
|
||||
diff -Naur grub-0.97.orig/stage2/Makefile.am grub-0.97/stage2/Makefile.am
|
||||
--- grub-0.97.orig/stage2/Makefile.am 2005-02-02 12:37:35.000000000 -0800
|
||||
+++ grub-0.97/stage2/Makefile.am 2006-05-28 20:28:41.590818435 -0700
|
||||
@@ -24,7 +24,8 @@
|
||||
-DGRUB_UTIL=1 -DFSYS_EXT2FS=1 -DFSYS_FAT=1 -DFSYS_FFS=1 \
|
||||
-DFSYS_ISO9660=1 -DFSYS_JFS=1 -DFSYS_MINIX=1 -DFSYS_REISERFS=1 \
|
||||
-DFSYS_UFS2=1 -DFSYS_VSTAFS=1 -DFSYS_XFS=1 \
|
||||
- -DUSE_MD5_PASSWORDS=1 -DSUPPORT_SERIAL=1 -DSUPPORT_HERCULES=1
|
||||
+ -DUSE_MD5_PASSWORDS=1 -DSUPPORT_SERIAL=1 -DSUPPORT_HERCULES=1 \
|
||||
+ -fno-strict-aliasing
|
||||
|
||||
# Stage 2 and Stage 1.5's.
|
||||
pkglibdir = $(libdir)/$(PACKAGE)/$(host_cpu)-$(host_vendor)
|
||||
diff -Naur grub-0.97.orig/stage2/boot.c grub-0.97/stage2/boot.c
|
||||
--- grub-0.97.orig/stage2/boot.c 2004-03-30 03:44:08.000000000 -0800
|
||||
+++ grub-0.97/stage2/boot.c 2006-05-28 20:33:30.123638792 -0700
|
||||
@@ -55,7 +55,7 @@
|
||||
pu;
|
||||
/* presuming that MULTIBOOT_SEARCH is large enough to encompass an
|
||||
executable header */
|
||||
- unsigned char buffer[MULTIBOOT_SEARCH];
|
||||
+ char buffer[MULTIBOOT_SEARCH];
|
||||
|
||||
/* sets the header pointer to point to the beginning of the
|
||||
buffer by default */
|
||||
@@ -98,7 +98,7 @@
|
||||
/* ELF loading supported if multiboot, FreeBSD and NetBSD. */
|
||||
if ((type == KERNEL_TYPE_MULTIBOOT
|
||||
|| pu.elf->e_ident[EI_OSABI] == ELFOSABI_FREEBSD
|
||||
- || grub_strcmp (pu.elf->e_ident + EI_BRAND, "FreeBSD") == 0
|
||||
+ || grub_strcmp ((char *) pu.elf->e_ident + EI_BRAND, "FreeBSD") == 0
|
||||
|| suggested_type == KERNEL_TYPE_NETBSD)
|
||||
&& len > sizeof (Elf32_Ehdr)
|
||||
&& BOOTABLE_I386_ELF ((*((Elf32_Ehdr *) buffer))))
|
||||
@@ -824,8 +824,12 @@
|
||||
moveto = (mbi.mem_upper + 0x400) << 10;
|
||||
|
||||
moveto = (moveto - len) & 0xfffff000;
|
||||
+#if 0
|
||||
max_addr = (lh->header == LINUX_MAGIC_SIGNATURE && lh->version >= 0x0203
|
||||
? lh->initrd_addr_max : LINUX_INITRD_MAX_ADDRESS);
|
||||
+#else
|
||||
+ max_addr = LINUX_INITRD_MAX_ADDRESS;
|
||||
+#endif
|
||||
if (moveto + len >= max_addr)
|
||||
moveto = (max_addr - len) & 0xfffff000;
|
||||
|
||||
diff -Naur grub-0.97.orig/stage2/disk_io.c grub-0.97/stage2/disk_io.c
|
||||
--- grub-0.97.orig/stage2/disk_io.c 2004-05-23 09:35:24.000000000 -0700
|
||||
+++ grub-0.97/stage2/disk_io.c 2006-05-28 20:28:41.582818634 -0700
|
||||
@@ -127,12 +127,19 @@
|
||||
int filepos;
|
||||
int filemax;
|
||||
|
||||
-static inline unsigned long
|
||||
-log2 (unsigned long word)
|
||||
+#define log2(n) ffz(~(n))
|
||||
+
|
||||
+/* include/asm-i386/bitops.h */
|
||||
+/*
|
||||
+ * ffz = Find First Zero in word. Undefined if no zero exists,
|
||||
+ * so code should check against ~0UL first..
|
||||
+ */
|
||||
+static __inline__ unsigned long
|
||||
+ffz (unsigned long word)
|
||||
{
|
||||
- asm volatile ("bsfl %1,%0"
|
||||
- : "=r" (word)
|
||||
- : "r" (word));
|
||||
+ __asm__ ("bsfl %1,%0"
|
||||
+: "=r" (word)
|
||||
+: "r" (~word));
|
||||
return word;
|
||||
}
|
||||
|
||||
diff -Naur grub-0.97.orig/stage2/freebsd.h grub-0.97/stage2/freebsd.h
|
||||
--- grub-0.97.orig/stage2/freebsd.h 2003-07-09 04:45:52.000000000 -0700
|
||||
+++ grub-0.97/stage2/freebsd.h 2006-05-28 20:28:41.582818634 -0700
|
||||
@@ -78,7 +78,7 @@
|
||||
struct bootinfo
|
||||
{
|
||||
unsigned int bi_version;
|
||||
- unsigned char *bi_kernelname;
|
||||
+ char *bi_kernelname;
|
||||
struct nfs_diskless *bi_nfs_diskless;
|
||||
/* End of fields that are always present. */
|
||||
#define bi_endcommon bi_n_bios_used
|
||||
diff -Naur grub-0.97.orig/stage2/fsys_fat.c grub-0.97/stage2/fsys_fat.c
|
||||
--- grub-0.97.orig/stage2/fsys_fat.c 2005-03-15 08:52:00.000000000 -0800
|
||||
+++ grub-0.97/stage2/fsys_fat.c 2006-05-28 20:28:41.582818634 -0700
|
||||
@@ -54,12 +54,19 @@
|
||||
|
||||
#define FAT_CACHE_SIZE 2048
|
||||
|
||||
+#define log2(n) ffz(~(n))
|
||||
+
|
||||
+/* include/asm-i386/bitops.h */
|
||||
+/*
|
||||
+ * ffz = Find First Zero in word. Undefined if no zero exists,
|
||||
+ * so code should check against ~0UL first..
|
||||
+ */
|
||||
static __inline__ unsigned long
|
||||
-log2 (unsigned long word)
|
||||
+ffz (unsigned long word)
|
||||
{
|
||||
__asm__ ("bsfl %1,%0"
|
||||
- : "=r" (word)
|
||||
- : "r" (word));
|
||||
+: "=r" (word)
|
||||
+: "r" (~word));
|
||||
return word;
|
||||
}
|
||||
|
||||
diff -Naur grub-0.97.orig/stage2/fsys_iso9660.c grub-0.97/stage2/fsys_iso9660.c
|
||||
--- grub-0.97.orig/stage2/fsys_iso9660.c 2004-05-11 05:11:19.000000000 -0700
|
||||
+++ grub-0.97/stage2/fsys_iso9660.c 2006-05-28 20:28:41.582818634 -0700
|
||||
@@ -55,13 +55,19 @@
|
||||
#define RRCONT_BUF ((unsigned char *)(FSYS_BUF + 6144))
|
||||
#define NAME_BUF ((unsigned char *)(FSYS_BUF + 8192))
|
||||
|
||||
+#define log2(n) ffz(~(n))
|
||||
|
||||
-static inline unsigned long
|
||||
-log2 (unsigned long word)
|
||||
+/* include/asm-i386/bitops.h */
|
||||
+/*
|
||||
+ * ffz = Find First Zero in word. Undefined if no zero exists,
|
||||
+ * so code should check against ~0UL first..
|
||||
+ */
|
||||
+static __inline__ unsigned long
|
||||
+ffz (unsigned long word)
|
||||
{
|
||||
- asm volatile ("bsfl %1,%0"
|
||||
- : "=r" (word)
|
||||
- : "r" (word));
|
||||
+ __asm__ ("bsfl %1,%0"
|
||||
+: "=r" (word)
|
||||
+: "r" (~word));
|
||||
return word;
|
||||
}
|
||||
|
||||
@@ -120,7 +126,7 @@
|
||||
break;
|
||||
/* check ISO_VD_PRIMARY and ISO_STANDARD_ID */
|
||||
if (PRIMDESC->type.l == ISO_VD_PRIMARY
|
||||
- && !memcmp(PRIMDESC->id, ISO_STANDARD_ID, sizeof(PRIMDESC->id)))
|
||||
+ && !memcmp((char *) PRIMDESC->id, ISO_STANDARD_ID, sizeof(PRIMDESC->id)))
|
||||
{
|
||||
ISO_SUPER->vol_sector = sector;
|
||||
INODE->file_start = 0;
|
||||
@@ -175,7 +181,7 @@
|
||||
for (; idr->length.l > 0;
|
||||
idr = (struct iso_directory_record *)((char *)idr + idr->length.l) )
|
||||
{
|
||||
- const char *name = idr->name;
|
||||
+ const u_int8_t *name = idr->name;
|
||||
unsigned int name_len = idr->name_len.l;
|
||||
|
||||
file_type = (idr->flags.l & 2) ? ISO_DIRECTORY : ISO_REGULAR;
|
||||
@@ -198,7 +204,7 @@
|
||||
rr_len = (idr->length.l - idr->name_len.l
|
||||
- sizeof(struct iso_directory_record)
|
||||
+ sizeof(idr->name));
|
||||
- rr_ptr.ptr = ((unsigned char *)idr + idr->name_len.l
|
||||
+ rr_ptr.ptr = ((char *)idr + idr->name_len.l
|
||||
+ sizeof(struct iso_directory_record)
|
||||
- sizeof(idr->name));
|
||||
if (rr_ptr.i & 1)
|
||||
@@ -331,9 +337,9 @@
|
||||
memcpy(NAME_BUF, name, name_len);
|
||||
name = NAME_BUF;
|
||||
}
|
||||
- rr_ptr.ptr = RRCONT_BUF + ce_ptr->u.ce.offset.l;
|
||||
+ rr_ptr.ptr = (char *) RRCONT_BUF + ce_ptr->u.ce.offset.l;
|
||||
rr_len = ce_ptr->u.ce.size.l;
|
||||
- if (!iso9660_devread(ce_ptr->u.ce.extent.l, 0, ISO_SECTOR_SIZE, RRCONT_BUF))
|
||||
+ if (!iso9660_devread(ce_ptr->u.ce.extent.l, 0, ISO_SECTOR_SIZE, (char *) RRCONT_BUF))
|
||||
{
|
||||
errnum = 0; /* this is not fatal. */
|
||||
break;
|
||||
@@ -344,7 +350,7 @@
|
||||
|
||||
filemax = MAXINT;
|
||||
if (name_len >= pathlen
|
||||
- && !memcmp(name, dirname, pathlen))
|
||||
+ && !memcmp((char *) name, dirname, pathlen))
|
||||
{
|
||||
if (dirname[pathlen] == '/' || !print_possibilities)
|
||||
{
|
||||
@@ -381,7 +387,7 @@
|
||||
print_possibilities = -print_possibilities;
|
||||
memcpy(NAME_BUF, name, name_len);
|
||||
NAME_BUF[name_len] = '\0';
|
||||
- print_a_completion (NAME_BUF);
|
||||
+ print_a_completion ((char *) NAME_BUF);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
diff -Naur grub-0.97.orig/stage2/fsys_reiserfs.c grub-0.97/stage2/fsys_reiserfs.c
|
||||
--- grub-0.97.orig/stage2/fsys_reiserfs.c 2004-02-18 14:09:10.000000000 -0800
|
||||
+++ grub-0.97/stage2/fsys_reiserfs.c 2006-05-28 20:28:41.586818535 -0700
|
||||
@@ -365,13 +365,19 @@
|
||||
#define JOURNAL_START ((__u32 *) (INFO + 1))
|
||||
#define JOURNAL_END ((__u32 *) (FSYS_BUF + FSYS_BUFLEN))
|
||||
|
||||
+#define log2(n) ffz(~(n))
|
||||
|
||||
+/* include/asm-i386/bitops.h */
|
||||
+/*
|
||||
+ * ffz = Find First Zero in word. Undefined if no zero exists,
|
||||
+ * so code should check against ~0UL first..
|
||||
+ */
|
||||
static __inline__ unsigned long
|
||||
-log2 (unsigned long word)
|
||||
+ffz (unsigned long word)
|
||||
{
|
||||
__asm__ ("bsfl %1,%0"
|
||||
- : "=r" (word)
|
||||
- : "r" (word));
|
||||
+: "=r" (word)
|
||||
+: "r" (~word));
|
||||
return word;
|
||||
}
|
||||
|
||||
diff -Naur grub-0.97.orig/stage2/fsys_vstafs.c grub-0.97/stage2/fsys_vstafs.c
|
||||
--- grub-0.97.orig/stage2/fsys_vstafs.c 2003-07-09 04:45:53.000000000 -0700
|
||||
+++ grub-0.97/stage2/fsys_vstafs.c 2006-05-28 20:28:41.586818535 -0700
|
||||
@@ -186,35 +186,35 @@
|
||||
int
|
||||
vstafs_read (char *addr, int len)
|
||||
{
|
||||
- struct alloc *a;
|
||||
+ struct alloc *b;
|
||||
int size, ret = 0, offset, curr_len = 0;
|
||||
- int curr_ext;
|
||||
+ int curr_exten;
|
||||
char extent;
|
||||
int ext_size;
|
||||
char *curr_pos;
|
||||
|
||||
get_file_info (f_sector);
|
||||
size = FILE_INFO->len-VSTAFS_START_DATA;
|
||||
- a = FILE_INFO->blocks;
|
||||
+ b = FILE_INFO->blocks;
|
||||
|
||||
if (filepos > 0)
|
||||
{
|
||||
- if (filepos < a[0].a_len * 512 - VSTAFS_START_DATA)
|
||||
+ if (filepos < b[0].a_len * 512 - VSTAFS_START_DATA)
|
||||
{
|
||||
offset = filepos + VSTAFS_START_DATA;
|
||||
extent = 0;
|
||||
- curr_len = a[0].a_len * 512 - offset - filepos;
|
||||
+ curr_len = b[0].a_len * 512 - offset - filepos;
|
||||
}
|
||||
else
|
||||
{
|
||||
- ext_size = a[0].a_len * 512 - VSTAFS_START_DATA;
|
||||
+ ext_size = b[0].a_len * 512 - VSTAFS_START_DATA;
|
||||
offset = filepos - ext_size;
|
||||
extent = 1;
|
||||
do
|
||||
{
|
||||
curr_len -= ext_size;
|
||||
offset -= ext_size;
|
||||
- ext_size = a[extent+1].a_len * 512;
|
||||
+ ext_size = b[extent+1].a_len * 512;
|
||||
}
|
||||
while (extent < FILE_INFO->extents && offset>ext_size);
|
||||
}
|
||||
@@ -223,16 +223,16 @@
|
||||
{
|
||||
offset = VSTAFS_START_DATA;
|
||||
extent = 0;
|
||||
- curr_len = a[0].a_len * 512 - offset;
|
||||
+ curr_len = b[0].a_len * 512 - offset;
|
||||
}
|
||||
|
||||
curr_pos = addr;
|
||||
if (curr_len > len)
|
||||
curr_len = len;
|
||||
|
||||
- for (curr_ext=extent;
|
||||
- curr_ext < FILE_INFO->extents;
|
||||
- curr_len = a[curr_ext].a_len * 512, curr_pos += curr_len, curr_ext++)
|
||||
+ for (curr_exten = extent;
|
||||
+ curr_exten < FILE_INFO->extents;
|
||||
+ curr_len = b[curr_exten].a_len * 512, curr_pos += curr_len, curr_exten++)
|
||||
{
|
||||
ret += curr_len;
|
||||
size -= curr_len;
|
||||
@@ -242,7 +242,7 @@
|
||||
curr_len += size;
|
||||
}
|
||||
|
||||
- devread (a[curr_ext].a_start,offset, curr_len, curr_pos);
|
||||
+ devread (b[curr_exten].a_start, offset, curr_len, curr_pos);
|
||||
offset = 0;
|
||||
}
|
||||
|
||||
diff -Naur grub-0.97.orig/stage2/fsys_xfs.c grub-0.97/stage2/fsys_xfs.c
|
||||
--- grub-0.97.orig/stage2/fsys_xfs.c 2005-05-07 19:15:55.000000000 -0700
|
||||
+++ grub-0.97/stage2/fsys_xfs.c 2006-05-28 20:28:41.586818535 -0700
|
||||
@@ -97,7 +97,7 @@
|
||||
return ino & XFS_INO_MASK(XFS_INO_OFFSET_BITS);
|
||||
}
|
||||
|
||||
-static inline __const__ xfs_uint16_t
|
||||
+static inline __attribute__((const)) xfs_uint16_t
|
||||
le16 (xfs_uint16_t x)
|
||||
{
|
||||
__asm__("xchgb %b0,%h0" \
|
||||
@@ -106,7 +106,7 @@
|
||||
return x;
|
||||
}
|
||||
|
||||
-static inline __const__ xfs_uint32_t
|
||||
+static inline __attribute__((const)) xfs_uint32_t
|
||||
le32 (xfs_uint32_t x)
|
||||
{
|
||||
#if 0
|
||||
@@ -122,7 +122,7 @@
|
||||
return x;
|
||||
}
|
||||
|
||||
-static inline __const__ xfs_uint64_t
|
||||
+static inline __attribute__((const)) xfs_uint64_t
|
||||
le64 (xfs_uint64_t x)
|
||||
{
|
||||
xfs_uint32_t h = x >> 32;
|
||||
@@ -368,7 +368,7 @@
|
||||
default:
|
||||
namelen = sfe->namelen;
|
||||
*ino = sf_ino ((char *)sfe, namelen);
|
||||
- name = sfe->name;
|
||||
+ name = (char *) sfe->name;
|
||||
sfe = (xfs_dir2_sf_entry_t *)
|
||||
((char *)sfe + namelen + 11 - xfs.i8param);
|
||||
}
|
||||
diff -Naur grub-0.97.orig/stage2/gunzip.c grub-0.97/stage2/gunzip.c
|
||||
--- grub-0.97.orig/stage2/gunzip.c 2003-07-09 04:45:53.000000000 -0700
|
||||
+++ grub-0.97/stage2/gunzip.c 2006-05-28 20:28:41.586818535 -0700
|
||||
@@ -277,7 +277,7 @@
|
||||
* is a compressed file, and simply mark it as such.
|
||||
*/
|
||||
if (no_decompression
|
||||
- || grub_read (buf, 10) != 10
|
||||
+ || grub_read ((char *) buf, 10) != 10
|
||||
|| ((*((unsigned short *) buf) != GZIP_HDR_LE)
|
||||
&& (*((unsigned short *) buf) != OLD_GZIP_HDR_LE)))
|
||||
{
|
||||
@@ -293,7 +293,7 @@
|
||||
if (buf[2] != DEFLATED
|
||||
|| (buf[3] & UNSUPP_FLAGS)
|
||||
|| ((buf[3] & EXTRA_FIELD)
|
||||
- && (grub_read (buf, 2) != 2
|
||||
+ && (grub_read ((char *) buf, 2) != 2
|
||||
|| bad_field (*((unsigned short *) buf))))
|
||||
|| ((buf[3] & ORIG_NAME) && bad_field (-1))
|
||||
|| ((buf[3] & COMMENT) && bad_field (-1)))
|
||||
@@ -308,7 +308,7 @@
|
||||
|
||||
filepos = filemax - 8;
|
||||
|
||||
- if (grub_read (buf, 8) != 8)
|
||||
+ if (grub_read ((char *) buf, 8) != 8)
|
||||
{
|
||||
if (! errnum)
|
||||
errnum = ERR_BAD_GZIP_HEADER;
|
||||
@@ -485,8 +485,8 @@
|
||||
|
||||
#define INBUFSIZ 0x2000
|
||||
|
||||
-static uch inbuf[INBUFSIZ];
|
||||
-static int bufloc;
|
||||
+static unsigned char inbuf[INBUFSIZ];
|
||||
+static int bufloc;
|
||||
|
||||
static int
|
||||
get_byte (void)
|
||||
@@ -494,7 +494,7 @@
|
||||
if (filepos == gzip_data_offset || bufloc == INBUFSIZ)
|
||||
{
|
||||
bufloc = 0;
|
||||
- grub_read (inbuf, INBUFSIZ);
|
||||
+ grub_read ((char *) inbuf, INBUFSIZ);
|
||||
}
|
||||
|
||||
return inbuf[bufloc++];
|
||||
@@ -925,7 +925,7 @@
|
||||
unsigned m; /* mask for bit lengths table */
|
||||
unsigned n; /* number of lengths to get */
|
||||
unsigned nb; /* number of bit length codes */
|
||||
- unsigned nl; /* number of literal/length codes */
|
||||
+ unsigned nc; /* number of literal/length codes */
|
||||
unsigned nd; /* number of distance codes */
|
||||
unsigned ll[286 + 30]; /* literal/length and distance code lengths */
|
||||
register ulg b; /* bit buffer */
|
||||
@@ -937,7 +937,7 @@
|
||||
|
||||
/* read in table lengths */
|
||||
NEEDBITS (5);
|
||||
- nl = 257 + ((unsigned) b & 0x1f); /* number of literal/length codes */
|
||||
+ nc = 257 + ((unsigned) b & 0x1f); /* number of literal/length codes */
|
||||
DUMPBITS (5);
|
||||
NEEDBITS (5);
|
||||
nd = 1 + ((unsigned) b & 0x1f); /* number of distance codes */
|
||||
@@ -945,7 +945,7 @@
|
||||
NEEDBITS (4);
|
||||
nb = 4 + ((unsigned) b & 0xf); /* number of bit length codes */
|
||||
DUMPBITS (4);
|
||||
- if (nl > 286 || nd > 30)
|
||||
+ if (nc > 286 || nd > 30)
|
||||
{
|
||||
errnum = ERR_BAD_GZIP_DATA;
|
||||
return;
|
||||
@@ -970,7 +970,7 @@
|
||||
}
|
||||
|
||||
/* read in literal and distance code lengths */
|
||||
- n = nl + nd;
|
||||
+ n = nc + nd;
|
||||
m = mask_bits[bl];
|
||||
i = l = 0;
|
||||
while ((unsigned) i < n)
|
||||
@@ -1034,7 +1034,7 @@
|
||||
|
||||
/* build the decoding tables for literal/length and distance codes */
|
||||
bl = lbits;
|
||||
- if ((i = huft_build (ll, nl, 257, cplens, cplext, &tl, &bl)) != 0)
|
||||
+ if ((i = huft_build (ll, nc, 257, cplens, cplext, &tl, &bl)) != 0)
|
||||
{
|
||||
#if 0
|
||||
if (i == 1)
|
||||
@@ -1045,7 +1045,7 @@
|
||||
return;
|
||||
}
|
||||
bd = dbits;
|
||||
- if ((i = huft_build (ll + nl, nd, 0, cpdist, cpdext, &td, &bd)) != 0)
|
||||
+ if ((i = huft_build (ll + nc, nd, 0, cpdist, cpdext, &td, &bd)) != 0)
|
||||
{
|
||||
#if 0
|
||||
if (i == 1)
|
||||
diff -Naur grub-0.97.orig/stage2/md5.c grub-0.97/stage2/md5.c
|
||||
--- grub-0.97.orig/stage2/md5.c 2003-07-09 04:45:53.000000000 -0700
|
||||
+++ grub-0.97/stage2/md5.c 2006-05-28 20:28:41.590818435 -0700
|
||||
@@ -166,7 +166,7 @@
|
||||
inputlen -= 64 - buflen;
|
||||
while (inputlen >= 64)
|
||||
{
|
||||
- md5_transform (input);
|
||||
+ md5_transform ((unsigned char *) input);
|
||||
input += 64;
|
||||
inputlen -= 64;
|
||||
}
|
||||
@@ -211,7 +211,7 @@
|
||||
char *p;
|
||||
int saltlen;
|
||||
int i, n;
|
||||
- unsigned char alt_result[16];
|
||||
+ char alt_result[16];
|
||||
unsigned char *digest;
|
||||
|
||||
if (check)
|
||||
diff -Naur grub-0.97.orig/stage2/start_eltorito.S grub-0.97/stage2/start_eltorito.S
|
||||
--- grub-0.97.orig/stage2/start_eltorito.S 2004-03-27 08:14:20.000000000 -0800
|
||||
+++ grub-0.97/stage2/start_eltorito.S 2006-05-28 20:31:17.770936712 -0700
|
||||
@@ -40,9 +40,9 @@
|
||||
#define ABS(x) (x-_start+BOOTSEC_LOCATION)
|
||||
|
||||
#ifdef STAGE1_5
|
||||
-# define STAGE_ADDR 0x2000
|
||||
+# define STAGE_ADDR 0x2200
|
||||
#else
|
||||
-# define STAGE_ADDR 0x8000
|
||||
+# define STAGE_ADDR 0x8200
|
||||
#endif /* STAGE1_5 */
|
||||
|
||||
/* Print message string */
|
||||
@@ -71,12 +71,14 @@
|
||||
. = _start + 8 /* Pad to file offset 8 */
|
||||
|
||||
/* This table gets filled in by mkisofs using the
|
||||
- -boot-info-table option */
|
||||
-bi_pvd: .long 0xDEADBEEF /* LBA of primary volume descript */
|
||||
-bi_file: .long 0xDEADBEEF /* LBA of boot file */
|
||||
-bi_length: .long 0xDEADBEEF /* Length of boot file */
|
||||
-bi_csum: .long 0xDEADBEEF /* Checksum of boot file */
|
||||
-bi_reserved: .space (10*4) /* Reserved */
|
||||
+ -boot-info-table option If not, the values in this
|
||||
+ table are default values that we can use to get us
|
||||
+ what we need, at least under a certain set of assumptions. */
|
||||
+bi_pvd: .long 16 /* LBA of primary volume descript */
|
||||
+bi_file: .long 0 /* LBA of boot file */
|
||||
+bi_length: .long 0xDEADBEEF /* Length of boot file */
|
||||
+bi_csum: .long 0xDEADBEEF /* Checksum of boot file */
|
||||
+bi_reserved: .space (10*4) /* Reserved */
|
||||
|
||||
real_start:
|
||||
xor %ax, %ax
|
||||
@@ -92,10 +94,28 @@
|
||||
/* save drive reference first thing! */
|
||||
mov %dl, ABS(BootDrive)
|
||||
|
||||
- /* print a notification message on the screen */
|
||||
- MSG(notification_string)
|
||||
+ /* check if machine support IBM/MS int 13h extensions */
|
||||
+ mov $0x41, %ah
|
||||
+ mov $0x55AA, %bx
|
||||
+ int $0x13
|
||||
+ jnc load_image
|
||||
+
|
||||
+ /* bios doesn't support int 13h extensions, print error messages */
|
||||
+ MSG(int13_error_string1)
|
||||
+ MSG(notification_done)
|
||||
+ MSG(int13_error_string2)
|
||||
+ MSG(notification_done)
|
||||
+ MSG(int13_error_string3)
|
||||
+ MSG(notification_done)
|
||||
+ /* even when bios says that it doesn't support int 13h
|
||||
+ extensions, do not stop here and try to load image anyway,
|
||||
+ because some bioses says that there isn't support for
|
||||
+ extended functions but have the needed extended read function
|
||||
+ (int 13h, function AH=42h) */
|
||||
|
||||
load_image:
|
||||
+ /* print a notification message on the screen */
|
||||
+ MSG(notification_string)
|
||||
/* Set up boot file sector, size, load address */
|
||||
mov ABS(bi_length), %eax
|
||||
add $(ISO_SECTOR_SIZE-1), %eax
|
||||
@@ -105,6 +125,8 @@
|
||||
mov %bx, %es
|
||||
xor %bx, %bx
|
||||
mov ABS(bi_file), %eax
|
||||
+ inc %eax /* do not reload the first sector (this code) */
|
||||
+ dec %bp /* this way we have more room for code in stage1 */
|
||||
call getlinsec
|
||||
mov %ds, %ax
|
||||
mov %ax, %es
|
||||
@@ -115,7 +137,7 @@
|
||||
mov $ABS(firstlist - BOOTSEC_LISTSIZE), %si
|
||||
mov (%si), %ebp
|
||||
mov ABS(BootDrive), %dl /* this makes sure %dl is our "boot" drive */
|
||||
- ljmp $0, $(STAGE_ADDR+SECTOR_SIZE) /* jump to main() in asm.S */
|
||||
+ ljmp $0, $(STAGE_ADDR) /* jump to main() in asm.S */
|
||||
|
||||
/* go here when you need to stop the machine hard after an error condition */
|
||||
stop: jmp stop
|
||||
@@ -171,11 +193,11 @@
|
||||
*/
|
||||
xint13:
|
||||
movb $6, ABS(RetryCount)
|
||||
- pushal
|
||||
.try:
|
||||
+ pushal
|
||||
int $0x13
|
||||
jc 1f
|
||||
- add $(8*4), %sp /* Clean up stack */
|
||||
+ popal /* Clean up stack */
|
||||
ret
|
||||
1:
|
||||
mov %ah, %dl /* Save error code */
|
||||
@@ -276,6 +298,10 @@
|
||||
|
||||
read_error_string: .string "Read error 0x"
|
||||
|
||||
+int13_error_string1: .string "Support for IBM/MS INT 13h extensions not found"
|
||||
+int13_error_string2: .string "GRUB cannot be loaded if int 13h/function AH=42h isn't present"
|
||||
+int13_error_string3: .string "Trying to load stage 2 anyway..."
|
||||
+
|
||||
/*
|
||||
* EBIOS disk address packet
|
||||
*/
|
||||
@@ -306,7 +332,8 @@
|
||||
.word 0
|
||||
.word 0
|
||||
|
||||
- . = _start + SECTOR_SIZE - BOOTSEC_LISTSIZE
|
||||
+ /* size of the code we can place between main body and fixed top location */
|
||||
+ . = _start + 1536 - BOOTSEC_LISTSIZE
|
||||
|
||||
/* fill the first data listing with the default */
|
||||
blocklist_default_start:/* this is the sector start parameter, in logical
|
||||
@@ -321,6 +348,12 @@
|
||||
#endif
|
||||
blocklist_default_seg: /* this is the segment of the starting address
|
||||
to load the data into */
|
||||
- .word (STAGE_ADDR + SECTOR_SIZE) >> 4
|
||||
+ .word (STAGE_ADDR) >> 4
|
||||
|
||||
firstlist: /* this label has to be after the list data!!! */
|
||||
+
|
||||
+ /* this is a workaround to allow more code to be added in stage1,
|
||||
+ it allows more code to be added for this stage, but for this
|
||||
+ we can't reload the first sector. So we have to align the code
|
||||
+ to ISO_SECTOR_SIZE. */
|
||||
+ . = _start + ISO_SECTOR_SIZE
|
||||
diff -Naur grub-0.97.orig/util/grub-install.in grub-0.97/util/grub-install.in
|
||||
--- grub-0.97.orig/util/grub-install.in 2004-07-24 11:57:31.000000000 -0700
|
||||
+++ grub-0.97/util/grub-install.in 2006-05-28 20:30:31.484088268 -0700
|
||||
@@ -336,6 +336,10 @@
|
||||
# Create a safe temporary file.
|
||||
test -n "$mklog" && log_file=`$mklog`
|
||||
|
||||
+ # Before all invocations of the grub shell, call sync to make sure
|
||||
+ # the raw device is in sync with any bufferring in filesystems.
|
||||
+ sync
|
||||
+
|
||||
$grub_shell --batch $no_floppy --device-map=$device_map <<EOF >$log_file
|
||||
quit
|
||||
EOF
|
||||
@@ -450,6 +454,10 @@
|
||||
# Create a safe temporary file.
|
||||
test -n "$mklog" && log_file=`$mklog`
|
||||
|
||||
+# Before all invocations of the grub shell, call sync to make sure
|
||||
+# the raw device is in sync with any bufferring in filesystems.
|
||||
+sync
|
||||
+
|
||||
# Now perform the installation.
|
||||
$grub_shell --batch $no_floppy --device-map=$device_map <<EOF >$log_file
|
||||
root $root_drive
|
||||
@@ -1,994 +0,0 @@
|
||||
--- docs/grub.texi
|
||||
+++ docs/grub.texi
|
||||
@@ -2118,6 +2118,7 @@
|
||||
* default:: Set the default entry
|
||||
* fallback:: Set the fallback entry
|
||||
* hiddenmenu:: Hide the menu interface
|
||||
+* gfxmenu:: Use graphical menu interface
|
||||
* timeout:: Set the timeout
|
||||
* title:: Start a menu entry
|
||||
@end menu
|
||||
@@ -2150,6 +2151,15 @@
|
||||
@end deffn
|
||||
|
||||
|
||||
+@node gfxmenu
|
||||
+@subsection gfxmenu
|
||||
+
|
||||
+@deffn Command gfxmenu file
|
||||
+Use the graphical menu interface. The graphics data are taken from
|
||||
+@var{file} and must be created using 'mkbootmsg' from the gfxboot package.
|
||||
+@end deffn
|
||||
+
|
||||
+
|
||||
@node hiddenmenu
|
||||
@subsection hiddenmenu
|
||||
|
||||
--- grub/asmstub.c
|
||||
+++ grub/asmstub.c
|
||||
@@ -498,6 +498,32 @@
|
||||
return 0;
|
||||
}
|
||||
|
||||
+/* graphical menu functions . */
|
||||
+int
|
||||
+gfx_init (gfx_data_t *gfx_data)
|
||||
+{
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+int
|
||||
+gfx_done (gfx_data_t *gfx_data)
|
||||
+{
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+int
|
||||
+gfx_input (gfx_data_t *gfx_data, int *menu_entry)
|
||||
+{
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+int
|
||||
+gfx_setup_menu (gfx_data_t *gfx_data)
|
||||
+{
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+
|
||||
/* low-level timing info */
|
||||
int
|
||||
getrtsecs (void)
|
||||
--- stage2/asm.S
|
||||
+++ stage2/asm.S
|
||||
@@ -1614,6 +1614,286 @@
|
||||
popl %ebp
|
||||
ret
|
||||
|
||||
+
|
||||
+/*
|
||||
+ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
+ *
|
||||
+ * graphical menu functions
|
||||
+ *
|
||||
+ */
|
||||
+
|
||||
+/*
|
||||
+ * int gfx_init (gfx_data_t *gfx_data)
|
||||
+ *
|
||||
+ * init gfx things
|
||||
+ *
|
||||
+ * return vales:
|
||||
+ * 0: ok
|
||||
+ * 1: failed
|
||||
+ * sets gfx_data->ok
|
||||
+ */
|
||||
+
|
||||
+ENTRY(gfx_init)
|
||||
+ pushl %ebp
|
||||
+ movl %esp, %ebp
|
||||
+
|
||||
+ pushl %edi
|
||||
+ pushl %esi
|
||||
+ pushl %ebx
|
||||
+
|
||||
+ movl 8(%ebp),%edx
|
||||
+ movl %edx,%edi
|
||||
+ leal gfx_ofs_sys_cfg(%edx),%esi
|
||||
+ andl $0xf,%edi
|
||||
+ shrl $4,%edx
|
||||
+
|
||||
+ pushl %ebp
|
||||
+
|
||||
+ call EXT_C(prot_to_real)
|
||||
+ .code16
|
||||
+
|
||||
+ pushw %ds
|
||||
+ movw %dx,%ds
|
||||
+
|
||||
+ lcall *gfx_ofs_jmp_table + 4 * 0 (%di)
|
||||
+
|
||||
+ sbbl %ebx,%ebx
|
||||
+ negl %ebx
|
||||
+
|
||||
+ popw %ds
|
||||
+
|
||||
+ DATA32 call EXT_C(real_to_prot)
|
||||
+ .code32
|
||||
+
|
||||
+ popl %ebp
|
||||
+
|
||||
+ movl %ebx,%eax
|
||||
+ xorl $1,%ebx
|
||||
+ movl 8(%ebp),%edx
|
||||
+ movl %ebx,gfx_ofs_ok(%edx)
|
||||
+
|
||||
+ popl %ebx
|
||||
+ popl %esi
|
||||
+ popl %edi
|
||||
+
|
||||
+ popl %ebp
|
||||
+ ret
|
||||
+
|
||||
+
|
||||
+/*
|
||||
+ * int gfx_done (gfx_data_t *gfx_data)
|
||||
+ *
|
||||
+ * shut down gfx things
|
||||
+ *
|
||||
+ * return vales:
|
||||
+ * always 0
|
||||
+ * sets gfx_data->ok
|
||||
+ */
|
||||
+
|
||||
+ENTRY(gfx_done)
|
||||
+ pushl %ebp
|
||||
+ movl %esp, %ebp
|
||||
+
|
||||
+ pushl %edi
|
||||
+ pushl %esi
|
||||
+ pushl %ebx
|
||||
+
|
||||
+ movl 8(%ebp),%edx
|
||||
+ movl %edx,%ebx
|
||||
+ andl $0xf,%ebx
|
||||
+ shrl $4,%edx
|
||||
+
|
||||
+ pushl %ebp
|
||||
+
|
||||
+ call EXT_C(prot_to_real)
|
||||
+ .code16
|
||||
+
|
||||
+ pushw %ds
|
||||
+
|
||||
+ movw %dx,%ds
|
||||
+
|
||||
+ lcall *gfx_ofs_jmp_table + 4 * 1 (%bx)
|
||||
+
|
||||
+ popw %ds
|
||||
+
|
||||
+ DATA32 call EXT_C(real_to_prot)
|
||||
+ .code32
|
||||
+
|
||||
+ popl %ebp
|
||||
+
|
||||
+ xorl %eax,%eax
|
||||
+ movl 8(%ebp),%edx
|
||||
+ movl %eax,gfx_ofs_ok(%edx)
|
||||
+
|
||||
+ popl %ebx
|
||||
+ popl %esi
|
||||
+ popl %edi
|
||||
+
|
||||
+ popl %ebp
|
||||
+ ret
|
||||
+
|
||||
+
|
||||
+/*
|
||||
+ * int gfx_input (gfx_data_t *gfx_data, int *menu_entry)
|
||||
+ *
|
||||
+ * let user enter a command line
|
||||
+ *
|
||||
+ * uses gfx_data->cmdline as buffer
|
||||
+ *
|
||||
+ * return values:
|
||||
+ * 1: abort
|
||||
+ * 2: boot
|
||||
+ * menu_entry: selected entry
|
||||
+ */
|
||||
+
|
||||
+ENTRY(gfx_input)
|
||||
+ pushl %ebp
|
||||
+ movl %esp, %ebp
|
||||
+
|
||||
+ pushl %edi
|
||||
+ pushl %esi
|
||||
+ pushl %ebx
|
||||
+
|
||||
+ movl 8(%ebp),%edx
|
||||
+ movl %edx,%ebx
|
||||
+ leal gfx_ofs_sys_cfg(%edx),%esi
|
||||
+ andl $0xf,%ebx
|
||||
+ shrl $4,%edx
|
||||
+
|
||||
+ pushl %ebp
|
||||
+
|
||||
+ call EXT_C(prot_to_real)
|
||||
+ .code16
|
||||
+
|
||||
+ pushw %ds
|
||||
+
|
||||
+ movw %dx,%ds
|
||||
+
|
||||
+ movl gfx_ofs_cmdline(%bx),%edi
|
||||
+ movl gfx_ofs_cmdline_len(%bx),%ecx
|
||||
+ movl gfx_ofs_timeout(%bx),%eax
|
||||
+ imull $18,%eax
|
||||
+
|
||||
+ lcall *gfx_ofs_jmp_table + 4 * 2 (%bx)
|
||||
+
|
||||
+ movl %eax,%ecx
|
||||
+
|
||||
+ popw %ds
|
||||
+
|
||||
+ DATA32 call EXT_C(real_to_prot)
|
||||
+ .code32
|
||||
+
|
||||
+ popl %ebp
|
||||
+
|
||||
+ movl 12(%ebp),%edx
|
||||
+ movl %ebx,(%edx)
|
||||
+
|
||||
+ movl %ecx,%eax
|
||||
+
|
||||
+ popl %ebx
|
||||
+ popl %esi
|
||||
+ popl %edi
|
||||
+
|
||||
+ popl %ebp
|
||||
+ ret
|
||||
+
|
||||
+
|
||||
+/*
|
||||
+ * int gfx_setup_menu (gfx_data_t *gfx_data)
|
||||
+ *
|
||||
+ * draw boot menu
|
||||
+ *
|
||||
+ * return values:
|
||||
+ * always 0
|
||||
+ */
|
||||
+
|
||||
+/* menu entry descriptor */
|
||||
+#define menu_entries 0
|
||||
+#define menu_default 2 /* seg:ofs */
|
||||
+#define menu_ent_list 6 /* seg:ofs */
|
||||
+#define menu_ent_size 10
|
||||
+#define menu_arg_list 12 /* seg:ofs */
|
||||
+#define menu_arg_size 16
|
||||
+#define sizeof_menu_desc 18
|
||||
+
|
||||
+ENTRY(gfx_setup_menu)
|
||||
+ pushl %ebp
|
||||
+ movl %esp, %ebp
|
||||
+
|
||||
+ pushl %edi
|
||||
+ pushl %esi
|
||||
+ pushl %ebx
|
||||
+
|
||||
+ movl 8(%ebp),%edx
|
||||
+ movl %edx,%ebx
|
||||
+ andl $0xf,%ebx
|
||||
+ shrl $4,%edx
|
||||
+
|
||||
+ call EXT_C(prot_to_real)
|
||||
+ .code16
|
||||
+
|
||||
+ pushw %ds
|
||||
+
|
||||
+ movw %dx,%ds
|
||||
+ shll $4,%edx
|
||||
+
|
||||
+ subw $sizeof_menu_desc,%sp
|
||||
+ movw %esp,%ebp
|
||||
+
|
||||
+ movl gfx_ofs_menu_entries(%bx),%eax
|
||||
+ movw %ax,menu_entries(%bp)
|
||||
+
|
||||
+ movl gfx_ofs_menu_default_entry(%bx),%eax
|
||||
+ subl %edx,%eax
|
||||
+ movw %ax,menu_default(%bp)
|
||||
+ movw %ds,menu_default+2(%bp)
|
||||
+
|
||||
+ movl gfx_ofs_menu_list(%bx),%eax
|
||||
+ subl %edx,%eax
|
||||
+ movw %ax,menu_ent_list(%bp)
|
||||
+ movw %ds,menu_ent_list+2(%bp)
|
||||
+
|
||||
+ movl gfx_ofs_menu_entry_len(%bx),%eax
|
||||
+ movw %ax,menu_ent_size(%bp)
|
||||
+
|
||||
+ movl gfx_ofs_args_list(%bx),%eax
|
||||
+ subl %edx,%eax
|
||||
+ movw %ax,menu_arg_list(%bp)
|
||||
+ movw %ds,menu_arg_list+2(%bp)
|
||||
+
|
||||
+ movl gfx_ofs_args_entry_len(%bx),%eax
|
||||
+ movw %ax,menu_arg_size(%bp)
|
||||
+
|
||||
+ movl %ss,%esi
|
||||
+ shll $4,%esi
|
||||
+ addl %ebp,%esi
|
||||
+
|
||||
+ lcall %ds: *gfx_ofs_jmp_table + 4 * 3 (%bx)
|
||||
+
|
||||
+ addw $sizeof_menu_desc,%sp
|
||||
+
|
||||
+ popw %ds
|
||||
+
|
||||
+ DATA32 call EXT_C(real_to_prot)
|
||||
+ .code32
|
||||
+
|
||||
+ xorl %eax,%eax
|
||||
+
|
||||
+ popl %ebx
|
||||
+ popl %esi
|
||||
+ popl %edi
|
||||
+
|
||||
+ popl %ebp
|
||||
+ ret
|
||||
+
|
||||
+
|
||||
+/*
|
||||
+ *
|
||||
+ * end graphics stuff
|
||||
+ *
|
||||
+ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
+ */
|
||||
+
|
||||
|
||||
/*
|
||||
* gateA20(int linear)
|
||||
--- stage2/builtins.c
|
||||
+++ stage2/builtins.c
|
||||
@@ -63,6 +63,8 @@
|
||||
int fallback_entries[MAX_FALLBACK_ENTRIES];
|
||||
/* The number of current entry. */
|
||||
int current_entryno;
|
||||
+/* graphics file */
|
||||
+char graphics_file[64];
|
||||
/* The address for Multiboot command-line buffer. */
|
||||
static char *mb_cmdline;
|
||||
/* The password. */
|
||||
@@ -1351,6 +1353,26 @@
|
||||
};
|
||||
|
||||
|
||||
+/* graphics */
|
||||
+static int
|
||||
+gfxmenu_func (char *arg, int flags)
|
||||
+{
|
||||
+ memmove(graphics_file, arg, sizeof graphics_file - 1);
|
||||
+ graphics_file[sizeof graphics_file - 1] = 0;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static struct builtin builtin_gfxmenu =
|
||||
+{
|
||||
+ "gfxmenu",
|
||||
+ gfxmenu_func,
|
||||
+ BUILTIN_MENU | BUILTIN_HELP_LIST,
|
||||
+ "gfxmenu FILE",
|
||||
+ "Use the graphical menu from FILE."
|
||||
+};
|
||||
+
|
||||
+
|
||||
/* geometry */
|
||||
static int
|
||||
geometry_func (char *arg, int flags)
|
||||
@@ -4874,6 +4896,7 @@
|
||||
&builtin_find,
|
||||
&builtin_fstest,
|
||||
&builtin_geometry,
|
||||
+ &builtin_gfxmenu,
|
||||
&builtin_halt,
|
||||
&builtin_help,
|
||||
&builtin_hiddenmenu,
|
||||
--- stage2/shared.h
|
||||
+++ stage2/shared.h
|
||||
@@ -374,6 +374,22 @@
|
||||
#endif /* WITHOUT_LIBC_STUBS */
|
||||
|
||||
|
||||
+/* see typedef gfx_data_t below */
|
||||
+#define gfx_ofs_ok 0x00
|
||||
+#define gfx_ofs_code_seg 0x04
|
||||
+#define gfx_ofs_jmp_table 0x08
|
||||
+#define gfx_ofs_sys_cfg 0x38
|
||||
+#define gfx_ofs_cmdline 0x6c
|
||||
+#define gfx_ofs_cmdline_len 0x70
|
||||
+#define gfx_ofs_menu_list 0x74
|
||||
+#define gfx_ofs_menu_default_entry 0x78
|
||||
+#define gfx_ofs_menu_entries 0x7c
|
||||
+#define gfx_ofs_menu_entry_len 0x80
|
||||
+#define gfx_ofs_args_list 0x84
|
||||
+#define gfx_ofs_args_entry_len 0x88
|
||||
+#define gfx_ofs_timeout 0x8c
|
||||
+
|
||||
+
|
||||
#ifndef ASM_FILE
|
||||
/*
|
||||
* Below this should be ONLY defines and other constructs for C code.
|
||||
@@ -595,6 +611,38 @@
|
||||
extern int default_entry;
|
||||
extern int current_entryno;
|
||||
|
||||
+
|
||||
+/*
|
||||
+ * graphics menu stuff
|
||||
+ *
|
||||
+ * Note: gfx_data and all data referred to in it must lie within a 64k area.
|
||||
+ */
|
||||
+typedef struct {
|
||||
+ unsigned ok; /* set while we're in graphics mode */
|
||||
+ unsigned code_seg; /* code segment of binary graphics code */
|
||||
+ unsigned jmp_table[12]; /* link to graphics functions */
|
||||
+ unsigned char sys_cfg[52]; /* sys_cfg[0]: identifies boot loader (grub == 2) */
|
||||
+ char *cmdline; /* command line returned by gfx_input() */
|
||||
+ unsigned cmdline_len; /* length of the above */
|
||||
+ char *menu_list; /* list of menu entries, each of fixed length (menu_entry_len) */
|
||||
+ char *menu_default_entry; /* the default entry */
|
||||
+ unsigned menu_entries; /* number of entries in menu_list */
|
||||
+ unsigned menu_entry_len; /* one entry */
|
||||
+ char *args_list; /* same structure as menu_list, menu_entries entries */
|
||||
+ unsigned args_entry_len; /* one entry */
|
||||
+ unsigned timeout; /* in seconds (0: no timeout) */
|
||||
+} __attribute__ ((packed)) gfx_data_t;
|
||||
+
|
||||
+extern gfx_data_t *graphics_data;
|
||||
+
|
||||
+/* pointer to graphics image data */
|
||||
+extern char graphics_file[64];
|
||||
+
|
||||
+int gfx_init(gfx_data_t *gfx_data);
|
||||
+int gfx_done(gfx_data_t *gfx_data);
|
||||
+int gfx_input(gfx_data_t *gfx_data, int *menu_entry);
|
||||
+int gfx_setup_menu(gfx_data_t *gfx_data);
|
||||
+
|
||||
/* The constants for password types. */
|
||||
typedef enum
|
||||
{
|
||||
--- stage2/stage2.c
|
||||
+++ stage2/stage2.c
|
||||
@@ -22,6 +22,8 @@
|
||||
|
||||
grub_jmp_buf restart_env;
|
||||
|
||||
+gfx_data_t *graphics_data;
|
||||
+
|
||||
#if defined(PRESET_MENU_STRING) || defined(SUPPORT_DISKLESS)
|
||||
|
||||
# if defined(PRESET_MENU_STRING)
|
||||
@@ -310,6 +312,12 @@
|
||||
|
||||
if (! auth && password)
|
||||
{
|
||||
+ if (*graphics_file)
|
||||
+ {
|
||||
+ printf ("\
|
||||
+ WARNING: graphical menu doesn\'t work\
|
||||
+ in conjunction with the password feature\n" );
|
||||
+ }
|
||||
printf ("\
|
||||
Press enter to boot the selected OS or \'p\' to enter a\n\
|
||||
password to unlock the next set of features.");
|
||||
@@ -753,6 +761,493 @@
|
||||
}
|
||||
|
||||
|
||||
+
|
||||
+#if 0
|
||||
+/* for debugging */
|
||||
+static void hexdump(unsigned char *buf, unsigned len)
|
||||
+{
|
||||
+ int i, j = 0;
|
||||
+ char s[17];
|
||||
+ unsigned addr = (unsigned) buf;
|
||||
+
|
||||
+ s[16] = 0;
|
||||
+ while(len--) {
|
||||
+ i = buf[j];
|
||||
+ i = i & 0xff;
|
||||
+ s[j & 15] = (i >= 0x20 && i <= 0x7e) ? i : '.';
|
||||
+ if(!(j & 15)) {
|
||||
+ printf("%x ", j + addr);
|
||||
+ }
|
||||
+ if(!(j & 7) && (j & 15)) printf(" ");
|
||||
+ /* stupid grub_printf */
|
||||
+ printf("%x", (i >> 4) & 0x0f);
|
||||
+ printf("%x ", i & 0x0f);
|
||||
+ if(!(++j & 15)) {
|
||||
+ printf(" %s\n", s);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if(j & 15) {
|
||||
+ s[j & 15] = 0;
|
||||
+ if(!(j & 8)) printf(" ");
|
||||
+ i = 1 + 3 * (16 - (j & 15));
|
||||
+ while(i--) printf(" ");
|
||||
+ printf("%s\n", s);
|
||||
+ }
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
+
|
||||
+/* kernel + (grub-)module options */
|
||||
+#define GFX_CMD_BUF_SIZE 512
|
||||
+
|
||||
+/* command line separator char */
|
||||
+#define GFX_CMD_SEP 1
|
||||
+
|
||||
+/*
|
||||
+ * Go through config entry and find kernel args, if any.
|
||||
+ * Put things into buf and return it.
|
||||
+ */
|
||||
+static char *get_kernel_args(char *cfg, char *buf)
|
||||
+{
|
||||
+ int i, j;
|
||||
+ char *s, *t = "", *p, *t2;
|
||||
+
|
||||
+ *(p = buf) = 0;
|
||||
+
|
||||
+ for(j = 0; ; j++) {
|
||||
+ s = get_entry(cfg, j, 0);
|
||||
+ if(!*s) break;
|
||||
+ if(
|
||||
+ (!memcmp(s, "kernel", 6) || !memcmp(s, "module", 6)) &&
|
||||
+ (s[6] == ' ' || s[6] == '\t')
|
||||
+ ) {
|
||||
+ t = skip_to(0, s);
|
||||
+ t2 = s[0] == 'm' ? strstr(t, "initrd") : NULL;
|
||||
+ if(*t) t = skip_to(0, t);
|
||||
+ if(t2 && t2 < t) break; /* module is likely a normal initrd -> skip */
|
||||
+ i = strlen(t);
|
||||
+ if(p - buf + i > GFX_CMD_BUF_SIZE - 2) break;
|
||||
+ *p++ = GFX_CMD_SEP;
|
||||
+ strcpy(p, t);
|
||||
+ p += i;
|
||||
+
|
||||
+ continue;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if(*buf) buf++; /* skip initial separator char */
|
||||
+
|
||||
+ return buf;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+/*
|
||||
+ * Check header and return code start offset.
|
||||
+ */
|
||||
+static unsigned magic_ok(unsigned char *buf)
|
||||
+{
|
||||
+ if(
|
||||
+ *(unsigned *) buf == 0x0b2d97f00 && /* magic id */
|
||||
+ (buf[4] == 8) /* version 8 */
|
||||
+ ) {
|
||||
+ return *(unsigned *) (buf + 8);
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+/*
|
||||
+ * Search cpio archive for gfx file.
|
||||
+ */
|
||||
+static unsigned find_file(unsigned char *buf, unsigned len, unsigned *gfx_file_start, unsigned *file_len)
|
||||
+{
|
||||
+ unsigned i, fname_len, code_start = 0;
|
||||
+
|
||||
+ *gfx_file_start = 0;
|
||||
+
|
||||
+ for(i = 0; i < len;) {
|
||||
+ if((len - i) >= 0x1a && (buf[i] + (buf[i + 1] << 8)) == 0x71c7) {
|
||||
+ fname_len = *(unsigned short *) (buf + i + 20);
|
||||
+ *file_len = *(unsigned short *) (buf + i + 24) + (*(unsigned short *) (buf + i + 22) << 16);
|
||||
+ i += 26 + fname_len;
|
||||
+ i = ((i + 1) & ~1);
|
||||
+ if((code_start = magic_ok(buf + i))) {
|
||||
+ *gfx_file_start = i;
|
||||
+ return code_start;
|
||||
+ }
|
||||
+ i += *file_len;
|
||||
+ i = ((i + 1) & ~1);
|
||||
+ }
|
||||
+ else {
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return code_start;
|
||||
+}
|
||||
+
|
||||
+static inline unsigned char * stack_ptr(void)
|
||||
+{
|
||||
+ unsigned char * u;
|
||||
+
|
||||
+ asm("movl %%esp, %0" : "=r" (u));
|
||||
+
|
||||
+ return u;
|
||||
+}
|
||||
+
|
||||
+static void sleep(int delay)
|
||||
+{
|
||||
+ int tick, last_tick = currticks();
|
||||
+
|
||||
+ delay *= 18;
|
||||
+
|
||||
+ while(delay--) {
|
||||
+ while((tick = currticks()) == last_tick) { }
|
||||
+ last_tick = tick;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static void wait_for_key()
|
||||
+{
|
||||
+ printf("Press a key to continue...");
|
||||
+ getkey();
|
||||
+ printf("\r \r");
|
||||
+}
|
||||
+
|
||||
+
|
||||
+/*
|
||||
+ * Leave that much space on the heap. Everything else goes to the graphics
|
||||
+ * functions.
|
||||
+ *
|
||||
+ * 0x2000 is _not_ enough
|
||||
+ */
|
||||
+#define MIN_HEAP_SIZE 0x4000
|
||||
+#define MIN_GFX_FREE 0x1000
|
||||
+
|
||||
+#define SC_BOOTLOADER 0
|
||||
+#define SC_FAILSAFE 3
|
||||
+#define SC_SYSCONFIG_SIZE 4
|
||||
+#define SC_BOOTLOADER_SEG 8
|
||||
+#define SC_XMEM_0 24
|
||||
+#define SC_XMEM_1 26
|
||||
+#define SC_XMEM_2 28
|
||||
+#define SC_XMEM_3 30
|
||||
+#define SC_FILE 32
|
||||
+#define SC_ARCHIVE_START 36
|
||||
+#define SC_ARCHIVE_END 40
|
||||
+#define SC_MEM0_START 44
|
||||
+#define SC_MEM0_END 48
|
||||
+
|
||||
+/*
|
||||
+ * Does normally not return.
|
||||
+ */
|
||||
+static void
|
||||
+run_graphics_menu (char *menu_entries, char *config_entries, int num_entries,
|
||||
+ char *heap, int entryno)
|
||||
+{
|
||||
+ unsigned char *buf, *buf_ext;
|
||||
+ unsigned buf_size, buf_ext_size, code_start, file_start;
|
||||
+ char *s, *t, *t2, *cfg, *new_config, *p;
|
||||
+ char *saved_heap;
|
||||
+ int i, j, max_len, gfx_file_size, verbose;
|
||||
+ int selected_entry;
|
||||
+ gfx_data_t *gfx_data;
|
||||
+ char *cmd_buf;
|
||||
+ unsigned mem0_start, mem0_end, file_len;
|
||||
+
|
||||
+ /*
|
||||
+ * check gfx_data_t struct offsets for consistency; gcc will optimize away
|
||||
+ * the whole block
|
||||
+ */
|
||||
+
|
||||
+ /* dummy function to make ld fail */
|
||||
+ {
|
||||
+ extern void wrong_struct_size(void);
|
||||
+ #define gfx_ofs_check(a) if(gfx_ofs_##a != (char *) &gfx_data->a - (char *) gfx_data) wrong_struct_size();
|
||||
+ gfx_ofs_check(ok);
|
||||
+ gfx_ofs_check(code_seg);
|
||||
+ gfx_ofs_check(jmp_table);
|
||||
+ gfx_ofs_check(sys_cfg);
|
||||
+ gfx_ofs_check(cmdline);
|
||||
+ gfx_ofs_check(cmdline_len);
|
||||
+ gfx_ofs_check(menu_list);
|
||||
+ gfx_ofs_check(menu_default_entry);
|
||||
+ gfx_ofs_check(menu_entries);
|
||||
+ gfx_ofs_check(menu_entry_len);
|
||||
+ gfx_ofs_check(args_list);
|
||||
+ gfx_ofs_check(args_entry_len);
|
||||
+ gfx_ofs_check(timeout);
|
||||
+ #undef gfx_ofs_check
|
||||
+ }
|
||||
+
|
||||
+ if(!num_entries) return;
|
||||
+
|
||||
+ graphics_data = gfx_data = (gfx_data_t *) heap;
|
||||
+ heap += sizeof *gfx_data;
|
||||
+ memset(gfx_data, 0, sizeof *gfx_data);
|
||||
+
|
||||
+ gfx_data->sys_cfg[SC_BOOTLOADER] = 2; /* bootloader: grub */
|
||||
+ gfx_data->sys_cfg[SC_SYSCONFIG_SIZE] = 52; /* config data size */
|
||||
+ *(unsigned short *) (gfx_data->sys_cfg + SC_BOOTLOADER_SEG) = (unsigned) gfx_data >> 4; /* segment */
|
||||
+ gfx_data->sys_cfg[SC_XMEM_0] = 0x21; /* 1MB @ 2MB */
|
||||
+ gfx_data->sys_cfg[SC_XMEM_1] = 0x41; /* 1MB @ 4MB */
|
||||
+ verbose = (*(unsigned char *) 0x417) & 3 ? 1 : 0; /* SHIFT pressed */
|
||||
+ gfx_data->sys_cfg[SC_FAILSAFE] = verbose;
|
||||
+
|
||||
+ gfx_data->timeout = grub_timeout >= 0 ? grub_timeout : 0;
|
||||
+
|
||||
+
|
||||
+ /* setup command line edit buffer */
|
||||
+
|
||||
+ gfx_data->cmdline_len = 256;
|
||||
+
|
||||
+ gfx_data->cmdline = heap;
|
||||
+ heap += gfx_data->cmdline_len;
|
||||
+ memset(gfx_data->cmdline, 0, gfx_data->cmdline_len);
|
||||
+
|
||||
+ cmd_buf = heap;
|
||||
+ heap += GFX_CMD_BUF_SIZE;
|
||||
+
|
||||
+ /* setup menu entries */
|
||||
+
|
||||
+ for(i = max_len = 0; i < num_entries; i++) {
|
||||
+ j = strlen(get_entry(menu_entries, i, 0));
|
||||
+ if(j > max_len) max_len = j;
|
||||
+ }
|
||||
+
|
||||
+ if(!max_len) return;
|
||||
+
|
||||
+ gfx_data->menu_entry_len = max_len + 1;
|
||||
+ gfx_data->menu_entries = num_entries;
|
||||
+
|
||||
+ gfx_data->menu_list = heap;
|
||||
+ heap += gfx_data->menu_entry_len * gfx_data->menu_entries;
|
||||
+
|
||||
+ memset(gfx_data->menu_list, 0, gfx_data->menu_entry_len * gfx_data->menu_entries);
|
||||
+
|
||||
+ for(i = 0; i < (int) gfx_data->menu_entries; i++) {
|
||||
+ strcpy(gfx_data->menu_list + i * gfx_data->menu_entry_len, get_entry(menu_entries, i, 0));
|
||||
+ }
|
||||
+
|
||||
+ gfx_data->menu_default_entry = gfx_data->menu_list + entryno * gfx_data->menu_entry_len;
|
||||
+
|
||||
+
|
||||
+ /* setup list of kernel args */
|
||||
+
|
||||
+ for(i = max_len = 0; i < num_entries; i++) {
|
||||
+ s = get_kernel_args(get_entry(config_entries, i, 1), cmd_buf);
|
||||
+ j = strlen(s);
|
||||
+ if(j > max_len) max_len = j;
|
||||
+ }
|
||||
+
|
||||
+ gfx_data->args_entry_len = max_len + 1;
|
||||
+
|
||||
+ gfx_data->args_list = heap;
|
||||
+ heap += gfx_data->args_entry_len * gfx_data->menu_entries;
|
||||
+
|
||||
+ memset(gfx_data->args_list, 0, gfx_data->args_entry_len * gfx_data->menu_entries);
|
||||
+
|
||||
+ for(i = 0; i < (int) gfx_data->menu_entries; i++) {
|
||||
+ strcpy(gfx_data->args_list + i* gfx_data->args_entry_len, get_kernel_args(get_entry(config_entries, i, 1), cmd_buf));
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ /* go back here when we no longer need the graphics data */
|
||||
+ saved_heap = heap;
|
||||
+
|
||||
+
|
||||
+ /* get memory area to be used by graphics functions */
|
||||
+
|
||||
+ /* use 1MB starting at 2MB as file buffer */
|
||||
+ buf_ext = (unsigned char *) (2 << 20);
|
||||
+ buf_ext_size = 1 << 20;
|
||||
+
|
||||
+ /* must be 16-byte aligned */
|
||||
+ buf = (unsigned char *) (((unsigned) heap + 0xf) & ~0xf);
|
||||
+
|
||||
+ buf_size = stack_ptr() - buf - MIN_HEAP_SIZE;
|
||||
+ buf_size &= ~0xf;
|
||||
+
|
||||
+ mem0_start = (unsigned) buf;
|
||||
+ mem0_end = mem0_start + buf_size;
|
||||
+
|
||||
+ if(verbose) {
|
||||
+ printf("low memory 0x%x - 0x%x (%d bytes)\n", mem0_start, mem0_end, buf_size);
|
||||
+ wait_for_key();
|
||||
+ }
|
||||
+
|
||||
+ heap += buf_size;
|
||||
+
|
||||
+ /* read the file */
|
||||
+
|
||||
+ if(!grub_open(graphics_file)) {
|
||||
+ printf("%s: file not found\n", graphics_file);
|
||||
+ sleep(5);
|
||||
+ heap = saved_heap;
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ gfx_file_size = grub_read(buf_ext, buf_ext_size);
|
||||
+
|
||||
+ grub_close();
|
||||
+
|
||||
+ if(gfx_file_size <= 0) {
|
||||
+ printf("%s: read error\n", graphics_file);
|
||||
+ sleep(5);
|
||||
+ heap = saved_heap;
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if(verbose) {
|
||||
+ printf("%s: %d bytes (%d bytes left)\n", graphics_file, gfx_file_size, buf_ext_size - gfx_file_size);
|
||||
+ wait_for_key();
|
||||
+ }
|
||||
+
|
||||
+ /* locate file inside cpio archive */
|
||||
+ if(!(code_start = find_file(buf_ext, gfx_file_size, &file_start, &file_len))) {
|
||||
+ printf("%s: invalid file format\n", graphics_file);
|
||||
+ sleep(5);
|
||||
+ heap = saved_heap;
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if(verbose) {
|
||||
+ printf("init: start 0x%x, len %d; code offset 0x%x\n", file_start, file_len, code_start);
|
||||
+ wait_for_key();
|
||||
+ }
|
||||
+
|
||||
+ if(file_len - code_start + MIN_GFX_FREE > buf_size) {
|
||||
+ printf("not enough free memory: %d extra bytes need\n", file_len - code_start + MIN_GFX_FREE - buf_size);
|
||||
+ sleep(5);
|
||||
+ heap = saved_heap;
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ memcpy((void *) buf, (void *) (buf_ext + file_start + code_start), file_len - code_start);
|
||||
+
|
||||
+ mem0_start += file_len - code_start;
|
||||
+ mem0_start = (mem0_start + 3) & ~3; /* align */
|
||||
+
|
||||
+ /* init interface to graphics functions */
|
||||
+
|
||||
+ *(unsigned *) (gfx_data->sys_cfg + SC_FILE) = (unsigned) buf_ext + file_start;
|
||||
+ *(unsigned *) (gfx_data->sys_cfg + SC_ARCHIVE_START) = (unsigned) buf_ext;
|
||||
+ *(unsigned *) (gfx_data->sys_cfg + SC_ARCHIVE_END) = (unsigned) buf_ext + gfx_file_size;
|
||||
+ *(unsigned *) (gfx_data->sys_cfg + SC_MEM0_START) = mem0_start;
|
||||
+ *(unsigned *) (gfx_data->sys_cfg + SC_MEM0_END) = mem0_end;
|
||||
+
|
||||
+ gfx_data->code_seg = (unsigned) buf >> 4;
|
||||
+
|
||||
+ if(verbose) {
|
||||
+ printf("init 0x%x, archive 0x%x - 0x%x, low mem 0x%x - 0x%x\ncode seg 0x%x\n",
|
||||
+ (unsigned) buf_ext + file_start,
|
||||
+ (unsigned) buf_ext, (unsigned) buf_ext + gfx_file_size,
|
||||
+ mem0_start, mem0_end, gfx_data->code_seg
|
||||
+ );
|
||||
+ wait_for_key();
|
||||
+ }
|
||||
+
|
||||
+ for(i = 0; (unsigned) i < sizeof gfx_data->jmp_table / sizeof *gfx_data->jmp_table; i++) {
|
||||
+ gfx_data->jmp_table[i] = (gfx_data->code_seg << 16) + ((unsigned short *) buf)[i];
|
||||
+ }
|
||||
+
|
||||
+ if(verbose) {
|
||||
+ for(i = 0; i < 12; i++) {
|
||||
+ printf("%d: 0x%x\n", i, gfx_data->jmp_table[i]);
|
||||
+ }
|
||||
+
|
||||
+ for(i = 0; i < gfx_data->menu_entries; i++) {
|
||||
+ printf("\"%s\" -- \"%s\"\n",
|
||||
+ gfx_data->menu_list + i * gfx_data->menu_entry_len,
|
||||
+ gfx_data->args_list + i * gfx_data->args_entry_len
|
||||
+ );
|
||||
+ }
|
||||
+
|
||||
+ printf("default: \"%s\"\n", gfx_data->menu_default_entry);
|
||||
+ wait_for_key();
|
||||
+ }
|
||||
+
|
||||
+ /* switch to graphics mode */
|
||||
+
|
||||
+ if(gfx_init(gfx_data)) {
|
||||
+ printf("graphics initialization failed\n");
|
||||
+ sleep(5);
|
||||
+ heap = saved_heap;
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ gfx_setup_menu(gfx_data);
|
||||
+
|
||||
+ i = gfx_input(gfx_data, &selected_entry);
|
||||
+
|
||||
+ /* ESC -> show text menu */
|
||||
+ if(i == 1) {
|
||||
+ gfx_done(gfx_data);
|
||||
+ grub_timeout = -1;
|
||||
+
|
||||
+ heap = saved_heap;
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ gfx_done(gfx_data);
|
||||
+
|
||||
+ heap = saved_heap; /* free most of the graphics data */
|
||||
+
|
||||
+ // printf("cmdline: >%s<, entry = %d\n", gfx_data->cmdline, selected_entry);
|
||||
+
|
||||
+ if(selected_entry < 0 || selected_entry > num_entries) return;
|
||||
+
|
||||
+
|
||||
+ /* create new config with modified kernel option */
|
||||
+
|
||||
+ cfg = get_entry(config_entries, selected_entry, 1);
|
||||
+
|
||||
+ new_config = heap;
|
||||
+
|
||||
+ for(p = gfx_data->cmdline, i = 0; ; i++) {
|
||||
+ s = get_entry(cfg, i, 0);
|
||||
+ if(!*s) {
|
||||
+ if(!i) *heap++ = 0;
|
||||
+ *heap++ = 0;
|
||||
+ break;
|
||||
+ }
|
||||
+ /* note: must match get_kernel_args() */
|
||||
+ if(
|
||||
+ (!memcmp(s, "kernel", 6) || !memcmp(s, "module", 6)) &&
|
||||
+ (s[6] == ' ' || s[6] == '\t')
|
||||
+ ) {
|
||||
+ t = skip_to(0, s);
|
||||
+ t2 = s[0] == 'm' ? strstr(t, "initrd") : NULL;
|
||||
+ if(*t) t = skip_to(0, t);
|
||||
+ if(t2 && t2 < t) { /* module is likely a normal initrd -> skip */
|
||||
+ strcpy(heap, s);
|
||||
+ heap += strlen(s) + 1;
|
||||
+ continue;
|
||||
+ }
|
||||
+ memmove(heap, s, t - s);
|
||||
+ heap += t - s;
|
||||
+ *heap++ = ' ';
|
||||
+ while(*p && *p != GFX_CMD_SEP) *heap++ = *p++;
|
||||
+ *heap++ = 0;
|
||||
+ if(*p == GFX_CMD_SEP) p++;
|
||||
+ }
|
||||
+ else {
|
||||
+ strcpy(heap, s);
|
||||
+ heap += strlen(s) + 1;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ *heap++ = 0;
|
||||
+
|
||||
+ // hexdump(new_config, heap - new_config);
|
||||
+ // getkey();
|
||||
+
|
||||
+ run_script(new_config, heap);
|
||||
+}
|
||||
+
|
||||
+
|
||||
static int
|
||||
get_line_from_config (char *cmdline, int maxlen, int read_from_file)
|
||||
{
|
||||
@@ -1062,9 +1557,12 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
- /* Run menu interface. */
|
||||
- run_menu (menu_entries, config_entries, num_entries,
|
||||
- menu_entries + menu_len, default_entry);
|
||||
+ if (*graphics_file && !password && show_menu && grub_timeout)
|
||||
+ {
|
||||
+ run_graphics_menu(menu_entries, config_entries, num_entries,menu_entries + menu_len, default_entry);
|
||||
+ }
|
||||
+ /* Run menu interface. */
|
||||
+ run_menu (menu_entries, config_entries, num_entries, menu_entries + menu_len, default_entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user