grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Device syntax, scripting, partitions and filesystems


From: Serbinenko Vladimir
Subject: Device syntax, scripting, partitions and filesystems
Date: Fri, 21 Jan 2005 18:52:05 +0100
User-agent: Mozilla Thunderbird 1.0 (X11/20041206)

About device syntax. What realising quotting or escaping support like:

(/address@hidden,0/address@hidden,1/address@hidden/address@hidden,0)/path/file
Or
("/address@hidden,0/address@hidden,1/address@hidden/address@hidden,0")/path/file

I haven't recieved my copy of this letter. I suppose some e-mail problems. So I resend it. Sorry if recieved twice
Hollis Blanchard wrote:

On Jan 20, 2005, at 12:34 PM, Serbinenko Vladimir wrote:

I'm also curious about this. Could you provide some easily understood examples (in the syntax of your choosing)? What I mean is: if your ideal script engine were already part of GRUB, what scripts would you use with it? Don't just describe them; instead put them into an email.

-Hollis


For me scripting is necessary thing to write some features.
So examples
if bash:
#Wake-on-time at 17:02
if (((s=`time +"%H:%M"`)>="17:00" && s<="17:05")) then
   default=4;
   timeout=10;
else
   default=0;
   timeout=-1;
fi
if PHP
//Wake-on-time at 17:02
if((s=`time +"%H:%M"`)>="17:00" && s<="17:05")
{
   $_ENV["default"]=4;
   $_ENV["timeout"]=10;
}
else
{
   $_ENV["default"]=0;
   $_ENV["timeout"]=-1;
}
Bad OSes(just like windows)
togpt <device>
is a command that moves partition to GRUB Partion table invisible for
OSes. In some bootloaders it's called something like many primary
partiotions or EMBR
toprim <number> <device>
is the inverse <number> is an indication what slot in MBR to use.
For this feature some modifications are necessary to partition names as
it must be independent if part is MBR/GPT/logic. I think that we can
have two modules: gpt and pc
pc- standart pc parts
gpt- with gpt support and partition names by physical position
SAVEDBOOLS is array of bools stored in a file
#bash version
if((SAVEDBOOLS[0])); then
   togpt (hd0,4);
   SAVEDBOOLS[0]=0;
fi
...
title windows
toprim 0 (hd0,4);
SAVEDBOOLS[0]=1;
...
//PHP version script file
if($_SAVEDBOOLS[0])
{
   `togpt (hd0,4)`;
   $_SAVEDBOOLS[0]=0;
}
function win1boot(){
   $_SAVEDBOOLS[0]=1;
   `toprim 0 (hd0,4)`;
...
}

menu file:
....
script $prefix/scr.grb
...
title windows
eval win1boot()

Third example:fso
exchangefso is a command to exchange FileSystem Objects like
exchangefso /grubhid/win1/windows /windows
and /grubhid/win1/windows and /windows will be exchanged just by
exchanging directory entries
#bash example
#run: win_undo <number> <dir>
function win_undo()
{
   if((SAVEDBOOLS[$0])); then
      for u in $1/*; do
          if ((u!="$1\/bsect.bin"))
          exchangefso $u ${u:$(strlen $1)};
      done;
      SAVEDBOOLS[$0]=0;
   fi
}
function winboot()
{
      for u in $1/*; do
          if ((u!="$1\/bsect.bin"))
          exchangefso $u ${u:$(strlen $1)};
      done;
      SAVEDBOOLS[$0]=1;
      chainloader $1/bsect.bin;
}
...
root <device>
win_undo 1 /grubhid/win1
...
title windows
root <device>
winboot 1 /grubhid/win1
...
//PHP example
function win_undo($num,$dir)
{
   if($_SAVEDBOOLS[$num])
   {
      foreach(glob("$dir/*") as $u)
          if ($u!="$dir/bsect.bin")
              shell_execute("exchangefso $u ".substr($u,strlen($dir)));
      $_SAVEDBOOLS[$num]=0;
   }
}
function winboot()
{
      foreach(glob("$dir/*") as $u)
          if ($u!="$dir/bsect.bin")
              shell_execute("exchangefso $u ".substr($u,strlen($dir)));
      $_SAVEDBOOLS[$num]=1;
      `chainloader $dir/bsect.bin`;
}

menu file:
..
script $prefix/w32s.grb
..
root <device>
eval win_undo(1,"/grubhid/win1");

...
title windows
root <device>
eval winboot(1,"/grubhid/win1");

Some questions about future gpt:
do you think that format of gpt like
GPT2<4 bytes reserved><records>
And every record is
<4 bytes part begin><4 bytes part end><1 byte type>
And it takes 1 sector. So you can have 56 gpt partitions
And parts numbers will be in order of physical position.
About fso exchange I think that exchanging must be without name as in
many filesystems name has dynamic sizeor for FAT we will have no
problems with long names. OK?

P.S. I haven't had a lot of time to write this letter. Rorry for
possible erorrs










reply via email to

[Prev in Thread] Current Thread [Next in Thread]