It is currently Thu Apr 24, 2014 12:12 pm

All times are UTC - 8 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Enhanced config.c32 (econfig.c32) and whichsys.c32
PostPosted: Tue Mar 31, 2009 6:38 am 
Offline

Joined: Fri Jan 11, 2008 2:52 pm
Posts: 1278
I have written (together with Erwan Velu, developer of the Hardware Detection Tool) an enhanced config.c32 (econfig.c32) module for syslinux/isolinux.

It can load a different config file, depending if a menu entry is booted from isolinux or syslinux.

My post on the syslinux mailing list (Changed a bit, (renamed config.c32 to econfig.c32)):
Code:
For UBCD, we have a lot of config files.

Isolinux will load /boot/isolinux/isolinux.cfg, which will load /ubcd/menus/isolinux/main.cfg
Syslinux will load /boot/syslinux/syslinux.cfg, which will load /ubcd/menus/syslinux/main.cfg

The /ubcd/menus/syslinux/main.cfg loads several other config files when you select the appropriate menu.
From all those menus you can go back to  /ubcd/menus/syslinux/main.cfg.

The  /ubcd/menus/syslinux/main.cfg needs to be different for isolinux and syslinux:
- 'localboot -1' doesn't work with syslinux
- The contents for the config files for booting certain linux distro's differ when you run them from CD (isolinux)
  or from USB/HDD (syslinux)

