Mercurial > illumos > illumos-gate
changeset 13305:c0863802718a
720 be_utils should not use python
Reviewed by: Garrett D'Amore <garrett@nexenta.com>
Reviewed by: Dan McDonald <danmcd@nexenta.com>
Approved by: Gordon Ross <gwr@nexenta.com>
author | Alexander Eremin <a.eremin@nexenta.com> |
---|---|
date | Fri, 18 Mar 2011 14:06:44 -0400 |
parents | b54231762cfa |
children | 5dc578fe734a |
files | usr/src/lib/libbe/Makefile.com usr/src/lib/libbe/common/be_utils.c usr/src/lib/libbe/common/libbe_priv.h |
diffstat | 3 files changed, 98 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/usr/src/lib/libbe/Makefile.com Mon Mar 14 14:05:30 2011 -0400 +++ b/usr/src/lib/libbe/Makefile.com Fri Mar 18 14:06:44 2011 -0400 @@ -22,6 +22,9 @@ # # Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. # +# Copyright 2011 Nexenta Systems, Inc. All rights reserved. +# + LIBRARY= libbe.a VERS= .1 @@ -46,7 +49,7 @@ C99MODE= $(C99_ENABLE) -LDLIBS += -lzfs -linstzones -luuid -lnvpair -lc -lgen +LDLIBS += -lzfs -linstzones -luuid -lnvpair -lc -lgen -ldevinfo CPPFLAGS += $(INCS) $(LINTLIB) := SRCS= $(SRCDIR)/$(LINTSRC)
--- a/usr/src/lib/libbe/common/be_utils.c Mon Mar 14 14:05:30 2011 -0400 +++ b/usr/src/lib/libbe/common/be_utils.c Fri Mar 18 14:06:44 2011 -0400 @@ -24,6 +24,11 @@ */ /* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ + + +/* * System includes */ #include <assert.h> @@ -46,12 +51,11 @@ #include <unistd.h> #include <fcntl.h> #include <wait.h> +#include <libdevinfo.h> #include <libbe.h> #include <libbe_priv.h> -#define INST_ICT "/usr/lib/python2.6/vendor-packages/osol_install/ict.py" - /* Private function prototypes */ static int update_dataset(char *, int, char *, char *, char *); static int _update_vfstab(char *, char *, char *, char *, be_fs_list_data_t *); @@ -2775,8 +2779,6 @@ return (gettext("Invalid path for menu.lst file")); case BE_ERR_ZONE_SS_EXISTS: return (gettext("Zone snapshot exists.")); - case BE_ERR_ADD_SPLASH_ICT: - return (gettext("Add_spash_image ICT failed.")); case BE_ERR_BOOTFILE_INST: return (gettext("Error installing boot files.")); case BE_ERR_EXTCMD: @@ -3451,6 +3453,52 @@ } /* + * Function: be_get_console_prop + * Description: Determine console device. + * Returns: + * Success - pointer to console setting. + * Failure - NULL + * Scope: + * Private + */ +static char * +be_get_console_prop(void) +{ + di_node_t dn; + char *console = NULL; + + if ((dn = di_init("/", DINFOPROP)) == DI_NODE_NIL) { + be_print_err(gettext("be_get_console_prop: " + "di_init() failed\n")); + return (NULL); + } + + if (di_prop_lookup_strings(DDI_DEV_T_ANY, dn, + "console", &console) != -1) { + di_fini(dn); + return (console); + } + + if (console == NULL) { + if (di_prop_lookup_strings(DDI_DEV_T_ANY, dn, + "output-device", &console) != -1) { + di_fini(dn); + if (strncmp(console, "screen", strlen("screen")) == 0) + console = BE_DEFAULT_CONSOLE; + } + } + + /* + * Default console to text + */ + if (console == NULL) { + console = BE_DEFAULT_CONSOLE; + } + + return (console); +} + +/* * Function: be_create_menu * Description: * This function is used if no menu.lst file exists. In @@ -3480,11 +3528,10 @@ char *mode) { be_node_list_t *be_nodes = NULL; - char add_default_cmd[BUFSIZ]; char *menu_path = NULL; char *be_rpool = NULL; char *be_name = NULL; - + char *console = NULL; errno = 0; if (menu_file == NULL || menu_fp == NULL || mode == NULL) @@ -3513,23 +3560,43 @@ * Check to see if this system supports grub */ if (be_has_grub()) { - char be_run_cmd_errbuf[BUFSIZ]; /* * The grub menu is missing so we need to create it * and fill in the first few lines. */ - (void) snprintf(add_default_cmd, sizeof (add_default_cmd), - "%s add_splash_image_to_grub_menu %s", - INST_ICT, pool_mntpt); - if (be_run_cmd(add_default_cmd, be_run_cmd_errbuf, BUFSIZ, - NULL, 0) != BE_SUCCESS) { - be_print_err(gettext("be_create_menu: " - "add_splash_image_to_grub_menu ICT failed.\n")); - be_print_err(gettext(" Command: \"%s\"\n"), - add_default_cmd); - be_print_err(be_run_cmd_errbuf); - return (BE_ERR_ADD_SPLASH_ICT); + FILE *temp_fp = fopen(menu_file, "a+"); + if (temp_fp == NULL) { + *menu_fp = NULL; + return (errno_to_be_err(errno)); } + + if ((console = be_get_console_prop()) != NULL) { + + /* + * If console is redirected to serial line, + * GRUB splash screen will not be enabled. + */ + if (strncmp(console, "text", strlen("text")) == 0 || + strncmp(console, "graphics", + strlen("graphics")) == 0) { + + (void) fprintf(temp_fp, "%s\n", BE_GRUB_SPLASH); + (void) fprintf(temp_fp, "%s\n", + BE_GRUB_FOREGROUND); + (void) fprintf(temp_fp, "%s\n", + BE_GRUB_BACKGROUND); + (void) fprintf(temp_fp, "%s\n", + BE_GRUB_DEFAULT); + } else { + be_print_err(gettext("be_create_menu: " + "console on serial line, " + "GRUB splash image will be disabled\n")); + } + } + + (void) fprintf(temp_fp, "timeout 30\n"); + (void) fclose(temp_fp); + } else { /* * The menu file doesn't exist so we need to create a
--- a/usr/src/lib/libbe/common/libbe_priv.h Mon Mar 14 14:05:30 2011 -0400 +++ b/usr/src/lib/libbe/common/libbe_priv.h Fri Mar 18 14:06:44 2011 -0400 @@ -23,6 +23,10 @@ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. */ +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ + #ifndef _LIBBE_PRIV_H #define _LIBBE_PRIV_H @@ -38,6 +42,7 @@ #define BE_AUTO_NAME_MAX_TRY 3 #define BE_AUTO_NAME_DELIM '-' #define BE_CONTAINER_DS_NAME "ROOT" +#define BE_DEFAULT_CONSOLE "text" #define BE_POLICY_PROPERTY "org.opensolaris.libbe:policy" #define BE_UUID_PROPERTY "org.opensolaris.libbe:uuid" #define BE_PLCY_STATIC "static" @@ -45,6 +50,10 @@ #define BE_GRUB_MENU "/boot/grub/menu.lst" #define BE_SPARC_MENU "/boot/menu.lst" #define BE_GRUB_COMMENT "#============ End of LIBBE entry =============" +#define BE_GRUB_SPLASH "splashimage /boot/solaris.xpm" +#define BE_GRUB_FOREGROUND "foreground 343434" +#define BE_GRUB_BACKGROUND "background F7FBFF" +#define BE_GRUB_DEFAULT "default 0" #define BE_WHITE_SPACE " \t\r\n" #define BE_CAP_FILE "/boot/grub/capability" #define BE_INSTALL_GRUB "/sbin/installgrub"