usr/src/lib/liborchestrator/perform_slim_install.c
author Alasdair Lumsden <al@everycity.co.uk>
Sat, 10 Sep 2011 02:50:50 +0000
branchoi_151a
changeset 1430 398513b48d4c
parent 879 b65e82e368f5
child 956 4e40790503b0
permissions -rw-r--r--
1490 oi_151a installer Territory dropdown contains blank entries
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
     1
/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
     2
 * CDDL HEADER START
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
     3
 *
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
     4
 * The contents of this file are subject to the terms of the
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
     5
 * Common Development and Distribution License (the "License").
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
     6
 * You may not use this file except in compliance with the License.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
     7
 *
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
     8
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
     9
 * or http://www.opensolaris.org/os/licensing.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    10
 * See the License for the specific language governing permissions
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    11
 * and limitations under the License.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    12
 *
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    13
 * When distributing Covered Code, include this CDDL HEADER in each
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    14
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    15
 * If applicable, add the following below this CDDL HEADER, with the
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    16
 * fields enclosed by brackets "[]" replaced with your own identifying
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    17
 * information: Portions Copyright [yyyy] [name of copyright owner]
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    18
 *
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    19
 * CDDL HEADER END
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    20
 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    21
/*
845
1d8f110f7115 16192 auto-install core dumped when creating invalid size swap or dump
Matt Keenan <matt.keenan@oracle.com>
parents: 807
diff changeset
    22
 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    23
 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    24
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    25
#include <fcntl.h>
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    26
#include <stdio.h>
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    27
#include <stdlib.h>
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    28
#include <string.h>
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    29
#include <ctype.h>
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    30
#include <errno.h>
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    31
#include <pthread.h>
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    32
#include <sys/param.h>
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    33
#include <sys/stat.h>
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    34
#include <sys/types.h>
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    35
#include <dirent.h>
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    36
#include <sys/wait.h>
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    37
#include <crypt.h>
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    38
#include <unistd.h>
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    39
#include <time.h>
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    40
#include <libgen.h>
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    41
#include <netdb.h>
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    42
#include <locale.h>
98
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
    43
#include <wait.h>
531
e526f752d6d0 6440 Build 106 installer fails to start in 512 MB environment
David Miner <dminer@opensolaris.org>
parents: 515
diff changeset
    44
#include <sys/systeminfo.h>
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    45
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    46
#include "td_lib.h"
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    47
#include "cl_database_parms.h"
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    48
#include "admldb.h"
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    49
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    50
#include "orchestrator_private.h"
229
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
    51
#include "ict_api.h"
61
2f60ba79cd9c 851 liborchestrator should switch to the latest API when calling transfer module
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 48
diff changeset
    52
#include <transfermod.h>
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    53
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    54
#include <ls_api.h>
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    55
229
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
    56
#define	EMPTY_STR	""
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    57
#define	UN(string) ((string) ? (string) : "")
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    58
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    59
#define	STATE_FILE	"/etc/.sysIDtool.state"
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    60
538
914d2f79d86c 7838 Log installer build number and installed software build number in install_log
Evan Layton <Evan.Layton@Sun.COM>
parents: 531
diff changeset
    61
#define	PKG_PATH	"/usr/bin/pkg"
914d2f79d86c 7838 Log installer build number and installed software build number in install_log
Evan Layton <Evan.Layton@Sun.COM>
parents: 531
diff changeset
    62
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    63
#define	MAXDEVSIZE	100
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    64
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    65
struct icba {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    66
	om_install_type_t	install_type;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    67
	pid_t			pid;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    68
	om_callback_t		cb;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    69
};
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    70
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    71
struct transfer_callback {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    72
	char		*target;
229
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
    73
	char		*hostname;
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
    74
	char		*uname;
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
    75
	char		*lname;
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
    76
	char		*upasswd;
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
    77
	char		*rpasswd;
272
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
    78
	nvlist_t	**transfer_attr;
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
    79
	uint_t		transfer_attr_num;
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    80
	om_callback_t	cb;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    81
};
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    82
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    83
struct ti_callback {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    84
	nvlist_t *target_attrs;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    85
};
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    86
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    87
/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    88
 * Global Variables
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    89
 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    90
static	boolean_t	install_test = B_FALSE;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    91
static	char		*state_file_path = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    92
om_install_type_t	install_type;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    93
static	char		*def_locale;
191
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
    94
boolean_t		create_swap_and_dump = B_FALSE;
354
2c1eaf565c25 3597 Unable to install OpenSolaris with 512 MB base memory
Glenn Lagasse <Glenn.Lagasse@Sun.COM>
parents: 344
diff changeset
    95
boolean_t		create_swap_slice = B_FALSE;
94
fd4991588edd 1010 - Target Instantiation progress doesn't display in GUI
William Schumann <william.schumann@sun.com>
parents: 91
diff changeset
    96
static	pthread_t	ti_thread;
fd4991588edd 1010 - Target Instantiation progress doesn't display in GUI
William Schumann <william.schumann@sun.com>
parents: 91
diff changeset
    97
static	int		ti_ret;
459
56b6b042a167 5653 AI manifest should offer keyword to use max available space for partition/slice
William Schumann <william.schumann@sun.com>
parents: 447
diff changeset
    98
static	om_breakpoint_t	om_breakpoint = OM_no_breakpoint;
789
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
    99
int32_t requested_swap_size = -1;
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   100
int32_t requested_dump_size = -1;
157
4a430673694e 690 Target Discovery (TD) should be libspmi* clean
William Schumann <william.schumann@sun.com>
parents: 147
diff changeset
   101
229
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
   102
/*
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
   103
 * l_zfs_shared_fs_num is the local representation of ZFS_SHARED_FS_NUM
846
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   104
 * l_zfs_shared_fs_num is initially set to ZFS_SHARED_FS_NUM - 1 and
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   105
 * if the user wants to create user account and is running interactive
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   106
 * installer, the value will be increased by one to count in home directory
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   107
 * ZFS dataset.
229
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
   108
 */
846
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   109
static	int		l_zfs_shared_fs_num = ZFS_SHARED_FS_NUM - 1;
229
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
   110
405
785221d05f6b 4195 need to make changes to AI Engine for SPARC
William Schumann <william.schumann@sun.com>
parents: 389
diff changeset
   111
static om_callback_t	om_cb;
785221d05f6b 4195 need to make changes to AI Engine for SPARC
William Schumann <william.schumann@sun.com>
parents: 389
diff changeset
   112
static char		zfs_device[MAXDEVSIZE];
785221d05f6b 4195 need to make changes to AI Engine for SPARC
William Schumann <william.schumann@sun.com>
parents: 389
diff changeset
   113
static char		swap_device[MAXDEVSIZE];
785221d05f6b 4195 need to make changes to AI Engine for SPARC
William Schumann <william.schumann@sun.com>
parents: 389
diff changeset
   114
static char		*zfs_fs_names[ZFS_FS_NUM] = {"/"};
785221d05f6b 4195 need to make changes to AI Engine for SPARC
William Schumann <william.schumann@sun.com>
parents: 389
diff changeset
   115
static char		zfs_shared_user_login[MAXPATHLEN] = "";
785221d05f6b 4195 need to make changes to AI Engine for SPARC
William Schumann <william.schumann@sun.com>
parents: 389
diff changeset
   116
static char		*zfs_shared_fs_names[ZFS_SHARED_FS_NUM] =
229
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
   117
	{"/export", "/export/home", zfs_shared_user_login};
405
785221d05f6b 4195 need to make changes to AI Engine for SPARC
William Schumann <william.schumann@sun.com>
parents: 389
diff changeset
   118
static image_info_t	image_info = {B_FALSE, 4096, 1.0, "off"};
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   119
405
785221d05f6b 4195 need to make changes to AI Engine for SPARC
William Schumann <william.schumann@sun.com>
parents: 389
diff changeset
   120
extern	char		**environ;
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
   121
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   122
/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   123
 * local functions
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   124
 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   125
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   126
static char 	*find_state_file();
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   127
static void	remove_component(char *path);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   128
static void 	set_system_state(void);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   129
static int	trav_link(char **path);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   130
static void 	write_sysid_state(sys_config *sysconfigp);
94
fd4991588edd 1010 - Target Instantiation progress doesn't display in GUI
William Schumann <william.schumann@sun.com>
parents: 91
diff changeset
   131
static void	notify_error_status(int status);
fd4991588edd 1010 - Target Instantiation progress doesn't display in GUI
William Schumann <william.schumann@sun.com>
parents: 91
diff changeset
   132
static void	notify_install_complete();
229
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
   133
static int	call_transfer_module(
272
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
   134
    nvlist_t		**transfer_attr,
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
   135
    uint_t		transfer_attr_num,
229
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
   136
    char		*target_dir,
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
   137
    char		*hostname,
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
   138
    char		*uname,
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
   139
    char		*lname,
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
   140
    char		*upasswd,
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
   141
    char		*rpasswd,
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
   142
    om_callback_t	cb);
344
f6279fc734cf 4871 ICT failures are not reported as a failed installation
Joseph J Vlcek <Joseph.Vlcek@Sun.COM>
parents: 332
diff changeset
   143
static int	run_install_finish_script(
229
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
   144
    char		*target_dir,
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
   145
    char		*uname,
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
   146
    char		*lname,
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
   147
    char		*upasswd,
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
   148
    char		*rpasswd);
217
75a649a169f5 1008 Installer should completely unmount target/BE before it quits
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 208
diff changeset
   149
static void	setup_etc_vfstab_for_swap(char *target);
635
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   150
static int	reset_zfs_mount_property(char *target, int transfer_mode);
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
   151
static void	activate_be(char *be_name);
68
02c453401f20 910 - Progress bar text specified in back-end module
William Schumann <william.schumann@sun.com>
parents: 63
diff changeset
   152
static void	handle_TM_callback(const int percent, const char *message);
405
785221d05f6b 4195 need to make changes to AI Engine for SPARC
William Schumann <william.schumann@sun.com>
parents: 389
diff changeset
   153
static int	prepare_zfs_root_pool_attrs(nvlist_t **attrs, char *disk_name,
785221d05f6b 4195 need to make changes to AI Engine for SPARC
William Schumann <william.schumann@sun.com>
parents: 389
diff changeset
   154
    uint8_t slice_id);
191
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   155
static int	prepare_zfs_volume_attrs(nvlist_t **attrs,
208
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
   156
    uint64_t available_disk_space, boolean_t create_min_swap_only);
98
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
   157
static int	prepare_be_attrs(nvlist_t **attrs);
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
   158
static int	obtain_image_info(image_info_t *info);
282
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   159
static char	*get_dataset_property(char *dataset_name, char *property);
191
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   160
static uint64_t	get_available_disk_space(void);
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   161
static uint64_t get_recommended_size_for_software(void);
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   162
static uint32_t	get_mem_size(void);
538
914d2f79d86c 7838 Log installer build number and installed software build number in install_log
Evan Layton <Evan.Layton@Sun.COM>
parents: 531
diff changeset
   163
static void	log_bld_info(char *, char *);
191
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   164
static uint64_t	calc_swap_size(uint64_t available_swap_space);
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   165
static uint64_t	calc_dump_size(uint64_t available_dump_space);
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   166
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   167
void 		*do_transfer(void *arg);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   168
void		*do_ti(void *args);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   169
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   170
/*
635
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   171
 * om_unmount_target_be
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   172
 * Unmounts target boot environment using be_unmount() API. Only non-shared
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   173
 * datasets are handled here.
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   174
 *
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   175
 * Input:	none
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   176
 * Output:	none
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   177
 *
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   178
 * Return:	OM_SUCCESS, if BE was successfully unmounted
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   179
 *		OM_FAILURE, if BE couldn't be unmounted for some reason
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   180
 */
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   181
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   182
int
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   183
om_unmount_target_be(void)
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   184
{
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   185
	nvlist_t	*be_attrs;
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   186
	int		ret;
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   187
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   188
	/*
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   189
	 * Populate nv list holding BE attributes
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   190
	 */
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   191
	if (nvlist_alloc(&be_attrs, NV_UNIQUE_NAME, 0) != 0) {
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   192
		om_log_print("Couldn't create nv list for be_unmount().\n");
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   193
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   194
		return (OM_FAILURE);
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   195
	}
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   196
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   197
	if (nvlist_add_string(be_attrs, BE_ATTR_ORIG_BE_NAME,
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   198
	    INIT_BE_NAME) != 0) {
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   199
		om_log_print("Couldn't add BE name to nv list.\n");
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   200
		nvlist_free(be_attrs);
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   201
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   202
		return (OM_FAILURE);
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   203
	}
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   204
846
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   205
	if ((ret = be_unmount(be_attrs)) != BE_SUCCESS) {
635
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   206
		om_log_print("Couldn't unmount target BE,"
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   207
		    " be_unmount() failed with return code %d\n", ret);
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   208
		nvlist_free(be_attrs);
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   209
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   210
		return (OM_FAILURE);
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   211
	}
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   212
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   213
	nvlist_free(be_attrs);
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   214
	return (OM_SUCCESS);
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   215
}
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   216
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   217
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   218
/*
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   219
 * om_perform_install
272
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
   220
 * This function, called primarily from the GUI Installer or the Automated
282
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   221
 * Installer (AI), will setup configuration and call install/upgrade
272
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
   222
 * function(s).
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
   223
 *
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   224
 * Input:	nvlist_t *uchoices - The user choices will be provided as
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   225
 *		name-value pairs
272
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
   226
 *		void *cb - callback function to inform the Installer about
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   227
 *		the progress.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   228
 * Output:	None
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   229
 * Return:	OM_SUCCESS, if the install program started succcessfully
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   230
 *		OM_FAILURE, if the there is a failure
272
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
   231
 * Notes:	The user selected configuration is passed from the Installer
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
   232
 *		in the form of name-value pairs
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   233
 *		The current values passed are:
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   234
 *		install_type - uint8_t (initial_install/upgrade)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   235
 *		disk name - String (only for initial_install- example c0d0)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   236
 *		upgrade target - String (only for upgrade - example c0d0s0)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   237
 *		list of locales to be installed - String
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   238
 *		default locale - String
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   239
 *		user name - String - The name of the user account to be created
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   240
 *		user password - String - user password
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   241
 *		root password - String - root password
272
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
   242
 *
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
   243
 *              The Installer optionally also specifies the transfer mode
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
   244
 *              desired (IPS or CPIO) in the form of name-value pairs.
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   245
 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   246
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   247
int
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   248
om_perform_install(nvlist_t *uchoices, om_callback_t cb)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   249
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   250
	char		*name;
846
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   251
	char		*lname = EMPTY_STR;
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   252
	char		*rpasswd = OM_DEFAULT_ROOT_PASSWORD;
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   253
	char		*hostname = EMPTY_STR;
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   254
	char		*uname = EMPTY_STR;
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   255
	char		*upasswd = OM_DEFAULT_USER_PASSWORD;
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   256
	int		status = OM_SUCCESS;
272
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
   257
	nvlist_t	*target_attrs = NULL, **transfer_attr;
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
   258
	uint_t		transfer_attr_num;
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   259
	uint8_t		type;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   260
	char		*ti_test = getenv("TI_SLIM_TEST");
846
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   261
	char		*nv_string;
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   262
	int		ret = 0;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   263
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   264
	if (uchoices == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   265
		om_set_error(OM_BAD_INPUT);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   266
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   267
	if (!ti_test) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   268
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   269
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   270
	 * Get the install_type
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   271
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   272
	if (nvlist_lookup_uint8(uchoices,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   273
	    OM_ATTR_INSTALL_TYPE, &type) != 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   274
		om_set_error(OM_NO_INSTALL_TYPE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   275
		return (OM_FAILURE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   276
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   277
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   278
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   279
	 * Supports only initial_install and upgrade
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   280
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   281
	if (type != OM_INITIAL_INSTALL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   282
		om_set_error(OM_BAD_INSTALL_TYPE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   283
		return (OM_FAILURE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   284
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   285
	install_type = type;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   286
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   287
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   288
	 * Special value for testing
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   289
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   290
	if (nvlist_lookup_boolean_value(uchoices,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   291
	    OM_ATTR_INSTALL_TEST, (boolean_t *)&install_test) != 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   292
		install_test = B_FALSE;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   293
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   294
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   295
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   296
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   297
	 * Now process initial install
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   298
	 * Get the disk name - Install target
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   299
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   300
	if (nvlist_lookup_string(uchoices, OM_ATTR_DISK_NAME, &name) != 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   301
		om_set_error(OM_NO_INSTALL_TARGET);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   302
		return (OM_FAILURE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   303
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   304
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   305
	if (!is_diskname_valid(name)) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   306
		om_set_error(OM_BAD_INSTALL_TARGET);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   307
		return (OM_FAILURE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   308
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   309
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   310
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   311
	 * For initial install, set up the following things.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   312
	 * 1. Timezone
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   313
	 * 2. default locale
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   314
	 * 3. Root Password
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   315
	 * 4. User Name
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   316
	 * 5. User password
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   317
	 * 6. Host/nodename
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   318
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   319
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   320
	if (!ti_test) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   321
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   322
	 * Get the default locale. Save it off for later. We don't
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   323
	 * set the system default locale until after the installation
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   324
	 * has completed. XXX will Slim have this set from GUI?
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   325
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   326
	if (nvlist_lookup_string(uchoices,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   327
	    OM_ATTR_DEFAULT_LOCALE, &def_locale) != 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   328
		/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   329
		 * Default locale is not passed, so don't set it
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   330
		 * Log the information and continue
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   331
		 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   332
		om_debug_print(OM_DBGLVL_WARN, "OM_ATTR_DEFAULT_LOCALE not set,"
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   333
		    "default locale is null\n");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   334
		om_log_print("Default locale is NULL\n");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   335
		def_locale = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   336
	} else {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   337
		om_debug_print(OM_DBGLVL_INFO, "Default locale specified: %s\n",
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   338
		    def_locale);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   339
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   340
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   341
	/*
846
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   342
	 * In case of automated installation (AI), user and root accounts
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   343
	 * are configured on installed system at the first boot
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   344
	 * by svc:/system/install/config SMF service. Thus for AI scenario,
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   345
	 * just skip dealing with this kind of configuration in the installer.
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   346
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   347
846
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   348
	if (!om_is_automated_installation()) {
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   349
		/*
846
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   350
		 * Get the root password
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   351
		 */
846
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   352
		if (nvlist_lookup_string(uchoices,
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   353
		    OM_ATTR_ROOT_PASSWORD, &nv_string) != 0) {
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   354
			/*
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   355
			 * Root password is not passed, so don't set it,
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   356
			 * just log the information.
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   357
			 */
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   358
			om_debug_print(OM_DBGLVL_WARN, "OM_ATTR_ROOT_PASSWORD "
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   359
			    " not set, set the default root password\n");
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   360
			om_log_print("Root password not specified, set to "
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   361
			    " default\n");
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   362
		} else {
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   363
			rpasswd = nv_string;
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   364
			om_debug_print(OM_DBGLVL_INFO, "Got root passwd\n");
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   365
		}
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   366
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   367
		/*
846
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   368
		 * Get the user name,if set, which is different than the login
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   369
		 * name.
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   370
		 */
