--- /dev/null	2012-08-31 05:08:52.000000000 +0400
+++ new/grub/grub-core/commands/solarislegacy.c	2012-08-31 05:08:52.513929459 +0400
@@ -0,0 +1,213 @@
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2012 Daniil Lunev
+ *
+ *  GRUB is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  GRUB is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/command.h>
+#include <grub/mm.h>
+#include <grub/err.h>
+#include <grub/dl.h>
+#include <grub/file.h>
+#include <grub/normal.h>
+#include <grub/script_sh.h>
+#include <grub/i18n.h>
+#include <grub/term.h>
+#include <grub/legacy_parse.h>
+#include <grub/crypto.h>
+#include <grub/auth.h>
+#include <grub/disk.h>
+#include <grub/partition.h>
+
+#include "menu_managing.c"
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static entries *
+parse_entries(grub_file_t file)
+{
+  entries * list = NULL;
+  entries * current = NULL;
+  init_entries(&list);
+  for(;;) {
+    char * buf = grub_file_getline(file);
+    char * param = buf;
+    char * value;
+    
+    if (! buf) 
+      break;
+  
+    if ((buf[0] == '#') || (buf[0] == ' ') ||
+      (buf[0] == '\t') || (buf[0] == '\n')) {
+      grub_free(buf);
+      continue;
+    }
+
+    while ((*param == ' ') || (*param == '\t'))
+      ++param;
+
+    value = grub_strchr(param, ' ');
+    if (! value)
+      value = grub_strchr(param, '\t');
+
+    if (! value) {
+      grub_free(buf);
+      continue;
+    }
+
+    *value++ = 0;
+    while ((*value == ' ') || (*value == '\t'))
+      ++value;
+
+    if ((*value == '\0') || (*value == '\n')) {
+      grub_free(buf);
+      continue;
+    }
+    
+    if (! grub_strcmp(param, "default")) {
+    } else if (! grub_strcmp(param, "timeout")) {
+    } else if (! grub_strcmp(param, "serial")) {
+    } else if (! grub_strcmp(param, "terminal")) {
+    } else if (! grub_strcmp(param, "title")) {
+      current = new_entry(value, list);
+    } else if (! grub_strcmp(param, "bootfs")) {
+      char * lpath;
+      if (! current) {
+        grub_free(buf);
+        grub_error (GRUB_ERR_INVALID_COMMAND, N_("illumos syntax error"));
+        return NULL;
+      }
+      lpath = grub_strchr(value, '/');
+      *lpath = 0;
+      grub_strcpy(current->entry_info[POOL_LABEL], value);
+      *lpath = '/';
+      grub_strcpy(current->entry_info[DATA_SET], lpath);
+    } else if (! grub_strcmp(param, "kernel$")) {
+      char * ender;
+      ender = grub_strchr(value, ' ');
+      if (! ender)  
+        ender = grub_strchr(value, '\t');
+      if (ender)
+        *ender = 0;
+      grub_strcpy(current->entry_info[KERNEL_PATH], value);
+      if (ender) {
+        ++ender;
+        while ((*ender == ' ') || (*ender == '\t'))
+          ++ender;
+        grub_strcpy(current->entry_info[KERNEL_OPTIONS], ender);
+      }
+    } else if (! grub_strcmp(param, "module$")) {
+      grub_strcpy(current->entry_info[BA_PATH], value);
+    } else {
+      grub_free(buf);
+      continue;
+    }
+    grub_free(buf);
+  }
+  return list;
+}
+
+static grub_err_t
+grub_solaris_legacy_cmd(struct grub_command *cmd,
+      int argc, char **args)
+{
+  int new_env, extractor;
+  extractor = (cmd->name[0] == 'e');
+  new_env = (cmd->name[extractor ? (sizeof ("extract_slegacy_entries_") - 1)
+           : (sizeof ("slegacy_") - 1)] == 'c');
+
+
+  if (argc != 1)
+    return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+
+  grub_file_t file = grub_file_open(args[0]);
+
+  if (new_env)
+    grub_cls ();
+
+  if (new_env && !extractor)
+    grub_env_context_open ();
+  if (extractor)
+    grub_env_extractor_open (!new_env);
+
+  if (! file)
+    return grub_errno;
+
+  entries * list = parse_entries(file);
+
+  if (! list) {
+    return grub_error (GRUB_ERR_INVALID_COMMAND, N_("illumos syntax error"));
+  }
+  
+  add_entries(list);
+
+  if (new_env)
+  {
+    grub_menu_t menu;
+    menu = grub_env_get_menu ();
+    if (menu && menu->size)
+    grub_show_menu (menu, 1, 0);
+    if (!extractor)
+      grub_env_context_close ();
+  }
+  if (extractor)
+    grub_env_extractor_close (!new_env);
+
+  clear_entries(list);
+
+  grub_file_close(file);
+  return 0;
+}
+
+static grub_command_t cmd_source, cmd_configfile;
+static grub_command_t cmd_source_extract, cmd_configfile_extract;
+
+GRUB_MOD_INIT(solaris_legacy)
+{  
+  cmd_source
+    = grub_register_command ("slegacy_source",
+           grub_solaris_legacy_cmd,
+           N_("FILE"),
+           /* TRANSLATORS: "legacy config" means
+        "config as used by grub-legacy".  */
+           N_("Parse legacy config in same context"));
+  cmd_configfile
+    = grub_register_command ("slegacy_configfile",
+           grub_solaris_legacy_cmd,
+           N_("FILE"),
+           N_("Parse legacy config in new context"));
+  cmd_source_extract
+    = grub_register_command ("extract_slegacy_entries_source",
+           grub_solaris_legacy_cmd,
+           N_("FILE"),
+           N_("Parse legacy config in same context taking only menu entries"));
+  cmd_configfile_extract
+    = grub_register_command ("extract_slegacy_entries_configfile",
+           grub_solaris_legacy_cmd,
+           N_("FILE"),
+           N_("Parse legacy config in new context taking only menu entries"));
+
+
+}
+
+GRUB_MOD_FINI(solaris_legacy) 
+{
+  grub_unregister_command (cmd_source);
+  grub_unregister_command (cmd_configfile);
+  grub_unregister_command (cmd_source_extract);
+  grub_unregister_command (cmd_configfile_extract);
+}