To make this work, I did need to put the specific main.cfg (adapted for isolinux and syslinux in respectively,
/boot/isolinux or /boot/syslinux, but this is quite ugly because all other config files are in /ubcd/menus/syslinux/
(19 config files).


With a lot of help of Erwan Velu, I have now a com32 module that loads a config file depending on the running
syslinux variant. It is based on the config.c32 module.

  Usage: econfig.c32 <filename>
         econfig.c32 ext=<filename> iso=<filename> pxe=<filename> sys=<filename>


It supports the current style of loading a new config file:

  econfig.c32 another.cfg


And it support the "bootloader variant dependend" loading of a config:

  econfig.c32 iso=file1.cfg sys=file2.cfg

  This will load file1.cfg file, when this command is run from isolinux.
  It will load file2.cfg, when run from syslinux.


Now I can use it in UBCD a different config file for the "main.cfg" file (/ubcd/menus/mainiso.cfg or /ubcd/menus/mainsys.cfg):

/boot/isolinux/isolinux.cfg:
==================================
DEFAULT main

LABEL main
COM32 /boot/syslinux/menu.c32
APPEND /ubcd/menus/isolinux/main.cfg
==================================

/boot/syslinux/syslinux.cfg:
==================================
DEFAULT main

LABEL main
COM32 /boot/syslinux/menu.c32
APPEND /ubcd/menus/syslinux/main.cfg
==================================


In a entry (e.g..: in '/boot/menus/syslinux/bios.cfg') that does need to go back to the 'main.cfg' file
(/ubcd/menus/mainiso.cfg or /ubcd/menus/mainsys.cfg), I can use now:

========================================================================
LABEL -
MENU LABEL ..
COM32 /boot/syslinux/config.c32
APPEND iso=/ubcd/menus/isolinux/main.cfg sys=/ubcd/menus/syslinux/main.cfg
========================================================================


Gert Hulselmans




Probably it won't be that useful for other people, but just in case someone else needs this functionality:

/* ----------------------------------------------------------------------- *
*
*   Copyright 2009 H. Peter Anvin - All Rights Reserved
*
*   This program is free software; you can redistribute it and/or modify
*   it under the terms of the GNU General Public License as published by
*   the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
*   Boston MA 02110-1301, USA; either version 2 of the License, or
*   (at your option) any later version; incorporated herein by reference.
*
* ----------------------------------------------------------------------- */

/*
* econfig.c
*
* Loads a new configuration file
*
* Usage: econfig.c32 <filename>
*        econfig.c32 ext=<filename> iso=<filename> pxe=<filename> sys=<filename>
*
* Examples:
*
* - The following will load the config file 'another.cfg':
*
*     econfig.c32 another.cfg
*
* - The following will load 'file1.cfg' when you run it from isolinux,
*   and it will load 'file2.cfg' when you run it from syslinux.
*
*     econfig.c32 iso=file1.cfg sys=file2.cfg
*
*/

#include <stdio.h>
#include <console.h>
#include <string.h>
#include <stdbool.h>
#include <syslinux/boot.h>
#include "syslinux/config.h"

char bootlinux[255];
char extlinux[255];
char isolinux[255];
char pxelinux[255];
char syslinux[255];
bool extlinux_param;
bool isolinux_param;
bool pxelinux_param;
bool syslinux_param;
const struct syslinux_version *sv;

/*
* Detect which variant of syslinux is running.
*/
int detect_syslinux()
{
  sv = syslinux_version();
  switch (sv->filesystem) {
    case SYSLINUX_FS_EXTLINUX:
    strncpy(bootlinux,extlinux,sizeof(bootlinux));
    extlinux_param=true;
      break;
    case SYSLINUX_FS_ISOLINUX:
    strncpy(bootlinux,isolinux,sizeof(bootlinux));
    isolinux_param=true;
      break;
    case SYSLINUX_FS_PXELINUX:
    strncpy(bootlinux,pxelinux,sizeof(bootlinux));
    pxelinux_param=true;
      break;
    case SYSLINUX_FS_SYSLINUX:
    strncpy(bootlinux,syslinux,sizeof(bootlinux));
    syslinux_param=true;
      break;
    case SYSLINUX_FS_UNKNOWN:
    default:
      return 1;
  }
return 0;
}

/*
* Detect which parameters are passed to our module and store them.
*/
void detect_parameters(const int argc, const char *argv[])
{
  for (int i = 1; i < argc; i++) {
    if (strncmp(argv[i], "ext=", 4) == 0) {
        strncpy(extlinux, argv[i] + 4, sizeof(extlinux));
    } else if (strncmp(argv[i], "iso=", 4) == 0) {
        strncpy(isolinux, argv[i] + 4, sizeof(isolinux));
    } else if (strncmp(argv[i], "pxe=", 4) == 0) {
        strncpy(pxelinux, argv[i] + 4, sizeof(pxelinux));
    } else if (strncmp(argv[i], "sys=", 4) == 0) {
        strncpy(syslinux, argv[i] + 4, sizeof(syslinux));
    } else if (argc == 2) {
        strncpy(extlinux, argv[1], sizeof(extlinux));
        strncpy(isolinux, argv[1], sizeof(isolinux));
        strncpy(pxelinux, argv[1], sizeof(pxelinux));
        strncpy(syslinux, argv[1], sizeof(syslinux));
    }
  }
}

void init_structs() {
  memset(bootlinux,0,sizeof(bootlinux));
  memset(extlinux,0,sizeof(extlinux));
  memset(isolinux,0,sizeof(isolinux));
  memset(pxelinux,0,sizeof(pxelinux));
  memset(syslinux,0,sizeof(syslinux));

  extlinux_param=false;
  pxelinux_param=false;
  isolinux_param=false;
  syslinux_param=false;
}

void show_usage() {
  fprintf(stderr, "Usage: econfig.c32 <filename>\n");
  fprintf(stderr, "       econfig.c32 ext=<filename> iso=<filename> pxe=<filename> sys=<filename> \n");
}

int main(int argc, const char *argv[])
{
  openconsole(&dev_null_r, &dev_stdcon_w);

  if (argc < 2) {
    fprintf(stderr, "No config file specified.\n\n");
    show_usage();
    return 1;
  }

  init_structs();
  detect_parameters(argc,argv);
  if (detect_syslinux() == 1) {
    fprintf(stderr, "No valid bootloader found..\n\n");
    show_usage();
    return 1;
  }

  if (strlen(bootlinux) > 0 ) {
    syslinux_run_kernel_image(bootlinux, "", 0, IMAGE_TYPE_CONFIG);
    fprintf(stderr, "econfig.c32: failed to load '%s' (missing file?).\n\n", bootlinux);
    show_usage();
    return 1;
  } else if (extlinux_param | isolinux_param | pxelinux_param | syslinux_param) {
    fprintf(stderr, "No config file specified for the current bootloader.\n\n");
    show_usage();
    return 1;
  }

  return 0;
}


You can download the sourcecode and the compiled version from: http://ubcd.partedmagic.com/downloads/enhanced-config.zip

@ Victor:
Can you send me all the current config files for the next beta of UBCD50 so I can adapt them at the right place.

We can use it for making to different main.cfg files: mainiso.cfg and mainsys.cfg.

'localboot -1' does only work with isolinux
For syslinux we need to use:
Code:
COM32 /boot/syslinux/chain.c32
APPEND hd1 swap


The bug in the Hardware Detection Tool (didn't run with syslinux, but did run with isolinux on my PC) is solved. And the working version will be included in syslinux 3.74.
It is a very nice program and it works great.
http://syslinux.zytor.com/wiki/index.php/Hdt_%28Hardware_Detection_Tool%29

_________________
Download Ultimate Boot CD v5.0: http://www.ultimatebootcd.com/download.html
Use Parted Magic for handling all partitioning task: http://partedmagic.com/


Last edited by Icecube on Wed Jul 08, 2009 1:51 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 02, 2009 6:09 pm 
Offline

Joined: Mon Feb 21, 2005 10:59 pm
Posts: 1259
Quote:
Can you send me all the current config files for the next beta of UBCD50 so I can adapt them at the right place.


It's probably easier if you give me a list of the parts that need to be changed, since I am in the midst of updating for b13.

Thanks!


Top
 Profile  
 
 Post subject: Re: Enhanced config.c32 (econfig.c32) and whichsys.c32
PostPosted: Mon Jul 05, 2010 2:51 pm 
Offline

Joined: Fri Jan 11, 2008 2:52 pm
Posts: 1278
I wrote another module whichsys.c32, which is much better.
It doesn't accept another configfile (at least not directly), but it accepts labels and commands.
Code:
Detemine which command to execute, based on the Syslinux bootloader variant
from which you run it.

  Usage:    whichsys.c32 [-iso- command] [-pxe- command] [-sys- command]
  Examples: whichsys.c32 -iso- chain.c32 hd0 -sys- chain.c32 hd1 swap
            whichsys.c32 -iso- config iso.cfg -sys- sys.cfg -pxe- pxe.cfg

Using this module instead of econfig.c32 will make it possible to remove ubcd/menus/isolinux/main.cfg and it will remove the need to load econfig.c32 for the ".." entries that point back to ubcd/menus/isolinux/main.cfg or ubcd/menus/syslinux/main.cfg.

Source code can be downloaded from:
http://git.zytor.com/?p=users/gerth/sys ... e23342b98f

Binaries can be downloaded from (currently only compiled for Syslinux 4.01):
http://ubcd.stopspazzing.com/downloads/ ... /whichsys/

_________________
Download Ultimate Boot CD v5.0: http://www.ultimatebootcd.com/download.html
Use Parted Magic for handling all partitioning task: http://partedmagic.com/


Top
 Profile  
 
 Post subject: Re: Enhanced config.c32 (econfig.c32) and whichsys.c32
PostPosted: Mon Sep 06, 2010 9:56 pm 
Offline

Joined: Mon Feb 21, 2005 10:59 pm
Posts: 1259
@IceCube: I am using whichsys.c32 from syslinux V4.02.

When I use this command:

Code:
COM32 whichsys.c32 -iso- config /pmagic/boot/isolinux/isolinux.cfg -sys- config /pmagic/boot/syslinux/syslinux.cfg


I get this error:

Code:
Could not find kernel image: config


This doesn't work as well:

Code:
COM32 whichsys.c32 -sys- chain.c32 hd1 swap -iso- localboot -1


I get this error:

Code:
Could not find kernel image: localboot


Any idea what I did wrong?


Top
 Profile  
 
 Post subject: Re: Enhanced config.c32 (econfig.c32) and whichsys.c32
PostPosted: Tue Sep 07, 2010 2:47 am 
Offline

Joined: Fri Jan 11, 2008 2:52 pm
Posts: 1278
"config" and "localboot" only work directly from the config file as keyword.
If you want to run them from the command line or with whichsys.c32, you need to add the modules config.c32 and localboot.c32.

For clarity, you can best change, the commands too:
Code:
COM32 whichsys.c32 -iso- config.c32 /pmagic/boot/isolinux/isolinux.cfg -sys- config.c32 /pmagic/boot/syslinux/syslinux.cfg

Code:
COM32 whichsys.c32 -sys- chain.c32 hd1 swap -iso- localboot.c32 -1

_________________
Download Ultimate Boot CD v5.0: http://www.ultimatebootcd.com/download.html
Use Parted Magic for handling all partitioning task: http://partedmagic.com/


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Protected by Anti-Spam ACP Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group