grub-devel
[Top][All Lists]
Advanced

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

Some new ideas on transparent filters


From: Bean
Subject: Some new ideas on transparent filters
Date: Tue, 15 Jan 2008 17:14:00 +0800

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




reply via email to

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