From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1Cs38V-0008P3-Lt for mharc-grub-devel@gnu.org; Fri, 21 Jan 2005 13:03:55 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Cs38U-0008OR-Gz for grub-devel@gnu.org; Fri, 21 Jan 2005 13:03:54 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Cs38T-0008O6-Fi for grub-devel@gnu.org; Fri, 21 Jan 2005 13:03:53 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Cs32z-00073r-2v for grub-devel@gnu.org; Fri, 21 Jan 2005 12:58:13 -0500 Received: from [194.67.23.121] (helo=mx1.mail.ru) by monty-python.gnu.org with esmtp (Exim 4.34) id 1Cs2Un-0007FU-MI for grub-devel@gnu.org; Fri, 21 Jan 2005 12:22:54 -0500 Received: from [83.77.33.135] (port=1444 helo=[192.168.1.100]) by mx1.mail.ru with esmtp id 1Cs2Ul-000IBk-00 for grub-devel@gnu.org; Fri, 21 Jan 2005 20:22:51 +0300 Message-ID: <41F13A81.8000700@list.ru> Date: Fri, 21 Jan 2005 18:23:13 +0100 From: Serbinenko Vladimir User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: The development of GRUB 2 References: <87acr5ccq4.fsf@yahoo.it> <41EFE5F9.2020202@list.ru> <200501201856.47799.okuji@enbug.org> <41EFF9A9.5080109@list.ru> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam: Not detected Subject: Scripting, partitions and filesystems X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Jan 2005 18:03:54 -0000 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 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 is the inverse 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 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 win_undo 1 /grubhid/win1 ... title windows root 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 eval win_undo(1,"/grubhid/win1"); ... title windows root eval winboot(1,"/grubhid/win1"); Some questions about future gpt: do you think that format of gpt like GPT2<4 bytes reserved> 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