From: Serbinenko Vladimir <serbinenko.vova@list.ru>
To: The development of GRUB 2 <grub-devel@gnu.org>
Subject: Scripting, partitions and filesystems
Date: Fri, 21 Jan 2005 18:23:13 +0100 [thread overview]
Message-ID: <41F13A81.8000700@list.ru> (raw)
In-Reply-To: <EDB2BAAC-6B53-11D9-B730-000A95A0560C@penguinppc.org>
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
next prev parent reply other threads:[~2005-01-21 18:03 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <E1CpUhp-000IYX-00.grub-devel-bounces+serbinenko-vova=list-ru-gnu-org@mx11.mail.ru>
2005-01-14 18:48 ` Pre-alpha scripting engine Serbinenko Vladimir
2005-01-18 18:55 ` Marco Gerards
2005-01-18 19:54 ` Serbinenko Vladimir
2005-01-19 13:01 ` Marco Gerards
2005-01-19 20:04 ` Yoshinori K. Okuji
2005-01-19 20:48 ` Marco Gerards
2005-01-19 21:48 ` Maurizio Boriani
2005-01-20 17:10 ` Serbinenko Vladimir
2005-01-20 17:56 ` Yoshinori K. Okuji
2005-01-20 18:34 ` Serbinenko Vladimir
2005-01-21 2:26 ` Hollis Blanchard
2005-01-21 17:23 ` Serbinenko Vladimir [this message]
2005-01-21 17:52 ` Device syntax, scripting, partitions and filesystems Serbinenko Vladimir
2005-01-23 14:22 ` Pre-alpha scripting engine Yoshinori K. Okuji
2005-01-19 20:59 ` Tomas Ebenlendr
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=41F13A81.8000700@list.ru \
--to=serbinenko.vova@list.ru \
--cc=grub-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.