229
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
   371
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   372
		if (nvlist_lookup_string(uchoices,
846
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   373
		    OM_ATTR_USER_NAME, &nv_string) != 0) {
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   374
			/*
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   375
			 * User name is not passed, so don't set it
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   376
			 * Log the information and continue
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   377
			 */
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   378
			om_debug_print(OM_DBGLVL_WARN, "OM_ATTR_USER_NAME "
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   379
			    "not set, User name not available\n");
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   380
			om_log_print("User name not specified\n");
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   381
		} else {
846
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   382
			uname = nv_string;
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   383
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   384
			om_debug_print(OM_DBGLVL_INFO, "User name set to "
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   385
			    "%s\n", uname);
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   386
		}
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   387
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   388
		if (nvlist_lookup_string(uchoices, OM_ATTR_LOGIN_NAME,
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   389
		    &nv_string) != 0) {
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   390
			/*
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   391
			 * No login name, don't worry about getting passwd info.
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   392
			 * Log this data and move on.
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   393
			 */
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   394
			om_debug_print(OM_DBGLVL_WARN,
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   395
			    "OM_ATTR_LOGIN_NAME not set,"
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   396
			    "User login name not available\n");
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   397
			om_log_print("User login name not specified\n");
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   398
		} else {
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   399
			lname = nv_string;
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   400
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   401
			/*
846
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   402
			 * User account will be created - count in shared ZFS
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   403
			 * dataset which will be created for user's
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   404
			 * home directory
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   405
			 */
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   406
			l_zfs_shared_fs_num++;
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   407
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   408
			/*
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   409
			 * we got the user name.
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   410
			 * Get the password
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   411
			 */
846
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   412
			om_debug_print(OM_DBGLVL_INFO, "User login name set to "
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   413
			    "%s\n", lname);
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   414
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   415
			(void) snprintf(zfs_shared_user_login,
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   416
			    sizeof (zfs_shared_user_login),
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   417
			    "/export/home/%s", lname);
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   418
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   419
			om_debug_print(OM_DBGLVL_INFO, "zfs shared user login "
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   420
			    "set to %s\n", zfs_shared_user_login);
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   421
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   422
			if (nvlist_lookup_string(uchoices,
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   423
			    OM_ATTR_USER_PASSWORD, &nv_string) == 0) {
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   424
				upasswd = nv_string;
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   425
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   426
				/*
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   427
				 * Got user name and password
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   428
				 */
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   429
				om_debug_print(OM_DBGLVL_INFO,
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   430
				    "Got user password\n");
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   431
			}
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   432
		}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   433
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   434
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   435
	if (nvlist_lookup_string(uchoices, OM_ATTR_HOST_NAME,
846
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   436
	    &nv_string) != 0) {
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   437
		/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   438
		 * User has cleared default host name for some reason.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   439
		 * NWAM will use dhcp so a dhcp address will become
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   440
		 * the host/nodename.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   441
		 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   442
		om_debug_print(OM_DBGLVL_WARN, "OM_ATTR_HOST_NAME "
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   443
		    "not set,"
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   444
		    "User probably cleared default host name\n");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   445
	} else {
846
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
   446
		hostname = nv_string;
229
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
   447
		/*
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
   448
		 * Hostname will be set in function call_transfer_module
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
   449
		 * using ICT ict_set_host_node_name
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
   450
		 */
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
   451
		om_debug_print(OM_DBGLVL_INFO, "Hostname will be to %s\n",
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   452
		    hostname);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   453
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   454
789
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   455
	/* Get requested swap size if specified */
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   456
	if (nvlist_lookup_int32(uchoices,
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   457
	    OM_ATTR_SWAP_SIZE, &requested_swap_size) != 0) {
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   458
		requested_swap_size = -1;
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   459
		om_debug_print(OM_DBGLVL_INFO, "Swap size not requested.\n");
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   460
	} else {
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   461
		om_debug_print(OM_DBGLVL_INFO,
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   462
		    "Requested swap size : %ld.\n", requested_swap_size);
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   463
	}
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   464
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   465
	/* Get requested dump device size if specified */
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   466
	if (nvlist_lookup_int32(uchoices,
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   467
	    OM_ATTR_DUMP_SIZE, &requested_dump_size) != 0) {
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   468
		requested_dump_size = -1;
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   469
		om_debug_print(OM_DBGLVL_INFO, "Dump size not requested.\n");
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   470
	} else {
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   471
		om_debug_print(OM_DBGLVL_INFO,
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   472
		    "Requested dump size : %ld.\n", requested_dump_size);
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   473
	}
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   474
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   475
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   476
	 * The .sysIDtool.state file needs to be written before the
566
3d7530f2d94f 789 Remove the pfinstall references in liborchestrator
Jean McCormack <Jean.McCormack@Sun.COM>
parents: 549
diff changeset
   477
	 * install completes. Update the state here for install.
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   478
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   479
	set_system_state();
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   480
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   481
	 * Setup install targets. Set the global orchestrator callback
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   482
	 * value for use later. Ick.. this is ugly, but for now, until
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   483
	 * TI is finalized we need a way to translate the TI->OM
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   484
	 * callbacks.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   485
	 *
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   486
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   487
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   488
	if (cb) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   489
		om_cb = cb;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   490
	}
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
   491
	if (nvlist_alloc(&target_attrs, TI_TARGET_NVLIST_TYPE, 0) != 0) {
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   492
		om_log_print("Could not create target list.\n");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   493
		return (OM_NO_SPACE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   494
	}
405
785221d05f6b 4195 need to make changes to AI Engine for SPARC
William Schumann <william.schumann@sun.com>
parents: 389
diff changeset
   495
#ifndef	__sparc
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   496
	/*
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
   497
	 * Set fdisk configuration attributes
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   498
	 */
363
130c19a9f4de 4233 target instantiation gets called multiple times which results in installation failure
William Schumann <william.schumann@sun.com>
parents: 354
diff changeset
   499
	if (om_set_fdisk_target_attrs(target_attrs, name) != 0) {
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   500
		om_log_print("Couldn't set fdisk attributes.\n");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   501
		nvlist_free(target_attrs);
633
e631367ff83d 12459 AI hangs if "Disk doesn't contain valid Solaris partition"
William Schumann <william.schumann@sun.com>
parents: 566
diff changeset
   502
		return (OM_FAILURE);
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   503
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   504
	om_log_print("Set fdisk attrs\n");
405
785221d05f6b 4195 need to make changes to AI Engine for SPARC
William Schumann <william.schumann@sun.com>
parents: 389
diff changeset
   505
#endif
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
   506
	/*
282
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   507
	 * If installer was restarted after the failure, it is necessary
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   508
	 * to destroy the pool previously created by the installer.
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   509
	 *
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   510
	 * If there is a root pool manually imported by the user with
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   511
	 * the same name which will be finally picked up by installer
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   512
	 * for target root pool, there is nothing we can do at this point.
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   513
	 * Log warning message and exit.
98
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
   514
	 */
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
   515
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
   516
	ret = td_safe_system("/usr/sbin/zpool list " ROOTPOOL_NAME, B_TRUE);
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
   517
	if ((ret == -1) || WEXITSTATUS(ret) != 0) {
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
   518
		om_debug_print(OM_DBGLVL_INFO, "Root pool " ROOTPOOL_NAME
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
   519
		    " doesn't exist\n");
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
   520
	} else {
282
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   521
		char		*rpool_property;
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   522
		nvlist_t	*ti_attrs;
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   523
		ti_errno_t	ti_status;
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   524
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   525
		/*
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   526
		 * If ZFS pool was created by the installer and not finalized,
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   527
		 * it can be safely removed and installation can proceed.
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   528
		 */
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   529
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   530
		rpool_property = get_dataset_property(ROOT_DATASET_NAME,
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   531
		    TI_RPOOL_PROPERTY_STATE);
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   532
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   533
		om_debug_print(OM_DBGLVL_INFO, "%s %s: %s\n",
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   534
		    ROOT_DATASET_NAME, TI_RPOOL_PROPERTY_STATE,
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   535
		    rpool_property != NULL ? rpool_property : "not defined");
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   536
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   537
		/*
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   538
		 * If property can't be obtained, it must be assumed that
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   539
		 * root pool contains valid Solaris instance, otherwise
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   540
		 * installer might destroy older Solaris release which didn't
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   541
		 * support that feature.
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   542
		 */
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   543
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   544
		if ((rpool_property == NULL) ||
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   545
		    strcmp(rpool_property, TI_RPOOL_BUSY) != 0) {
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   546
			om_log_print("Root pool " ROOTPOOL_NAME " exists,"
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   547
			    " we can't proceed with the installation\n");
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   548
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   549
			om_set_error(OM_ZFS_ROOT_POOL_EXISTS);
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   550
			return (OM_FAILURE);
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   551
		}
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   552
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   553
		om_log_print("Root pool " ROOTPOOL_NAME " doesn't "
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   554
		    "contain valid Solaris instance, it will be "
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   555
		    "released\n");
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   556
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   557
		if (nvlist_alloc(&ti_attrs, TI_TARGET_NVLIST_TYPE, 0) != 0) {
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   558
			om_log_print("Could not create target list.\n");
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   559
			om_set_error(OM_NO_SPACE);
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   560
			return (OM_FAILURE);
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   561
		}
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   562
405
785221d05f6b 4195 need to make changes to AI Engine for SPARC
William Schumann <william.schumann@sun.com>
parents: 389
diff changeset
   563
		if (prepare_zfs_root_pool_attrs(&ti_attrs, name, 0) !=
282
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   564
		    OM_SUCCESS) {
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   565
			om_log_print("Could not prepare ZFS root pool "
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   566
			    "attribute set\n");
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   567
			nvlist_free(ti_attrs);
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   568
			return (OM_FAILURE);
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   569
		}
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   570
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   571
		ti_status = ti_release_target(ti_attrs);
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   572
		nvlist_free(ti_attrs);
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   573
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   574
		if (ti_status != TI_E_SUCCESS) {
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   575
			om_log_print("Couldn't release ZFS root pool "
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   576
			    ROOTPOOL_NAME "\n");
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   577
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   578
			om_set_error(OM_ZFS_ROOT_POOL_EXISTS);
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   579
			return (OM_FAILURE);
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   580
		}
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   581
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   582
		/*
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   583
		 * Finally, clean up target mount point
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   584
		 */
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   585
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   586
		om_log_print("Cleaning up target mount point "
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   587
		    INSTALLED_ROOT_DIR "\n");
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   588
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   589
		(void) td_safe_system("/usr/bin/rm -fr "
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   590
		    INSTALLED_ROOT_DIR "/*", B_TRUE);
98
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
   591
	}
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
   592
459
56b6b042a167 5653 AI manifest should offer keyword to use max available space for partition/slice
William Schumann <william.schumann@sun.com>
parents: 447
diff changeset
   593
	if (om_breakpoint == OM_breakpoint_before_TI) {
56b6b042a167 5653 AI manifest should offer keyword to use max available space for partition/slice
William Schumann <william.schumann@sun.com>
parents: 447
diff changeset
   594
		om_log_std(LS_STDERR,
56b6b042a167 5653 AI manifest should offer keyword to use max available space for partition/slice
William Schumann <william.schumann@sun.com>
parents: 447
diff changeset
   595
		    "Breakpoint requested before Target Instantiation."
56b6b042a167 5653 AI manifest should offer keyword to use max available space for partition/slice
William Schumann <william.schumann@sun.com>
parents: 447
diff changeset
   596
		    " Installer exiting.\n");
56b6b042a167 5653 AI manifest should offer keyword to use max available space for partition/slice
William Schumann <william.schumann@sun.com>
parents: 447
diff changeset
   597
		exit(0);
56b6b042a167 5653 AI manifest should offer keyword to use max available space for partition/slice
William Schumann <william.schumann@sun.com>
parents: 447
diff changeset
   598
	}
98
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
   599
	/*
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
   600
	 * Start a thread to call TI module for fdisk & vtoc targets.
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   601
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   602
94
fd4991588edd 1010 - Target Instantiation progress doesn't display in GUI
William Schumann <william.schumann@sun.com>
parents: 91
diff changeset
   603
	ti_ret = pthread_create(&ti_thread, NULL, do_ti, target_attrs);
fd4991588edd 1010 - Target Instantiation progress doesn't display in GUI
William Schumann <william.schumann@sun.com>
parents: 91
diff changeset
   604
	if (ti_ret != 0) {
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   605
		om_set_error(OM_ERROR_THREAD_CREATE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   606
		return (OM_FAILURE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   607
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   608
272
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
   609
	if (nvlist_lookup_nvlist_array(uchoices, OM_ATTR_TRANSFER,
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
   610
	    &transfer_attr, &transfer_attr_num) != 0) {
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
   611
		transfer_attr = NULL;
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
   612
	}
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
   613
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   614
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   615
	 * Start the install.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   616
	 */
272
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
   617
	if (call_transfer_module(transfer_attr, transfer_attr_num,
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
   618
	    INSTALLED_ROOT_DIR, hostname, uname, lname, upasswd,
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
   619
	    rpasswd, cb) != OM_SUCCESS) {
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   620
		om_log_print("Initial install failed\n");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   621
		status = OM_FAILURE;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   622
		om_set_error(OM_INITIAL_INSTALL_FAILED);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   623
		goto install_return;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   624
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   625
	om_debug_print(OM_DBGLVL_INFO, "om_perform_install() returned"
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   626
	    " success. The install is started\n");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   627
install_return:
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   628
	return (status);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   629
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   630
191
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   631
/*
495
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   632
 * perform transfer based on an ordered attribute list of initializers
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   633
 * followed by the transfer action itself
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   634
 *
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   635
 * Parameters:
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   636
 *   nvl - null-terminated list of nvlists with IPS parameters
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   637
 *   prog - progress callback information
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   638
 *
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   639
 * Returns:
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   640
 *   OM_SUCCESS - all IPS operations succeeded
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   641
 *   OM_FAILURE - IPS failed
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   642
 */
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   643
static int
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   644
om_perform_transfer_ips(nvlist_t **nvl, tm_callback_t prog)
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   645
{
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   646
	int		status;
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   647
	int		iattr;
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   648
	uint32_t	ips_action;
635
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   649
	boolean_t	ips_init_message_logged = B_FALSE;
495
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   650
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   651
	om_log_print("IPS transfer phase initiated\n");
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   652
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   653
	/*
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   654
	 * Go through array of nvlists (NULL terminated) and
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   655
	 * invoke transfer module for each IPS phase
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   656
	 */
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   657
	for (iattr = 0; nvl[iattr] != NULL; iattr++) {
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   658
		if (nvlist_lookup_uint32(nvl[iattr], TM_IPS_ACTION,
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   659
		    &ips_action) != 0) {
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   660
			om_log_print("Couldn't obtain information about "
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   661
			    "IPS action\n");
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   662
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   663
			return (OM_FAILURE);
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   664
		}
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   665
635
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   666
		/* inform user about next IPS phase */
495
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   667
		switch (ips_action) {
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   668
		/* installing packages */
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   669
		case TM_IPS_RETRIEVE:
635
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   670
			om_log_print("Installing pkg(5) packages...\n");
495
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   671
			break;
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   672
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   673
		/* removing packages */
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   674
		case TM_IPS_UNINSTALL:
635
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   675
			om_log_print("Uninstalling pkg(5) packages...\n");
495
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   676
			break;
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   677
635
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   678
		/*
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   679
		 * Everything else is initialization phase.
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   680
		 * Report it only once.
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   681
		 */
495
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   682
		default:
635
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   683
			if (!ips_init_message_logged) {
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   684
				ips_init_message_logged = B_TRUE;
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   685
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   686
				om_log_print("Creating and configuring pkg(5)"
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   687
				    " image area...\n");
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   688
			}
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   689
495
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   690
			break;
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   691
		}
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   692
635
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   693
		/* carry out IPS operation */
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   694
		status = TM_perform_transfer(nvl[iattr], prog);
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   695
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   696
		/*
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   697
		 * If particular IPS operation failed, report
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   698
		 * the failure and abort transfer process.
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   699
		 * More details were already provided and logged
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   700
		 * by transfer module.
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   701
		 */
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   702
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   703
		if (status != TM_SUCCESS) {
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
   704
			om_log_print("IPS transfer phase failed\n");
495
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   705
			return (OM_FAILURE);
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   706
		}
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   707
	}
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   708
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   709
	om_log_print("IPS transfer phase finished successfully\n");
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   710
	return (OM_SUCCESS);
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   711
}
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   712
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
   713
/*
191
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   714
 * get_mem_size
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   715
 * Function obtains information about amount of physical memory
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   716
 * installed. If it can't be determined, 0 is returned.
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   717
 *
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   718
 * Output:	size of physical memory in MiB, 0 if it can't be determined
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   719
 */
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   720
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   721
static uint32_t
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   722
get_mem_size(void)
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   723
{
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   724
	long		pages;
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   725
	uint64_t	page_size = PAGESIZE;
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   726
	uint32_t	mem_size;
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   727
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   728
	if ((pages = sysconf(_SC_PHYS_PAGES)) == -1) {
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   729
		om_debug_print(OM_DBGLVL_WARN,
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   730
		    "Couldn't obtain size of physical memory\n");
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   731
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   732
		return (0);
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   733
	}
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   734
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   735
	mem_size = (pages * page_size)/ONE_MB_TO_BYTE;
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   736
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   737
	om_debug_print(OM_DBGLVL_INFO,
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   738
	    "Size of physical memory: %lu MiB\n", mem_size);
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   739
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   740
	return (mem_size);
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   741
}
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   742
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   743
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   744
/*
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   745
 * calc_swap_size
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   746
 *
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   747
 * Function calculates size of swap in MiB based on amount of
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   748
 * physical memory available.
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   749
 *
789
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   750
 * If requested swap size is specified, attempt to use it.
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   751
 *
191
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   752
 * If size of memory can't be determined, minimum swap is returned.
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   753
 * If less than calculated space is available, swap size will
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   754
 * be adjusted (trimmed down to available disk space)
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   755
 *
879
b65e82e368f5 6978639 Default net AI install on x86 with 1GB or less memory no longer works when installing from /dev repo
Ethan Quach <Ethan.Quach@sun.com>
parents: 861
diff changeset
   756
 * Will always return a minimum MIN_SWAP_SIZE regardless of
789
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   757
 * available space or requested size.
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   758
 *
879
b65e82e368f5 6978639 Default net AI install on x86 with 1GB or less memory no longer works when installing from /dev repo
Ethan Quach <Ethan.Quach@sun.com>
parents: 861
diff changeset
   759
 * memory	swap
b65e82e368f5 6978639 Default net AI install on x86 with 1GB or less memory no longer works when installing from /dev repo
Ethan Quach <Ethan.Quach@sun.com>
parents: 861
diff changeset
   760
 * -----------------------------------------------
b65e82e368f5 6978639 Default net AI install on x86 with 1GB or less memory no longer works when installing from /dev repo
Ethan Quach <Ethan.Quach@sun.com>
parents: 861
diff changeset
   761
 * <64G		MAX( (2G - memory), (1/2 of memory) )
b65e82e368f5 6978639 Default net AI install on x86 with 1GB or less memory no longer works when installing from /dev repo
Ethan Quach <Ethan.Quach@sun.com>
parents: 861
diff changeset
   762
 * >64G		32G
b65e82e368f5 6978639 Default net AI install on x86 with 1GB or less memory no longer works when installing from /dev repo
Ethan Quach <Ethan.Quach@sun.com>
parents: 861
diff changeset
   763
 *
b65e82e368f5 6978639 Default net AI install on x86 with 1GB or less memory no longer works when installing from /dev repo
Ethan Quach <Ethan.Quach@sun.com>
parents: 861
diff changeset
   764
 * Below is a table with some example values.
b65e82e368f5 6978639 Default net AI install on x86 with 1GB or less memory no longer works when installing from /dev repo
Ethan Quach <Ethan.Quach@sun.com>
parents: 861
diff changeset
   765
 * 
b65e82e368f5 6978639 Default net AI install on x86 with 1GB or less memory no longer works when installing from /dev repo
Ethan Quach <Ethan.Quach@sun.com>
parents: 861
diff changeset
   766
 * memory	swap
b65e82e368f5 6978639 Default net AI install on x86 with 1GB or less memory no longer works when installing from /dev repo
Ethan Quach <Ethan.Quach@sun.com>
parents: 861
diff changeset
   767
 * ------------------
b65e82e368f5 6978639 Default net AI install on x86 with 1GB or less memory no longer works when installing from /dev repo
Ethan Quach <Ethan.Quach@sun.com>
parents: 861
diff changeset
   768
 * 512MB	(ufs slice)
b65e82e368f5 6978639 Default net AI install on x86 with 1GB or less memory no longer works when installing from /dev repo
Ethan Quach <Ethan.Quach@sun.com>
parents: 861
diff changeset
   769
 * 786MB	1.26G
b65e82e368f5 6978639 Default net AI install on x86 with 1GB or less memory no longer works when installing from /dev repo
Ethan Quach <Ethan.Quach@sun.com>
parents: 861
diff changeset
   770
 * 1024MB	1G
b65e82e368f5 6978639 Default net AI install on x86 with 1GB or less memory no longer works when installing from /dev repo
Ethan Quach <Ethan.Quach@sun.com>
parents: 861
diff changeset
   771
 * 1280MB	721MB
b65e82e368f5 6978639 Default net AI install on x86 with 1GB or less memory no longer works when installing from /dev repo
Ethan Quach <Ethan.Quach@sun.com>
parents: 861
diff changeset
   772
 * 1536MB	767MB
b65e82e368f5 6978639 Default net AI install on x86 with 1GB or less memory no longer works when installing from /dev repo
Ethan Quach <Ethan.Quach@sun.com>
parents: 861
diff changeset
   773
 * 1792MB	895MB
b65e82e368f5 6978639 Default net AI install on x86 with 1GB or less memory no longer works when installing from /dev repo
Ethan Quach <Ethan.Quach@sun.com>
parents: 861
diff changeset
   774
 * 2048MB	1G
191
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   775
 *
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   776
 * Input:	available_swap_space - disk space which can be used for swap
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   777
 *
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   778
 * Output:	size of swap in MiB
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   779
 */
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   780
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   781
static uint64_t
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   782
calc_swap_size(uint64_t available_swap_space)
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   783
{
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   784
	uint32_t	mem_size;
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   785
	uint64_t	swap_size;
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   786
789
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   787
	if (requested_swap_size > 0) {
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   788
		/* Swap specified in install paramaters */
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   789
		swap_size = requested_swap_size;
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   790
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   791
		om_debug_print(OM_DBGLVL_INFO,
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   792
		    "Calculated swap size: %llu MiB (requested)\n", swap_size);
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   793
	} else {
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   794
		/* Get amount of RAM in MB */
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   795
		if ((mem_size = get_mem_size()) == 0) {
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   796
			om_debug_print(OM_DBGLVL_WARN,
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   797
			    "Couldn't obtain size of physical memory,"
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   798
			    "swap size will be set to %dMiB\n", MIN_SWAP_SIZE);
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   799
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   800
			return (MIN_SWAP_SIZE);
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   801
		}
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   802
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   803
		/* Default swap size to half of system RAM */
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   804
		swap_size = mem_size / 2;
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   805
879
b65e82e368f5 6978639 Default net AI install on x86 with 1GB or less memory no longer works when installing from /dev repo
Ethan Quach <Ethan.Quach@sun.com>
parents: 861
diff changeset
   806
		/*
b65e82e368f5 6978639 Default net AI install on x86 with 1GB or less memory no longer works when installing from /dev repo
Ethan Quach <Ethan.Quach@sun.com>
parents: 861
diff changeset
   807
		 * Ensure swap_size is at least the size of the calculated
b65e82e368f5 6978639 Default net AI install on x86 with 1GB or less memory no longer works when installing from /dev repo
Ethan Quach <Ethan.Quach@sun.com>
parents: 861
diff changeset
   808
		 * required swap size.
b65e82e368f5 6978639 Default net AI install on x86 with 1GB or less memory no longer works when installing from /dev repo
Ethan Quach <Ethan.Quach@sun.com>
parents: 861
diff changeset
   809
		 */
b65e82e368f5 6978639 Default net AI install on x86 with 1GB or less memory no longer works when installing from /dev repo
Ethan Quach <Ethan.Quach@sun.com>
parents: 861
diff changeset
   810
		if (swap_size < calc_required_swap_size())
b65e82e368f5 6978639 Default net AI install on x86 with 1GB or less memory no longer works when installing from /dev repo
Ethan Quach <Ethan.Quach@sun.com>
parents: 861
diff changeset
   811
			swap_size = calc_required_swap_size();
b65e82e368f5 6978639 Default net AI install on x86 with 1GB or less memory no longer works when installing from /dev repo
Ethan Quach <Ethan.Quach@sun.com>
parents: 861
diff changeset
   812
789
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   813
		om_debug_print(OM_DBGLVL_INFO,
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   814
		    "Calculated swap size: %llu MiB (default)\n", swap_size);
191
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   815
	}
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   816
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   817
	/*
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   818
	 * If there is less disk space available on target which
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   819
	 * can be dedicated to swap device, adjust the swap size
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   820
	 * accordingly.
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   821
	 */
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   822
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   823
	om_debug_print(OM_DBGLVL_INFO,
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   824
	    "available_swap_space=%llu MiB\n", available_swap_space);
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   825
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   826
	if (available_swap_space < swap_size)
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   827
		swap_size = available_swap_space;
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   828
789
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   829
	if (requested_swap_size > 0) {
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   830
		/* If user specified size, just ensure it's at least 1MB */
807
0fc85ff363a2 15568 Checking unsigned int for value < 0 in liborchestrator
Matt Keenan <matt.keenan@oracle.com>
parents: 789
diff changeset
   831
		if (swap_size < 1)
789
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   832
			swap_size = 1;
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   833
	} else {
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   834
		swap_size =
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   835
		    limit_min_max(swap_size, MIN_SWAP_SIZE, MAX_SWAP_SIZE);
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   836
	}
191
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   837
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   838
	om_debug_print(OM_DBGLVL_INFO,
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   839
	    "Adjusted swap size: %llu MiB\n", swap_size);
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   840
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   841
	return (swap_size);
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   842
}
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   843
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   844
/*
208
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
   845
 * calc_required_swap_size
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
   846
 *
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
   847
 * Function calculates size of swap in MiB which is required
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
   848
 * in order to run installer successfully.
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
   849
 *
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
   850
 * If there is less than SWAP_MIN_MEMORY_SIZE amount of physical
354
2c1eaf565c25 3597 Unable to install OpenSolaris with 512 MB base memory
Glenn Lagasse <Glenn.Lagasse@Sun.COM>
parents: 344
diff changeset
   851
 * memory available, swap will be mandatory.  If there is less
2c1eaf565c25 3597 Unable to install OpenSolaris with 512 MB base memory
Glenn Lagasse <Glenn.Lagasse@Sun.COM>
parents: 344
diff changeset
   852
 * than SWAP_MIN_MEMORY_SIZE_CREATE_SLICE, swap will be mandatory
2c1eaf565c25 3597 Unable to install OpenSolaris with 512 MB base memory
Glenn Lagasse <Glenn.Lagasse@Sun.COM>
parents: 344
diff changeset
   853
 * and a vtoc slice will be created for swap instead of a zvol.
208
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
   854
 *
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
   855
 * Output:	size of required swap in MiB
539
2d996f9b841a 7758 AI install always fails after swap slice is created
William Schumann <william.schumann@sun.com>
parents: 538
diff changeset
   856
 * Side effect:
2d996f9b841a 7758 AI install always fails after swap slice is created
William Schumann <william.schumann@sun.com>
parents: 538
diff changeset
   857
 *	global boolean create_swap_size will be set to B_TRUE if swap slice
2d996f9b841a 7758 AI install always fails after swap slice is created
William Schumann <william.schumann@sun.com>
parents: 538
diff changeset
   858
 *		if a swap slice needs to be created
208
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
   859
 */
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
   860
354
2c1eaf565c25 3597 Unable to install OpenSolaris with 512 MB base memory
Glenn Lagasse <Glenn.Lagasse@Sun.COM>
parents: 344
diff changeset
   861
uint64_t
208
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
   862
calc_required_swap_size(void)
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
   863
{
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
   864
	static int	required_swap_size = -1;
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
   865
	uint32_t	mem;
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
   866
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
   867
	/* calculate it only once */
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
   868
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
   869
	if (required_swap_size != -1)
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
   870
		return ((uint64_t)required_swap_size);
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
   871
515
a143d4b29f8f 7788 Remove workaround fix - 7718
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 501
diff changeset
   872
	if ((mem = get_mem_size()) < SWAP_MIN_MEMORY_SIZE) {
208
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
   873
		om_log_print("System reports only %lu MB of physical memory, "
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
   874
		    "swap will be created\n", mem);
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
   875
879
b65e82e368f5 6978639 Default net AI install on x86 with 1GB or less memory no longer works when installing from /dev repo
Ethan Quach <Ethan.Quach@sun.com>
parents: 861
diff changeset
   876
		required_swap_size = SWAP_MIN_MEMORY_SIZE - mem;
354
2c1eaf565c25 3597 Unable to install OpenSolaris with 512 MB base memory
Glenn Lagasse <Glenn.Lagasse@Sun.COM>
parents: 344
diff changeset
   877
515
a143d4b29f8f 7788 Remove workaround fix - 7718
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 501
diff changeset
   878
		if (mem < SWAP_MIN_MEMORY_SIZE_CREATE_SLICE) {
354
2c1eaf565c25 3597 Unable to install OpenSolaris with 512 MB base memory
Glenn Lagasse <Glenn.Lagasse@Sun.COM>
parents: 344
diff changeset
   879
			om_log_print("Swap device will be created from a "
2c1eaf565c25 3597 Unable to install OpenSolaris with 512 MB base memory
Glenn Lagasse <Glenn.Lagasse@Sun.COM>
parents: 344
diff changeset
   880
			    "slice\n");
2c1eaf565c25 3597 Unable to install OpenSolaris with 512 MB base memory
Glenn Lagasse <Glenn.Lagasse@Sun.COM>
parents: 344
diff changeset
   881
2c1eaf565c25 3597 Unable to install OpenSolaris with 512 MB base memory
Glenn Lagasse <Glenn.Lagasse@Sun.COM>
parents: 344
diff changeset
   882
			create_swap_slice = B_TRUE;
2c1eaf565c25 3597 Unable to install OpenSolaris with 512 MB base memory
Glenn Lagasse <Glenn.Lagasse@Sun.COM>
parents: 344
diff changeset
   883
		}
2c1eaf565c25 3597 Unable to install OpenSolaris with 512 MB base memory
Glenn Lagasse <Glenn.Lagasse@Sun.COM>
parents: 344
diff changeset
   884
208
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
   885
	} else {
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
   886
		om_log_print("System reports enough physical memory "
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
   887
		    "for installation, swap is optional\n");
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
   888
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
   889
		required_swap_size = 0;
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
   890
	}
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
   891
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
   892
	return ((uint64_t)required_swap_size);
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
   893
}
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
   894
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
   895
/*
191
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   896
 * calc_dump_size
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   897
 *
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   898
 * Function calculates size of dump in MiB based on amount of
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   899
 * physical memory available.
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   900
 *
789
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   901
 * If requested dump size is specified, attempt to use it.
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   902
 *
191
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   903
 * If size of memory can't be determined, minimum dump is returned.
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   904
 * If less than calculated space is available, dump size will
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   905
 * be adjusted (trimmed down to available disk space)
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   906
 *
789
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   907
 * Will always return a mimimum MIN_DUMP_SIZE regardless of
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   908
 * available space or requested size.
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   909
 *
191
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   910
 * memory  dump
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   911
 * -------------
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   912
 *  <0,5G   256M
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   913
 *  0,5-32G 256M-16G (1/2 of memory)
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   914
 *  >32G    16G
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   915
 *
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   916
 * Input:	available_dump_space - disk space which can be used for swap
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   917
 *
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   918
 * Output:	size of dump in MiB
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   919
 */
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   920
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   921
static uint64_t
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   922
calc_dump_size(uint64_t available_dump_space)
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   923
{
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   924
	uint32_t	mem_size;
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   925
	uint64_t	dump_size;
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   926
789
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   927
	if (requested_dump_size > 0) {
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   928
		/* Dump specified in install paramaters */
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   929
		dump_size = requested_dump_size;
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   930
		om_debug_print(OM_DBGLVL_INFO,
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   931
		    "Calculated dump size: %llu MiB (requested)\n", dump_size);
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   932
	} else {
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   933
		/* Get amount of RAM in MB */
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   934
		if ((mem_size = get_mem_size()) == 0) {
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   935
			om_debug_print(OM_DBGLVL_WARN,
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   936
			    "Couldn't obtain size of physical memory,"
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   937
			    "dump size will be set to %dMiB\n", MIN_DUMP_SIZE);
879
b65e82e368f5 6978639 Default net AI install on x86 with 1GB or less memory no longer works when installing from /dev repo
Ethan Quach <Ethan.Quach@sun.com>
parents: 861
diff changeset
   938
			return (MIN_DUMP_SIZE);
789
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   939
		}
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   940
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   941
		/* Default dump size to half of system RAM */
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   942
		dump_size = mem_size / 2;
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   943
		om_debug_print(OM_DBGLVL_INFO,
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   944
		    "Calculated dump size: %llu MiB (default)\n", dump_size);
191
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   945
	}
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   946
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   947
	/*
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   948
	 * If there is less disk space available on target which
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   949
	 * can be dedicated to dump device, adjust the dump size
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   950
	 * accordingly.
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   951
	 */
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   952
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   953
	om_debug_print(OM_DBGLVL_INFO,
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   954
	    "available_dump_space=%llu MiB\n", available_dump_space);
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   955
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   956
	if (available_dump_space < dump_size)
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   957
		dump_size = available_dump_space;
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   958
789
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   959
	if (requested_dump_size > 0) {
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   960
		/* If user specified size, just ensure it's at least 1MB */
807
0fc85ff363a2 15568 Checking unsigned int for value < 0 in liborchestrator
Matt Keenan <matt.keenan@oracle.com>
parents: 789
diff changeset
   961
		if (dump_size < 1)
789
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   962
			dump_size = 1;
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   963
	} else {
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   964
		dump_size =
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   965
		    limit_min_max(dump_size, MIN_DUMP_SIZE, MAX_DUMP_SIZE);
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
   966
	}
191
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   967
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   968
	om_debug_print(OM_DBGLVL_INFO,
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   969
	    "Adjusted dump size: %llu MiB\n", dump_size);
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   970
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   971
	return (dump_size);
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   972
}
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   973
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
   974
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   975
/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   976
 * call_transfer_module
68
02c453401f20 910 - Progress bar text specified in back-end module
William Schumann <william.schumann@sun.com>
parents: 63
diff changeset
   977
 * This function creates the a thread to call the transfer module
282
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
   978
 * Input:	transfer_attr - list of attrs that describe the transfer
272
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
   979
 * 		target_dir - The mounted directory for alternate root
229
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
   980
 *		hostname - The user specified host name.
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
   981
 *		uname - The user specified user name, gcos.
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
   982
 *		lname - The user specified login name.
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
   983
 *		upasswd - The user specified user password
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
   984
 *		rpasswd - The user specified root password
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   985
 *		om_call_back_t *cb - The callback function
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   986
 * Output:	None
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   987
 * Return:	OM_SUCCESS, if the all threads are started successfully
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   988
 *		OM_FAILURE, if the there is a failure
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   989
 */
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
   990
static int
229
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
   991
call_transfer_module(
272
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
   992
    nvlist_t		**transfer_attr,
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
   993
    uint_t		transfer_attr_num,
229
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
   994
    char		*target_dir,
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
   995
    char		*hostname,
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
   996
    char		*uname,
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
   997
    char		*lname,
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
   998
    char		*upasswd,
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
   999
    char		*rpasswd,
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1000
    om_callback_t	cb)
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1001
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1002
	struct transfer_callback	*tcb_args;
272
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1003
	int				i, ret;
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1004
	pthread_t			transfer_thread;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1005
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1006
	if (target_dir == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1007
		om_set_error(OM_NO_INSTALL_TARGET);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1008
		return (OM_FAILURE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1009
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1010
229
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1011
	if (hostname == NULL) {
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1012
		om_set_error(OM_NO_HOSTNAME);
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1013
		return (OM_FAILURE);
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1014
	}
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1015
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1016
	if (uname == NULL) {
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1017
		om_set_error(OM_NO_UNAME);
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1018
		return (OM_FAILURE);
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1019
	}
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1020
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1021
	if (lname == NULL) {
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1022
		om_set_error(OM_NO_LNAME);
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1023
		return (OM_FAILURE);
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1024
	}
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1025
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1026
	if (upasswd == NULL) {
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1027
		om_set_error(OM_NO_UPASSWD);
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1028
		return (OM_FAILURE);
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1029
	}
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1030
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1031
	if (rpasswd == NULL) {
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1032
		om_set_error(OM_NO_RPASSWD);
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1033
		return (OM_FAILURE);
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1034
	}
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1035
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1036
	/*
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1037
	 * Populate the callback arguments structure, tcb_args.
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1038
	 */
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1039
	tcb_args = (struct transfer_callback *)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1040
	    calloc(1, sizeof (struct transfer_callback));
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1041
	if (tcb_args == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1042
		om_set_error(OM_NO_SPACE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1043
		return (OM_FAILURE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1044
	}
229
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1045
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1046
	/*
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1047
	 * Put target in callback arguments structure, tcb_args.
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1048
	 */
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1049
	tcb_args->target = strdup(target_dir);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1050
	if (tcb_args->target == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1051
		om_set_error(OM_NO_SPACE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1052
		return (OM_FAILURE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1053
	}
229
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1054
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1055
	/*
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1056
	 * Put hostname in callback arguments structure, tcb_args.
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1057
	 */
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1058
	tcb_args->hostname = strdup(hostname);
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1059
	if (tcb_args->hostname == NULL) {
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1060
		om_set_error(OM_NO_SPACE);
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1061
		return (OM_FAILURE);
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1062
	}
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1063
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1064
	/*
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1065
	 * Put user name (uname) in callback arguments structure, tcb_args.
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1066
	 */
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1067
	tcb_args->uname = strdup(uname);
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1068
	if (tcb_args->uname == NULL) {
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1069
		om_set_error(OM_NO_SPACE);
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1070
		return (OM_FAILURE);
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1071
	}
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1072
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1073
	/*
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1074
	 * Put login name (lname) in callback arguments structure, tcb_args.
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1075
	 */
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1076
	tcb_args->lname = strdup(lname);
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1077
	if (tcb_args->lname == NULL) {
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1078
		om_set_error(OM_NO_SPACE);
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1079
		return (OM_FAILURE);
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1080
	}
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1081
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1082
	/*
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1083
	 * Put user passwd (upasswd) in callback arguments structure, tcb_args.
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1084
	 */
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1085
	tcb_args->upasswd = strdup(upasswd);
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1086
	if (tcb_args->upasswd == NULL) {
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1087
		om_set_error(OM_NO_SPACE);
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1088
		return (OM_FAILURE);
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1089
	}
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1090
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1091
	/*
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1092
	 * Put root passwd (rpasswd) in callback arguments structure, tcb_args.
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1093
	 */
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1094
	tcb_args->rpasswd = strdup(rpasswd);
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1095
	if (tcb_args->rpasswd == NULL) {
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1096
		om_set_error(OM_NO_SPACE);
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1097
		return (OM_FAILURE);
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1098
	}
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1099
274
002946e882e4 3899 LiveCD installation fails with SUNWinstall built from tip 272:6ffbbcf6242a
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 272
diff changeset
  1100
	/*
002946e882e4 3899 LiveCD installation fails with SUNWinstall built from tip 272:6ffbbcf6242a
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 272
diff changeset
  1101
	 * transfer_attr describe the transfer in question.
002946e882e4 3899 LiveCD installation fails with SUNWinstall built from tip 272:6ffbbcf6242a
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 272
diff changeset
  1102
	 * The only time transfer attrs are set is during
002946e882e4 3899 LiveCD installation fails with SUNWinstall built from tip 272:6ffbbcf6242a
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 272
diff changeset
  1103
	 * an automated install. In all other cases, they
002946e882e4 3899 LiveCD installation fails with SUNWinstall built from tip 272:6ffbbcf6242a
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 272
diff changeset
  1104
	 * are set to NULL
282
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
  1105
	 */
272
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1106
	if (transfer_attr != NULL) {
460
22e95ec02b00 6610 AI does not recognize additional IPS repository
William Schumann <william.schumann@sun.com>
parents: 459
diff changeset
  1107
		/*
22e95ec02b00 6610 AI does not recognize additional IPS repository
William Schumann <william.schumann@sun.com>
parents: 459
diff changeset
  1108
		 * allocate NULL-terminated attribute list pointer list
22e95ec02b00 6610 AI does not recognize additional IPS repository
William Schumann <william.schumann@sun.com>
parents: 459
diff changeset
  1109
		 */
272
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1110
		tcb_args->transfer_attr =
460
22e95ec02b00 6610 AI does not recognize additional IPS repository
William Schumann <william.schumann@sun.com>
parents: 459
diff changeset
  1111
		    calloc(transfer_attr_num + 1, sizeof (nvlist_t *));
272
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1112
274
002946e882e4 3899 LiveCD installation fails with SUNWinstall built from tip 272:6ffbbcf6242a
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 272
diff changeset
  1113
		if (tcb_args->transfer_attr == NULL) {
002946e882e4 3899 LiveCD installation fails with SUNWinstall built from tip 272:6ffbbcf6242a
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 272
diff changeset
  1114
			om_set_error(OM_NO_SPACE);
002946e882e4 3899 LiveCD installation fails with SUNWinstall built from tip 272:6ffbbcf6242a
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 272
diff changeset
  1115
			return (OM_FAILURE);
002946e882e4 3899 LiveCD installation fails with SUNWinstall built from tip 272:6ffbbcf6242a
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 272
diff changeset
  1116
		}
272
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1117
		for (i = 0; i < transfer_attr_num; i++) {
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1118
			if (nvlist_dup(transfer_attr[i],
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1119
			    &(tcb_args->transfer_attr[i]), 0) != 0) {
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1120
				om_set_error(OM_NO_SPACE);
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1121
				return (OM_FAILURE);
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1122
			}
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1123
		}
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1124
	}
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1125
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1126
	/*
68
02c453401f20 910 - Progress bar text specified in back-end module
William Schumann <william.schumann@sun.com>
parents: 63
diff changeset
  1127
	 * Create a thread for running Transfer Module
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1128
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1129
	ret = pthread_create(&transfer_thread, NULL,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1130
	    do_transfer, (void *)tcb_args);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1131
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1132
	if (ret != 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1133
		om_set_error(OM_ERROR_THREAD_CREATE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1134
		return (OM_FAILURE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1135
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1136
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1137
	return (OM_SUCCESS);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1138
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1139
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1140
void *
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1141
do_ti(void *args)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1142
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1143
	struct ti_callback	*ti_args;
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1144
	static int		status = 0;
94
fd4991588edd 1010 - Target Instantiation progress doesn't display in GUI
William Schumann <william.schumann@sun.com>
parents: 91
diff changeset
  1145
	ti_errno_t		ti_status;
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1146
	nvlist_t		*attrs = (nvlist_t *)args;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1147
	om_callback_info_t	cb_data;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1148
	uintptr_t		app_data = 0;
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1149
	char			*disk_name;
845
1d8f110f7115 16192 auto-install core dumped when creating invalid size swap or dump
Matt Keenan <matt.keenan@oracle.com>
parents: 807
diff changeset
  1150
	nvlist_t		*ti_ex_attrs = NULL;
191
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  1151
	uint64_t		available_disk_space;
208
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1152
	uint64_t		recommended_size;
405
785221d05f6b 4195 need to make changes to AI Engine for SPARC
William Schumann <william.schumann@sun.com>
parents: 389
diff changeset
  1153
	uint8_t			install_slice_id;
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1154
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1155
	ti_args = (struct ti_callback *)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1156
	    calloc(1, sizeof (struct ti_callback));
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1157
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1158
	if (ti_args == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1159
		om_log_print("Couldn't create ti_callback args\n");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1160
		om_set_error(OM_NO_SPACE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1161
		status = -1;
94
fd4991588edd 1010 - Target Instantiation progress doesn't display in GUI
William Schumann <william.schumann@sun.com>
parents: 91
diff changeset
  1162
		goto ti_error;
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1163
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1164
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1165
	nvlist_dup(attrs, &ti_args->target_attrs, 0);
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1166
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1167
	if (ti_args->target_attrs == NULL) {
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1168
		om_log_print("ti_args == NULL\n");
94
fd4991588edd 1010 - Target Instantiation progress doesn't display in GUI
William Schumann <william.schumann@sun.com>
parents: 91
diff changeset
  1169
		om_set_error(OM_NO_TARGET_ATTRS);
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1170
		status = -1;
94
fd4991588edd 1010 - Target Instantiation progress doesn't display in GUI
William Schumann <william.schumann@sun.com>
parents: 91
diff changeset
  1171
		goto ti_error;
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1172
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1173
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1174
	/*
405
785221d05f6b 4195 need to make changes to AI Engine for SPARC
William Schumann <william.schumann@sun.com>
parents: 389
diff changeset
  1175
	 * get target device information
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1176
	 */
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1177
405
785221d05f6b 4195 need to make changes to AI Engine for SPARC
William Schumann <william.schumann@sun.com>
parents: 389
diff changeset
  1178
	if (om_get_device_target_info(&install_slice_id, &disk_name) != 0) {
785221d05f6b 4195 need to make changes to AI Engine for SPARC
William Schumann <william.schumann@sun.com>
parents: 389
diff changeset
  1179
		om_log_print("Couldn't get device target info. \n");
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1180
		status = -1;
94
fd4991588edd 1010 - Target Instantiation progress doesn't display in GUI
William Schumann <william.schumann@sun.com>
parents: 91
diff changeset
  1181
		goto ti_error;
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1182
	}
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1183
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1184
	/* initialize progress report structures */
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1185
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1186
	cb_data.num_milestones = 3;
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1187
	cb_data.callback_type = OM_INSTALL_TYPE;
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1188
	cb_data.curr_milestone = OM_TARGET_INSTANTIATION;
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1189
	cb_data.percentage_done = 0;
405
785221d05f6b 4195 need to make changes to AI Engine for SPARC
William Schumann <william.schumann@sun.com>
parents: 389
diff changeset
  1190
#ifndef	__sparc
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1191
	/*
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1192
	 * create fdisk target
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1193
	 */
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1194
94
fd4991588edd 1010 - Target Instantiation progress doesn't display in GUI
William Schumann <william.schumann@sun.com>
parents: 91
diff changeset
  1195
	ti_status = ti_create_target(ti_args->target_attrs, NULL);
fd4991588edd 1010 - Target Instantiation progress doesn't display in GUI
William Schumann <william.schumann@sun.com>
parents: 91
diff changeset
  1196
fd4991588edd 1010 - Target Instantiation progress doesn't display in GUI
William Schumann <william.schumann@sun.com>
parents: 91
diff changeset
  1197
	if (ti_status != TI_E_SUCCESS) {
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1198
		om_log_print("Could not create fdisk target\n");
94
fd4991588edd 1010 - Target Instantiation progress doesn't display in GUI
William Schumann <william.schumann@sun.com>
parents: 91
diff changeset
  1199
		om_set_error(OM_TARGET_INSTANTIATION_FAILED);
fd4991588edd 1010 - Target Instantiation progress doesn't display in GUI
William Schumann <william.schumann@sun.com>
parents: 91
diff changeset
  1200
		status = -1;
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1201
		goto ti_error;
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1202
	}
405
785221d05f6b 4195 need to make changes to AI Engine for SPARC
William Schumann <william.schumann@sun.com>
parents: 389
diff changeset
  1203
#endif
144
1bcfac4d8e02 1299 orchestrator shouldn't take care of creating <root_pool>/ROOT dataset
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 131
diff changeset
  1204
	cb_data.percentage_done = 20;
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1205
	om_cb(&cb_data, app_data);
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1206
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1207
	/*
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1208
	 * create VTOC target
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1209
	 */
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1210
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1211
	if (nvlist_alloc(&ti_ex_attrs, TI_TARGET_NVLIST_TYPE, 0) != 0) {
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1212
		om_log_print("Could not create target list.\n");
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1213
		om_set_error(OM_NO_SPACE);
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1214
		status = -1;
94
fd4991588edd 1010 - Target Instantiation progress doesn't display in GUI
William Schumann <william.schumann@sun.com>
parents: 91
diff changeset
  1215
		goto ti_error;
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1216
	}
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1217
363
130c19a9f4de 4233 target instantiation gets called multiple times which results in installation failure
William Schumann <william.schumann@sun.com>
parents: 354
diff changeset
  1218
	if (om_set_vtoc_target_attrs(ti_ex_attrs, disk_name) != 0) {
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1219
		om_log_print("Couldn't set slice attributes. \n");
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1220
		nvlist_free(ti_ex_attrs);
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1221
		status = -1;
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1222
		goto ti_error;
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1223
	}
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1224
354
2c1eaf565c25 3597 Unable to install OpenSolaris with 512 MB base memory
Glenn Lagasse <Glenn.Lagasse@Sun.COM>
parents: 344
diff changeset
  1225
	if (create_swap_slice) {
2c1eaf565c25 3597 Unable to install OpenSolaris with 512 MB base memory
Glenn Lagasse <Glenn.Lagasse@Sun.COM>
parents: 344
diff changeset
  1226
		(void) snprintf(swap_device, sizeof (swap_device),
2c1eaf565c25 3597 Unable to install OpenSolaris with 512 MB base memory
Glenn Lagasse <Glenn.Lagasse@Sun.COM>
parents: 344
diff changeset
  1227
		    "/dev/dsk/%ss1", disk_name);
2c1eaf565c25 3597 Unable to install OpenSolaris with 512 MB base memory
Glenn Lagasse <Glenn.Lagasse@Sun.COM>
parents: 344
diff changeset
  1228
	} else {
2c1eaf565c25 3597 Unable to install OpenSolaris with 512 MB base memory
Glenn Lagasse <Glenn.Lagasse@Sun.COM>
parents: 344
diff changeset
  1229
		(void) snprintf(swap_device, sizeof (swap_device),
2c1eaf565c25 3597 Unable to install OpenSolaris with 512 MB base memory
Glenn Lagasse <Glenn.Lagasse@Sun.COM>
parents: 344
diff changeset
  1230
		    "/dev/zvol/dsk/" ROOTPOOL_NAME "/" TI_ZFS_VOL_NAME_SWAP);
2c1eaf565c25 3597 Unable to install OpenSolaris with 512 MB base memory
Glenn Lagasse <Glenn.Lagasse@Sun.COM>
parents: 344
diff changeset
  1231
	}
2c1eaf565c25 3597 Unable to install OpenSolaris with 512 MB base memory
Glenn Lagasse <Glenn.Lagasse@Sun.COM>
parents: 344
diff changeset
  1232
94
fd4991588edd 1010 - Target Instantiation progress doesn't display in GUI
William Schumann <william.schumann@sun.com>
parents: 91
diff changeset
  1233
	ti_status = ti_create_target(ti_ex_attrs, NULL);
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1234
	nvlist_free(ti_ex_attrs);
845
1d8f110f7115 16192 auto-install core dumped when creating invalid size swap or dump
Matt Keenan <matt.keenan@oracle.com>
parents: 807
diff changeset
  1235
	ti_ex_attrs = NULL;
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1236
94
fd4991588edd 1010 - Target Instantiation progress doesn't display in GUI
William Schumann <william.schumann@sun.com>
parents: 91
diff changeset
  1237
	if (ti_status != TI_E_SUCCESS) {
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1238
		om_log_print("Could not create VTOC target\n");
94
fd4991588edd 1010 - Target Instantiation progress doesn't display in GUI
William Schumann <william.schumann@sun.com>
parents: 91
diff changeset
  1239
		om_set_error(OM_CANT_CREATE_VTOC_TARGET);
fd4991588edd 1010 - Target Instantiation progress doesn't display in GUI
William Schumann <william.schumann@sun.com>
parents: 91
diff changeset
  1240
		status = -1;
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1241
		goto ti_error;
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1242
	}
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1243
144
1bcfac4d8e02 1299 orchestrator shouldn't take care of creating <root_pool>/ROOT dataset
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 131
diff changeset
  1244
	cb_data.percentage_done = 40;
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1245
	om_cb(&cb_data, app_data);
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1246
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1247
	/*
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1248
	 * Create ZFS root pool.
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1249
	 */
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1250
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1251
	om_log_print("Set zfs root pool device\n");
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1252
405
785221d05f6b 4195 need to make changes to AI Engine for SPARC
William Schumann <william.schumann@sun.com>
parents: 389
diff changeset
  1253
	if (prepare_zfs_root_pool_attrs(&ti_ex_attrs, disk_name,
785221d05f6b 4195 need to make changes to AI Engine for SPARC
William Schumann <william.schumann@sun.com>
parents: 389
diff changeset
  1254
	    install_slice_id) != OM_SUCCESS) {
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1255
		om_log_print("Could not prepare ZFS root pool attribute set\n");
845
1d8f110f7115 16192 auto-install core dumped when creating invalid size swap or dump
Matt Keenan <matt.keenan@oracle.com>
parents: 807
diff changeset
  1256
		if (ti_ex_attrs != NULL) {
1d8f110f7115 16192 auto-install core dumped when creating invalid size swap or dump
Matt Keenan <matt.keenan@oracle.com>
parents: 807
diff changeset
  1257
			nvlist_free(ti_ex_attrs);
1d8f110f7115 16192 auto-install core dumped when creating invalid size swap or dump
Matt Keenan <matt.keenan@oracle.com>
parents: 807
diff changeset
  1258
		}
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1259
		status = -1;
94
fd4991588edd 1010 - Target Instantiation progress doesn't display in GUI
William Schumann <william.schumann@sun.com>
parents: 91
diff changeset
  1260
		goto ti_error;
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1261
	}
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1262
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1263
	om_log_print("creating zpool\n");
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1264
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1265
	/* call TI for creating zpool */
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1266
94
fd4991588edd 1010 - Target Instantiation progress doesn't display in GUI
William Schumann <william.schumann@sun.com>
parents: 91
diff changeset
  1267
	ti_status = ti_create_target(ti_ex_attrs, NULL);
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1268
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1269
	nvlist_free(ti_ex_attrs);
845
1d8f110f7115 16192 auto-install core dumped when creating invalid size swap or dump
Matt Keenan <matt.keenan@oracle.com>
parents: 807
diff changeset
  1270
	ti_ex_attrs = NULL;
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1271
94
fd4991588edd 1010 - Target Instantiation progress doesn't display in GUI
William Schumann <william.schumann@sun.com>
parents: 91
diff changeset
  1272
	if (ti_status != TI_E_SUCCESS) {
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1273
		om_log_print("Could not create ZFS root pool target\n");
94
fd4991588edd 1010 - Target Instantiation progress doesn't display in GUI
William Schumann <william.schumann@sun.com>
parents: 91
diff changeset
  1274
		om_set_error(OM_CANT_CREATE_ZPOOL);
fd4991588edd 1010 - Target Instantiation progress doesn't display in GUI
William Schumann <william.schumann@sun.com>
parents: 91
diff changeset
  1275
		status = -1;
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1276
		goto ti_error;
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1277
	}
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1278
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1279
	cb_data.percentage_done = 60;
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1280
	om_cb(&cb_data, app_data);
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1281
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1282
	/*
191
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  1283
	 * Create swap & dump on ZFS volumes
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  1284
	 */
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  1285
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  1286
	available_disk_space = get_available_disk_space();
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  1287
208
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1288
	/*
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1289
	 * Calculate actual disk space, which can be utilized for
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1290
	 * swap and dump. If zero, only minimum swap and dump
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1291
	 * will be created
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1292
	 */
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1293
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1294
	recommended_size = get_recommended_size_for_software();
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1295
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1296
	if (available_disk_space < recommended_size) {
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1297
		available_disk_space = 0;
191
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  1298
	} else {
208
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1299
		available_disk_space -= recommended_size;
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1300
	}
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1301
789
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1302
	om_debug_print(OM_DBGLVL_INFO,
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1303
	    "Available disk space for swap/dump: %llu MiB\n",
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1304
	    available_disk_space);
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1305
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1306
	/* create_swap_and_dump is set in disk_parts.c or disk_slices.c */
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1307
	/* Basic check to ensure there is space on actual partition/slice */
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1308
	/* for software and some left over for swap/dump */
208
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1309
	if (create_swap_and_dump) {
789
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1310
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1311
		if (requested_swap_size == 0 && requested_dump_size == 0) {
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1312
			/*
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1313
			 * Both swap and dump sizes have been requested as zero.
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1314
			 * Indicating to not create them, so don't.
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1315
			 */
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1316
			om_log_print("Not creating swap and dump on ZFS"
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1317
			    "volumes as requested\n");
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1318
		} else if (requested_dump_size == 0 && create_swap_slice) {
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1319
			/*
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1320
			 * Special scenario, minimum swap slice has already been
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1321
			 * created. So we would normally just create dump
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1322
			 * volume. However requested dump size is zero,
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1323
			 * indicating to not create it.
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1324
			 */
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1325
			om_log_print(
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1326
			    "Default swap slice already created, not creating "
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1327
			    "dump ZFS volume as requested\n");
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1328
		} else {
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1329
			/*
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1330
			 * Creating at least one of swap and/or
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1331
			 * dump zfs volumes.
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1332
			 */
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1333
			if (requested_swap_size == 0) {
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1334
				om_log_print(
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1335
				    "Not creating swap ZFS volume as "
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1336
				    "requested, attempting to creating "
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1337
				    "dump ZFS volume.\n");
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1338
			} else if (requested_dump_size == 0) {
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1339
				om_log_print(
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1340
				    "Not creating dump ZFS volume as "
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1341
				    "requested, attempting to creating "
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1342
				    "swap ZFS volume.\n");
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1343
			} else {
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1344
				om_log_print(
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1345
				    "Attempting to create swap and dump on ZFS "
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1346
				    "volumes\n");
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1347
			}
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1348
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1349
			if (prepare_zfs_volume_attrs(&ti_ex_attrs,
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1350
			    available_disk_space, B_FALSE) != OM_SUCCESS) {
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1351
				om_log_print(
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1352
				    "Could not prepare ZFS volume attribute "
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1353
				    "set\n");
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1354
845
1d8f110f7115 16192 auto-install core dumped when creating invalid size swap or dump
Matt Keenan <matt.keenan@oracle.com>
parents: 807
diff changeset
  1355
				if (ti_ex_attrs != NULL) {
1d8f110f7115 16192 auto-install core dumped when creating invalid size swap or dump
Matt Keenan <matt.keenan@oracle.com>
parents: 807
diff changeset
  1356
					nvlist_free(ti_ex_attrs);
1d8f110f7115 16192 auto-install core dumped when creating invalid size swap or dump
Matt Keenan <matt.keenan@oracle.com>
parents: 807
diff changeset
  1357
				}
789
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1358
				status = -1;
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1359
				goto ti_error;
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1360
			}
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1361
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1362
			/* call TI for creating ZFS volumes */
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1363
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1364
			ti_status = ti_create_target(ti_ex_attrs, NULL);
191
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  1365
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  1366
			nvlist_free(ti_ex_attrs);
845
1d8f110f7115 16192 auto-install core dumped when creating invalid size swap or dump
Matt Keenan <matt.keenan@oracle.com>
parents: 807
diff changeset
  1367
			ti_ex_attrs = NULL;
789
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1368
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1369
			if (ti_status != TI_E_SUCCESS) {
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1370
				om_log_print(
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1371
				    "Could not create ZFS volume target\n");
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1372
				om_set_error(OM_CANT_CREATE_ZVOL);
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1373
				status = -1;
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1374
				goto ti_error;
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1375
			}
191
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  1376
		}
354
2c1eaf565c25 3597 Unable to install OpenSolaris with 512 MB base memory
Glenn Lagasse <Glenn.Lagasse@Sun.COM>
parents: 344
diff changeset
  1377
	} else if (calc_required_swap_size() != 0 && !create_swap_slice) {
191
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  1378
		/*
879
b65e82e368f5 6978639 Default net AI install on x86 with 1GB or less memory no longer works when installing from /dev repo
Ethan Quach <Ethan.Quach@sun.com>
parents: 861
diff changeset
  1379
		 * The larger of -- required swap size and MIN_SWAP_SIZE --
b65e82e368f5 6978639 Default net AI install on x86 with 1GB or less memory no longer works when installing from /dev repo
Ethan Quach <Ethan.Quach@sun.com>
parents: 861
diff changeset
  1380
		 * will be created on a ZFS volume since insufficient amount
b65e82e368f5 6978639 Default net AI install on x86 with 1GB or less memory no longer works when installing from /dev repo
Ethan Quach <Ethan.Quach@sun.com>
parents: 861
diff changeset
  1381
		 * of physical memory is available.
191
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  1382
		 */
789
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1383
		om_log_print(
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1384
		    "There is not enough physical memory available, "
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1385
		    "the installer will create default size ZFS "
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  1386
		    "volume for swap\n");
208
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1387
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1388
		if (prepare_zfs_volume_attrs(&ti_ex_attrs, available_disk_space,
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1389
		    B_TRUE) != OM_SUCCESS) {
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1390
			om_log_print("Could not prepare ZFS volume attribute "
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1391
			    "set\n");
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1392
845
1d8f110f7115 16192 auto-install core dumped when creating invalid size swap or dump
Matt Keenan <matt.keenan@oracle.com>
parents: 807
diff changeset
  1393
			if (ti_ex_attrs != NULL) {
1d8f110f7115 16192 auto-install core dumped when creating invalid size swap or dump
Matt Keenan <matt.keenan@oracle.com>
parents: 807
diff changeset
  1394
				nvlist_free(ti_ex_attrs);
1d8f110f7115 16192 auto-install core dumped when creating invalid size swap or dump
Matt Keenan <matt.keenan@oracle.com>
parents: 807
diff changeset
  1395
			}
208
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1396
			status = -1;
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1397
			goto ti_error;
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1398
		}
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1399
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1400
		om_log_print("creating ZFS volume for swap\n");
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1401
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1402
		/* call TI for creating ZFS volumes */
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1403
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1404
		ti_status = ti_create_target(ti_ex_attrs, NULL);
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1405
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1406
		nvlist_free(ti_ex_attrs);
845
1d8f110f7115 16192 auto-install core dumped when creating invalid size swap or dump
Matt Keenan <matt.keenan@oracle.com>
parents: 807
diff changeset
  1407
		ti_ex_attrs = NULL;
208
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1408
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1409
		if (ti_status != TI_E_SUCCESS) {
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1410
			om_log_print("Could not create ZFS volume target\n");
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1411
			om_set_error(OM_CANT_CREATE_ZVOL);
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1412
			status = -1;
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1413
			goto ti_error;
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1414
		}
354
2c1eaf565c25 3597 Unable to install OpenSolaris with 512 MB base memory
Glenn Lagasse <Glenn.Lagasse@Sun.COM>
parents: 344
diff changeset
  1415
	} else if (!create_swap_slice) {
208
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1416
		om_log_print("There is not enough disk space available for "
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1417
		    "swap and dump, they won't be created\n");
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1418
217
75a649a169f5 1008 Installer should completely unmount target/BE before it quits
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 208
diff changeset
  1419
		om_log_print("%lluGiB of free space is required "
208
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1420
		    "for swap and dump devices, please refer to recommended "
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1421
		    "value on Disk screen\n",
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1422
		    (om_get_recommended_size(NULL, NULL) + ONE_GB_TO_MB / 2) /
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1423
		    ONE_GB_TO_MB);
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1424
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1425
		swap_device[0] = '\0';
191
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  1426
	}
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  1427
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  1428
	cb_data.percentage_done = 80;
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  1429
	om_cb(&cb_data, app_data);
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  1430
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  1431
	/*
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1432
	 * Create BE
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1433
	 */
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1434
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1435
	if (prepare_be_attrs(&ti_ex_attrs) != OM_SUCCESS) {
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1436
		om_log_print("Could not prepare BE attribute set\n");
845
1d8f110f7115 16192 auto-install core dumped when creating invalid size swap or dump
Matt Keenan <matt.keenan@oracle.com>
parents: 807
diff changeset
  1437
		if (ti_ex_attrs != NULL) {
1d8f110f7115 16192 auto-install core dumped when creating invalid size swap or dump
Matt Keenan <matt.keenan@oracle.com>
parents: 807
diff changeset
  1438
			nvlist_free(ti_ex_attrs);
1d8f110f7115 16192 auto-install core dumped when creating invalid size swap or dump
Matt Keenan <matt.keenan@oracle.com>
parents: 807
diff changeset
  1439
		}
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1440
		status = -1;
94
fd4991588edd 1010 - Target Instantiation progress doesn't display in GUI
William Schumann <william.schumann@sun.com>
parents: 91
diff changeset
  1441
		goto ti_error;
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1442
	}
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1443
94
fd4991588edd 1010 - Target Instantiation progress doesn't display in GUI
William Schumann <william.schumann@sun.com>
parents: 91
diff changeset
  1444
	ti_status = ti_create_target(ti_ex_attrs, NULL);
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1445
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1446
	nvlist_free(ti_ex_attrs);
845
1d8f110f7115 16192 auto-install core dumped when creating invalid size swap or dump
Matt Keenan <matt.keenan@oracle.com>
parents: 807
diff changeset
  1447
	ti_ex_attrs = NULL;
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1448
94
fd4991588edd 1010 - Target Instantiation progress doesn't display in GUI
William Schumann <william.schumann@sun.com>
parents: 91
diff changeset
  1449
	if (ti_status != TI_E_SUCCESS) {
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1450
		om_log_print("Could not create BE target\n");
94
fd4991588edd 1010 - Target Instantiation progress doesn't display in GUI
William Schumann <william.schumann@sun.com>
parents: 91
diff changeset
  1451
		status = -1;
fd4991588edd 1010 - Target Instantiation progress doesn't display in GUI
William Schumann <william.schumann@sun.com>
parents: 91
diff changeset
  1452
		goto ti_error;
217
75a649a169f5 1008 Installer should completely unmount target/BE before it quits
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 208
diff changeset
  1453
	}
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1454
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1455
	cb_data.percentage_done = 99;
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1456
	om_cb(&cb_data, app_data);
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1457
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1458
ti_error:
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1459
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1460
	cb_data.num_milestones = 3;
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1461
	cb_data.callback_type = OM_INSTALL_TYPE;
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1462
94
fd4991588edd 1010 - Target Instantiation progress doesn't display in GUI
William Schumann <william.schumann@sun.com>
parents: 91
diff changeset
  1463
	if (status != 0) {
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1464
		cb_data.curr_milestone = OM_INVALID_MILESTONE;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1465
		cb_data.percentage_done = OM_TARGET_INSTANTIATION_FAILED;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1466
	} else {
635
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1467
		om_log_print("Target Instantiation finished successfully\n");
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1468
		cb_data.curr_milestone = OM_TARGET_INSTANTIATION;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1469
		cb_data.percentage_done = 100;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1470
	}
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1471
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1472
	om_cb(&cb_data, app_data);
459
56b6b042a167 5653 AI manifest should offer keyword to use max available space for partition/slice
William Schumann <william.schumann@sun.com>
parents: 447
diff changeset
  1473
56b6b042a167 5653 AI manifest should offer keyword to use max available space for partition/slice
William Schumann <william.schumann@sun.com>
parents: 447
diff changeset
  1474
	if (om_breakpoint == OM_breakpoint_after_TI) {
56b6b042a167 5653 AI manifest should offer keyword to use max available space for partition/slice
William Schumann <william.schumann@sun.com>
parents: 447
diff changeset
  1475
		om_log_std(LS_STDERR,
56b6b042a167 5653 AI manifest should offer keyword to use max available space for partition/slice
William Schumann <william.schumann@sun.com>
parents: 447
diff changeset
  1476
		    "Breakpoint requested after Target Instantiation."
56b6b042a167 5653 AI manifest should offer keyword to use max available space for partition/slice
William Schumann <william.schumann@sun.com>
parents: 447
diff changeset
  1477
		    " Installer exiting.\n");
56b6b042a167 5653 AI manifest should offer keyword to use max available space for partition/slice
William Schumann <william.schumann@sun.com>
parents: 447
diff changeset
  1478
		exit(0);
56b6b042a167 5653 AI manifest should offer keyword to use max available space for partition/slice
William Schumann <william.schumann@sun.com>
parents: 447
diff changeset
  1479
	}
56b6b042a167 5653 AI manifest should offer keyword to use max available space for partition/slice
William Schumann <william.schumann@sun.com>
parents: 447
diff changeset
  1480
	pthread_exit((void *)status);
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1481
	/* LINTED [no return statement] */
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1482
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1483
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1484
/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1485
 * do_transfer
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1486
 * This function calls the api to do the actual transfer of install contents
272
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1487
 * from cd/dvd/ips to hard disk
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1488
 * Input:	void *arg - Pointer to the parameters needed to call
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1489
 *		transfer mdoule. Currently the full path of the alternate root
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1490
 *		and callback parameter
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1491
 * Output:	None
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1492
 * Return:	status is returned as part of pthread_exit function
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1493
 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1494
void *
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1495
do_transfer(void *args)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1496
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1497
	struct transfer_callback	*tcb_args;
272
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1498
	nvlist_t			**transfer_attr;
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1499
	uint_t				transfer_attr_num;
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1500
	int				i, status;
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1501
	int				transfer_mode = OM_CPIO_TRANSFER;
405
785221d05f6b 4195 need to make changes to AI Engine for SPARC
William Schumann <william.schumann@sun.com>
parents: 389
diff changeset
  1502
	int				value;
94
fd4991588edd 1010 - Target Instantiation progress doesn't display in GUI
William Schumann <william.schumann@sun.com>
parents: 91
diff changeset
  1503
	void				*exit_val;
531
e526f752d6d0 6440 Build 106 installer fails to start in 512 MB environment
David Miner <dminer@opensolaris.org>
parents: 515
diff changeset
  1504
	char				buf[20], arc[MAXPATHLEN];
94
fd4991588edd 1010 - Target Instantiation progress doesn't display in GUI
William Schumann <william.schumann@sun.com>
parents: 91
diff changeset
  1505
fd4991588edd 1010 - Target Instantiation progress doesn't display in GUI
William Schumann <william.schumann@sun.com>
parents: 91
diff changeset
  1506
	(void) pthread_join(ti_thread, &exit_val);
fd4991588edd 1010 - Target Instantiation progress doesn't display in GUI
William Schumann <william.schumann@sun.com>
parents: 91
diff changeset
  1507
459
56b6b042a167 5653 AI manifest should offer keyword to use max available space for partition/slice
William Schumann <william.schumann@sun.com>
parents: 447
diff changeset
  1508
	ti_ret += (int)exit_val;
94
fd4991588edd 1010 - Target Instantiation progress doesn't display in GUI
William Schumann <william.schumann@sun.com>
parents: 91
diff changeset
  1509
	if (ti_ret != 0) {
fd4991588edd 1010 - Target Instantiation progress doesn't display in GUI
William Schumann <william.schumann@sun.com>
parents: 91
diff changeset
  1510
		om_set_error(OM_TARGET_INSTANTIATION_FAILED);
fd4991588edd 1010 - Target Instantiation progress doesn't display in GUI
William Schumann <william.schumann@sun.com>
parents: 91
diff changeset
  1511
		notify_error_status(OM_TARGET_INSTANTIATION_FAILED);
fd4991588edd 1010 - Target Instantiation progress doesn't display in GUI
William Schumann <william.schumann@sun.com>
parents: 91
diff changeset
  1512
		status = -1;
fd4991588edd 1010 - Target Instantiation progress doesn't display in GUI
William Schumann <william.schumann@sun.com>
parents: 91
diff changeset
  1513
		pthread_exit((void *)&status);
fd4991588edd 1010 - Target Instantiation progress doesn't display in GUI
William Schumann <william.schumann@sun.com>
parents: 91
diff changeset
  1514
	}
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1515
217
75a649a169f5 1008 Installer should completely unmount target/BE before it quits
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 208
diff changeset
  1516
	om_log_print("Transfer process initiated\n");
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1517
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1518
	tcb_args = (struct transfer_callback *)args;
272
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1519
	transfer_attr = tcb_args->transfer_attr;
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1520
	transfer_attr_num = tcb_args->transfer_attr_num;
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1521
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1522
	if (tcb_args->target == NULL) {
272
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1523
		if (transfer_attr != NULL) {
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1524
			for (i = 0; i < transfer_attr_num; i++)
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1525
				nvlist_free(transfer_attr[i]);
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1526
			free(transfer_attr);
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1527
		}
94
fd4991588edd 1010 - Target Instantiation progress doesn't display in GUI
William Schumann <william.schumann@sun.com>
parents: 91
diff changeset
  1528
		om_set_error(OM_NO_TARGET_ATTRS);
fd4991588edd 1010 - Target Instantiation progress doesn't display in GUI
William Schumann <william.schumann@sun.com>
parents: 91
diff changeset
  1529
		notify_error_status(OM_NO_TARGET_ATTRS);
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1530
		status = -1;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1531
		pthread_exit((void *)&status);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1532
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1533
272
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1534
	/*
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1535
	 * Determine the mode of operation (IPS or CPIO) and
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1536
	 * set up the transfer appropriately
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1537
	 *
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1538
	 * If the mode is not specified, CPIO is assumed as the default
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1539
	 */
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1540
	if (transfer_attr != NULL) {
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1541
		if (nvlist_lookup_uint32(transfer_attr[0], TM_ATTR_MECHANISM,
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1542
		    ((uint32_t *)&value)) != 0) {
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1543
			for (i = 0; i < transfer_attr_num; i++)
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1544
				nvlist_free(transfer_attr[i]);
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1545
			free(transfer_attr);
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1546
			om_set_error(OM_NO_TARGET_ATTRS);
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1547
			notify_error_status(OM_NO_TARGET_ATTRS);
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1548
			status = -1;
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1549
			pthread_exit((void *)&status);
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1550
		}
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1551
		if (value == TM_PERFORM_IPS)
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1552
			transfer_mode = OM_IPS_TRANSFER;
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1553
	} else {
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1554
		transfer_attr_num = 1;
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1555
		transfer_attr = malloc(sizeof (nvlist_t *) * transfer_attr_num);
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1556
		if (nvlist_alloc(transfer_attr, NV_UNIQUE_NAME, 0) != 0) {
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1557
			om_set_error(OM_NO_SPACE);
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1558
			notify_error_status(OM_NO_SPACE);
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1559
			status = -1;
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1560
			pthread_exit((void *)&status);
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1561
		}
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1562
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1563
		if (nvlist_add_uint32(*transfer_attr, TM_ATTR_MECHANISM,
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1564
		    TM_PERFORM_CPIO) != 0) {
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1565
			for (i = 0; i < transfer_attr_num; i++)
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1566
				nvlist_free(transfer_attr[i]);
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1567
			free(transfer_attr);
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1568
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1569
			om_set_error(OM_NO_SPACE);
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1570
			notify_error_status(OM_NO_SPACE);
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1571
			status = -1;
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1572
			pthread_exit((void *)&status);
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1573
		}
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1574
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1575
		if (nvlist_add_uint32(*transfer_attr, TM_CPIO_ACTION,
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1576
		    TM_CPIO_ENTIRE) != 0) {
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1577
			for (i = 0; i < transfer_attr_num; i++)
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1578
				nvlist_free(transfer_attr[i]);
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1579
			free(transfer_attr);
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1580
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1581
			om_set_error(OM_NO_SPACE);
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1582
			notify_error_status(OM_NO_SPACE);
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1583
			status = -1;
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1584
			pthread_exit((void *)&status);
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1585
		}
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1586
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1587
		if (nvlist_add_string(*transfer_attr, TM_CPIO_SRC_MNTPT,
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1588
		    "/") != 0) {
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1589
			for (i = 0; i < transfer_attr_num; i++)
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1590
				nvlist_free(transfer_attr[i]);
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1591
			free(transfer_attr);
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1592
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1593
			om_set_error(OM_NO_SPACE);
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1594
			notify_error_status(OM_NO_SPACE);
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1595
			status = -1;
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1596
			pthread_exit((void *)&status);
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1597
		}
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1598
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1599
		if (nvlist_add_string(*transfer_attr, TM_CPIO_DST_MNTPT,
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1600
		    tcb_args->target) != 0) {
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1601
			for (i = 0; i < transfer_attr_num; i++)
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1602
				nvlist_free(transfer_attr[i]);
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1603
			free(transfer_attr);
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1604
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1605
			om_set_error(OM_NO_SPACE);
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1606
			notify_error_status(OM_NO_SPACE);
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1607
			status = -1;
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1608
			pthread_exit((void *)&status);
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1609
		}
61
2f60ba79cd9c 851 liborchestrator should switch to the latest API when calling transfer module
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 48
diff changeset
  1610
	}
2f60ba79cd9c 851 liborchestrator should switch to the latest API when calling transfer module
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 48
diff changeset
  1611
495
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
  1612
	/* do transfer using either CPIO or IPS mechanism */
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
  1613
	if (transfer_mode == OM_IPS_TRANSFER) {
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
  1614
		om_log_print("IPS transfer mechanism selected\n");
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
  1615
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
  1616
		status = om_perform_transfer_ips(transfer_attr,
272
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1617
		    handle_TM_callback);
635
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1618
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1619
		/*
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1620
		 * If IPS transfer phase failed, notify the caller and exit
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1621
		 */
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1622
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1623
		if (status != OM_SUCCESS) {
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1624
			notify_error_status(OM_TRANSFER_FAILED);
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1625
			pthread_exit((void *)&status);
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1626
		}
495
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
  1627
	} else {
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
  1628
		om_log_print("CPIO transfer mechanism selected\n");
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
  1629
531
e526f752d6d0 6440 Build 106 installer fails to start in 512 MB environment
David Miner <dminer@opensolaris.org>
parents: 515
diff changeset
  1630
		/*
e526f752d6d0 6440 Build 106 installer fails to start in 512 MB environment
David Miner <dminer@opensolaris.org>
parents: 515
diff changeset
  1631
		 * Add mounting the root archive that we're not booted from
e526f752d6d0 6440 Build 106 installer fails to start in 512 MB environment
David Miner <dminer@opensolaris.org>
parents: 515
diff changeset
  1632
		 * into the transfer tasks; do it there so that progress
e526f752d6d0 6440 Build 106 installer fails to start in 512 MB environment
David Miner <dminer@opensolaris.org>
parents: 515
diff changeset
  1633
		 * reporting can remain reasonably accurate.
e526f752d6d0 6440 Build 106 installer fails to start in 512 MB environment
David Miner <dminer@opensolaris.org>
parents: 515
diff changeset
  1634
		 */
549
92a75e20577f 8409 Installer doesn't install 32-bit kernel modules on 64-bit systems
David Miner <dminer@opensolaris.org>
parents: 539
diff changeset
  1635
		if (sysinfo(SI_ARCHITECTURE_64, buf, sizeof (buf)) == -1) {
531
e526f752d6d0 6440 Build 106 installer fails to start in 512 MB environment
David Miner <dminer@opensolaris.org>
parents: 515
diff changeset
  1636
			/* 32-bit, so we need to unpack 64-bit */
e526f752d6d0 6440 Build 106 installer fails to start in 512 MB environment
David Miner <dminer@opensolaris.org>
parents: 515
diff changeset
  1637
			(void) snprintf(arc, sizeof (arc), ARCHIVE_PATH,
e526f752d6d0 6440 Build 106 installer fails to start in 512 MB environment
David Miner <dminer@opensolaris.org>
parents: 515
diff changeset
  1638
			    "amd64");
e526f752d6d0 6440 Build 106 installer fails to start in 512 MB environment
David Miner <dminer@opensolaris.org>
parents: 515
diff changeset
  1639
		} else {
e526f752d6d0 6440 Build 106 installer fails to start in 512 MB environment
David Miner <dminer@opensolaris.org>
parents: 515
diff changeset
  1640
			/* 64-bit, so we need to unpack 32-bit */
e526f752d6d0 6440 Build 106 installer fails to start in 512 MB environment
David Miner <dminer@opensolaris.org>
parents: 515
diff changeset
  1641
			(void) snprintf(arc, sizeof (arc), ARCHIVE_PATH, "");
e526f752d6d0 6440 Build 106 installer fails to start in 512 MB environment
David Miner <dminer@opensolaris.org>
parents: 515
diff changeset
  1642
		}
e526f752d6d0 6440 Build 106 installer fails to start in 512 MB environment
David Miner <dminer@opensolaris.org>
parents: 515
diff changeset
  1643
		if (nvlist_add_string(*transfer_attr, TM_UNPACK_ARCHIVE, arc)
e526f752d6d0 6440 Build 106 installer fails to start in 512 MB environment
David Miner <dminer@opensolaris.org>
parents: 515
diff changeset
  1644
		    != 0) {
e526f752d6d0 6440 Build 106 installer fails to start in 512 MB environment
David Miner <dminer@opensolaris.org>
parents: 515
diff changeset
  1645
			for (i = 0; i < transfer_attr_num; i++)
e526f752d6d0 6440 Build 106 installer fails to start in 512 MB environment
David Miner <dminer@opensolaris.org>
parents: 515
diff changeset
  1646
				nvlist_free(transfer_attr[i]);
e526f752d6d0 6440 Build 106 installer fails to start in 512 MB environment
David Miner <dminer@opensolaris.org>
parents: 515
diff changeset
  1647
			free(transfer_attr);
e526f752d6d0 6440 Build 106 installer fails to start in 512 MB environment
David Miner <dminer@opensolaris.org>
parents: 515
diff changeset
  1648
e526f752d6d0 6440 Build 106 installer fails to start in 512 MB environment
David Miner <dminer@opensolaris.org>
parents: 515
diff changeset
  1649
			om_set_error(OM_NO_SPACE);
e526f752d6d0 6440 Build 106 installer fails to start in 512 MB environment
David Miner <dminer@opensolaris.org>
parents: 515
diff changeset
  1650
			notify_error_status(OM_NO_SPACE);
e526f752d6d0 6440 Build 106 installer fails to start in 512 MB environment
David Miner <dminer@opensolaris.org>
parents: 515
diff changeset
  1651
			status = -1;
e526f752d6d0 6440 Build 106 installer fails to start in 512 MB environment
David Miner <dminer@opensolaris.org>
parents: 515
diff changeset
  1652
			pthread_exit((void *)&status);
e526f752d6d0 6440 Build 106 installer fails to start in 512 MB environment
David Miner <dminer@opensolaris.org>
parents: 515
diff changeset
  1653
		}
e526f752d6d0 6440 Build 106 installer fails to start in 512 MB environment
David Miner <dminer@opensolaris.org>
parents: 515
diff changeset
  1654
495
a0961490f883 7415 'slim_install' is left on system when Automated Installer is used for the installation
Jan Damborsky <jan.damborsky@sun.com>
parents: 477
diff changeset
  1655
		status = TM_perform_transfer(*transfer_attr,
272
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1656
		    handle_TM_callback);
229
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1657
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1658
		/*
635
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1659
		 * Since CPIO transfer phase finished, release nvlists holding
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1660
		 * the transfer mechanism attributes.
229
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1661
		 */
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1662
635
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1663
		for (i = 0; i < transfer_attr_num; i++)
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1664
			nvlist_free(transfer_attr[i]);
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1665
		free(transfer_attr);
217
75a649a169f5 1008 Installer should completely unmount target/BE before it quits
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 208
diff changeset
  1666
75a649a169f5 1008 Installer should completely unmount target/BE before it quits
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 208
diff changeset
  1667
		/*
635
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1668
		 * If CPIO transfer phase failed, notify the caller and exit
217
75a649a169f5 1008 Installer should completely unmount target/BE before it quits
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 208
diff changeset
  1669
		 */
75a649a169f5 1008 Installer should completely unmount target/BE before it quits
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 208
diff changeset
  1670
635
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1671
		if (status != TM_SUCCESS) {
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1672
			om_log_print(NSI_TRANSFER_FAILED, status);
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1673
			notify_error_status(OM_TRANSFER_FAILED);
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1674
			pthread_exit((void *)&status);
229
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1675
		}
635
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1676
	}
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1677
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1678
	/*
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1679
	 * Customize the installed image.
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1680
	 */
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1681
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1682
	status = 0;
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1683
	/*
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1684
	 * Set the language locale.
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1685
	 */
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1686
	if (def_locale != NULL) {
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1687
		if (ict_set_lang_locale(tcb_args->target,
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1688
		    def_locale, transfer_mode) != ICT_SUCCESS) {
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1689
			om_log_print("Failed to set locale: "
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1690
			    "%s\n%s\n", def_locale,
229
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1691
			    ICT_STR_ERROR(ict_errno));
344
f6279fc734cf 4871 ICT failures are not reported as a failed installation
Joseph J Vlcek <Joseph.Vlcek@Sun.COM>
parents: 332
diff changeset
  1692
			status = -1;
229
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1693
		}
635
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1694
	}
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1695
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1696
	/*
846
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
  1697
	 * Configure user account - only for interactive installers
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
  1698
	 * In case of automated installation (AI), user and root accounts
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
  1699
	 * are configured on installed system at the first boot
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
  1700
	 * by svc:/system/install/config SMF service. Thus for AI scenario,
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
  1701
	 * just skip dealing with this kind of configuration in the installer.
635
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1702
	 */
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1703
846
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
  1704
	if (!om_is_automated_installation()) {
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
  1705
		/* Configure user directory */
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
  1706
		if (ict_configure_user_directory(INSTALLED_ROOT_DIR,
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
  1707
		    tcb_args->lname) != ICT_SUCCESS) {
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
  1708
			om_log_print("Couldn't configure user directory\n"
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
  1709
			    "for user: %s\n%s\n", tcb_args->lname,
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
  1710
			    ICT_STR_ERROR(ict_errno));
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
  1711
			status = -1;
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
  1712
		}
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
  1713
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
  1714
		/* Create personal initialization files */
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
  1715
		if (ict_set_user_profile(tcb_args->target, tcb_args->lname) !=
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
  1716
		    ICT_SUCCESS) {
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
  1717
			om_log_print("Couldn't set the user environment\n"
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
  1718
			    "for user: %s\n%s\n",
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
  1719
			    tcb_args->lname, ICT_STR_ERROR(ict_errno));
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
  1720
			status = -1;
70dd9e819f25 15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
Jan Damborsky <jan.damborsky@sun.com>
parents: 845
diff changeset
  1721
		}
635
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1722
	}
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1723
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1724
	/*
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1725
	 * If swap was created, add appropriate entry to
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1726
	 * <target>/etc/vfstab
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1727
	 */
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1728
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1729
	if (swap_device[0] != '\0') {
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1730
		setup_etc_vfstab_for_swap(tcb_args->target);
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1731
	}
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1732
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1733
	if (ict_set_host_node_name(tcb_args->target, tcb_args->hostname)
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1734
	    != ICT_SUCCESS) {
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1735
		om_log_print("Couldn't set the host and node name\n"
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1736
		    "to hostname: %s\n%s\n", tcb_args->hostname,
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1737
		    ICT_STR_ERROR(ict_errno));
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1738
		status = -1;
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1739
	}
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1740
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1741
	activate_be(INIT_BE_NAME);
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1742
674
4f42a30c01c2 13432 - circular dependency between libict and liborchestor exists
William Schumann <william.schumann@sun.com>
parents: 635
diff changeset
  1743
	if (ict_installboot(tcb_args->target, zfs_device,
4f42a30c01c2 13432 - circular dependency between libict and liborchestor exists
William Schumann <william.schumann@sun.com>
parents: 635
diff changeset
  1744
	    om_install_partition_is_logical()) != ICT_SUCCESS) {
635
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1745
		om_log_print("installboot failed\n%s\n",
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1746
		    ICT_STR_ERROR(ict_errno));
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1747
		status = -1;
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1748
	}
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1749
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1750
	/*
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1751
	 * run_install_finish_script performs a group of ICT
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1752
	 */
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1753
	if (run_install_finish_script(tcb_args->target,
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1754
	    tcb_args->uname, tcb_args->lname,
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1755
	    tcb_args->upasswd, tcb_args->rpasswd) == OM_FAILURE) {
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1756
		om_log_print("The install finish script reported "
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1757
		    "failures\n");
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1758
		status = -1;
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1759
	}
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1760
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1761
	/*
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1762
	 * Take a snapshot of the installation.
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1763
	 */
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1764
	if (ict_snapshot(INIT_BE_NAME, INSTALL_SNAPSHOT) !=
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1765
	    ICT_SUCCESS) {
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1766
		om_log_print("Failed to generate snapshot\n"
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1767
		    "pool: %s\nsnapshot: %s\n%s\n",
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1768
		    INIT_BE_NAME, INSTALL_SNAPSHOT,
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1769
		    ICT_STR_ERROR(ict_errno));
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1770
		status = -1;
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1771
	}
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1772
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1773
	/*
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1774
	 * mark ZFS root pool 'ready' - it was successfully populated
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1775
	 * and contains valid Solaris instance
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1776
	 */
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1777
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1778
	om_log_print("Marking root pool as 'ready'\n");
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1779
	if (ict_mark_root_pool_ready(ROOTPOOL_NAME) != ICT_SUCCESS) {
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1780
		om_log_print("%s\n", ICT_STR_ERROR(ict_errno));
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1781
		status = -1;
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1782
	} else {
635
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1783
		om_debug_print(OM_DBGLVL_INFO,
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1784
		    "Root pool %s was marked as 'ready'\n",
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1785
		    ROOTPOOL_NAME);
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1786
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1787
635
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1788
	/*
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1789
	 * Log the build version we're running on.
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1790
	 */
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1791
	log_bld_info(ROOT_FS, "Installer build version:");
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1792
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1793
	/*
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1794
	 * Log the build version we've installed.
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1795
	 */
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1796
	log_bld_info(INSTALLED_ROOT_DIR, "Target build version:");
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1797
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1798
	if (reset_zfs_mount_property(tcb_args->target,
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1799
	    transfer_mode) != OM_SUCCESS)
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1800
		status = -1;
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1801
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1802
	/*
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1803
	 * Notify the caller that install is completed
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1804
	 */
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1805
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1806
	if (status == 0)
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1807
		notify_install_complete();
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1808
	else
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  1809
		notify_error_status(OM_ICT_FAILURE);
272
6ffbbcf6242a 3611 liborchestrator needs to be enhanced to support IPS based installs
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 244
diff changeset
  1810
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1811
	pthread_exit((void *)&status);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1812
	/* LINTED [no return statement] */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1813
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1814
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1815
/*
68
02c453401f20 910 - Progress bar text specified in back-end module
William Schumann <william.schumann@sun.com>
parents: 63
diff changeset
  1816
 * handle_TM_callback
02c453401f20 910 - Progress bar text specified in back-end module
William Schumann <william.schumann@sun.com>
parents: 63
diff changeset
  1817
 * This function handles the callbacks for TM
02c453401f20 910 - Progress bar text specified in back-end module
William Schumann <william.schumann@sun.com>
parents: 63
diff changeset
  1818
 * It builds the callback data the GUI expects
02c453401f20 910 - Progress bar text specified in back-end module
William Schumann <william.schumann@sun.com>
parents: 63
diff changeset
  1819
 * Input:	percent - percentage complete
02c453401f20 910 - Progress bar text specified in back-end module
William Schumann <william.schumann@sun.com>
parents: 63
diff changeset
  1820
 *		message - localized text message for GUI to display
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1821
 * Output:	None
68
02c453401f20 910 - Progress bar text specified in back-end module
William Schumann <william.schumann@sun.com>
parents: 63
diff changeset
  1822
 * Return:	None
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1823
 */
68
02c453401f20 910 - Progress bar text specified in back-end module
William Schumann <william.schumann@sun.com>
parents: 63
diff changeset
  1824
static void
02c453401f20 910 - Progress bar text specified in back-end module
William Schumann <william.schumann@sun.com>
parents: 63
diff changeset
  1825
handle_TM_callback(const int percent, const char *message)
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1826
{
68
02c453401f20 910 - Progress bar text specified in back-end module
William Schumann <william.schumann@sun.com>
parents: 63
diff changeset
  1827
	om_callback_info_t cb_data;
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1828
94
fd4991588edd 1010 - Target Instantiation progress doesn't display in GUI
William Schumann <william.schumann@sun.com>
parents: 91
diff changeset
  1829
	cb_data.num_milestones = 3;
91
ac77f3175bdb 990 - Install complete reported before post-install tasks complete
William Schumann <william.schumann@sun.com>
parents: 74
diff changeset
  1830
	cb_data.curr_milestone = OM_SOFTWARE_UPDATE;
68
02c453401f20 910 - Progress bar text specified in back-end module
William Schumann <william.schumann@sun.com>
parents: 63
diff changeset
  1831
	cb_data.callback_type = OM_INSTALL_TYPE;
02c453401f20 910 - Progress bar text specified in back-end module
William Schumann <william.schumann@sun.com>
parents: 63
diff changeset
  1832
	cb_data.percentage_done = percent;
02c453401f20 910 - Progress bar text specified in back-end module
William Schumann <william.schumann@sun.com>
parents: 63
diff changeset
  1833
	cb_data.message = message;
02c453401f20 910 - Progress bar text specified in back-end module
William Schumann <william.schumann@sun.com>
parents: 63
diff changeset
  1834
	om_cb(&cb_data, 0);
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1835
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1836
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1837
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1838
/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1839
 * Parsing function to get the percentage value from the string.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1840
 * The string will be like "percent=11"
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1841
 * The output is an integer from 0 - 100
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1842
 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1843
int16_t
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1844
get_the_percentage(char *str)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1845
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1846
	char	*ptr, *ptr1;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1847
	int16_t	percent;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1848
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1849
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1850
	 * Look for percent="N"
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1851
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1852
	ptr = strstr(str, "percent=");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1853
	if (ptr == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1854
		return (-1);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1855
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1856
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1857
	 * Find where the number is starting
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1858
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1859
	while (isdigit(*ptr) == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1860
		ptr++;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1861
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1862
	ptr1 = strchr(ptr, '"');
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1863
	if (ptr1 == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1864
		return (-1);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1865
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1866
	*ptr1 = '\0';
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1867
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1868
	errno = 0;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1869
	percent = (int16_t)strtol(ptr, (char **)NULL, 10);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1870
	if (errno != 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1871
		/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1872
		 * Log the information
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1873
		 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1874
		return (-1);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1875
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1876
	return (percent);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1877
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1878
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1879
/*ARGSUSED*/
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1880
uint64_t
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1881
om_get_min_size(char *media, char *distro)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1882
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1883
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1884
	 * Size in MB that is the minimum device size we will allow
389
f9a7dbcea5b5 4280 AI tries to open nonexistent /.cdrom/.image_info file
Jan Damborsky <jan.damborsky@sun.com>
parents: 369
diff changeset
  1885
	 * for installing.
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1886
	 *
208
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1887
	 * Get uncompressed size of image and add 20% reserve.
389
f9a7dbcea5b5 4280 AI tries to open nonexistent /.cdrom/.image_info file
Jan Damborsky <jan.damborsky@sun.com>
parents: 369
diff changeset
  1888
	 * For Slim installer, information about size of bits to be installed
f9a7dbcea5b5 4280 AI tries to open nonexistent /.cdrom/.image_info file
Jan Damborsky <jan.damborsky@sun.com>
parents: 369
diff changeset
  1889
	 * is generated by Distro Constructor and stored in /.image_info file.
f9a7dbcea5b5 4280 AI tries to open nonexistent /.cdrom/.image_info file
Jan Damborsky <jan.damborsky@sun.com>
parents: 369
diff changeset
  1890
	 * In this case, we just parse that file and load required data.
208
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1891
	 *
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1892
	 * If system has not enough physical memory for installation,
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1893
	 * swap is required and minimum size will account for it.
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1894
	 *
208
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1895
	 * Otherwise, create swap and dump only if user dedicated
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1896
	 * at least recommended disk size for installation.
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1897
	 *
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1898
	 * Dump is always optional.
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1899
	 *
389
f9a7dbcea5b5 4280 AI tries to open nonexistent /.cdrom/.image_info file
Jan Damborsky <jan.damborsky@sun.com>
parents: 369
diff changeset
  1900
	 * If information about image size is not available, default
f9a7dbcea5b5 4280 AI tries to open nonexistent /.cdrom/.image_info file
Jan Damborsky <jan.damborsky@sun.com>
parents: 369
diff changeset
  1901
	 * is used (4GiB).
f9a7dbcea5b5 4280 AI tries to open nonexistent /.cdrom/.image_info file
Jan Damborsky <jan.damborsky@sun.com>
parents: 369
diff changeset
  1902
	 * This is the case of Automated Installation, as the size needs to be
f9a7dbcea5b5 4280 AI tries to open nonexistent /.cdrom/.image_info file
Jan Damborsky <jan.damborsky@sun.com>
parents: 369
diff changeset
  1903
	 * dynamically calculated, since list of packages to be installed is
f9a7dbcea5b5 4280 AI tries to open nonexistent /.cdrom/.image_info file
Jan Damborsky <jan.damborsky@sun.com>
parents: 369
diff changeset
  1904
	 * provided in AI manifest and thus can be customized.
f9a7dbcea5b5 4280 AI tries to open nonexistent /.cdrom/.image_info file
Jan Damborsky <jan.damborsky@sun.com>
parents: 369
diff changeset
  1905
	 * Until there is a mechanism which would dynamically calculate total
f9a7dbcea5b5 4280 AI tries to open nonexistent /.cdrom/.image_info file
Jan Damborsky <jan.damborsky@sun.com>
parents: 369
diff changeset
  1906
	 * size of packages to be installed, we keep image_size set to the
f9a7dbcea5b5 4280 AI tries to open nonexistent /.cdrom/.image_info file
Jan Damborsky <jan.damborsky@sun.com>
parents: 369
diff changeset
  1907
	 * default value for now (4GiB). Initialization of image_info variable
f9a7dbcea5b5 4280 AI tries to open nonexistent /.cdrom/.image_info file
Jan Damborsky <jan.damborsky@sun.com>
parents: 369
diff changeset
  1908
	 * is part of its definition.
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1909
	 */
191
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  1910
539
2d996f9b841a 7758 AI install always fails after swap slice is created
William Schumann <william.schumann@sun.com>
parents: 538
diff changeset
  1911
	if (!om_is_automated_installation()) {
389
f9a7dbcea5b5 4280 AI tries to open nonexistent /.cdrom/.image_info file
Jan Damborsky <jan.damborsky@sun.com>
parents: 369
diff changeset
  1912
		if (obtain_image_info(&image_info) != OM_SUCCESS)
f9a7dbcea5b5 4280 AI tries to open nonexistent /.cdrom/.image_info file
Jan Damborsky <jan.damborsky@sun.com>
parents: 369
diff changeset
  1913
			om_log_print("Couldn't read image info file\n");
f9a7dbcea5b5 4280 AI tries to open nonexistent /.cdrom/.image_info file
Jan Damborsky <jan.damborsky@sun.com>
parents: 369
diff changeset
  1914
	}
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1915
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1916
	return ((uint64_t)(image_info.image_size *
208
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  1917
	    image_info.compress_ratio * 1.2) + calc_required_swap_size());
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1918
}
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1919
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1920
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1921
/*ARGSUSED*/
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1922
uint64_t
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1923
om_get_recommended_size(char *media, char *distro)
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1924
{
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1925
	/*
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1926
	 * Size in MB that is the recommended device size we will allow
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1927
	 * for installing Slim.
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1928
	 *
191
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  1929
	 * Account for one full upgrade, minimal swap and dump volumes
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  1930
	 * and add nother 2 GiB for additional software.
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1931
	 */
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  1932
191
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  1933
	return (get_recommended_size_for_software()
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  1934
	    + MIN_DUMP_SIZE + MIN_SWAP_SIZE);
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1935
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1936
233
77e7268f9c10 3448 GUI needs to be enhanced in order to support +1TB phase 1 project
Jan Damborsky <jan.damborsky@sun.com>
parents: 229
diff changeset
  1937
/*
77e7268f9c10 3448 GUI needs to be enhanced in order to support +1TB phase 1 project
Jan Damborsky <jan.damborsky@sun.com>
parents: 229
diff changeset
  1938
 * Return maximum usable disk size in MiB
77e7268f9c10 3448 GUI needs to be enhanced in order to support +1TB phase 1 project
Jan Damborsky <jan.damborsky@sun.com>
parents: 229
diff changeset
  1939
 */
77e7268f9c10 3448 GUI needs to be enhanced in order to support +1TB phase 1 project
Jan Damborsky <jan.damborsky@sun.com>
parents: 229
diff changeset
  1940
uint32_t
77e7268f9c10 3448 GUI needs to be enhanced in order to support +1TB phase 1 project
Jan Damborsky <jan.damborsky@sun.com>
parents: 229
diff changeset
  1941
om_get_max_usable_disk_size(void)
77e7268f9c10 3448 GUI needs to be enhanced in order to support +1TB phase 1 project
Jan Damborsky <jan.damborsky@sun.com>
parents: 229
diff changeset
  1942
{
77e7268f9c10 3448 GUI needs to be enhanced in order to support +1TB phase 1 project
Jan Damborsky <jan.damborsky@sun.com>
parents: 229
diff changeset
  1943
	return (MAX_USABLE_DISK);
77e7268f9c10 3448 GUI needs to be enhanced in order to support +1TB phase 1 project
Jan Damborsky <jan.damborsky@sun.com>
parents: 229
diff changeset
  1944
}
77e7268f9c10 3448 GUI needs to be enhanced in order to support +1TB phase 1 project
Jan Damborsky <jan.damborsky@sun.com>
parents: 229
diff changeset
  1945
63
c1fdc489e0eb 811 GUI refuses to allow install to continue if user name is in /etc/passwd
Joseph J Vlcek <Joseph.Vlcek@Sun.COM>
parents: 61
diff changeset
  1946
/*
c1fdc489e0eb 811 GUI refuses to allow install to continue if user name is in /etc/passwd
Joseph J Vlcek <Joseph.Vlcek@Sun.COM>
parents: 61
diff changeset
  1947
 * Return the UID which will be assigned to the new user
c1fdc489e0eb 811 GUI refuses to allow install to continue if user name is in /etc/passwd
Joseph J Vlcek <Joseph.Vlcek@Sun.COM>
parents: 61
diff changeset
  1948
 * created by the installer.
c1fdc489e0eb 811 GUI refuses to allow install to continue if user name is in /etc/passwd
Joseph J Vlcek <Joseph.Vlcek@Sun.COM>
parents: 61
diff changeset
  1949
 */
c1fdc489e0eb 811 GUI refuses to allow install to continue if user name is in /etc/passwd
Joseph J Vlcek <Joseph.Vlcek@Sun.COM>
parents: 61
diff changeset
  1950
uid_t
c1fdc489e0eb 811 GUI refuses to allow install to continue if user name is in /etc/passwd
Joseph J Vlcek <Joseph.Vlcek@Sun.COM>
parents: 61
diff changeset
  1951
om_get_user_uid(void)
c1fdc489e0eb 811 GUI refuses to allow install to continue if user name is in /etc/passwd
Joseph J Vlcek <Joseph.Vlcek@Sun.COM>
parents: 61
diff changeset
  1952
{
229
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  1953
	return ((uid_t)ICT_USER_UID);
63
c1fdc489e0eb 811 GUI refuses to allow install to continue if user name is in /etc/passwd
Joseph J Vlcek <Joseph.Vlcek@Sun.COM>
parents: 61
diff changeset
  1954
}
c1fdc489e0eb 811 GUI refuses to allow install to continue if user name is in /etc/passwd
Joseph J Vlcek <Joseph.Vlcek@Sun.COM>
parents: 61
diff changeset
  1955
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1956
char *
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1957
om_encrypt_passwd(char *passwd, char *username)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1958
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1959
	char	*e_pw = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1960
	char	*saltc;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1961
	struct 	passwd	*u_pw = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1962
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1963
	u_pw = getpwnam(username);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1964
	if (u_pw == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1965
		u_pw = malloc(sizeof (struct passwd));
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1966
		if (u_pw == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1967
			om_set_error(OM_NO_SPACE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1968
			return (NULL);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1969
		}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1970
		u_pw->pw_name = strdup(username);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1971
		if (u_pw->pw_name == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1972
			free((void *)u_pw);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1973
			om_set_error(OM_NO_SPACE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1974
			return (NULL);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1975
		}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1976
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1977
	saltc = crypt_gensalt(NULL, u_pw);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1978
	if (saltc == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1979
		free((void *)u_pw->pw_name);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1980
		free((void *)u_pw);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1981
		om_set_error(errno);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1982
		return (NULL);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1983
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1984
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1985
	e_pw = crypt((const char *)passwd, saltc);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1986
	return (e_pw);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1987
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1988
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1989
static void
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1990
set_system_state(void)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1991
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1992
	sys_config	sysconfig;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1993
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1994
	sysconfig.configured = 1;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1995
	sysconfig.bootparamed = 1;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1996
	sysconfig.networked = 1;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1997
	sysconfig.extnetwork = 1;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1998
	sysconfig.autobound = 1;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1999
	sysconfig.subnetted = 1;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2000
	sysconfig.passwdset = 1;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2001
	sysconfig.localeset = 1;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2002
	sysconfig.security = 1;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2003
	sysconfig.nfs4domain = 1;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2004
	(void) sprintf(sysconfig.termtype, "sun");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2005
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2006
	write_sysid_state(&sysconfig);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2007
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2008
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2009
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2010
static char *
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2011
find_state_file()
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2012
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2013
	char *path;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2014
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2015
	if (state_file_path == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2016
		path = STATE_FILE;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2017
		if (trav_link(&path) == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2018
			state_file_path = strdup(path);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2019
			if (state_file_path == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2020
				om_set_error(OM_NO_SPACE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2021
				return (NULL);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2022
			}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2023
			om_debug_print(OM_DBGLVL_INFO,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2024
			    "State file changing = %s\n", state_file_path);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2025
		} else {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2026
			state_file_path = STATE_FILE;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2027
			om_debug_print(OM_DBGLVL_INFO,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2028
			    "State file changing = %s\n", state_file_path);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2029
		}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2030
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2031
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2032
	om_debug_print(OM_DBGLVL_INFO,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2033
	    "sydIDtool.state file is %s\n", state_file_path);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2034
	return (state_file_path);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2035
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2036
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2037
static int
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2038
trav_link(char **path)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2039
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2040
	static char	newpath[MAXPATHLEN];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2041
	char 		lastpath[MAXPATHLEN];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2042
	int 		len;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2043
	char 		*tp;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2044
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2045
	(void) strcpy(lastpath, *path);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2046
	while ((len = readlink(*path, newpath, sizeof (newpath))) != -1) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2047
		newpath[len] = '\0';
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2048
		if (newpath[0] != '/') {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2049
			tp = strdup(newpath);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2050
			if (tp == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2051
				om_set_error(OM_NO_SPACE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2052
				om_debug_print(OM_DBGLVL_ERR,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2053
				    "Could not allocate space for "
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2054
				    "%s\n", newpath);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2055
				return (OM_FAILURE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2056
			}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2057
			remove_component(lastpath);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2058
			(void) snprintf(newpath, sizeof (newpath), "%s/%s",
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2059
			    lastpath, tp);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2060
			free(tp);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2061
		}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2062
		(void) strcpy(lastpath, newpath);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2063
		*path = newpath;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2064
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2065
	/* XXX why is this so? XXX */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2066
	if (errno == ENOENT || errno == EINVAL)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2067
		return (OM_SUCCESS);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2068
	return (OM_FAILURE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2069
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2070
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2071
static void
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2072
remove_component(char *path)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2073
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2074
	char	*p;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2075
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2076
	p = strrchr(path, '/');	/* find last '/' */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2077
	if (p == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2078
		*path = '\0';
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2079
	} else {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2080
		*p = '\0';
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2081
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2082
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2083
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2084
static void
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2085
write_sysid_state(sys_config *sysconfigp)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2086
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2087
	mode_t	cmask;	/* Current umask */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2088
	FILE	*fp;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2089
	char	*file = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2090
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2091
	cmask = umask((mode_t)022);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2092
	file = find_state_file();
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2093
	if (file == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2094
		om_set_error(OM_CANT_OPEN_FILE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2095
		om_debug_print(OM_DBGLVL_WARN,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2096
		    "Could not find sysidtool.state file\n");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2097
		return;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2098
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2099
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2100
	fp = fopen(file, "w");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2101
	(void) umask(cmask);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2102
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2103
	if (fp == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2104
		om_debug_print(OM_DBGLVL_WARN,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2105
		    "sysIDtool %s couldn't open: "
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2106
		    "errno = %d\n", find_state_file(), errno);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2107
		return;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2108
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2109
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2110
	 * Write each state component.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2111
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2112
	(void) fprintf(fp, "%d\t%s\n", sysconfigp->configured,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2113
	    "# System previously configured?");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2114
	om_debug_print(OM_DBGLVL_INFO, "write ( configured): %d\n",
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2115
	    sysconfigp->configured);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2116
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2117
	(void) fprintf(fp, "%d\t%s\n", sysconfigp->bootparamed,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2118
	    "# Bootparams succeeded?");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2119
	om_debug_print(OM_DBGLVL_INFO, "write (bootparamed): %d\n",
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2120
	    sysconfigp->bootparamed);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2121
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2122
	(void) fprintf(fp, "%d\t%s\n", sysconfigp->networked,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2123
	    "# System is on a network?");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2124
	om_debug_print(OM_DBGLVL_INFO, "write (  networked): %d\n",
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2125
	    sysconfigp->networked);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2126
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2127
	(void) fprintf(fp, "%d\t%s\n", sysconfigp->extnetwork,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2128
	    "# Extended network information gathered?");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2129
	om_debug_print(OM_DBGLVL_INFO, "write (ext network): %d\n",
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2130
	    sysconfigp->extnetwork);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2131
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2132
	(void) fprintf(fp, "%d\t%s\n", sysconfigp->autobound,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2133
	    "# Autobinder succeeded?");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2134
	om_debug_print(OM_DBGLVL_INFO, "write (  autobound): %d\n",
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2135
	    sysconfigp->autobound);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2136
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2137
	(void) fprintf(fp, "%d\t%s\n", sysconfigp->subnetted,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2138
	    "# Network has subnets?");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2139
	om_debug_print(OM_DBGLVL_INFO, "write (  subnetted): %d\n",
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2140
	    sysconfigp->subnetted);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2141
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2142
	(void) fprintf(fp, "%d\t%s\n", sysconfigp->passwdset,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2143
	    "# root password prompted for?");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2144
	om_debug_print(OM_DBGLVL_INFO, "write (     passwd): %d\n",
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2145
	    sysconfigp->passwdset);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2146
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2147
	(void) fprintf(fp, "%d\t%s\n", sysconfigp->localeset,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2148
	    "# locale and term prompted for?");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2149
	om_debug_print(OM_DBGLVL_INFO, "write (     locale): %d\n",
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2150
	    sysconfigp->localeset);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2151
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2152
	(void) fprintf(fp, "%d\t%s\n", sysconfigp->security,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2153
	    "# security policy in place");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2154
	om_debug_print(OM_DBGLVL_INFO, "write (   security): %d\n",
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2155
	    sysconfigp->security);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2156
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2157
	(void) fprintf(fp, "%d\t%s\n", sysconfigp->nfs4domain,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2158
	    "# NFSv4 domain configured");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2159
	om_debug_print(OM_DBGLVL_INFO, "write ( nfs4domain): %d\n",
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2160
	    sysconfigp->nfs4domain);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2161
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2162
	 * N.B.: termtype MUST be the last entry in sysIDtool.state,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2163
	 * as suninstall.sh tails this file to get the TERM env variable.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2164
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2165
	(void) fprintf(fp, "%s\n", sysconfigp->termtype);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2166
	om_debug_print(OM_DBGLVL_INFO, "write (       term): %s\n",
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2167
	    sysconfigp->termtype);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2168
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2169
	(void) fclose(fp);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2170
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2171
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2172
/*
91
ac77f3175bdb 990 - Install complete reported before post-install tasks complete
William Schumann <william.schumann@sun.com>
parents: 74
diff changeset
  2173
 * Inform GUI of error condition through callback
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2174
 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2175
static	void
94
fd4991588edd 1010 - Target Instantiation progress doesn't display in GUI
William Schumann <william.schumann@sun.com>
parents: 91
diff changeset
  2176
notify_error_status(int status)
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2177
{
91
ac77f3175bdb 990 - Install complete reported before post-install tasks complete
William Schumann <william.schumann@sun.com>
parents: 74
diff changeset
  2178
	om_callback_info_t cb_data;
ac77f3175bdb 990 - Install complete reported before post-install tasks complete
William Schumann <william.schumann@sun.com>
parents: 74
diff changeset
  2179
94
fd4991588edd 1010 - Target Instantiation progress doesn't display in GUI
William Schumann <william.schumann@sun.com>
parents: 91
diff changeset
  2180
	cb_data.num_milestones = 3;
91
ac77f3175bdb 990 - Install complete reported before post-install tasks complete
William Schumann <william.schumann@sun.com>
parents: 74
diff changeset
  2181
	cb_data.curr_milestone = -1; /* signals error to GUI */
ac77f3175bdb 990 - Install complete reported before post-install tasks complete
William Schumann <william.schumann@sun.com>
parents: 74
diff changeset
  2182
	cb_data.callback_type = OM_INSTALL_TYPE;
94
fd4991588edd 1010 - Target Instantiation progress doesn't display in GUI
William Schumann <william.schumann@sun.com>
parents: 91
diff changeset
  2183
	cb_data.percentage_done = status; /* overload value on error */
91
ac77f3175bdb 990 - Install complete reported before post-install tasks complete
William Schumann <william.schumann@sun.com>
parents: 74
diff changeset
  2184
	cb_data.message = NULL;
ac77f3175bdb 990 - Install complete reported before post-install tasks complete
William Schumann <william.schumann@sun.com>
parents: 74
diff changeset
  2185
	om_cb(&cb_data, 0);
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2186
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2187
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2188
/*
91
ac77f3175bdb 990 - Install complete reported before post-install tasks complete
William Schumann <william.schumann@sun.com>
parents: 74
diff changeset
  2189
 * Notify the GUI that the installation is complete
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2190
 */
94
fd4991588edd 1010 - Target Instantiation progress doesn't display in GUI
William Schumann <william.schumann@sun.com>
parents: 91
diff changeset
  2191
static	void
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2192
notify_install_complete()
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2193
{
91
ac77f3175bdb 990 - Install complete reported before post-install tasks complete
William Schumann <william.schumann@sun.com>
parents: 74
diff changeset
  2194
	om_callback_info_t cb_data;
ac77f3175bdb 990 - Install complete reported before post-install tasks complete
William Schumann <william.schumann@sun.com>
parents: 74
diff changeset
  2195
94
fd4991588edd 1010 - Target Instantiation progress doesn't display in GUI
William Schumann <william.schumann@sun.com>
parents: 91
diff changeset
  2196
	cb_data.num_milestones = 3;
91
ac77f3175bdb 990 - Install complete reported before post-install tasks complete
William Schumann <william.schumann@sun.com>
parents: 74
diff changeset
  2197
	cb_data.curr_milestone = OM_POSTINSTAL_TASKS;
ac77f3175bdb 990 - Install complete reported before post-install tasks complete
William Schumann <william.schumann@sun.com>
parents: 74
diff changeset
  2198
	cb_data.callback_type = OM_INSTALL_TYPE;
ac77f3175bdb 990 - Install complete reported before post-install tasks complete
William Schumann <william.schumann@sun.com>
parents: 74
diff changeset
  2199
	cb_data.percentage_done = 100;
ac77f3175bdb 990 - Install complete reported before post-install tasks complete
William Schumann <william.schumann@sun.com>
parents: 74
diff changeset
  2200
	cb_data.message = NULL;
ac77f3175bdb 990 - Install complete reported before post-install tasks complete
William Schumann <william.schumann@sun.com>
parents: 74
diff changeset
  2201
	om_cb(&cb_data, 0);
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2202
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2203
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2204
/*
217
75a649a169f5 1008 Installer should completely unmount target/BE before it quits
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 208
diff changeset
  2205
 * Add swap entry to /etc/vfstab
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2206
 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2207
static void
217
75a649a169f5 1008 Installer should completely unmount target/BE before it quits
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 208
diff changeset
  2208
setup_etc_vfstab_for_swap(char *target)
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2209
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2210
	FILE	*fp;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2211
	char	cmd[MAXPATHLEN];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2212
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2213
	if (target == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2214
		return;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2215
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2216
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2217
	(void) snprintf(cmd, sizeof (cmd), "%s/etc/vfstab", target);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2218
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2219
	fp = fopen(cmd, "a+");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2220
	if (fp == NULL) {
217
75a649a169f5 1008 Installer should completely unmount target/BE before it quits
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 208
diff changeset
  2221
		om_log_print("Cannot open %s to add entry for swap\n", cmd);
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2222
		return;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2223
	}
217
75a649a169f5 1008 Installer should completely unmount target/BE before it quits
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 208
diff changeset
  2224
75a649a169f5 1008 Installer should completely unmount target/BE before it quits
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 208
diff changeset
  2225
	om_log_print("Setting up swap mount in %s\n", cmd);
75a649a169f5 1008 Installer should completely unmount target/BE before it quits
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 208
diff changeset
  2226
75a649a169f5 1008 Installer should completely unmount target/BE before it quits
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 208
diff changeset
  2227
	(void) fprintf(fp, "%s\t%s\t\t%s\t\t%s\t%s\t%s\t%s\n",
75a649a169f5 1008 Installer should completely unmount target/BE before it quits
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 208
diff changeset
  2228
	    swap_device, "-", "-", "swap", "-", "no", "-");
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2229
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2230
	(void) fclose(fp);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2231
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2232
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2233
/*
131
0924b7312a4f 1567 orchestrator should unmount ZFS dataset before resetting the mountpoint property
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 98
diff changeset
  2234
 * Setup mountpoint property back to "/" from "/a" for
0924b7312a4f 1567 orchestrator should unmount ZFS dataset before resetting the mountpoint property
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 98
diff changeset
  2235
 * /, /opt, /export, /export/home
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2236
 */
635
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  2237
static int
496
51900384c4fd 6744 beadm fails for sparc AI sun4v due to missing /rpool/boot/menu.lst
Joseph J Vlcek <Joseph.Vlcek@Sun.COM>
parents: 495
diff changeset
  2238
reset_zfs_mount_property(char *target, int transfer_mode)
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2239
{
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2240
	char 		cmd[MAXPATHLEN];
131
0924b7312a4f 1567 orchestrator should unmount ZFS dataset before resetting the mountpoint property
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 98
diff changeset
  2241
	int		i, ret;
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2242
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2243
	if (target == NULL) {
635
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  2244
		return (OM_FAILURE);
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2245
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2246
635
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  2247
	om_log_print("Unmounting shared BE filesystems\n");
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2248
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2249
	/*
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2250
	 * make sure we are not in alternate root
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2251
	 * otherwise be_unmount() fails
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2252
	 */
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2253
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2254
	chdir("/root");
16
c82dd8a4617c 354 better hierarchy for initial datasets
equach@ethos
parents: 13
diff changeset
  2255
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2256
	/*
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2257
	 * Since be_unmount() can't currently handle shared filesystems,
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2258
	 * it is necessary to manually set their mountpoint to the
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2259
	 * appropriate value.
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2260
	 */
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2261
229
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  2262
	for (i = l_zfs_shared_fs_num - 1; i >= 0; i--) {
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2263
		(void) snprintf(cmd, sizeof (cmd),
131
0924b7312a4f 1567 orchestrator should unmount ZFS dataset before resetting the mountpoint property
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 98
diff changeset
  2264
		    "/usr/sbin/zfs unmount %s%s",
0924b7312a4f 1567 orchestrator should unmount ZFS dataset before resetting the mountpoint property
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 98
diff changeset
  2265
		    ROOTPOOL_NAME, zfs_shared_fs_names[i]);
0924b7312a4f 1567 orchestrator should unmount ZFS dataset before resetting the mountpoint property
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 98
diff changeset
  2266
0924b7312a4f 1567 orchestrator should unmount ZFS dataset before resetting the mountpoint property
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 98
diff changeset
  2267
		om_log_print("%s\n", cmd);
0924b7312a4f 1567 orchestrator should unmount ZFS dataset before resetting the mountpoint property
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 98
diff changeset
  2268
		ret = td_safe_system(cmd, B_TRUE);
0924b7312a4f 1567 orchestrator should unmount ZFS dataset before resetting the mountpoint property
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 98
diff changeset
  2269
0924b7312a4f 1567 orchestrator should unmount ZFS dataset before resetting the mountpoint property
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 98
diff changeset
  2270
		if ((ret == -1) || WEXITSTATUS(ret) != 0) {
635
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  2271
			om_debug_print(OM_DBGLVL_ERR,
131
0924b7312a4f 1567 orchestrator should unmount ZFS dataset before resetting the mountpoint property
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 98
diff changeset
  2272
			    "Couldn't unmount %s%s, err=%d\n", ROOTPOOL_NAME,
0924b7312a4f 1567 orchestrator should unmount ZFS dataset before resetting the mountpoint property
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 98
diff changeset
  2273
			    zfs_shared_fs_names[i], ret);
0924b7312a4f 1567 orchestrator should unmount ZFS dataset before resetting the mountpoint property
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 98
diff changeset
  2274
		}
0924b7312a4f 1567 orchestrator should unmount ZFS dataset before resetting the mountpoint property
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 98
diff changeset
  2275
0924b7312a4f 1567 orchestrator should unmount ZFS dataset before resetting the mountpoint property
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 98
diff changeset
  2276
		(void) snprintf(cmd, sizeof (cmd),
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2277
		    "/usr/sbin/zfs set mountpoint=%s %s%s",
131
0924b7312a4f 1567 orchestrator should unmount ZFS dataset before resetting the mountpoint property
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 98
diff changeset
  2278
		    zfs_shared_fs_names[i], ROOTPOOL_NAME,
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2279
		    zfs_shared_fs_names[i]);
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2280
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2281
		om_log_print("%s\n", cmd);
131
0924b7312a4f 1567 orchestrator should unmount ZFS dataset before resetting the mountpoint property
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 98
diff changeset
  2282
		ret = td_safe_system(cmd, B_TRUE);
0924b7312a4f 1567 orchestrator should unmount ZFS dataset before resetting the mountpoint property
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 98
diff changeset
  2283
0924b7312a4f 1567 orchestrator should unmount ZFS dataset before resetting the mountpoint property
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 98
diff changeset
  2284
		if ((ret == -1) || WEXITSTATUS(ret) != 0) {
635
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  2285
			om_debug_print(OM_DBGLVL_ERR,
131
0924b7312a4f 1567 orchestrator should unmount ZFS dataset before resetting the mountpoint property
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 98
diff changeset
  2286
			    "Couldn't change mountpoint for %s%s, err=%d\n",
0924b7312a4f 1567 orchestrator should unmount ZFS dataset before resetting the mountpoint property
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 98
diff changeset
  2287
			    ROOTPOOL_NAME, zfs_shared_fs_names[i], ret);
0924b7312a4f 1567 orchestrator should unmount ZFS dataset before resetting the mountpoint property
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 98
diff changeset
  2288
		}
30
21835f70424f 135 .bashrc owned by root
<sarah.jelinek@sun.com>
parents: 26
diff changeset
  2289
	}
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2290
16
c82dd8a4617c 354 better hierarchy for initial datasets
equach@ethos
parents: 13
diff changeset
  2291
	/*
635
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  2292
	 * Transfer log files to the destination.
217
75a649a169f5 1008 Installer should completely unmount target/BE before it quits
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 208
diff changeset
  2293
	 */
75a649a169f5 1008 Installer should completely unmount target/BE before it quits
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 208
diff changeset
  2294
496
51900384c4fd 6744 beadm fails for sparc AI sun4v due to missing /rpool/boot/menu.lst
Joseph J Vlcek <Joseph.Vlcek@Sun.COM>
parents: 495
diff changeset
  2295
	if (ict_transfer_logs("/", target, transfer_mode) != ICT_SUCCESS) {
229
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  2296
		om_log_print("Failed to transfer install log file\n"
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  2297
		    "%s\n", ICT_STR_ERROR(ict_errno));
635
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  2298
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  2299
		return (OM_FAILURE);
229
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  2300
	}
217
75a649a169f5 1008 Installer should completely unmount target/BE before it quits
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 208
diff changeset
  2301
635
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  2302
	/*
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  2303
	 * Unmount non-shared BE filesystems for CPIO transfer mode.
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  2304
	 * Automated Installer which uses IPS transfer mode takes care
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  2305
	 * of this later, since it will omit more log messages which should
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  2306
	 * be captured in log file and transfered to the target.
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  2307
	 */
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  2308
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  2309
	if (transfer_mode == OM_CPIO_TRANSFER)
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  2310
		return (om_unmount_target_be());
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  2311
74823d433dc4 6651 autoinstall needs more useful error messages from Orchestrator module
Jan Damborsky <jan.damborsky@sun.com>
parents: 633
diff changeset
  2312
	return (OM_SUCCESS);
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2313
}
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2314
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2315
/*
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2316
 * Setup bootfs property, so that newly created Solaris instance
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2317
 * is boooted appropriately
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2318
 */
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2319
static void
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2320
activate_be(char *be_name)
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2321
{
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2322
	char 		cmd[MAXPATHLEN];
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2323
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2324
	/*
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2325
	 * Set bootfs property for root pool. It can't be
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2326
	 * set before root filesystem is created.
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2327
	 */
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2328
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2329
	(void) snprintf(cmd, sizeof (cmd),
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2330
	    "/usr/sbin/zpool set bootfs=%s/ROOT/%s %s",
131
0924b7312a4f 1567 orchestrator should unmount ZFS dataset before resetting the mountpoint property
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 98
diff changeset
  2331
	    ROOTPOOL_NAME, be_name, ROOTPOOL_NAME);
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2332
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2333
	om_log_print("%s\n", cmd);
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2334
	td_safe_system(cmd, B_TRUE);
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2335
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2336
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2337
/*
229
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  2338
 * Execute install-finish script to complete setup.
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2339
 */
344
f6279fc734cf 4871 ICT failures are not reported as a failed installation
Joseph J Vlcek <Joseph.Vlcek@Sun.COM>
parents: 332
diff changeset
  2340
static int
229
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  2341
run_install_finish_script(char *target, char *uname, char *lname,
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  2342
    char *upasswd, char *rpasswd)
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2343
{
220
eee8efa772f8 2901 install-finish is in the wrong package
Dave Miner <dminer@opensolaris.org>
parents: 217
diff changeset
  2344
	char cmd[1024];
229
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  2345
	char *tool = "/sbin/install-finish ";
332
9d076128dd86 4344 ICT fails to create user account if real name contains an apostrophe
Joseph J Vlcek <Joseph.Vlcek@Sun.COM>
parents: 282
diff changeset
  2346
	char *fixed_rpasswd = NULL;
9d076128dd86 4344 ICT fails to create user account if real name contains an apostrophe
Joseph J Vlcek <Joseph.Vlcek@Sun.COM>
parents: 282
diff changeset
  2347
	char *fixed_uname = NULL;
9d076128dd86 4344 ICT fails to create user account if real name contains an apostrophe
Joseph J Vlcek <Joseph.Vlcek@Sun.COM>
parents: 282
diff changeset
  2348
	char *fixed_upasswd = NULL;
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2349
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2350
	if (target == NULL) {
344
f6279fc734cf 4871 ICT failures are not reported as a failed installation
Joseph J Vlcek <Joseph.Vlcek@Sun.COM>
parents: 332
diff changeset
  2351
		return (OM_SUCCESS);
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2352
	}
332
9d076128dd86 4344 ICT fails to create user account if real name contains an apostrophe
Joseph J Vlcek <Joseph.Vlcek@Sun.COM>
parents: 282
diff changeset
  2353
9d076128dd86 4344 ICT fails to create user account if real name contains an apostrophe
Joseph J Vlcek <Joseph.Vlcek@Sun.COM>
parents: 282
diff changeset
  2354
	/*
9d076128dd86 4344 ICT fails to create user account if real name contains an apostrophe
Joseph J Vlcek <Joseph.Vlcek@Sun.COM>
parents: 282
diff changeset
  2355
	 * It is possible that the username, and passwords could
9d076128dd86 4344 ICT fails to create user account if real name contains an apostrophe
Joseph J Vlcek <Joseph.Vlcek@Sun.COM>
parents: 282
diff changeset
  2356
	 * contain a single quote. Invoking ict_escape will prepare
9d076128dd86 4344 ICT fails to create user account if real name contains an apostrophe
Joseph J Vlcek <Joseph.Vlcek@Sun.COM>
parents: 282
diff changeset
  2357
	 * them to be passed to the shell without the risk of the
9d076128dd86 4344 ICT fails to create user account if real name contains an apostrophe
Joseph J Vlcek <Joseph.Vlcek@Sun.COM>
parents: 282
diff changeset
  2358
	 * shell misinterpreting a single quote.
9d076128dd86 4344 ICT fails to create user account if real name contains an apostrophe
Joseph J Vlcek <Joseph.Vlcek@Sun.COM>
parents: 282
diff changeset
  2359
	 */
9d076128dd86 4344 ICT fails to create user account if real name contains an apostrophe
Joseph J Vlcek <Joseph.Vlcek@Sun.COM>
parents: 282
diff changeset
  2360
	if (((fixed_rpasswd = ict_escape(rpasswd)) == NULL) ||
9d076128dd86 4344 ICT fails to create user account if real name contains an apostrophe
Joseph J Vlcek <Joseph.Vlcek@Sun.COM>
parents: 282
diff changeset
  2361
	    ((fixed_uname = ict_escape(uname)) == NULL) ||
9d076128dd86 4344 ICT fails to create user account if real name contains an apostrophe
Joseph J Vlcek <Joseph.Vlcek@Sun.COM>
parents: 282
diff changeset
  2362
	    ((fixed_upasswd = ict_escape(upasswd)) == NULL)) {
9d076128dd86 4344 ICT fails to create user account if real name contains an apostrophe
Joseph J Vlcek <Joseph.Vlcek@Sun.COM>
parents: 282
diff changeset
  2363
		/*
9d076128dd86 4344 ICT fails to create user account if real name contains an apostrophe
Joseph J Vlcek <Joseph.Vlcek@Sun.COM>
parents: 282
diff changeset
  2364
		 * Not all of the above calls to ict_escape()s succeeded
9d076128dd86 4344 ICT fails to create user account if real name contains an apostrophe
Joseph J Vlcek <Joseph.Vlcek@Sun.COM>
parents: 282
diff changeset
  2365
		 * but some may have. Issue free an all of them is a
9d076128dd86 4344 ICT fails to create user account if real name contains an apostrophe
Joseph J Vlcek <Joseph.Vlcek@Sun.COM>
parents: 282
diff changeset
  2366
		 * safe way to clean up before returning.
9d076128dd86 4344 ICT fails to create user account if real name contains an apostrophe
Joseph J Vlcek <Joseph.Vlcek@Sun.COM>
parents: 282
diff changeset
  2367
		 */
9d076128dd86 4344 ICT fails to create user account if real name contains an apostrophe
Joseph J Vlcek <Joseph.Vlcek@Sun.COM>
parents: 282
diff changeset
  2368
		free(fixed_rpasswd);
9d076128dd86 4344 ICT fails to create user account if real name contains an apostrophe
Joseph J Vlcek <Joseph.Vlcek@Sun.COM>
parents: 282
diff changeset
  2369
		free(fixed_uname);
9d076128dd86 4344 ICT fails to create user account if real name contains an apostrophe
Joseph J Vlcek <Joseph.Vlcek@Sun.COM>
parents: 282
diff changeset
  2370
		free(fixed_upasswd);
9d076128dd86 4344 ICT fails to create user account if real name contains an apostrophe
Joseph J Vlcek <Joseph.Vlcek@Sun.COM>
parents: 282
diff changeset
  2371
		om_log_print("Out of memory\n");
344
f6279fc734cf 4871 ICT failures are not reported as a failed installation
Joseph J Vlcek <Joseph.Vlcek@Sun.COM>
parents: 332
diff changeset
  2372
		return (OM_FAILURE);
332
9d076128dd86 4344 ICT fails to create user account if real name contains an apostrophe
Joseph J Vlcek <Joseph.Vlcek@Sun.COM>
parents: 282
diff changeset
  2373
	}
9d076128dd86 4344 ICT fails to create user account if real name contains an apostrophe
Joseph J Vlcek <Joseph.Vlcek@Sun.COM>
parents: 282
diff changeset
  2374
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2375
	om_log_print("Running install-finish script\n");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2376
	(void) snprintf(cmd, sizeof (cmd),
244
de31188f80e4 3788 SHA256 passwords and ICT don't mix
Dave Miner <dminer@opensolaris.org>
parents: 238
diff changeset
  2377
	    "%s -B '%s' -R '%s' -n '%s' -l '%s' -p '%s' "
de31188f80e4 3788 SHA256 passwords and ICT don't mix
Dave Miner <dminer@opensolaris.org>
parents: 238
diff changeset
  2378
	    "-G '%d' -U '%d'",
332
9d076128dd86 4344 ICT fails to create user account if real name contains an apostrophe
Joseph J Vlcek <Joseph.Vlcek@Sun.COM>
parents: 282
diff changeset
  2379
	    tool, target, fixed_rpasswd, fixed_uname, lname,
9d076128dd86 4344 ICT fails to create user account if real name contains an apostrophe
Joseph J Vlcek <Joseph.Vlcek@Sun.COM>
parents: 282
diff changeset
  2380
	    fixed_upasswd, ICT_USER_GID, ICT_USER_UID);
9d076128dd86 4344 ICT fails to create user account if real name contains an apostrophe
Joseph J Vlcek <Joseph.Vlcek@Sun.COM>
parents: 282
diff changeset
  2381
9d076128dd86 4344 ICT fails to create user account if real name contains an apostrophe
Joseph J Vlcek <Joseph.Vlcek@Sun.COM>
parents: 282
diff changeset
  2382
	free(fixed_rpasswd);
9d076128dd86 4344 ICT fails to create user account if real name contains an apostrophe
Joseph J Vlcek <Joseph.Vlcek@Sun.COM>
parents: 282
diff changeset
  2383
	free(fixed_uname);
9d076128dd86 4344 ICT fails to create user account if real name contains an apostrophe
Joseph J Vlcek <Joseph.Vlcek@Sun.COM>
parents: 282
diff changeset
  2384
	free(fixed_upasswd);
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  2385
755
3831fc5aa665 14913 orchestrator and install-finish shouldn't be logging password hashes
David Miner <dminer@opensolaris.org>
parents: 674
diff changeset
  2386
	om_debug_print(OM_DBGLVL_INFO, "%s\n", cmd);
344
f6279fc734cf 4871 ICT failures are not reported as a failed installation
Joseph J Vlcek <Joseph.Vlcek@Sun.COM>
parents: 332
diff changeset
  2387
	if (td_safe_system(cmd, B_TRUE) != 0) {
f6279fc734cf 4871 ICT failures are not reported as a failed installation
Joseph J Vlcek <Joseph.Vlcek@Sun.COM>
parents: 332
diff changeset
  2388
		om_log_print("The install-finish script reported failures.\n");
f6279fc734cf 4871 ICT failures are not reported as a failed installation
Joseph J Vlcek <Joseph.Vlcek@Sun.COM>
parents: 332
diff changeset
  2389
		return (OM_FAILURE);
f6279fc734cf 4871 ICT failures are not reported as a failed installation
Joseph J Vlcek <Joseph.Vlcek@Sun.COM>
parents: 332
diff changeset
  2390
	} else {
f6279fc734cf 4871 ICT failures are not reported as a failed installation
Joseph J Vlcek <Joseph.Vlcek@Sun.COM>
parents: 332
diff changeset
  2391
		om_log_print("The install-finish script succeeded\n");
f6279fc734cf 4871 ICT failures are not reported as a failed installation
Joseph J Vlcek <Joseph.Vlcek@Sun.COM>
parents: 332
diff changeset
  2392
		return (OM_SUCCESS);
f6279fc734cf 4871 ICT failures are not reported as a failed installation
Joseph J Vlcek <Joseph.Vlcek@Sun.COM>
parents: 332
diff changeset
  2393
	}
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2394
}
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2395
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2396
/*
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2397
 * prepare_zfs_root_pool_attrs
282
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
  2398
 * Creates nvlist set of attributes describing ZFS pool to be created/released
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2399
 * Input:	nvlist_t **attrs - attributes describing the target
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2400
 *		char *disk_name - disk name which will hold the pool
405
785221d05f6b 4195 need to make changes to AI Engine for SPARC
William Schumann <william.schumann@sun.com>
parents: 389
diff changeset
  2401
 *		uint8_t slice_id - number of disk slice into which the zfs
785221d05f6b 4195 need to make changes to AI Engine for SPARC
William Schumann <william.schumann@sun.com>
parents: 389
diff changeset
  2402
 *			root pool will be created (ignored for release pool)
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2403
 * Output:
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2404
 * Return:	OM_SUCCESS
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2405
 *		OM_FAILURE
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2406
 * Notes:
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2407
 */
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2408
static int
405
785221d05f6b 4195 need to make changes to AI Engine for SPARC
William Schumann <william.schumann@sun.com>
parents: 389
diff changeset
  2409
prepare_zfs_root_pool_attrs(nvlist_t **attrs, char *disk_name, uint8_t slice_id)
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2410
{
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2411
	if (nvlist_alloc(attrs, TI_TARGET_NVLIST_TYPE, 0) != 0) {
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2412
		om_log_print("Could not create target nvlist.\n");
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2413
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2414
		return (OM_FAILURE);
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2415
	}
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2416
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2417
	if (nvlist_add_uint32(*attrs, TI_ATTR_TARGET_TYPE,
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2418
	    TI_TARGET_TYPE_ZFS_RPOOL) != 0) {
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2419
		(void) om_log_print("Couldn't add TI_ATTR_TARGET_TYPE to"
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2420
		    "nvlist\n");
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2421
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2422
		return (OM_FAILURE);
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2423
	}
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2424
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2425
	if (nvlist_add_string(*attrs, TI_ATTR_ZFS_RPOOL_NAME,
131
0924b7312a4f 1567 orchestrator should unmount ZFS dataset before resetting the mountpoint property
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 98
diff changeset
  2426
	    ROOTPOOL_NAME) != 0) {
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2427
		om_log_print("ZFS root pool name could not be added. \n");
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2428
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2429
		return (OM_FAILURE);
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2430
	}
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2431
405
785221d05f6b 4195 need to make changes to AI Engine for SPARC
William Schumann <william.schumann@sun.com>
parents: 389
diff changeset
  2432
	snprintf(zfs_device, sizeof (zfs_device), "%ss%d", disk_name, slice_id);
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2433
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2434
	if (nvlist_add_string(*attrs, TI_ATTR_ZFS_RPOOL_DEVICE,
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2435
	    zfs_device) != 0) {
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2436
		om_log_print("Could not set zfs rpool device name\n");
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2437
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2438
		return (OM_FAILURE);
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2439
	}
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2440
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2441
	return (OM_SUCCESS);
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2442
}
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2443
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2444
/*
789
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2445
 * calculate_available_swap_dump_space
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2446
 * Calculates the available space for both swap and dump devices, using
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2447
 * actual space available and the potential requested swap and dump sizes.
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2448
 *
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2449
 * Input:
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2450
 *		available_disk_space - space which can be dedicated to
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2451
 *			swap and dump.
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2452
 *      available_swap_space - container for calculated swap space available
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2453
 *      available_dump_space - container for calculated dump space available
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2454
 *
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2455
 * Output:	available_swap_space,
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2456
 *		available_dump_space
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2457
 * Return: OM_SUCCESS : Space available
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2458
 *		OM_FAILURE : Space not available for requested swap/dump
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2459
 * Notes:
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2460
 */
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2461
static int
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2462
calculate_available_swap_dump_space(uint64_t available_disk_space,
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2463
	uint32_t *available_swap_space,
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2464
	uint32_t *available_dump_space)
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2465
{
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2466
	/*
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2467
	 * If swap or dump is explicitly specified and insufficient space
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2468
	 * exists to create them, OM_FAILURE is returned.
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2469
	 *
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2470
	 * If neither are specified, then the original space available
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2471
	 * calculations are used, roughly 66% for swap and 33% for dump.
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2472
	 */
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2473
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2474
	/* Both swap and dump have been requested */
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2475
	if (requested_swap_size >= 0 && requested_dump_size >= 0) {
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2476
		if ((requested_swap_size + requested_dump_size) <=
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2477
		    available_disk_space) {
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2478
			/* Sufficient space for both requested swap and dump */
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2479
			*available_swap_space =
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2480
			    available_disk_space - requested_dump_size;
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2481
			*available_dump_space =
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2482
			    available_disk_space - requested_swap_size;
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2483
		} else {
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2484
			/*
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2485
			 * Not enough space available for both specified swap
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2486
			 * and dump, install should fail as these values are
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2487
			 * required.
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2488
			 */
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2489
			(void) om_log_print("Not enough space available for "
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2490
			    "swap&dump specified in manifest, %lu required "
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2491
			    "(%lu swap requested + %lu dump requested), only "
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2492
			    "%llu space available\n",
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2493
			    requested_swap_size + requested_dump_size,
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2494
			    requested_swap_size, requested_dump_size,
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2495
			    available_disk_space);
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2496
			return (OM_FAILURE);
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2497
		}
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2498
	} else if (requested_swap_size >= 0) {
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2499
		/*
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2500
		 * Only swap requested, Try and honor this
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2501
		 * request if possible, dump will be created from remainder.
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2502
		 */
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2503
		if (requested_swap_size == 0) {
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2504
			/*
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2505
			 * Requested to not create swap at all
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2506
			 * so all remainder disk space is available
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2507
			 * for dump.
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2508
			 */
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2509
			*available_swap_space = 0;
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2510
			*available_dump_space = available_disk_space;
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2511
		} else if ((requested_swap_size + MIN_DUMP_SIZE) >
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2512
		    available_disk_space) {
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2513
			/*
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2514
			 * Not enough space for requested swap + MIN_DUMP_SIZE.
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2515
			 * install should fail.
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2516
			 */
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2517
			(void) om_log_print("Not enough space available for "
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2518
			    "swap specified in manifest, %lu required (%lu "
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2519
			    "swap requested + %lu MIN_DUMP_SIZE), "
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2520
			    "only %llu space available\n",
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2521
			    requested_swap_size + MIN_DUMP_SIZE,
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2522
			    requested_swap_size, MIN_DUMP_SIZE,
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2523
			    available_disk_space);
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2524
			return (OM_FAILURE);
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2525
		} else {
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2526
			/*
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2527
			 * Space available for swap, use remainder for dump.
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2528
			 */
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2529
			*available_swap_space = requested_swap_size;
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2530
			*available_dump_space =
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2531
			    available_disk_space - requested_swap_size;
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2532
		}
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2533
	} else if (requested_dump_size >= 0) {
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2534
		/*
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2535
		 * Only dump requested.
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2536
		 * Swap of MIN_SWAP_SIZE will be created, leaving remainder
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2537
		 * for dump
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2538
		 * Should we validate remainder >= MIN_SWAP_SIZE.
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2539
		 */
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2540
		if (requested_dump_size == 0) {
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2541
			/*
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2542
			 * Requested To not create dump,
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2543
			 * all available space for swap
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2544
			 */
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2545
			*available_swap_space = available_disk_space;
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2546
			*available_dump_space = 0;
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2547
		} else if ((requested_dump_size + MIN_SWAP_SIZE) >
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2548
		    available_disk_space) {
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2549
			/*
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2550
			 * Not enough space for requested dump + MIN_SWAP_SIZE
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2551
			 * install should fail.
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2552
			 */
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2553
			(void) om_log_print("Not enough space available for "
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2554
			    "dump specified in manifest, %lu required (%lu "
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2555
			    "dump requested + %lu MIN_SWAP_SPACE), "
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2556
			    "only %llu space available\n",
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2557
			    requested_dump_size + MIN_SWAP_SIZE,
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2558
			    requested_dump_size, MIN_SWAP_SIZE,
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2559
			    available_disk_space);
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2560
			return (OM_FAILURE);
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2561
		} else {
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2562
			/*
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2563
			 * Requested dump will be created
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2564
			 * And Swap from remainder.
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2565
			 */
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2566
			*available_swap_space =
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2567
			    available_disk_space - requested_dump_size;
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2568
			*available_dump_space = requested_dump_size;
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2569
		}
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2570
	} else {
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2571
		/*
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2572
		 * Neither swap/dump requested, use existing
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2573
		 * default calculations
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2574
		 */
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2575
		*available_swap_space = ((available_disk_space *
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2576
		    MIN_SWAP_SIZE) / (MIN_SWAP_SIZE + MIN_DUMP_SIZE));
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2577
		*available_dump_space = ((available_disk_space *
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2578
		    MIN_DUMP_SIZE) / (MIN_SWAP_SIZE + MIN_DUMP_SIZE));
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2579
	}
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2580
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2581
	om_debug_print(OM_DBGLVL_INFO,
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2582
	    "Calculated available space for swap : %lu, and dump : %lu\n",
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2583
	    *available_swap_space, *available_dump_space);
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2584
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2585
	return (OM_SUCCESS);
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2586
}
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2587
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2588
/*
191
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2589
 * prepare_zfs_volume_attrs
354
2c1eaf565c25 3597 Unable to install OpenSolaris with 512 MB base memory
Glenn Lagasse <Glenn.Lagasse@Sun.COM>
parents: 344
diff changeset
  2590
 * Creates nvlist set of attributes describing ZFS volumes to be created.
2c1eaf565c25 3597 Unable to install OpenSolaris with 512 MB base memory
Glenn Lagasse <Glenn.Lagasse@Sun.COM>
parents: 344
diff changeset
  2591
 * If a slice has already been created for the swap device, create a zvol
2c1eaf565c25 3597 Unable to install OpenSolaris with 512 MB base memory
Glenn Lagasse <Glenn.Lagasse@Sun.COM>
parents: 344
diff changeset
  2592
 * only for the dump device.  Else if the flag to create only the minimum
2c1eaf565c25 3597 Unable to install OpenSolaris with 512 MB base memory
Glenn Lagasse <Glenn.Lagasse@Sun.COM>
parents: 344
diff changeset
  2593
 * sized swap device is passed in, create a zvol only for the swap device.
2c1eaf565c25 3597 Unable to install OpenSolaris with 512 MB base memory
Glenn Lagasse <Glenn.Lagasse@Sun.COM>
parents: 344
diff changeset
  2594
 * Otherwise, create zvols for both swap and dump.
2c1eaf565c25 3597 Unable to install OpenSolaris with 512 MB base memory
Glenn Lagasse <Glenn.Lagasse@Sun.COM>
parents: 344
diff changeset
  2595
 *
191
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2596
 * Input:	nvlist_t **attrs - attributes describing the target
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2597
 *		available_disk_space - space which can be dedicated to
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2598
 *			swap and dump.
208
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  2599
 *		create_min_swap_only - only swap with minimum size is created
191
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2600
 *
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2601
 * Output:
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2602
 * Return:	OM_SUCCESS
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2603
 *		OM_FAILURE
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2604
 * Notes:
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2605
 */
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2606
static int
208
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  2607
prepare_zfs_volume_attrs(nvlist_t **attrs, uint64_t available_disk_space,
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  2608
    boolean_t create_min_swap_only)
191
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2609
{
354
2c1eaf565c25 3597 Unable to install OpenSolaris with 512 MB base memory
Glenn Lagasse <Glenn.Lagasse@Sun.COM>
parents: 344
diff changeset
  2610
	uint16_t	vol_num = 0;
2c1eaf565c25 3597 Unable to install OpenSolaris with 512 MB base memory
Glenn Lagasse <Glenn.Lagasse@Sun.COM>
parents: 344
diff changeset
  2611
	char		*vol_names[2] = { 0 };
2c1eaf565c25 3597 Unable to install OpenSolaris with 512 MB base memory
Glenn Lagasse <Glenn.Lagasse@Sun.COM>
parents: 344
diff changeset
  2612
	uint16_t	vol_types[2] = { 0 };
2c1eaf565c25 3597 Unable to install OpenSolaris with 512 MB base memory
Glenn Lagasse <Glenn.Lagasse@Sun.COM>
parents: 344
diff changeset
  2613
	uint32_t	vol_sizes[2] = { 0 };
789
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2614
	uint32_t	available_swap_space = 0;
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2615
	uint32_t	available_dump_space = 0;
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2616
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2617
	if (calculate_available_swap_dump_space(available_disk_space,
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2618
	    &available_swap_space, &available_dump_space) != OM_SUCCESS) {
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2619
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2620
		return (OM_FAILURE);
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2621
	}
354
2c1eaf565c25 3597 Unable to install OpenSolaris with 512 MB base memory
Glenn Lagasse <Glenn.Lagasse@Sun.COM>
parents: 344
diff changeset
  2622
2c1eaf565c25 3597 Unable to install OpenSolaris with 512 MB base memory
Glenn Lagasse <Glenn.Lagasse@Sun.COM>
parents: 344
diff changeset
  2623
	if (create_swap_slice) {
2c1eaf565c25 3597 Unable to install OpenSolaris with 512 MB base memory
Glenn Lagasse <Glenn.Lagasse@Sun.COM>
parents: 344
diff changeset
  2624
		/*
2c1eaf565c25 3597 Unable to install OpenSolaris with 512 MB base memory
Glenn Lagasse <Glenn.Lagasse@Sun.COM>
parents: 344
diff changeset
  2625
		 * A slice for swap has already been created, create
2c1eaf565c25 3597 Unable to install OpenSolaris with 512 MB base memory
Glenn Lagasse <Glenn.Lagasse@Sun.COM>
parents: 344
diff changeset
  2626
		 * a zvol only for the dump device.
2c1eaf565c25 3597 Unable to install OpenSolaris with 512 MB base memory
Glenn Lagasse <Glenn.Lagasse@Sun.COM>
parents: 344
diff changeset
  2627
		 */
789
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2628
		if (requested_dump_size != 0) {
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2629
			om_debug_print(OM_DBGLVL_INFO,
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2630
			    "Setting up DUMP zvol\n");
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2631
			vol_num = 1;
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2632
			vol_names[0] = TI_ZFS_VOL_NAME_DUMP;
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2633
			vol_types[0] = TI_ZFS_VOL_TYPE_DUMP;
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2634
			vol_sizes[0] = calc_dump_size(available_dump_space);
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2635
		}
354
2c1eaf565c25 3597 Unable to install OpenSolaris with 512 MB base memory
Glenn Lagasse <Glenn.Lagasse@Sun.COM>
parents: 344
diff changeset
  2636
	} else if (create_min_swap_only) {
2c1eaf565c25 3597 Unable to install OpenSolaris with 512 MB base memory
Glenn Lagasse <Glenn.Lagasse@Sun.COM>
parents: 344
diff changeset
  2637
		/*
2c1eaf565c25 3597 Unable to install OpenSolaris with 512 MB base memory
Glenn Lagasse <Glenn.Lagasse@Sun.COM>
parents: 344
diff changeset
  2638
		 * Create a zvol only for swap with the minimum swap size.
2c1eaf565c25 3597 Unable to install OpenSolaris with 512 MB base memory
Glenn Lagasse <Glenn.Lagasse@Sun.COM>
parents: 344
diff changeset
  2639
		 */
789
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2640
		/* Do not check for requested swap size in this scenario */
879
b65e82e368f5 6978639 Default net AI install on x86 with 1GB or less memory no longer works when installing from /dev repo
Ethan Quach <Ethan.Quach@sun.com>
parents: 861
diff changeset
  2641
		om_debug_print(OM_DBGLVL_INFO,
b65e82e368f5 6978639 Default net AI install on x86 with 1GB or less memory no longer works when installing from /dev repo
Ethan Quach <Ethan.Quach@sun.com>
parents: 861
diff changeset
  2642
		    "Setting up required swap zvol\n");
354
2c1eaf565c25 3597 Unable to install OpenSolaris with 512 MB base memory
Glenn Lagasse <Glenn.Lagasse@Sun.COM>
parents: 344
diff changeset
  2643
		vol_num = 1;
2c1eaf565c25 3597 Unable to install OpenSolaris with 512 MB base memory
Glenn Lagasse <Glenn.Lagasse@Sun.COM>
parents: 344
diff changeset
  2644
		vol_names[0] = TI_ZFS_VOL_NAME_SWAP;
2c1eaf565c25 3597 Unable to install OpenSolaris with 512 MB base memory
Glenn Lagasse <Glenn.Lagasse@Sun.COM>
parents: 344
diff changeset
  2645
		vol_types[0] = TI_ZFS_VOL_TYPE_SWAP;
879
b65e82e368f5 6978639 Default net AI install on x86 with 1GB or less memory no longer works when installing from /dev repo
Ethan Quach <Ethan.Quach@sun.com>
parents: 861
diff changeset
  2646
		vol_sizes[0] = limit_min_max(calc_required_swap_size(),
b65e82e368f5 6978639 Default net AI install on x86 with 1GB or less memory no longer works when installing from /dev repo
Ethan Quach <Ethan.Quach@sun.com>
parents: 861
diff changeset
  2647
		    MIN_SWAP_SIZE, MAX_SWAP_SIZE);
354
2c1eaf565c25 3597 Unable to install OpenSolaris with 512 MB base memory
Glenn Lagasse <Glenn.Lagasse@Sun.COM>
parents: 344
diff changeset
  2648
	} else {
2c1eaf565c25 3597 Unable to install OpenSolaris with 512 MB base memory
Glenn Lagasse <Glenn.Lagasse@Sun.COM>
parents: 344
diff changeset
  2649
		/*
2c1eaf565c25 3597 Unable to install OpenSolaris with 512 MB base memory
Glenn Lagasse <Glenn.Lagasse@Sun.COM>
parents: 344
diff changeset
  2650
		 * Create zvols for both swap and dump.
789
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2651
		 * If requested size of zero do not create.
354
2c1eaf565c25 3597 Unable to install OpenSolaris with 512 MB base memory
Glenn Lagasse <Glenn.Lagasse@Sun.COM>
parents: 344
diff changeset
  2652
		 */
789
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2653
		vol_num = 0;
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2654
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2655
		/* Check of requested swap is zero */
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2656
		if (requested_swap_size != 0) {
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2657
			om_debug_print(OM_DBGLVL_INFO,
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2658
			    "Setting up SWAP zvol\n");
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2659
			vol_names[vol_num] = TI_ZFS_VOL_NAME_SWAP;
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2660
			vol_types[vol_num] = TI_ZFS_VOL_TYPE_SWAP;
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2661
			vol_sizes[vol_num] =
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2662
			    calc_swap_size(available_swap_space);
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2663
			vol_num++;
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2664
		}
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2665
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2666
		/* Check of requested dump is zero */
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2667
		if (requested_dump_size != 0) {
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2668
			om_debug_print(OM_DBGLVL_INFO,
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2669
			    "Setting up DUMP zvol\n");
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2670
			vol_names[vol_num] = TI_ZFS_VOL_NAME_DUMP;
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2671
			vol_types[vol_num] = TI_ZFS_VOL_TYPE_DUMP;
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2672
			vol_sizes[vol_num] =
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2673
			    calc_dump_size(available_dump_space);
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2674
			vol_num++;
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2675
		}
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2676
	}
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2677
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2678
	if (vol_num == 0) {
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2679
		om_log_print("No ZFS Volume information configured\n");
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2680
282f473d34ee 10115 AI ignores desired swap listed in ai manifest
Matt Keenan <matt.keenan@sun.com>
parents: 755
diff changeset
  2681
		return (OM_FAILURE);
354
2c1eaf565c25 3597 Unable to install OpenSolaris with 512 MB base memory
Glenn Lagasse <Glenn.Lagasse@Sun.COM>
parents: 344
diff changeset
  2682
	}
191
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2683
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2684
	if (nvlist_alloc(attrs, TI_TARGET_NVLIST_TYPE, 0) != 0) {
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2685
		om_log_print("Could not create target nvlist.\n");
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2686
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2687
		return (OM_FAILURE);
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2688
	}
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2689
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2690
	if (nvlist_add_uint32(*attrs, TI_ATTR_TARGET_TYPE,
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2691
	    TI_TARGET_TYPE_ZFS_VOLUME) != 0) {
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2692
		(void) om_log_print("Couldn't add TI_ATTR_TARGET_TYPE to "
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2693
		    "nvlist\n");
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2694
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2695
		return (OM_FAILURE);
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2696
	}
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2697
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2698
	if (nvlist_add_string(*attrs, TI_ATTR_ZFS_VOL_POOL_NAME, ROOTPOOL_NAME)
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2699
	    != 0) {
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2700
		(void) om_log_print("Couldn't add TI_ATTR_ZFS_VOL_POOL_NAME to "
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2701
		    "nvlist\n");
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2702
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2703
		return (OM_FAILURE);
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2704
	}
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2705
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2706
	if (nvlist_add_uint16(*attrs, TI_ATTR_ZFS_VOL_NUM, vol_num) != 0) {
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2707
		(void) om_log_print("Couldn't add TI_ATTR_ZFS_VOL_NUM to "
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2708
		    "nvlist\n");
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2709
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2710
		return (OM_FAILURE);
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2711
	}
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2712
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2713
	if (nvlist_add_string_array(*attrs, TI_ATTR_ZFS_VOL_NAMES, vol_names,
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2714
	    vol_num) != 0) {
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2715
		(void) om_log_print("Couldn't add TI_ATTR_ZFS_VOL_NAMES to "
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2716
		    "nvlist\n");
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2717
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2718
		return (OM_FAILURE);
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2719
	}
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2720
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2721
	if (nvlist_add_uint32_array(*attrs, TI_ATTR_ZFS_VOL_MB_SIZES,
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2722
	    vol_sizes, vol_num) != 0) {
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2723
		(void) om_log_print("Couldn't add TI_ATTR_ZFS_VOL_SIZES to "
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2724
		    "nvlist\n");
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2725
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2726
		return (OM_FAILURE);
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2727
	}
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2728
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2729
	if (nvlist_add_uint16_array(*attrs, TI_ATTR_ZFS_VOL_TYPES,
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2730
	    vol_types, vol_num) != 0) {
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2731
		(void) om_log_print("Couldn't add TI_ATTR_ZFS_VOL_TYPES to "
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2732
		    "nvlist\n");
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2733
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2734
		return (OM_FAILURE);
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2735
	}
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2736
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2737
	return (OM_SUCCESS);
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2738
}
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2739
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  2740
/*
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2741
 * prepare_be_attrs
144
1bcfac4d8e02 1299 orchestrator shouldn't take care of creating <root_pool>/ROOT dataset
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 131
diff changeset
  2742
 * Creates nvlist set of attributes describing boot environment (BE)
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2743
 * Input:	nvlist_t **attrs - attributes describing the target
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2744
 *
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2745
 * Output:
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2746
 * Return:	OM_SUCCESS
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2747
 *		OM_FAILURE
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2748
 * Notes:
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2749
 */
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2750
static int
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2751
prepare_be_attrs(nvlist_t **attrs)
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2752
{
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2753
	if (nvlist_alloc(attrs, TI_TARGET_NVLIST_TYPE, 0) != 0) {
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2754
		om_log_print("Could not create target nvlist.\n");
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2755
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2756
		return (OM_FAILURE);
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2757
	}
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2758
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2759
	if (nvlist_add_uint32(*attrs, TI_ATTR_TARGET_TYPE,
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2760
	    TI_TARGET_TYPE_BE) != 0) {
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2761
		(void) om_log_print("Couldn't add TI_ATTR_TARGET_TYPE to"
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2762
		    "nvlist\n");
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2763
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2764
		return (OM_FAILURE);
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2765
	}
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2766
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2767
	if (nvlist_add_string(*attrs, TI_ATTR_BE_RPOOL_NAME,
131
0924b7312a4f 1567 orchestrator should unmount ZFS dataset before resetting the mountpoint property
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 98
diff changeset
  2768
	    ROOTPOOL_NAME) != 0) {
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2769
		om_log_print("BE root pool name could not be added. \n");
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2770
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2771
		return (OM_FAILURE);
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2772
	}
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2773
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2774
	if (nvlist_add_string(*attrs, TI_ATTR_BE_NAME,
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2775
	    INIT_BE_NAME) != 0) {
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2776
		om_log_print("BE name could not be added. \n");
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2777
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2778
		return (OM_FAILURE);
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2779
	}
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2780
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2781
	if (nvlist_add_string_array(*attrs, TI_ATTR_BE_FS_NAMES,
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2782
	    zfs_fs_names, ZFS_FS_NUM) != 0) {
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2783
		om_log_print("Couldn't set zfs fs name attr\n");
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2784
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2785
		return (OM_FAILURE);
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2786
	}
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2787
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2788
	if (nvlist_add_string_array(*attrs, TI_ATTR_BE_SHARED_FS_NAMES,
229
9e8783c6042e 1040 post-installation phase should be redesigned
William Schumann <william.schumann@sun.com>
parents: 220
diff changeset
  2789
	    zfs_shared_fs_names, l_zfs_shared_fs_num) != 0) {
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2790
		om_log_print("Couldn't set zfs shared fs name attr\n");
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2791
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2792
		return (OM_FAILURE);
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2793
	}
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2794
147
ad29d9ae205f 1906 BE mountpoint shouldn't be hardcoded in libti
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 146
diff changeset
  2795
	if (nvlist_add_string(*attrs, TI_ATTR_BE_MOUNTPOINT,
ad29d9ae205f 1906 BE mountpoint shouldn't be hardcoded in libti
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 146
diff changeset
  2796
	    INSTALLED_ROOT_DIR) != 0) {
ad29d9ae205f 1906 BE mountpoint shouldn't be hardcoded in libti
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 146
diff changeset
  2797
		om_log_print("Couldn't set be mountpoint attr\n");
ad29d9ae205f 1906 BE mountpoint shouldn't be hardcoded in libti
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 146
diff changeset
  2798
ad29d9ae205f 1906 BE mountpoint shouldn't be hardcoded in libti
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 146
diff changeset
  2799
		return (OM_FAILURE);
ad29d9ae205f 1906 BE mountpoint shouldn't be hardcoded in libti
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 146
diff changeset
  2800
	}
ad29d9ae205f 1906 BE mountpoint shouldn't be hardcoded in libti
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 146
diff changeset
  2801
74
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2802
	return (OM_SUCCESS);
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2803
}
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2804
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2805
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2806
/*
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2807
 * obtain_image_info
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2808
 * Parse image info file and reads following information from it:
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2809
 * [1] total size of installed bits
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2810
 * [2] compression ratio, if ZFS compression is turned on
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2811
 * [3] compression type
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2812
 * Input:	image_info_t * info - pointer to structure, which will
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2813
 *		be populated with image information
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2814
 *
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2815
 * Output:
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2816
 * Return:	OM_SUCCESS - information read successfully
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2817
 *		OM_FAILURE - image information couldn't be obtained
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2818
 * Notes:
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2819
 */
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2820
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2821
static int
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2822
obtain_image_info(image_info_t *info)
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2823
{
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2824
	FILE		*info_file;
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2825
	char		line[IMAGE_INFO_LINE_MAXLN];
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2826
	boolean_t	got_size = B_FALSE;
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2827
	boolean_t	got_cratio = B_FALSE;
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2828
	boolean_t	got_ctype = B_FALSE;
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2829
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2830
	/*
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2831
	 * fill in the structure only once
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2832
	 */
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2833
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2834
	if (info->initialized) {
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2835
		return (OM_SUCCESS);
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2836
	}
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2837
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2838
	/*
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2839
	 * open image info file, parse it
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2840
	 * and populate data structure
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2841
	 */
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2842
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2843
	info_file = fopen(IMAGE_INFO_FILE_NAME, "r");
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2844
	if (info_file == NULL) {
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2845
		om_debug_print(OM_DBGLVL_WARN,
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2846
		    "Couldn't open image info file " IMAGE_INFO_FILE_NAME "\n");
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2847
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2848
		return (OM_FAILURE);
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2849
	}
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2850
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2851
	while (fgets(line, sizeof (line), info_file) != NULL) {
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2852
		char	*par_name, *par_value;
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2853
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2854
		/*
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2855
		 * get parameter name
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2856
		 */
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2857
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2858
		/* TAB is one of separators */
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2859
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2860
		par_name = strtok(line, "= 	");
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2861
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2862
		if (par_name == NULL) {
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2863
			om_debug_print(OM_DBGLVL_WARN,
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2864
			    "Invalid parameter %s\n", line);
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2865
			continue;
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2866
		}
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2867
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2868
		/*
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2869
		 * get parameter value
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2870
		 */
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2871
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2872
		par_value = strtok(NULL, "= 	");
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2873
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2874
		if (par_value == NULL) {
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2875
			om_debug_print(OM_DBGLVL_WARN,
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2876
			    "Invalid parameter %s\n", line);
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2877
			continue;
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2878
		}
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2879
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2880
		/*
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2881
		 * look at the parameter name and compare to
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2882
		 * known/requested
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2883
		 */
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2884
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2885
		if (strcmp(par_name, IMAGE_INFO_TOTAL_SIZE) == 0) {
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2886
			uint64_t	size;
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2887
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2888
			errno = 0;
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2889
			size = strtoll(par_value, NULL, 10);
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2890
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2891
			if (errno == 0) {
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2892
				om_debug_print(OM_DBGLVL_INFO,
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2893
				    "Got image size: %lld\n", size);
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2894
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2895
				/* convert kiB -> MiB */
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2896
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2897
				image_info.image_size = size/ONE_MB_TO_KB;
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2898
				got_size = B_TRUE;
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2899
			} else
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2900
				om_debug_print(OM_DBGLVL_WARN,
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2901
				    "Invalid format of total size parameter\n");
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2902
		}
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2903
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2904
		/*
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2905
		 * ask for compression ratio
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2906
		 */
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2907
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2908
		if (strcmp(par_name, IMAGE_INFO_COMPRESSION_RATIO) == 0) {
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2909
			float ratio;
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2910
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2911
			errno = 0;
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2912
			ratio = strtof(par_value, NULL);
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2913
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2914
			if (errno == 0) {
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2915
				om_debug_print(OM_DBGLVL_INFO,
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2916
				    "Got compression ratio: %f\n", ratio);
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2917
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2918
				image_info.compress_ratio = ratio;
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2919
				got_cratio = B_TRUE;
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2920
			} else
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2921
				om_debug_print(OM_DBGLVL_WARN,
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2922
				    "Invalid format of compression ratio "
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2923
				    "parameter\n");
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2924
		}
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2925
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2926
		/*
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2927
		 * ask for compression type
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2928
		 */
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2929
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2930
		if (strcmp(par_name, IMAGE_INFO_COMPRESSION_TYPE) == 0) {
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2931
			char *type;
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2932
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2933
			type = strdup(par_value);
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2934
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2935
			if (type != NULL) {
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2936
				om_debug_print(OM_DBGLVL_INFO,
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2937
				    "Got compression type: %s\n", type);
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2938
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2939
				image_info.compress_type = type;
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2940
				got_ctype = B_TRUE;
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2941
			} else
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2942
				om_debug_print(OM_DBGLVL_WARN,
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2943
				    "Invalid format of compression type "
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2944
				    "parameter\n");
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2945
		}
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2946
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2947
		if (got_size && got_cratio && got_ctype)
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2948
			break;
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2949
	}
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2950
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2951
	(void) fclose(info_file);
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2952
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2953
	/*
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2954
	 * if at least one of parameters obtained,
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2955
	 * we read image info file successfully
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2956
	 */
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2957
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2958
	if (got_size || got_cratio || got_ctype) {
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2959
		info->initialized = B_TRUE;
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2960
		return (OM_SUCCESS);
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2961
	} else
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2962
		return (OM_FAILURE);
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2963
}
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2964
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2965
ba240cbcdf1c 833 TI, TD, orchestrator has to be enhanced for Slim and DC
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 69
diff changeset
  2966
/*
282
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
  2967
 * get_dataset_property
98
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
  2968
 *
282
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
  2969
 * Obtains value of dataset property
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
  2970
 * Return:	== NULL - couldn't obtain property
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
  2971
 *		!= NULL - pointer to property value
98
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
  2972
 * Notes:
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
  2973
 */
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
  2974
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
  2975
static char *
282
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
  2976
get_dataset_property(char *dataset_name, char *property)
98
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
  2977
{
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
  2978
	FILE	*p;
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
  2979
	char	cmd[MAXPATHLEN];
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
  2980
	char	*strbuf;
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
  2981
	int	ret;
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
  2982
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
  2983
	strbuf = malloc(MAXPATHLEN);
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
  2984
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
  2985
	if (strbuf == NULL) {
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
  2986
		om_log_print("Out of memory\n");
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
  2987
		return (NULL);
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
  2988
	}
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
  2989
282
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
  2990
	(void) snprintf(cmd, sizeof (cmd),
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
  2991
	    "/usr/sbin/zfs get -H -o value %s %s", property, dataset_name);
98
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
  2992
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
  2993
	om_log_print("%s\n", cmd);
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
  2994
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
  2995
	if ((p = popen(cmd, "r")) == NULL) {
282
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
  2996
		om_log_print("Couldn't obtain dataset property\n");
98
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
  2997
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
  2998
		free(strbuf);
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
  2999
		return (NULL);
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
  3000
	}
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
  3001
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
  3002
	if (fgets(strbuf, MAXPATHLEN, p) == NULL) {
282
29220561caa5 1771 Install will fail if rpool ZFS pool already exists
Jan Damborsky <jan.damborsky@sun.com>
parents: 274
diff changeset
  3003
		om_log_print("Couldn't obtain dataset property\n");
98
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
  3004
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
  3005
		free(strbuf);
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
  3006
		(void) pclose(p);
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
  3007
		return (NULL);
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
  3008
	}
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
  3009
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
  3010
	ret = WEXITSTATUS(pclose(p));
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
  3011
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
  3012
	if (ret != 0) {
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
  3013
		om_log_print("Command failed with error %d\n", ret);
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
  3014
		free(strbuf);
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
  3015
		return (NULL);
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
  3016
	}
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
  3017
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
  3018
	/* strip new line */
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
  3019
	if (strbuf[strlen(strbuf) - 1] == '\n')
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
  3020
		strbuf[strlen(strbuf) - 1] = '\0';
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
  3021
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
  3022
	return (strbuf);
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
  3023
}
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
  3024
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
  3025
e6f4c48366dc 1013 TI shouldn't destroy 'rpool' on other than target disk
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 94
diff changeset
  3026
/*
191
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3027
 * get_available_disk_space
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3028
 *
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3029
 * Obtains information about real disk space available for installation
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3030
 * by taking a look at ZFS "available" attribute of pool root dataset
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3031
 *
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3032
 * Return:	0  - couldn't obtain available disk space
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3033
 *		>0 - available disk space in MiB
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3034
 * Notes:
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3035
 */
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3036
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3037
static uint64_t
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3038
get_available_disk_space(void)
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3039
{
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3040
	FILE		*p;
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3041
	char		cmd[MAXPATHLEN];
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3042
	char		*strbuf;
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3043
	int		ret;
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3044
	uint64_t	avail_space;
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3045
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3046
	strbuf = malloc(MAXPATHLEN);
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3047
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3048
	if (strbuf == NULL) {
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3049
		om_log_print("Out of memory\n");
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3050
		return (0);
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3051
	}
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3052
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3053
	(void) snprintf(cmd, sizeof (cmd),
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3054
	    "/usr/sbin/zfs get -Hp -o value available " ROOTPOOL_NAME);
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3055
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3056
	om_log_print("%s\n", cmd);
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3057
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3058
	if ((p = popen(cmd, "r")) == NULL) {
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3059
		om_log_print("Couldn't obtain available space\n");
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3060
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3061
		free(strbuf);
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3062
		return (0);
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3063
	}
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3064
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3065
	if (fgets(strbuf, MAXPATHLEN, p) == NULL) {
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3066
		om_log_print("Couldn't obtain available space\n");
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3067
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3068
		free(strbuf);
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3069
		(void) pclose(p);
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3070
		return (0);
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3071
	}
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3072
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3073
	ret = WEXITSTATUS(pclose(p));
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3074
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3075
	if (ret != 0) {
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3076
		om_log_print("Command failed with error %d\n", ret);
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3077
		free(strbuf);
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3078
		return (0);
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3079
	}
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3080
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3081
	/* strip new line */
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3082
	if (strbuf[strlen(strbuf) - 1] == '\n')
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3083
		strbuf[strlen(strbuf) - 1] = '\0';
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3084
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3085
	om_debug_print(OM_DBGLVL_INFO,
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3086
	    ROOTPOOL_NAME " pool: %s bytes are available\n", strbuf);
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3087
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3088
	/* convert to MiB */
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3089
	errno = 0;
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3090
	avail_space = strtoll(strbuf, NULL, 10) / ONE_MB_TO_BYTE;
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3091
	if (errno != 0) {
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3092
		om_log_print("Couldn't obtain available space, strtoll() "
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3093
		"failed with error %d\n", errno);
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3094
		free(strbuf);
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3095
		return (0);
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3096
	}
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3097
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3098
	om_debug_print(OM_DBGLVL_INFO,
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3099
	    ROOTPOOL_NAME " pool: %llu MiB are available\n", avail_space);
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3100
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3101
	return (avail_space);
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3102
}
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3103
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3104
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3105
/*
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3106
 * get_recommended_size_for_software
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3107
 *
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3108
 * Calculates recommended disk size for software portion
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3109
 * of installation
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3110
 *
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3111
 * Return:	0  - couldn't obtain available disk space
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3112
 *		>0 - available disk space in MiB
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3113
 * Notes:
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3114
 */
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3115
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3116
static uint64_t
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3117
get_recommended_size_for_software(void)
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3118
{
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3119
	/*
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3120
	 * Size in MB that is the recommended device size we will allow
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3121
	 * for installing Slim.
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3122
	 *
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3123
	 * Account for one full upgrade and add another 2 GiB for additional
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3124
	 * software.
208
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  3125
	 *
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  3126
	 * If minimum disk size accounts for swap, exclude it.
191
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3127
	 */
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3128
208
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  3129
	return ((om_get_min_size(NULL, NULL) - calc_required_swap_size()) * 2 +
00a9763a29a6 3050 swap should be mandatory on systems with less than 1GB memory
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 191
diff changeset
  3130
	    2048);
191
4ca865e3c121 2161 installer should be compliant with "ZFS root" design specification
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 157
diff changeset
  3131
}
389
f9a7dbcea5b5 4280 AI tries to open nonexistent /.cdrom/.image_info file
Jan Damborsky <jan.damborsky@sun.com>
parents: 369
diff changeset
  3132
f9a7dbcea5b5 4280 AI tries to open nonexistent /.cdrom/.image_info file
Jan Damborsky <jan.damborsky@sun.com>
parents: 369
diff changeset
  3133
f9a7dbcea5b5 4280 AI tries to open nonexistent /.cdrom/.image_info file
Jan Damborsky <jan.damborsky@sun.com>
parents: 369
diff changeset
  3134
/*
f9a7dbcea5b5 4280 AI tries to open nonexistent /.cdrom/.image_info file
Jan Damborsky <jan.damborsky@sun.com>
parents: 369
diff changeset
  3135
 * Check if we are running within Automated Installer environment
f9a7dbcea5b5 4280 AI tries to open nonexistent /.cdrom/.image_info file
Jan Damborsky <jan.damborsky@sun.com>
parents: 369
diff changeset
  3136
 *
f9a7dbcea5b5 4280 AI tries to open nonexistent /.cdrom/.image_info file
Jan Damborsky <jan.damborsky@sun.com>
parents: 369
diff changeset
  3137
 * Return:	B_TRUE - yes, this is Automated Installation
f9a7dbcea5b5 4280 AI tries to open nonexistent /.cdrom/.image_info file
Jan Damborsky <jan.damborsky@sun.com>
parents: 369
diff changeset
  3138
 *		B_FALSE - other type of installation is running
f9a7dbcea5b5 4280 AI tries to open nonexistent /.cdrom/.image_info file
Jan Damborsky <jan.damborsky@sun.com>
parents: 369
diff changeset
  3139
 * Notes:
f9a7dbcea5b5 4280 AI tries to open nonexistent /.cdrom/.image_info file
Jan Damborsky <jan.damborsky@sun.com>
parents: 369
diff changeset
  3140
 */
f9a7dbcea5b5 4280 AI tries to open nonexistent /.cdrom/.image_info file
Jan Damborsky <jan.damborsky@sun.com>
parents: 369
diff changeset
  3141
539
2d996f9b841a 7758 AI install always fails after swap slice is created
William Schumann <william.schumann@sun.com>
parents: 538
diff changeset
  3142
boolean_t
2d996f9b841a 7758 AI install always fails after swap slice is created
William Schumann <william.schumann@sun.com>
parents: 538
diff changeset
  3143
om_is_automated_installation()
389
f9a7dbcea5b5 4280 AI tries to open nonexistent /.cdrom/.image_info file
Jan Damborsky <jan.damborsky@sun.com>
parents: 369
diff changeset
  3144
{
f9a7dbcea5b5 4280 AI tries to open nonexistent /.cdrom/.image_info file
Jan Damborsky <jan.damborsky@sun.com>
parents: 369
diff changeset
  3145
	return (access(AUTOMATED_INSTALLER_MARK, F_OK) == 0 ? B_TRUE : B_FALSE);
f9a7dbcea5b5 4280 AI tries to open nonexistent /.cdrom/.image_info file
Jan Damborsky <jan.damborsky@sun.com>
parents: 369
diff changeset
  3146
}
459
56b6b042a167 5653 AI manifest should offer keyword to use max available space for partition/slice
William Schumann <william.schumann@sun.com>
parents: 447
diff changeset
  3147
56b6b042a167 5653 AI manifest should offer keyword to use max available space for partition/slice
William Schumann <william.schumann@sun.com>
parents: 447
diff changeset
  3148
void
56b6b042a167 5653 AI manifest should offer keyword to use max available space for partition/slice
William Schumann <william.schumann@sun.com>
parents: 447
diff changeset
  3149
om_set_breakpoint(om_breakpoint_t breakpoint)
56b6b042a167 5653 AI manifest should offer keyword to use max available space for partition/slice
William Schumann <william.schumann@sun.com>
parents: 447
diff changeset
  3150
{
56b6b042a167 5653 AI manifest should offer keyword to use max available space for partition/slice
William Schumann <william.schumann@sun.com>
parents: 447
diff changeset
  3151
	om_breakpoint = breakpoint;
56b6b042a167 5653 AI manifest should offer keyword to use max available space for partition/slice
William Schumann <william.schumann@sun.com>
parents: 447
diff changeset
  3152
}
538
914d2f79d86c 7838 Log installer build number and installed software build number in install_log
Evan Layton <Evan.Layton@Sun.COM>
parents: 531
diff changeset
  3153
914d2f79d86c 7838 Log installer build number and installed software build number in install_log
Evan Layton <Evan.Layton@Sun.COM>
parents: 531
diff changeset
  3154
/*
914d2f79d86c 7838 Log installer build number and installed software build number in install_log
Evan Layton <Evan.Layton@Sun.COM>
parents: 531
diff changeset
  3155
 * log_bld_info
914d2f79d86c 7838 Log installer build number and installed software build number in install_log
Evan Layton <Evan.Layton@Sun.COM>
parents: 531
diff changeset
  3156
 * Description:
914d2f79d86c 7838 Log installer build number and installed software build number in install_log
Evan Layton <Evan.Layton@Sun.COM>
parents: 531
diff changeset
  3157
 *		log the build information of an image root path using the
914d2f79d86c 7838 Log installer build number and installed software build number in install_log
Evan Layton <Evan.Layton@Sun.COM>
parents: 531
diff changeset
  3158
 *		output of "pkg info" for the "entire" package.
914d2f79d86c 7838 Log installer build number and installed software build number in install_log
Evan Layton <Evan.Layton@Sun.COM>
parents: 531
diff changeset
  3159
 * Arguments:
914d2f79d86c 7838 Log installer build number and installed software build number in install_log
Evan Layton <Evan.Layton@Sun.COM>
parents: 531
diff changeset
  3160
 *		mountpnt - The image root path to check
914d2f79d86c 7838 Log installer build number and installed software build number in install_log
Evan Layton <Evan.Layton@Sun.COM>
parents: 531
diff changeset
  3161
 *		comment - The comment to be logged before the version
914d2f79d86c 7838 Log installer build number and installed software build number in install_log
Evan Layton <Evan.Layton@Sun.COM>
parents: 531
diff changeset
  3162
 *			  information is logged.
914d2f79d86c 7838 Log installer build number and installed software build number in install_log
Evan Layton <Evan.Layton@Sun.COM>
parents: 531
diff changeset
  3163
 * Return:
914d2f79d86c 7838 Log installer build number and installed software build number in install_log
Evan Layton <Evan.Layton@Sun.COM>
parents: 531
diff changeset
  3164
 *		None.
914d2f79d86c 7838 Log installer build number and installed software build number in install_log
Evan Layton <Evan.Layton@Sun.COM>
parents: 531
diff changeset
  3165
 * Scope:
914d2f79d86c 7838 Log installer build number and installed software build number in install_log
Evan Layton <Evan.Layton@Sun.COM>
parents: 531
diff changeset
  3166
 *		Private
914d2f79d86c 7838 Log installer build number and installed software build number in install_log
Evan Layton <Evan.Layton@Sun.COM>
parents: 531
diff changeset
  3167
 */
914d2f79d86c 7838 Log installer build number and installed software build number in install_log
Evan Layton <Evan.Layton@Sun.COM>
parents: 531
diff changeset
  3168
static void
914d2f79d86c 7838 Log installer build number and installed software build number in install_log
Evan Layton <Evan.Layton@Sun.COM>
parents: 531
diff changeset
  3169
log_bld_info(char *mountpnt, char *comment)
914d2f79d86c 7838 Log installer build number and installed software build number in install_log
Evan Layton <Evan.Layton@Sun.COM>
parents: 531
diff changeset
  3170
{
914d2f79d86c 7838 Log installer build number and installed software build number in install_log
Evan Layton <Evan.Layton@Sun.COM>
parents: 531
diff changeset
  3171
	char rel_str[BUFSIZ] = {0};
914d2f79d86c 7838 Log installer build number and installed software build number in install_log
Evan Layton <Evan.Layton@Sun.COM>
parents: 531
diff changeset
  3172
	char cmd[MAXPATHLEN] = {0};
914d2f79d86c 7838 Log installer build number and installed software build number in install_log
Evan Layton <Evan.Layton@Sun.COM>
parents: 531
diff changeset
  3173
	FILE *fp = NULL;
914d2f79d86c 7838 Log installer build number and installed software build number in install_log
Evan Layton <Evan.Layton@Sun.COM>
parents: 531
diff changeset
  3174
914d2f79d86c 7838 Log installer build number and installed software build number in install_log
Evan Layton <Evan.Layton@Sun.COM>
parents: 531
diff changeset
  3175
	if (mountpnt == NULL || comment == NULL) {
914d2f79d86c 7838 Log installer build number and installed software build number in install_log
Evan Layton <Evan.Layton@Sun.COM>
parents: 531
diff changeset
  3176
		return;
914d2f79d86c 7838 Log installer build number and installed software build number in install_log
Evan Layton <Evan.Layton@Sun.COM>
parents: 531
diff changeset
  3177
	}
914d2f79d86c 7838 Log installer build number and installed software build number in install_log
Evan Layton <Evan.Layton@Sun.COM>
parents: 531
diff changeset
  3178
914d2f79d86c 7838 Log installer build number and installed software build number in install_log
Evan Layton <Evan.Layton@Sun.COM>
parents: 531
diff changeset
  3179
	(void) snprintf(cmd, MAXPATHLEN, "%s -R %s info entire | grep FMRI",
914d2f79d86c 7838 Log installer build number and installed software build number in install_log
Evan Layton <Evan.Layton@Sun.COM>
parents: 531
diff changeset
  3180
	    PKG_PATH, mountpnt);
914d2f79d86c 7838 Log installer build number and installed software build number in install_log
Evan Layton <Evan.Layton@Sun.COM>
parents: 531
diff changeset
  3181
914d2f79d86c 7838 Log installer build number and installed software build number in install_log
Evan Layton <Evan.Layton@Sun.COM>
parents: 531
diff changeset
  3182
	if ((fp = popen(cmd, "r")) != NULL) {
914d2f79d86c 7838 Log installer build number and installed software build number in install_log
Evan Layton <Evan.Layton@Sun.COM>
parents: 531
diff changeset
  3183
		if (fgets(rel_str, BUFSIZ, fp) != NULL) {
914d2f79d86c 7838 Log installer build number and installed software build number in install_log
Evan Layton <Evan.Layton@Sun.COM>
parents: 531
diff changeset
  3184
			om_log_print("%s %s\n", comment, rel_str);
914d2f79d86c 7838 Log installer build number and installed software build number in install_log
Evan Layton <Evan.Layton@Sun.COM>
parents: 531
diff changeset
  3185
			(void) pclose(fp);
914d2f79d86c 7838 Log installer build number and installed software build number in install_log
Evan Layton <Evan.Layton@Sun.COM>
parents: 531
diff changeset
  3186
			return;
914d2f79d86c 7838 Log installer build number and installed software build number in install_log
Evan Layton <Evan.Layton@Sun.COM>
parents: 531
diff changeset
  3187
		}
914d2f79d86c 7838 Log installer build number and installed software build number in install_log
Evan Layton <Evan.Layton@Sun.COM>
parents: 531
diff changeset
  3188
		(void) pclose(fp);
914d2f79d86c 7838 Log installer build number and installed software build number in install_log
Evan Layton <Evan.Layton@Sun.COM>
parents: 531
diff changeset
  3189
	}
914d2f79d86c 7838 Log installer build number and installed software build number in install_log
Evan Layton <Evan.Layton@Sun.COM>
parents: 531
diff changeset
  3190
914d2f79d86c 7838 Log installer build number and installed software build number in install_log
Evan Layton <Evan.Layton@Sun.COM>
parents: 531
diff changeset
  3191
	om_debug_print(OM_DBGLVL_WARN, "log_bld_info: Unable to "
914d2f79d86c 7838 Log installer build number and installed software build number in install_log
Evan Layton <Evan.Layton@Sun.COM>
parents: 531
diff changeset
  3192
	    "retrieve build version information for image root %s\n", mountpnt);
914d2f79d86c 7838 Log installer build number and installed software build number in install_log
Evan Layton <Evan.Layton@Sun.COM>
parents: 531
diff changeset
  3193
	om_log_print("Warning: Unable to retrieve build version "
914d2f79d86c 7838 Log installer build number and installed software build number in install_log
Evan Layton <Evan.Layton@Sun.COM>
parents: 531
diff changeset
  3194
	    "information for image root %s\n", mountpnt);
914d2f79d86c 7838 Log installer build number and installed software build number in install_log
Evan Layton <Evan.Layton@Sun.COM>
parents: 531
diff changeset
  3195
}