Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1JEhsT-00039n-AQ for mharc-grub-devel@gnu.org; Tue, 15 Jan 2008 04:14:38 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JEhsO-000397-NQ for grub-devel@gnu.org; Tue, 15 Jan 2008 04:14:33 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JEhsH-00037d-0t for grub-devel@gnu.org; Tue, 15 Jan 2008 04:14:31 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JEhsE-00037I-K0 for grub-devel@gnu.org; Tue, 15 Jan 2008 04:14:23 -0500 Received: from py-out-1112.google.com ([64.233.166.180]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JEhsD-00020P-02 for grub-devel@gnu.org; Tue, 15 Jan 2008 04:14:22 -0500 Received: by py-out-1112.google.com with SMTP id u52so2701951pyb.1 for ; Tue, 15 Jan 2008 01:14:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; bh=0jgp9/e8savi+zIj6+9TtVQnJePduu1Ugb0w+IV1roc=; b=syzDGi3pzX4x1oHVFrVhcWT2kffS4zX6SdsWxwIAVzSoXavLEGb+g3/DCGhNZP0QgGAgDVfMapXyowmcxuaOWZO9a9lPRRpZ6T2aodLs3/zVZDy4UBRc+nHOE5Z7T7/mXERCS6e8jxePsmDMtYfWxcPM022/2lBWKxZCsBeBEPE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=pb+FQjOeg/jaK/L3npQI5yFceGDHPO/k/3X/Jz0VPGvUwzyuuueSSlCmX+eUAhFrz27YmB2XdN/1Hqo4O3HB3Ra/+67SpCNgFKRwjCrORqd89QiA6ysZaQIVtsWrSH63sEMYW1eTnRHPnF8xVSGP46dlseh9NQRLR3mfrmdJDdc= Received: by 10.35.87.10 with SMTP id p10mr8940632pyl.34.1200388440165; Tue, 15 Jan 2008 01:14:00 -0800 (PST) Received: by 10.35.110.12 with HTTP; Tue, 15 Jan 2008 01:14:00 -0800 (PST) Message-ID: Date: Tue, 15 Jan 2008 17:14:00 +0800 From: Bean To: "The development of GRUB 2" MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 2) Subject: Some new ideas on transparent filters 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: Tue, 15 Jan 2008 09:14:34 -0000 Hi, as Okuji suggested, the filter interface should be more general. I'm thinking about the following implementaion. 1, the filehook structure: struct grub_filehook { char *name; int priority; grub_file_t (*open_func) (grub_file_t file); struct grub_filehook *next; }; name is the text representation of the filter, and priority is integer of value 0 to 9. 2. priority By default, at most one filter of the same priority is applied to the same file, and higher priority filters are used before lower ones. In the following sections, we assume that decompression filter is of priority 4, and decryption filter is of priority 8. Priority 0 is a special case, it doesn't participate in auto filter selection, you must use it manually. This priority is usually used for filters that can't identify itself from file content, such as the little endian/big endian coversion filter. 3. filter rules you can customize how to apply the filters using a variable, say default_filter. you can use number 0-9 to represent filters of a certain priority, or use specific filter name, such as: set default_filter="9-1" This is actually the default handling described in section 2. set default_filter="9-1,be_to_le" Use the big endian to little endian conversion filter after normal processing. set default_filter="9,4,7-5,8,3-1" Swap processing order of decompression and decryption filters. set default_filter="-gzip,9-1" don't use gzip, otherwise the same as default handling. set default_filter="9-5,gzip,3-1" only try the gzip decompression filter. 4. enable/disable filters you can use two method to control the status of filter, you can enable all, then disable specific filter, or disable all, and enable specific ones. such as: set filehook=0 set filehook.gzip=1 set filehook.bzip2=1 set filehook=1 set filehook.gzip=0 set filehook.bzip2=0 5, source level control the function to open files with filter support: grub_open_file_ex(char* name,char *filter) filter is used to specify the filter rules to use. Examples: NULL use default filter rules "" don't use any filters "gzip" use only the gzip filter "-gzip,." don't use gzip, otherwise the same as default handling, . will be substituded with default_filter at runtime. 6. Filter filesystem In some case, we might want to apply a specify filter to a file, we can do this use the filter fileystem, such as: filter -a aa (hd0,1)/aa gzip.be_to_le now (filter)/aa is (hd0,1)/aa after gzip decompression and big endian to little endian conversion. to delete the mapping: filter -d aa This can also be used to add filter support to commands that dones't use grub_open_file_ex to open files. -- Bean