From 21ba817cf9fbfe996f2d2729ed55dd15531eb5c7 Mon Sep 17 00:00:00 2001 From: Toomas Soome Date: Fri, 26 Jun 2015 18:55:09 +0300 Subject: [PATCH] 6039 installgrub MBR update response check should use locale specific yesexpr Reviewed by: Dan McDonald Reviewed by: Hans Rosenfeld Approved by: Garrett D'Amore --- usr/src/cmd/boot/installgrub/Makefile | 9 +++++++-- usr/src/cmd/boot/installgrub/inc.flg | 21 +++++++++++++++++++++ usr/src/cmd/boot/installgrub/installgrub.c | 8 +++++++- usr/src/cmd/boot/installgrub/message.h | 2 +- 4 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 usr/src/cmd/boot/installgrub/inc.flg diff --git a/usr/src/cmd/boot/installgrub/Makefile b/usr/src/cmd/boot/installgrub/Makefile index aecf0f7096..5d58bd3200 100644 --- a/usr/src/cmd/boot/installgrub/Makefile +++ b/usr/src/cmd/boot/installgrub/Makefile @@ -29,14 +29,16 @@ EINFO_SRC= ./../common/bblk_einfo.c UTILS_SRC =./../common/boot_utils.c EXTRA_SRC =./../common/mboot_extra.c -OBJS= installgrub.o pcfs_glue.o pcfs.o bblk_einfo.o boot_utils.o mboot_extra.o +OBJS= installgrub.o pcfs_glue.o pcfs.o bblk_einfo.o boot_utils.o mboot_extra.o \ + getresponse.o SRCS= installgrub.c pcfs_glue.c $(PCFS_SRC) $(UTILS_SRC) $(EINFO_SRC) \ - $(EXTRA_SRC) + $(EXTRA_SRC) $(SRC)/common/util/getresponse.c SBINLINKS= $(PROG) include ../Makefile.com CPPFLAGS += -I$(SRC)/uts/i86pc -I$(SRC)/uts/intel -I$(SRC)/uts/common +CPPFLAGS += -I$(SRC)/common/util CERRWARN += -_gcc=-Wno-unused-label CERRWARN += -_gcc=-Wno-unused-function CERRWARN += -_gcc=-Wno-uninitialized @@ -80,6 +82,9 @@ mboot_extra.o: $(EXTRA_SRC) bblk_einfo.o: $(EINFO_SRC) $(COMPILE.c) -o $@ $(EINFO_SRC) +%.o: $(SRC)/common/util/%.c + $(COMPILE.c) $(OUTPUT_OPTION) $< + install: all $(ROOTSBINPROG) .WAIT $(ROOTUSRSBINLINKS) clean: diff --git a/usr/src/cmd/boot/installgrub/inc.flg b/usr/src/cmd/boot/installgrub/inc.flg new file mode 100644 index 0000000000..50d189cb2e --- /dev/null +++ b/usr/src/cmd/boot/installgrub/inc.flg @@ -0,0 +1,21 @@ +#!/bin/sh +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright 2015 Toomas Soome +# + +echo_file usr/src/cmd/boot/common/bblk_einfo.c +echo_file usr/src/cmd/boot/common/boot_utils.c +echo_file usr/src/cmd/boot/common/mboot_extra.c +echo_file usr/src/common/util/getresponse.c +echo_file usr/src/common/util/getresponse.h diff --git a/usr/src/cmd/boot/installgrub/installgrub.c b/usr/src/cmd/boot/installgrub/installgrub.c index 694193d9c7..0ae6749bcc 100644 --- a/usr/src/cmd/boot/installgrub/installgrub.c +++ b/usr/src/cmd/boot/installgrub/installgrub.c @@ -58,6 +58,7 @@ #include "./../common/bblk_einfo.h" #include "./../common/boot_utils.h" #include "./../common/mboot_extra.h" +#include "getresponse.h" #ifndef TEXT_DOMAIN #define TEXT_DOMAIN "SUNW_OST_OSCMD" @@ -131,6 +132,11 @@ main(int argc, char *argv[]) (void) setlocale(LC_ALL, ""); (void) textdomain(TEXT_DOMAIN); + if (init_yes() < 0) { + (void) fprintf(stderr, gettext(ERR_MSG_INIT_YES), + strerror(errno)); + exit(BC_ERROR); + } /* * retro-compatibility: installing the bootblock is the default @@ -849,7 +855,7 @@ found_part: /* get confirmation for -m */ if (write_mbr && !force_mbr) { (void) fprintf(stdout, MBOOT_PROMPT); - if (getchar() != 'y') { + if (!yes()) { write_mbr = 0; (void) fprintf(stdout, MBOOT_NOT_UPDATED); return (BC_ERROR); diff --git a/usr/src/cmd/boot/installgrub/message.h b/usr/src/cmd/boot/installgrub/message.h index 6a2b98069d..2dc6caba6e 100644 --- a/usr/src/cmd/boot/installgrub/message.h +++ b/usr/src/cmd/boot/installgrub/message.h @@ -57,7 +57,7 @@ extern "C" { #define MBOOT_PROMPT \ gettext("Updating master boot sector destroys existing boot " \ - "managers (if any).\ncontinue (y/n)?") + "managers (if any).\ncontinue (y/n)? ") #define MBOOT_NOT_UPDATED gettext("master boot sector not updated\n") -- 2.11.4.GIT