#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
"""
Various support code for the bootmgmt package
"""
import inspect
import libbe_py
import logging
import os
import sys
import platform
def get_current_arch_string():
"Returns the current architecture string"
if proc == 'i386':
return 'x86'
elif proc == 'sparc':
return 'sparc'
"""Splits the bootfs passed in into rpool and bootfs values
"""
"""Construct a bootfs string from a root pool and BE name
"""
"""Returns True if the string is a representation of True.
"""
return True
return False
the path to the EFI system partition and return it. This only works
on x86 systems.
"""
esp_dev = None
if lastslash == -1:
# We need the character device, below
if last_ess != -1:
else:
if last_pee != -1:
else:
# If the caller already computed is_gpt, use that to reduce duplicated
# work, otherwise, do it here:
if is_gpt is None:
try:
raise BootmgmtError('Error while accessing "%s": %s' %
if is_gpt:
if esp_index >= 0:
if esp_index > 8:
raise BootmgmtError('The EFI System Partition (ESP) '
'for device %s is not accessible in Solaris because it is '
'located in partition number %d (Solaris can only access the '
# else
else:
# Find the EFI System Partition on a DOS-partitioned drive
if part_no != -1:
return esp_dev
"""Returns the default bootfs property for the specified pool
"""
zph = None
try:
except IOError:
if zph:
pool_default_bootfs = None
return pool_default_bootfs
"""Returns True if the specified dataset has encryption enabled.
"""
zfsh = None
try:
# pylint: disable=E1103
return True
# pylint: enable=E1103
except IOError:
if zfsh:
return False
def get_bootfs_list_from_libbe():
"""Returns a list of bootfs strings that identify the BEs on the system.
"""
if ret != 0:
return []
bootfses = []
if 'root_ds' in bootenv:
return bootfses
"""Logging helper functions
"""
if debug_enabled:
"""Main debugging helper method
"""
if not cls.debug_enabled:
return
try:
': PROBLEM INSPECTING STACK: %s' % exc)
func = '?'
try:
except ValueError:
else:
"""Scrubs the $ZFS-BOOTFS kernel argument, while preserving others.
"""
# $ZFS-BOOTFS can be in the kernel argument list in a variety of
# ways, i.e.:
# -B [<otherargs>,]*$ZFS-BOOTFS[,<otherargs>]*
# Here, we compose a simple replace -- the order matters here. First
# we remove the string if it's in the middle of a comma-delimited
# arg list and then we remove instances bordered on either side.
# finally, we remove the entire -B argument but only if $ZFS-BOOTFS
# is the only -B argument (we're guaranteed that's the case by the
# time we get there because the previous cases would have eliminated
# instances where $ZFS-BOOTFS was the first in a -B arg list.
return new_kargs