Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1KSeXr-0007yP-Dd for mharc-grub-devel@gnu.org; Mon, 11 Aug 2008 17:03:15 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KSeXq-0007we-9C for grub-devel@gnu.org; Mon, 11 Aug 2008 17:03:14 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KSeXp-0007uz-Kk for grub-devel@gnu.org; Mon, 11 Aug 2008 17:03:13 -0400 Received: from [199.232.76.173] (port=38173 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KSeXp-0007uq-Aw for grub-devel@gnu.org; Mon, 11 Aug 2008 17:03:13 -0400 Received: from ti-out-0910.google.com ([209.85.142.188]:16600) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KSeXo-0005sA-VH for grub-devel@gnu.org; Mon, 11 Aug 2008 17:03:13 -0400 Received: by ti-out-0910.google.com with SMTP id u5so1056660tia.10 for ; Mon, 11 Aug 2008 14:03:11 -0700 (PDT) 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=DzD/JmvTmKuDtTWdnxPUZd4rofJQPUkauI13MJPBRwk=; b=Ds+6unOXnHPyQSP3riRtfCLBeiPT0yeoyPAPQUM4HixfgB1NPDEEbzg1lzHjT3XDa/ L3OdD9y39297jysbnn63E2gD5E7T4Ox8MXi9Mu6zfoYucp/rWz+qc41yvwXHD6FR8LB4 g6f7BI/4d5qsZSSN7IYGF+uEkQkPzjB4oG6Q0= 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=YT6q9HwZL6YA1+cUxUN5j68H4+fNP8wcdHvz+NQo6WIgI+F5BfWoMgp619/1DAROqA NpRpuE32X6Xet8vEMFHM9y4Yw92fbBzl3t7sqVmBhqGYDa9OZhXtn/X2b4pvtlkBeX1W NE8NKS6DNK5Up4OxB/a/HYcgpiCnEdVbAyfwY= Received: by 10.110.7.18 with SMTP id 18mr10002704tig.32.1218488590944; Mon, 11 Aug 2008 14:03:10 -0700 (PDT) Received: by 10.110.16.5 with HTTP; Mon, 11 Aug 2008 14:03:10 -0700 (PDT) Message-ID: Date: Tue, 12 Aug 2008 05:03:10 +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: Idea: use menu hook to implement the savedefault command 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: Mon, 11 Aug 2008 21:03:14 -0000 Hi, Now it's possible to implement savedefault with load_env and save_env, but the problem is we need to add it to every menuitem, it's tedious process, and new item don't get it automatically. I'm thinking about using menu hook to solve this. I can think of two implementation: 1. Function interface We can install hooks, which get called just before the menu is invoked. 2. Script interface We can use certain variable to specific the command to use, for example: set MENU_PRELOAD=save_env default The first menu is easier to implement, but the second one is more flexible. btw, we can also use this to implement the password command. Just before the menu is executed, we call the hook. If the password is not match, we return false and it quit. But it's a little tricky this time, as some item may not be protected. For this, we introduce another concept, the attributes of an menu item. For example, we can set an lock attribute that indicate that this item should be verified for password. The attribute list is passed to the hook function, so they can just lookup it's value and decide what to do. Note that the attribute concept is already used in Colin's GSOC project, it uses to specific the icon of a boot item, we just extent it to include other attributes. -- Bean -- Bean