--- /dev/null	2012-08-31 05:08:50.000000000 +0400
+++ new/grub/grub-core/commands/illumos_entries.c	2012-08-31 05:08:50.595738459 +0400
@@ -0,0 +1,197 @@
+/*
+ *  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/file.h>
+#include <grub/disk.h>
+#include <grub/misc.h>
+#include <grub/err.h>
+#include <grub/dl.h>
+#include <grub/extcmd.h>
+#include <grub/i18n.h>
+#include <grub/normal.h>
+
+#include "menu_managing.c"
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static const struct grub_arg_option options[] = {
+  {0, 0, 0, 0, 0, 0}
+};
+
+static const char * globals[] = {
+  "default_entry",
+  "timeout",
+  "serial",
+  "terminal",
+  NULL
+};
+
+static grub_err_t
+get_value(char * buf, char ** value)
+{
+  *value = grub_strchr(buf, '=');
+  if (! *value)
+    return grub_error (GRUB_ERR_INVALID_COMMAND, N_("illumos syntax error"));
+  **value = '\0';
+  ++(*value);
+  return 0;
+}
+
+static int
+check_param(char * param)
+{
+  int i = 0;
+  
+  for (; params_list[i]; ++i)
+    if (!grub_strcmp(param, params_list[i]))
+      return i;
+  
+  return -1;
+}
+
+static int
+check_global(char * param)
+{
+  int i = 0;
+  
+  for (; globals[i]; ++i)
+    if (!grub_strcmp(param, globals[i]))
+      return i;
+  
+  return -1;
+}
+
+static grub_err_t
+parse_config(grub_file_t file, entries * entry_list)
+{
+  char * param;
+  char * value;
+  entries * current_entry = NULL;
+  int param_id = 0;
+  int global_id = 0;
+  grub_err_t err;
+  
+  for(;;) {
+    param = grub_file_getline(file);
+    if (! param)
+      return grub_errno;
+
+    if ((*param == '#') || (*param == ' ') || 
+      (*param == '\t') || (*param == '\n') ||
+      (*param == 0)) {
+      grub_free(param);
+      continue;
+    }
+    global_id = -1;
+      
+    err = get_value(param, &value);
+    if (err)
+      return err;
+
+    param_id = check_param(param);
+    if (param_id < 0) {
+      global_id = check_global(param);
+      if (global_id < 0) {
+        grub_free(param);
+        return grub_error (GRUB_ERR_INVALID_COMMAND, N_("illumos syntax error"));
+      }
+    }
+    if (err)
+      return err;
+    if (!value[0])
+      return grub_error (GRUB_ERR_INVALID_COMMAND, N_("illumos syntax error"));
+    if (global_id < 0) {
+      if (param_id == 0) {
+        current_entry = new_entry(value, entry_list);
+        if (! current_entry) {
+          grub_free(param);
+          return grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("memory can not be allocated"));
+        }
+      } else {
+        grub_strcpy(current_entry->entry_info[param_id], value);
+      }
+    } else {
+      char line[512];
+      switch (global_id) {
+      case 0:
+        grub_env_set("default", value);
+        break;
+      case 1:
+        grub_env_set("timeout", value);
+        break;
+      case 2:
+        grub_strcpy(line, "serial ");
+        grub_strcat(line, value);
+        grub_normal_parse_line(line, NULL);
+        break;
+      case 3:
+        grub_strcpy(line, "terminal_input ");
+        grub_strcat(line, value);
+        grub_strcat(line, "; terminal_output ");
+        grub_strcat(line, value);
+        grub_normal_parse_line(line, NULL);
+        break;
+      default:
+        break;
+      }
+    }
+    grub_free(param);
+  }    
+  return 0;
+}
+
+static grub_err_t
+grub_cmd_illumos_entries (grub_extcmd_context_t ctxt __attribute__ ((unused)), int argc, char **args)
+{
+  grub_file_t file;
+  entries * menu_entries = NULL;
+  
+  if (argc != 1)
+    return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+  
+  file = grub_file_open(args[0]);
+  
+  if (!file)
+    return grub_errno;
+    
+  init_entries(&menu_entries);
+  
+  if (parse_config(file, menu_entries) == 0) {
+    add_entries(menu_entries);
+  }  
+  clear_entries(menu_entries);
+  
+  grub_refresh();
+  grub_file_close(file);
+
+  return 0;
+}
+
+static grub_extcmd_t illumos_entries;
+
+GRUB_MOD_INIT(illumos_entries)
+{
+  illumos_entries = grub_register_extcmd ("illumos_entries", grub_cmd_illumos_entries, 0,
+            N_("FILE"), N_("Define an illumos menu entries."), options);
+}
+
+GRUB_MOD_FINI(illumos_entries)
+{
+  grub_unregister_extcmd (illumos_entries);
+}
