7039244 Additional slim_code_cleaness failures after pyboot management putback.
7042722 slim_unit_test failure after 7038421 is put back
--- a/usr/src/cmd/distro_const/checkpoints/test/test_create_iso.py Fri May 13 16:43:12 2011 -0700
+++ b/usr/src/cmd/distro_const/checkpoints/test/test_create_iso.py Mon May 16 17:24:57 2011 -0700
@@ -54,6 +54,7 @@
self.c_iso.distro_name = "distro name"
self.c_iso.partial_distro_name = self.c_iso.distro_name
self.c_iso.dist_iso = "/var/tmp/dist.iso"
+ self.c_iso.bios_eltorito = "boot/grub/stage2_eltorito"
self.c_iso.ba_build = testlib.create_filesystem(*self.ba_filelist)
self.c_iso.pkg_img_path = testlib.create_filesystem(*self.pi_filelist)
self.c_iso.arch = "i386"
--- a/usr/src/lib/bootmgmt/__init__.py Fri May 13 16:43:12 2011 -0700
+++ b/usr/src/lib/bootmgmt/__init__.py Mon May 16 17:24:57 2011 -0700
@@ -26,6 +26,7 @@
A Python package for management of all things Boot
"""
+
class BootmgmtError(Exception):
def __init__(self, msg, xcpt=None):
self.msg = msg
@@ -37,21 +38,27 @@
else:
return self.msg
+
class BootmgmtNotSupportedError(BootmgmtError):
pass
+
class BootmgmtArgumentError(BootmgmtError):
pass
+
class BootmgmtMissingInfoError(BootmgmtError):
pass
+
class BootmgmtUnsupportedOperationError(BootmgmtError):
pass
+
class BootmgmtMalformedPropertyNameError(BootmgmtError):
pass
+
class BootmgmtMalformedPropertyValueError(BootmgmtError):
def __init__(self, propname, propval):
super(self, BootmgmtMalformedPropertyValueError).__init__(
@@ -60,26 +67,34 @@
self.propname = propname
self.propval = propval
+
class BootmgmtReadError(BootmgmtError):
pass
+
class BootmgmtWriteError(BootmgmtError):
pass
+
class BootmgmtUnsupportedPlatformError(BootmgmtError):
pass
+
class BootmgmtInterfaceCodingError(BootmgmtError):
pass
+
class BootmgmtConfigReadError(BootmgmtError):
pass
+
class BootmgmtConfigWriteError(BootmgmtError):
pass
+
class BootmgmtIncompleteBootConfigError(BootmgmtError):
pass
+
class BootmgmtUnsupportedPropertyError(BootmgmtUnsupportedOperationError):
pass
--- a/usr/src/lib/bootmgmt/backend/autogen/__init__.py Fri May 13 16:43:12 2011 -0700
+++ b/usr/src/lib/bootmgmt/backend/autogen/__init__.py Mon May 16 17:24:57 2011 -0700
@@ -28,7 +28,8 @@
import sys
-autogen_backends = [ 'solaris' ]
+autogen_backends = ['solaris']
+
class BootInstanceAutogenFactory(object):
@staticmethod
--- a/usr/src/lib/bootmgmt/backend/autogen/solaris.py Fri May 13 16:43:12 2011 -0700
+++ b/usr/src/lib/bootmgmt/backend/autogen/solaris.py Mon May 16 17:24:57 2011 -0700
@@ -31,9 +31,11 @@
from ...bootconfig import BootConfig, SolarisDiskBootInstance
from ...bootutil import LoggerMixin
+
class SolarisBootInstanceAutogenerator(LoggerMixin):
pass
+
def autogenerate_boot_instances(bootconfig):
sbia = SolarisBootInstanceAutogenerator()
@@ -47,7 +49,8 @@
# (i.e. <pool>/ROOT/<title>)
retcode, belist = libbe_py.beList()
if retcode != 0:
- sbia._debug('libbe_py.beList() failed; return code was ' + str(retcode))
+ sbia._debug('libbe_py.beList() failed; return code was ' +
+ str(retcode))
return []
inst_list = []
--- a/usr/src/lib/bootmgmt/backend/bootvars/__init__.py Fri May 13 16:43:12 2011 -0700
+++ b/usr/src/lib/bootmgmt/backend/bootvars/__init__.py Mon May 16 17:24:57 2011 -0700
@@ -30,6 +30,7 @@
from ... import bootutil
from ... import BootmgmtArgumentError
+
class BackendBootVarsFactory(object):
@staticmethod
def get(sysroot, arch, osname):
--- a/usr/src/lib/bootmgmt/backend/bootvars/sparc/solaris.py Fri May 13 16:43:12 2011 -0700
+++ b/usr/src/lib/bootmgmt/backend/bootvars/sparc/solaris.py Mon May 16 17:24:57 2011 -0700
@@ -29,8 +29,10 @@
import sys
from .... import bootinfo
+
class OBPBootVariables(bootinfo.BootVariables):
pass
+
def bootvars_backend():
return OBPBootVariables
--- a/usr/src/lib/bootmgmt/backend/bootvars/x86/solaris.py Fri May 13 16:43:12 2011 -0700
+++ b/usr/src/lib/bootmgmt/backend/bootvars/x86/solaris.py Mon May 16 17:24:57 2011 -0700
@@ -36,6 +36,7 @@
logger = logging.getLogger('bootmgmt')
+
class BootenvBootVariables(bootinfo.BootVariables):
"""This class supports manipulation of boot variables stored in the
<root>/boot/solaris/bootenv.rc file."""
@@ -56,7 +57,8 @@
if not type(value) is bool:
raise ValueError('dirty is a bool')
if self._dirty != value:
- logger.debug(self.__class__.__name__ + ': dirty => %s' % str(value))
+ logger.debug(self.__class__.__name__ + ': dirty => %s'
+ % str(value))
self._dirty = value
def setprop(self, propname, value):
@@ -80,9 +82,7 @@
self._vardict[propname] = proplist
self._rawlines.append(proplist)
self.dirty = True
-
-
def getprop(self, propname):
val_list = self._vardict.get(propname, None)
# The values stored in the dictionary are 2-element lists
@@ -137,7 +137,6 @@
self._vardict[prop] = newbep
else:
self._rawlines.append(rawline)
-
except IOError as e:
raise BootmgmtReadError('Error while loading boot variables ' +
@@ -150,7 +149,8 @@
if not alt_dir is None:
try:
- fileobj = tempfile.NamedTemporaryFile(dir=alt_dir, delete=False)
+ fileobj = tempfile.NamedTemporaryFile(dir=alt_dir,
+ delete=False)
except IOError as err:
raise BootmgmtWriteError('Error while writing to temporary ' +
'bootenv.rc (%s)' % fileobj.name, err)
@@ -209,8 +209,9 @@
return len(self._vardict)
def __iter__(self):
- classic_dict = [(x, z) for (x,[y,z]) in self._vardict.items()]
+ classic_dict = [(x, z) for (x, [y, z]) in self._vardict.items()]
return classic_dict.__iter__()
+
def bootvars_backend():
return BootenvBootVariables
--- a/usr/src/lib/bootmgmt/backend/fw/__init__.py Fri May 13 16:43:12 2011 -0700
+++ b/usr/src/lib/bootmgmt/backend/fw/__init__.py Mon May 16 17:24:57 2011 -0700
@@ -31,6 +31,7 @@
from ... import pysol
import sys
+
class BackendFWFactory(object):
@staticmethod
def get(fw_name):
@@ -72,5 +73,3 @@
__import__(fwmod, level=0)
ns = sys.modules[fwmod]
return ns.firmware_backend()(fw_name)
-
-
--- a/usr/src/lib/bootmgmt/backend/fw/bios.py Fri May 13 16:43:12 2011 -0700
+++ b/usr/src/lib/bootmgmt/backend/fw/bios.py Mon May 16 17:24:57 2011 -0700
@@ -29,6 +29,7 @@
from ... import bootinfo
from ... import BootmgmtUnsupportedOperationError, BootmgmtWriteError
+
class BIOSFirmware(bootinfo.SystemFirmware):
def getprop(self, propname):
return super(BIOSFirmware, self).getprop(propname)
@@ -46,5 +47,6 @@
raise BootmgmtUnsupportedOperationError('Properties cannot be '
'deleted on systems with BIOS firmware')
+
def firmware_backend():
return BIOSFirmware
--- a/usr/src/lib/bootmgmt/backend/fw/obp.py Fri May 13 16:43:12 2011 -0700
+++ b/usr/src/lib/bootmgmt/backend/fw/obp.py Mon May 16 17:24:57 2011 -0700
@@ -28,8 +28,10 @@
from ... import bootinfo
+
class OBPFirmware(bootinfo.SystemFirmware):
pass
+
def firmware_backend():
return OBPFirmware
--- a/usr/src/lib/bootmgmt/backend/fw/uefi64.py Fri May 13 16:43:12 2011 -0700
+++ b/usr/src/lib/bootmgmt/backend/fw/uefi64.py Mon May 16 17:24:57 2011 -0700
@@ -28,8 +28,10 @@
from ... import bootinfo
+
class UEFI64Firmware(bootinfo.SystemFirmware):
pass
+
def firmware_backend():
return UEFI64Firmware
--- a/usr/src/lib/bootmgmt/backend/loader/__init__.py Fri May 13 16:43:12 2011 -0700
+++ b/usr/src/lib/bootmgmt/backend/loader/__init__.py Mon May 16 17:24:57 2011 -0700
@@ -29,7 +29,8 @@
import sys
from ...bootutil import LoggerMixin
-boot_loader_backends = [ 'grub2', 'legacygrub', 'sbb' ]
+boot_loader_backends = ['grub2', 'legacygrub', 'sbb']
+
class BackendBootLoaderFactory(LoggerMixin):
@classmethod
--- a/usr/src/lib/bootmgmt/backend/loader/grub2.py Fri May 13 16:43:12 2011 -0700
+++ b/usr/src/lib/bootmgmt/backend/loader/grub2.py Mon May 16 17:24:57 2011 -0700
@@ -28,10 +28,12 @@
from ...bootloader import BootLoader
+
class GRUB2BootLoader(BootLoader):
@classmethod
def probe(cls, **kwargs):
return (None, None)
+
def bootloader_classes():
return [GRUB2BootLoader]
--- a/usr/src/lib/bootmgmt/backend/loader/legacygrub.py Fri May 13 16:43:12 2011 -0700
+++ b/usr/src/lib/bootmgmt/backend/loader/legacygrub.py Mon May 16 17:24:57 2011 -0700
@@ -49,6 +49,7 @@
_ = gettext.translation("SUNW_OST_OSCMD", "/usr/lib/locale",
fallback=True).gettext
+
class LegacyGRUBBootLoader(BootLoader):
"""Implementation of a Legacy GRUB (GRUB 0.97) BootLoader. Handles parsing
the menu.lst file (reading and writing), though reading it and creating
@@ -204,7 +205,7 @@
return (None, None)
# XXX - In addition to the loader files themselves, we need to ensure
- # XXX - that we have access to the installgrub program in the currently-
+ # XXX - that we have access to the installgrub program in the currently
# XXX - running system (otherwise, we'll have no way to install Legacy
# XXX - GRUB).
@@ -255,9 +256,9 @@
if not params is None:
if not params[BootLoader.PROP_SP_PARITY] is None:
try:
- parity = {'N' : 'no',
- 'E' : 'even',
- 'O' : 'odd'}[params[BootLoader.PROP_SP_PARITY]]
+ parity = {'N': 'no',
+ 'E': 'even',
+ 'O': 'odd'}[params[BootLoader.PROP_SP_PARITY]]
except KeyError:
self._debug('Bad parity value in serial_params')
parity = None
@@ -277,7 +278,7 @@
return ('0', '9600', None, None, None)
def __init__(self, **kwargs):
- self.pkg_names = [ 'system/boot/grub', 'SUNWgrub' ]
+ self.pkg_names = ['system/boot/grub', 'SUNWgrub']
self.name = 'Legacy GRUB'
self._menufile = None
super(LegacyGRUBBootLoader, self).__init__(**kwargs)
@@ -339,8 +340,8 @@
try:
self._menufile = LegacyGRUBMenuFile(menu_lst)
except IOError as err:
- raise BootmgmtConfigReadError('Error while processing the %s file' %
- menu_lst, err)
+ raise BootmgmtConfigReadError('Error while processing the %s \
+ file' % menu_lst, err)
except MenuLstError as err:
raise BootmgmtConfigReadError('Error while processing the %s '
'file: %s' % (menu_lst, str(err)))
@@ -459,9 +460,10 @@
return None
for idx, item in enumerate(tuples):
- if (item[BootConfig.IDX_FILETYPE] is BootConfig.OUTPUT_TYPE_FILE and
+ if (item[BootConfig.IDX_FILETYPE] is BootConfig.OUTPUT_TYPE_FILE
+ and
item[BootConfig.IDX_DESTNAME] ==
- LegacyGRUBBootLoader.MENU_LST_PATH):
+ LegacyGRUBBootLoader.MENU_LST_PATH):
# Make a copy of the tuple so we can change it:
item = list(item)
@@ -549,7 +551,6 @@
'root',
0644)]
-
def _write_config_odd(self, basepath):
if basepath is None:
@@ -643,9 +644,10 @@
# Menu-entry generator infrastructure
def _generate_entry(self, instance):
- """Use the BootInstance's class name to find the entry-generator method.
- Entry generator functions are responsible for producing a string
- with the rest of the entry (the title is printed by the caller)"""
+ """Use the BootInstance's class name to find the entry-generator
+ method. Entry generator functions are responsible for producing a
+ string with the rest of the entry (the title is printed by the
+ caller)"""
instclsname = instance.__class__.__name__
method_name = '_generate_entry_' + instclsname
@@ -664,7 +666,7 @@
kargs = '' if kargs is None else kargs
try:
- inst.kernel = inst.kernel % {'karch' : "$ISADIR"}
+ inst.kernel = inst.kernel % {'karch': "$ISADIR"}
except KeyError:
# If somehow another Python conversion specifier snuck in,
# raise an exception
@@ -679,7 +681,7 @@
ostr += (' ' if not kargs == '' else '') + kargs + '\n'
try:
- inst.boot_archive = inst.boot_archive % {'karch' : "$ISADIR"}
+ inst.boot_archive = inst.boot_archive % {'karch': "$ISADIR"}
except KeyError:
# If somehow another Python conversion specifier snuck in,
# raise an exception
@@ -693,7 +695,6 @@
return ostr
-
def _generate_entry_SolarisDiskBootInstance(self, inst):
"Menu-entry generator function for SolarisDiskBootInstance instances"
@@ -828,12 +829,13 @@
filemode = os.stat(devname).st_mode
except OSError as err:
self._debug('Error stat()ing %s' % devname)
- raise BootLoaderInstallError('Error stat()ing %s' % devname,
- err)
+ raise BootLoaderInstallError('Error stat()ing %s'
+ % devname, err)
if stat.S_ISCHR(filemode):
self._write_loader(devname)
else:
- raise BootmgmtArgumentError('%s is not a characters-special'
+ raise BootmgmtArgumentError('%s is not a \
+ characters-special'
' file' % devname)
self._write_config(None)
@@ -905,6 +907,8 @@
#
# Legacy GRUB menu.lst
#
+
+
class LegacyGRUBMenuFile(MenuDotLst):
def __init__(self, filename='/boot/solaris/menu.lst'):
super(LegacyGRUBMenuFile, self).__init__(filename)
@@ -942,4 +946,3 @@
def bootloader_classes():
return [LegacyGRUBBootLoader]
-
--- a/usr/src/lib/bootmgmt/backend/loader/menulst.py Fri May 13 16:43:12 2011 -0700
+++ b/usr/src/lib/bootmgmt/backend/loader/menulst.py Mon May 16 17:24:57 2011 -0700
@@ -28,6 +28,7 @@
import re
+
class MenuLstError(Exception):
def __init__(self, msg):
super(LegacyGRUBMenuError, self).__init__()
@@ -63,6 +64,7 @@
repr(self._args) + ')')
return ostr
+
class MenuLstMenuEntry(object):
"""Representation of a menu.lst menu entry, which consists of a list of
MenuLstCommand objects (the first of which must be the 'title' command).
--- a/usr/src/lib/bootmgmt/backend/loader/sbb.py Fri May 13 16:43:12 2011 -0700
+++ b/usr/src/lib/bootmgmt/backend/loader/sbb.py Mon May 16 17:24:57 2011 -0700
@@ -28,29 +28,34 @@
from ...bootloader import BootLoader
+
class OBPBootLoader(BootLoader):
pass
+
class WanbootBootLoader(OBPBootLoader):
@staticmethod
def probe(**kwargs):
return (None, None)
+
class HSFSBootLoader(OBPBootLoader):
@staticmethod
def probe(**kwargs):
return (None, None)
+
class UFSBootLoader(OBPBootLoader):
@staticmethod
def probe(**kwargs):
return (None, None)
+
class ZFSBootLoader(OBPBootLoader):
@staticmethod
def probe(**kwargs):
return (None, None)
+
def bootloader_classes():
return [WanbootBootLoader, HSFSBootLoader, UFSBootLoader, ZFSBootLoader]
-
--- a/usr/src/lib/bootmgmt/bootarchive.py Fri May 13 16:43:12 2011 -0700
+++ b/usr/src/lib/bootmgmt/bootarchive.py Mon May 16 17:24:57 2011 -0700
@@ -30,4 +30,3 @@
archive (which consists of compressed objects on x86), allowing faster
update of an archive when changed objects are detected
"""
-
--- a/usr/src/lib/bootmgmt/bootconfig.py Fri May 13 16:43:12 2011 -0700
+++ b/usr/src/lib/bootmgmt/bootconfig.py Mon May 16 17:24:57 2011 -0700
@@ -45,6 +45,7 @@
_ = gettext.translation("SUNW_OST_OSCMD", "/usr/lib/locale",
fallback=True).gettext
+
class BootConfig(LoggerMixin):
"""Abstract base class for boot configuration classes"""
@@ -228,7 +229,6 @@
else:
self._add_one_boot_instance(boot_instances, where)
-
def _add_one_boot_instance(self, boot_instance, where=-1):
prevDefault = None
@@ -398,7 +398,6 @@
return tuple_list
-
def __str__(self):
s = 'State: ' + ('dirty' if self.dirty else 'clean') + '\n'
s += 'Class: ' + (self.boot_class
@@ -460,6 +459,7 @@
super(self.__class__, self).__init__(flags,
boot_class=BootConfig.BOOT_CLASS_DISK,
boot_fstype=fstype, **kwargs)
+
def get_root(self):
return self.sysroot
@@ -482,7 +482,8 @@
# Weed out unsupported flags:
if BootConfig.BCF_MIGRATE in flags:
raise BootmgmtUnsupportedOperationError(self.__class__.__name__ +
- ': Migration is not supported')
+ ': Migration is not \
+ supported')
# Save the image's root directory:
self.odd_image_root = kwargs.get('oddimage_root', None)
@@ -495,9 +496,6 @@
def get_root(self):
return self.odd_image_root
-
-
-
###############################################################################
@@ -512,7 +510,7 @@
when a BootInstance is passed to BootConfig.add_boot_instance()."""
# Valid attributes ('default' is a special case)
- _attributes = { 'title' : None }
+ _attributes = {'title': None}
def __init__(self, rootpath, **kwargs):
# If the child class added its own set of attributes, just append to
@@ -531,9 +529,9 @@
# If the key wasn't already set in this instance (in
# init_from_rootpath), init it to a default value here
if not key in kwargs and not key in self.__dict__:
- self._debug('DEFAULT: Setting %s="%s"' %
+ self._debug('DEFAULT: Setting %s="%s"' %
(str(key), str(value)))
- self.__setattr__(key, value)
+ self.__setattr__(key, value)
# If the user passed in keyword args, add them as attributes
for key, value in kwargs.items():
@@ -597,10 +595,10 @@
return bootinfo.BootVariables.get(sysroot=rootpath)
def __setattr__(self, key, value):
- """Intercept the set attribute method to enforce setting of a particular
- set of boot instance attributes (the union of those defined in child
- classes and this class). 'default' is treated specially (see
- _set_default())"""
+ """Intercept the set attribute method to enforce setting of a
+ particular set of boot instance attributes (the union of those
+ defined in child classes and this class). 'default' is treated
+ specially (see _set_default())"""
if key == 'default':
self._debug('key="%s" value="%s"' % (key, value))
@@ -648,9 +646,9 @@
class ChainDiskBootInstance(BootInstance):
"""A boot instance of a chainloaded operating system"""
- _attributes = { 'chaininfo' : None,
- 'chainstart' : '0',
- 'chaincount' : '1' }
+ _attributes = {'chaininfo': None,
+ 'chainstart': '0',
+ 'chaincount': '1'}
def __init__(self, rootpath=None, **kwargs):
"""rootpath is not supported, so should remain `None'"""
@@ -670,15 +668,14 @@
if get_current_arch_string() == 'x86':
_attributes = {
- 'kernel' : '/platform/i86pc/kernel/%(karch)s/unix',
- 'boot_archive' : '/platform/i86pc/%(karch)s/boot_archive',
- 'kargs' : None,
- 'signature' : None,
+ 'kernel': '/platform/i86pc/kernel/%(karch)s/unix',
+ 'boot_archive': '/platform/i86pc/%(karch)s/boot_archive',
+ 'kargs': None,
+ 'signature': None,
}
else:
_attributes = {}
-
def __init__(self, rootpath, **kwargs):
# If the child class added its own set of attributes, just append to
# it; overwise, set it to the default set from this class
@@ -695,8 +692,8 @@
- If fstype == 'zfs':
* bootfs [string] [required]
"""
- _attributes = { 'fstype' : 'zfs',
- 'bootfs' : None }
+ _attributes = {'fstype': 'zfs',
+ 'bootfs': None}
def __init__(self, rootpath, **kwargs):
# If the child class added its own set of attributes, just append to
@@ -790,6 +787,7 @@
def test_flags(self):
pass
+
def testSuite():
return unittest.TestLoader().loadTestsFromTestCase(TestBootConfig)
--- a/usr/src/lib/bootmgmt/bootinfo.py Fri May 13 16:43:12 2011 -0700
+++ b/usr/src/lib/bootmgmt/bootinfo.py Mon May 16 17:24:57 2011 -0700
@@ -33,6 +33,7 @@
logger = logging.getLogger('bootmgmt')
+
class SystemFirmware(object):
PROP_BOOT_DEVICE = 'boot-device'
@@ -57,11 +58,15 @@
if propname == SystemFirmware.PROP_BOOT_DEVICE:
return devfs_bootdev_get_list()
- def setprop(self, propname, value): pass
- def delprop(self, propname): pass
+ def setprop(self, propname, value):
+ pass
+
+ def delprop(self, propname):
+ pass
###############################################################################
+
class BootVariables(object):
@staticmethod
def get(sysroot=None, arch=None, osname='solaris'):
--- a/usr/src/lib/bootmgmt/bootloader.py Fri May 13 16:43:12 2011 -0700
+++ b/usr/src/lib/bootmgmt/bootloader.py Mon May 16 17:24:57 2011 -0700
@@ -32,6 +32,7 @@
from . import BootmgmtError, BootmgmtNotSupportedError
from . import BootmgmtUnsupportedPropertyError
+
class BootLoader(LoggerMixin):
PROP_MINMEM64 = 'minmem64'
@@ -56,14 +57,13 @@
PROP_SP_STOPB = 4
PROP_SP_FLOWC = 5
-
@staticmethod
def get(**kwargs):
return BackendBootLoaderFactory.get(**kwargs)
@classmethod
def probe(cls, **kwargs):
- return (None, None)
+ return (None, None)
@property
def dirty(self):
@@ -91,22 +91,21 @@
bc_sysroot = '/'
if (not self._boot_config is None and
not self._boot_config.get_root() is None):
- bc_sysroot = self._boot_config.get_root()
+ bc_sysroot = self._boot_config.get_root()
self.rootpath = kwargs.get('rootpath', bc_sysroot)
-
def _write_config(self, basepath):
- pass
+ pass
def load_config(self):
- pass
+ pass
def new_config(self):
- pass
+ pass
def migrate_config(self):
- pass
+ pass
# Property-related methods
def _prop_validate(self, key, value=None, validate_value=False):
@@ -116,13 +115,13 @@
'property')
def setprop(self, key, value):
- pass
+ pass
def getprop(self, key):
- pass
+ pass
def delprop(self, key):
- pass
+ pass
def install(self, location):
"""Install the boot loader onto a disk or set of disks. location
@@ -169,14 +168,18 @@
class BootLoaderInstallError(BootmgmtError):
pass
+
class BootPartitionAccessError(BootLoaderInstallError):
pass
+
class BootDeviceNotFoundError(BootLoaderInstallError):
pass
+
class BootLoaderFeatureUnsupportedError(BootmgmtNotSupportedError):
pass
+
class BootLoaderUnsupportedPartTypeError(BootLoaderFeatureUnsupportedError):
pass
--- a/usr/src/lib/bootmgmt/bootutil.py Fri May 13 16:43:12 2011 -0700
+++ b/usr/src/lib/bootmgmt/bootutil.py Mon May 16 17:24:57 2011 -0700
@@ -32,6 +32,7 @@
from . import BootmgmtNotSupportedError
+
def get_current_arch_string():
proc = platform.processor()
if proc == 'i386':
@@ -40,6 +41,7 @@
return 'sparc'
raise BootmgmtNotSupportedError('Unsupported platform: ' + proc)
+
class LoggerMixin(object):
logger = logging.getLogger('bootmgmt')
--- a/usr/src/lib/bootmgmt/pysol.py Fri May 13 16:43:12 2011 -0700
+++ b/usr/src/lib/bootmgmt/pysol.py Mon May 16 17:24:57 2011 -0700
@@ -48,7 +48,7 @@
_libc = CDLL('libc.so', use_errno=True)
_platwidth = platform.architecture()[0][:2]
_libc.fopen.restype = c_void_p
-_libc.free.argtypes = [ c_void_p ]
+_libc.free.argtypes = [c_void_p]
_libc.free.restype = None
_statvfs_syscall = 'statvfs' + ('64' if _platwidth == '32' else '')
# print 'platwidth = `%s\' | _syscall = `%s\'' % (_platwidth, _syscall)
@@ -56,210 +56,214 @@
def ctype2dict(ctype_struct_instance):
- dictresult = {}
+ dictresult = {}
- # A very important side-effect of calling getattr() here is
- # that the ctypes API creates copies of the data we're
- # retrieving from the "structure". If it did not do that,
- # calling libc APIs that use static data areas would cause
- # the resulting Python strings to refer to the same storage
- # area.
- for x in [x for (x, y) in ctype_struct_instance._fields_]:
- dictresult[x] = getattr(ctype_struct_instance, x)
+ # A very important side-effect of calling getattr() here is
+ # that the ctypes API creates copies of the data we're
+ # retrieving from the "structure". If it did not do that,
+ # calling libc APIs that use static data areas would cause
+ # the resulting Python strings to refer to the same storage
+ # area.
+ for x in [x for (x, y) in ctype_struct_instance._fields_]:
+ dictresult[x] = getattr(ctype_struct_instance, x)
- return dictresult
+ return dictresult
# ==============================[ statvfs ]===============================
+
class StatVFS_Result(Structure):
- """From the manpage:
- int statvfs(const char *restrict path, struct statvfs *restrict buf);
+ """From the manpage:
+ int statvfs(const char *restrict path, struct statvfs *restrict buf);
- u_long f_bsize; /* preferred file system block size */
- u_long f_frsize; /* fundamental filesystem block
- (size if supported) */
- fsblkcnt_t f_blocks; /* total # of blocks on file system
- in units of f_frsize */
- fsblkcnt_t f_bfree; /* total # of free blocks */
- fsblkcnt_t f_bavail; /* # of free blocks avail to
- non-privileged user */
- fsfilcnt_t f_files; /* total # of file nodes (inodes) */
- fsfilcnt_t f_ffree; /* total # of free file nodes */
- fsfilcnt_t f_favail; /* # of inodes avail to
- non-privileged user*/
- u_long f_fsid; /* file system id (dev for now) */
- char f_basetype[FSTYPSZ]; /* target fs type name,
- null-terminated */
- u_long f_flag; /* bit mask of flags */
- u_long f_namemax; /* maximum file name length */
- char f_fstr[32]; /* file system specific string */
- if not 64-bit process
- u_long f_filler[16]; /* reserved for future expansion */
- endif
+ u_long f_bsize; /* preferred file system block size */
+ u_long f_frsize; /* fundamental filesystem block
+ (size if supported) */
+ fsblkcnt_t f_blocks; /* total # of blocks on file system
+ in units of f_frsize */
+ fsblkcnt_t f_bfree; /* total # of free blocks */
+ fsblkcnt_t f_bavail; /* # of free blocks avail to
+ non-privileged user */
+ fsfilcnt_t f_files; /* total # of file nodes (inodes) */
+ fsfilcnt_t f_ffree; /* total # of free file nodes */
+ fsfilcnt_t f_favail; /* # of inodes avail to
+ non-privileged user*/
+ u_long f_fsid; /* file system id (dev for now) */
+ char f_basetype[FSTYPSZ]; /* target fs type name,
+ null-terminated */
+ u_long f_flag; /* bit mask of flags */
+ u_long f_namemax; /* maximum file name length */
+ char f_fstr[32]; /* file system specific string */
+ if not 64-bit process
+ u_long f_filler[16]; /* reserved for future expansion */
+ endif
- We always use the 64-bit statvfs variant (statvfs64 in 32-bit
- processes and statvfs in 64-bit processes)
+ We always use the 64-bit statvfs variant (statvfs64 in 32-bit
+ processes and statvfs in 64-bit processes)
- """
+ """
- _fields_ = [ ("f_bsize", c_ulong),
- ("f_frsize", c_ulong),
- ("f_blocks", c_ulonglong),
- ("f_bfree", c_ulonglong),
- ("f_bavail", c_ulonglong),
- ("f_files", c_ulonglong),
- ("f_ffree", c_ulonglong),
- ("f_favail", c_ulonglong),
- ("f_fsid", c_ulong),
- ("f_basetype", c_char * FSTYPSZ),
- ("f_flag", c_ulong),
- ("f_namemax", c_ulong),
- ("f_fstr", c_char * 32),
- ("f_filler", c_int * 16) ]
+ _fields_ = [ ("f_bsize", c_ulong),
+ ("f_frsize", c_ulong),
+ ("f_blocks", c_ulonglong),
+ ("f_bfree", c_ulonglong),
+ ("f_bavail", c_ulonglong),
+ ("f_files", c_ulonglong),
+ ("f_ffree", c_ulonglong),
+ ("f_favail", c_ulonglong),
+ ("f_fsid", c_ulong),
+ ("f_basetype", c_char * FSTYPSZ),
+ ("f_flag", c_ulong),
+ ("f_namemax", c_ulong),
+ ("f_fstr", c_char * 32),
+ ("f_filler", c_int * 16) ]
def statvfs(path):
- """Returns a dictionary whose members are the result of the Solaris
- statvfs() call"""
+ """Returns a dictionary whose members are the result of the Solaris
+ statvfs() call"""
- result = StatVFS_Result()
+ result = StatVFS_Result()
- if _statvfs(path, pointer(result)) != 0:
- raise IOError(get_errno(), os.strerror(get_errno()))
+ if _statvfs(path, pointer(result)) != 0:
+ raise IOError(get_errno(), os.strerror(get_errno()))
- return ctype2dict(result)
+ return ctype2dict(result)
# ===========================[ mnttab functions ]============================
class SolarisMntTab(Structure):
- "Python ctype expression of the Solaris mnttab structure"
- _fields_ = [('mnt_special', c_char_p),
- ('mnt_mountp', c_char_p),
- ('mnt_fstype', c_char_p),
- ('mnt_mntopts', c_char_p),
- ('mnt_time', c_char_p)]
+ "Python ctype expression of the Solaris mnttab structure"
+ _fields_ = [('mnt_special', c_char_p),
+ ('mnt_mountp', c_char_p),
+ ('mnt_fstype', c_char_p),
+ ('mnt_mntopts', c_char_p),
+ ('mnt_time', c_char_p)]
+
class SolarisExtMntTab(Structure):
- "Python ctype expression of the Solaris extmnttab structure"
- _fields_ = [('mnt_special', c_char_p),
- ('mnt_mountp', c_char_p),
- ('mnt_fstype', c_char_p),
- ('mnt_mntopts', c_char_p),
- ('mnt_time', c_char_p),
- ('mnt_major', c_uint),
- ('mnt_minor', c_uint)]
+ "Python ctype expression of the Solaris extmnttab structure"
+ _fields_ = [('mnt_special', c_char_p),
+ ('mnt_mountp', c_char_p),
+ ('mnt_fstype', c_char_p),
+ ('mnt_mntopts', c_char_p),
+ ('mnt_time', c_char_p),
+ ('mnt_major', c_uint),
+ ('mnt_minor', c_uint)]
+
def mnttab_err_decode(code):
- """Decodes the following error codes from mnttab.h:
- #define MNT_TOOLONG 1 /* entry exceeds MNT_LINE_MAX */
- #define MNT_TOOMANY 2 /* too many fields in line */
- #define MNT_TOOFEW 3 /* too few fields in line */
- """
- if code == 1:
- return 'Entry exceeds 1024 characters'
- elif code == 2:
- return 'Too many fields in line'
- elif code == 3:
- return 'Too few fields in line'
- else:
- return 'Unknown mnttab error'
+ """Decodes the following error codes from mnttab.h:
+ #define MNT_TOOLONG 1 /* entry exceeds MNT_LINE_MAX */
+ #define MNT_TOOMANY 2 /* too many fields in line */
+ #define MNT_TOOFEW 3 /* too few fields in line */
+ """
+ if code == 1:
+ return 'Entry exceeds 1024 characters'
+ elif code == 2:
+ return 'Too many fields in line'
+ elif code == 3:
+ return 'Too few fields in line'
+ else:
+ return 'Unknown mnttab error'
def mnttab_open(mtab='/etc/mnttab'):
- global _mnttab_FILE
- _mnttab_FILE = c_void_p(_libc.fopen(mtab, 'r'))
- if _mnttab_FILE.value is None:
- raise IOError(get_errno(), mtab + ': ' +
+ global _mnttab_FILE
+ _mnttab_FILE = c_void_p(_libc.fopen(mtab, 'r'))
+ if _mnttab_FILE.value is None:
+ raise IOError(get_errno(), mtab + ': ' +
os.strerror(get_errno()))
+
def getmntent():
- """Returns the next mnttab entry as a dictionary whose keys
- are:
- mnt_special
- mnt_mountp
- mnt_fstype
- mnt_mntopts
- mnt_time
- or None if there are no more entries
- """
- mntent = SolarisMntTab()
- r = _libc.getmntent(_mnttab_FILE, byref(mntent))
- if r < 0: # EOF
- return None
- elif r > 0: # Error
- raise IOError(r, mnttab_err_decode(r))
+ """Returns the next mnttab entry as a dictionary whose keys
+ are:
+ mnt_special
+ mnt_mountp
+ mnt_fstype
+ mnt_mntopts
+ mnt_time
+ or None if there are no more entries
+ """
+ mntent = SolarisMntTab()
+ r = _libc.getmntent(_mnttab_FILE, byref(mntent))
+ if r < 0: # EOF
+ return None
+ elif r > 0: # Error
+ raise IOError(r, mnttab_err_decode(r))
- return ctype2dict(mntent)
+ return ctype2dict(mntent)
def getmntany(**attrs):
- """Returns a mnttab entry matching the attributes passed in, or
- None if no entry matches.
- """
- mntent = SolarisMntTab()
- mntmatch = SolarisMntTab()
- for x in attrs.keys():
- mntent.__setattr__(x, attrs[x])
- r = _libc.getmntany(_mnttab_FILE, byref(mntmatch), byref(mntent))
- if r < 0: # EOF
- return None
- elif r > 0:
- raise IOError(r, mnttab_err_decode(r))
+ """Returns a mnttab entry matching the attributes passed in, or
+ None if no entry matches.
+ """
+ mntent = SolarisMntTab()
+ mntmatch = SolarisMntTab()
+ for x in attrs.keys():
+ mntent.__setattr__(x, attrs[x])
+ r = _libc.getmntany(_mnttab_FILE, byref(mntmatch), byref(mntent))
+ if r < 0: # EOF
+ return None
+ elif r > 0:
+ raise IOError(r, mnttab_err_decode(r))
- return ctype2dict(mntmatch)
+ return ctype2dict(mntmatch)
def getextmntent():
- """Returns the next extmnttab entry as a dictionary whose keys
- are:
- mnt_special
- mnt_mountp
- mnt_fstype
- mnt_mntopts
- mnt_time
- mnt_major
- mnt_minor
- or None if there are no more entries.
- """
- extmnt = SolarisExtMntTab()
- r = _libc.getextmntent(_mnttab_FILE, byref(extmnt), sizeof(extmnt))
- if r < 0: # EOF
- return None
- elif r > 0:
- raise IOError(r, mnttab_err_decode(r))
+ """Returns the next extmnttab entry as a dictionary whose keys
+ are:
+ mnt_special
+ mnt_mountp
+ mnt_fstype
+ mnt_mntopts
+ mnt_time
+ mnt_major
+ mnt_minor
+ or None if there are no more entries.
+ """
+ extmnt = SolarisExtMntTab()
+ r = _libc.getextmntent(_mnttab_FILE, byref(extmnt), sizeof(extmnt))
+ if r < 0: # EOF
+ return None
+ elif r > 0:
+ raise IOError(r, mnttab_err_decode(r))
- return ctype2dict(extmnt)
+ return ctype2dict(extmnt)
def resetmnttab(reopen=False):
- """Rewinds the mnttab file to the beginning
- if reopen is True, the mnttab file is closed, then reopened
- """
- if reopen is True:
- mnttab_close()
- mnttab_open()
- else:
- _libc.rewind(_mnttab_FILE)
+ """Rewinds the mnttab file to the beginning
+ if reopen is True, the mnttab file is closed, then reopened
+ """
+ if reopen is True:
+ mnttab_close()
+ mnttab_open()
+ else:
+ _libc.rewind(_mnttab_FILE)
-
+
def mnttab_close():
- _libc.fclose(_mnttab_FILE)
+ _libc.fclose(_mnttab_FILE)
# ==============================[devlink walking]============================
_libdi = CDLL('libdevinfo.so', use_errno=True)
_libdi.di_devlink_init.restype = c_void_p
-_libdi.di_devlink_init.argtypes = [ c_char_p, c_int ]
+_libdi.di_devlink_init.argtypes = [c_char_p, c_int]
_libdi.di_devlink_path.restype = c_char_p
-_libdi.di_devlink_path.argtypes = [ c_void_p ]
+_libdi.di_devlink_path.argtypes = [c_void_p]
# The walker function returns an int and takes 2 void *'s: the di_devlink_t,
# and the arg
_devlink_walkfunc_type = CFUNCTYPE(c_int, c_void_p, c_void_p)
-_libdi.di_devlink_walk.argtypes = [ c_void_p, c_char_p, c_char_p, c_int,
- c_void_p, _devlink_walkfunc_type ]
+_libdi.di_devlink_walk.argtypes = [c_void_p, c_char_p, c_char_p, c_int,
+ c_void_p, _devlink_walkfunc_type]
# from <libdevinfo.h>:
DI_MAKE_LINK = 1
DI_PRIMARY_LINK = 1
@@ -267,67 +271,71 @@
DI_WALK_CONTINUE = 0
DI_WALK_TERMINATE = -3
+
def di_devlink_init(drvname=None, flags=0):
- """Initialize the libdevinfo devlink interfaces"""
- hdl = c_void_p(_libdi.di_devlink_init(drvname, flags))
- if hdl.value is None:
- raise IOError(get_errno(), os.strerror(get_errno()))
- return hdl
+ """Initialize the libdevinfo devlink interfaces"""
+ hdl = c_void_p(_libdi.di_devlink_init(drvname, flags))
+ if hdl.value is None:
+ raise IOError(get_errno(), os.strerror(get_errno()))
+ return hdl
def di_devlink_path(dl):
- """Return a string that is the path corresponding to the devlink
- passed in
- """
- r = _libdi.di_devlink_path(dl)
- if r is None:
- raise IOError(get_errno(), os.strerror(get_errno()))
- return r
+ """Return a string that is the path corresponding to the devlink
+ passed in
+ """
+ r = _libdi.di_devlink_path(dl)
+ if r is None:
+ raise IOError(get_errno(), os.strerror(get_errno()))
+ return r
def di_devlink_walk(hdl, pattern, path, flags, walk_arg, walkfunc):
- """Conduct a walk of all devlinks that patch the given pattern and
- that pertain to the given path. Note that since ctypes passes
- arguments to callbacks as 'int's, those arguments must be converted
- into a useful Python type (passing a string, then reconstituting
- a list from that string, for example).
- """
+ """Conduct a walk of all devlinks that patch the given pattern and
+ that pertain to the given path. Note that since ctypes passes
+ arguments to callbacks as 'int's, those arguments must be converted
+ into a useful Python type (passing a string, then reconstituting
+ a list from that string, for example).
+ """
- wf = _devlink_walkfunc_type(walkfunc)
- r = _libdi.di_devlink_walk(hdl, pattern, path, flags, walk_arg, wf)
- if r < 0:
- raise IOError(get_errno(), os.strerror(get_errno()))
-
+ wf = _devlink_walkfunc_type(walkfunc)
+ r = _libdi.di_devlink_walk(hdl, pattern, path, flags, walk_arg, wf)
+ if r < 0:
+ raise IOError(get_errno(), os.strerror(get_errno()))
+
def di_devlink_fini(hdl):
- """Performs cleanup after use of the devlink interfaces"""
- _libdi.di_devlink_fini(hdl)
+ """Performs cleanup after use of the devlink interfaces"""
+ _libdi.di_devlink_fini(hdl)
# ==========================[ libdevinfo subset ]=============================
_minor_walkfunc_type = CFUNCTYPE(c_int, c_void_p, c_void_p, c_void_p)
_libdi.di_init.restype = c_void_p
-_libdi.di_init.argtypes = [ c_char_p, c_int ]
-_libdi.di_fini.argtypes = [ c_void_p ]
+_libdi.di_init.argtypes = [c_char_p, c_int]
+_libdi.di_fini.argtypes = [c_void_p]
_libdi.di_devfs_path.restype = c_void_p
-_libdi.di_devfs_path.argtypes = [ c_void_p ]
-_libdi.di_devfs_path_free.argtypes = [ c_void_p ]
-_libdi.di_minor_spectype.argtypes = [ c_void_p ]
+_libdi.di_devfs_path.argtypes = [c_void_p]
+_libdi.di_devfs_path_free.argtypes = [c_void_p]
+_libdi.di_minor_spectype.argtypes = [c_void_p]
_libdi.di_minor_name.restype = c_char_p
-_libdi.di_minor_name.argtypes = [ c_void_p ]
+_libdi.di_minor_name.argtypes = [c_void_p]
_libdi.di_minor_next.restype = c_void_p
-_libdi.di_minor_next.argtypes = [ c_void_p, c_void_p ]
-_libdi.di_walk_minor.argtypes = [ c_void_p, c_char_p, c_int, c_void_p,
- _minor_walkfunc_type ]
-_libdi.di_prop_lookup_strings.argtypes = [ c_ulong, c_void_p,
- c_char_p, c_void_p ]
+_libdi.di_minor_next.argtypes = [c_void_p, c_void_p]
+_libdi.di_walk_minor.argtypes = [c_void_p, c_char_p, c_int, c_void_p,
+ _minor_walkfunc_type]
+_libdi.di_prop_lookup_strings.argtypes = [c_ulong, c_void_p,
+ c_char_p, c_void_p]
+
+
class struct_boot_dev(Structure):
_fields_ = [('bootdev_element', c_char_p),
('bootdev_trans', POINTER(c_char_p))]
pp_struct_boot_dev = POINTER(POINTER(struct_boot_dev))
-_libdi.devfs_bootdev_get_list.argtypes = [ c_char_p, POINTER(pp_struct_boot_dev) ]
-_libdi.devfs_bootdev_free_list.argtypes = [ pp_struct_boot_dev ]
+_libdi.devfs_bootdev_get_list.argtypes = [c_char_p,
+ POINTER(pp_struct_boot_dev)]
+_libdi.devfs_bootdev_free_list.argtypes = [pp_struct_boot_dev]
_libdi.devfs_bootdev_free_list.restype = None
@@ -346,97 +354,99 @@
DDI_DEV_T_ANY = -2
DDI_DEV_T_NONE = -1
+
def _di_minor_spectype(minor):
- """Returns the type (block or char) of the special node whose minor
- info is passed in
- """
- return _libdi.di_minor_spectype(minor)
+ """Returns the type (block or char) of the special node whose minor
+ info is passed in
+ """
+ return _libdi.di_minor_spectype(minor)
-def di_init(path='/', flags=(DINFOPATH|DINFOCPYALL)):
- """Initialize the device tree snapshot, starting from the device path
- specified. flags are (DINFOPATH|DINFOCPYALL) by default.
- """
- hdl = c_void_p(_libdi.di_init(path, flags))
- if hdl.value is None:
- raise IOError(get_errno(), os.strerror(get_errno()))
- return hdl
+def di_init(path='/', flags=(DINFOPATH | DINFOCPYALL)):
+ """Initialize the device tree snapshot, starting from the device path
+ specified. flags are (DINFOPATH|DINFOCPYALL) by default.
+ """
+ hdl = c_void_p(_libdi.di_init(path, flags))
+ if hdl.value is None:
+ raise IOError(get_errno(), os.strerror(get_errno()))
+ return hdl
def di_minor_is_block(minor):
- return (True if _di_minor_spectype(minor) == S_IFBLK else False)
+ return (True if _di_minor_spectype(minor) == S_IFBLK else False)
def di_minor_name(minor):
- "Returns the string name of the minor passed in"
- return _libdi.di_minor_name(minor)
+ "Returns the string name of the minor passed in"
+ return _libdi.di_minor_name(minor)
def di_devfs_path(node):
- "Returns the string name of the node passed in"
- r = c_void_p(_libdi.di_devfs_path(node))
- if r.value is None:
- raise IOError(get_errno(), os.strerror(get_errno()))
- rs = c_char_p(r.value).value
- _libdi.di_devfs_path_free(r)
- return rs
+ "Returns the string name of the node passed in"
+ r = c_void_p(_libdi.di_devfs_path(node))
+ if r.value is None:
+ raise IOError(get_errno(), os.strerror(get_errno()))
+ rs = c_char_p(r.value).value
+ _libdi.di_devfs_path_free(r)
+ return rs
def di_minor_next(node, minor=None):
- """Returns the next minor node, relative to the minor passed in.
- If minor isn't specified, or is passed in as None, the first minor
- associated with the node is returned. None is returned when no
- more minors exist.
- """
- r = c_void_p(_libdi.di_minor_next(node, minor))
- if r.value is None:
- e = get_errno()
- # NXIO is a special case-- an indicator of no more minors
- if e == errno.ENXIO:
- return None
- else:
- raise IOError(e, os.strerror(e))
- return r
+ """Returns the next minor node, relative to the minor passed in.
+ If minor isn't specified, or is passed in as None, the first minor
+ associated with the node is returned. None is returned when no
+ more minors exist.
+ """
+ r = c_void_p(_libdi.di_minor_next(node, minor))
+ if r.value is None:
+ e = get_errno()
+ # NXIO is a special case-- an indicator of no more minors
+ if e == errno.ENXIO:
+ return None
+ else:
+ raise IOError(e, os.strerror(e))
+ return r
+
def di_walk_minor(rootnode, minortype, walkarg, walkfunc, flag=0):
- """Perform a walk of all minor nodes attached to device nodes
- in a subtree rooted at `root'. walkargs should be a simple Python
- type, since it will need to be reconstituted in the walkfunc callback.
- """
+ """Perform a walk of all minor nodes attached to device nodes
+ in a subtree rooted at `root'. walkargs should be a simple Python
+ type, since it will need to be reconstituted in the walkfunc callback.
+ """
- wf = _minor_walkfunc_type(walkfunc)
- r = _libdi.di_walk_minor(rootnode, minortype, flag, walkarg, wf)
- print r
- if r < 0:
- raise IOError(get_errno(), os.strerror(get_errno()))
+ wf = _minor_walkfunc_type(walkfunc)
+ r = _libdi.di_walk_minor(rootnode, minortype, flag, walkarg, wf)
+ print r
+ if r < 0:
+ raise IOError(get_errno(), os.strerror(get_errno()))
def di_fini(hdl):
- _libdi.di_fini(hdl)
+ _libdi.di_fini(hdl)
def devfs_bootdev_get_list():
- bdl = pp_struct_boot_dev()
+ bdl = pp_struct_boot_dev()
- rv = _libdi.devfs_bootdev_get_list('/', pointer(bdl))
+ rv = _libdi.devfs_bootdev_get_list('/', pointer(bdl))
# No exception is raised on error, because there is no errno
# value that accompanies the failure
if rv < 0 or bool(bdl) is False:
- return None
+ return None
- i = 0
+ i = 0
bootdevs = []
while not bool(bdl[i]) is False:
- physical = bdl[i][0].bootdev_element
- j = 0
+ physical = bdl[i][0].bootdev_element
+ j = 0
logicals = []
- while not bool(bdl[i][0].bootdev_trans[j]) is False:
- logicals.append(bdl[i][0].bootdev_trans[j])
+ while not bool(bdl[i][0].bootdev_trans[j]) is False:
+ logicals.append(bdl[i][0].bootdev_trans[j])
j += 1
bootdevs.append((physical, tuple(logicals)))
- i += 1
+ i += 1
_libdi.devfs_bootdev_free_list(bdl)
@@ -449,9 +459,11 @@
raise IOError(get_errno(), os.strerror(get_errno()))
return rv
+
def di_find_root_prop(propname):
return di_find_prop(propname, '/')
+
def di_find_prop(propname, root):
hdl = di_init(root, DINFOPROP)
propval = None
@@ -495,31 +507,34 @@
# ==============================[ libfstyp ]==================================
_libfstyp = CDLL('libfstyp.so.1', use_errno=True)
-_libfstyp.fstyp_init.argtypes = [ c_int, c_uint64, c_char_p, c_void_p ]
-_libfstyp.fstyp_ident.argtypes = [ c_void_p, c_char_p, c_void_p ]
-_libfstyp.fstyp_fini.argtypes = [ c_void_p ]
-_libfstyp.fstyp_strerror.argtypes = [ c_void_p, c_int ]
+_libfstyp.fstyp_init.argtypes = [c_int, c_uint64, c_char_p, c_void_p]
+_libfstyp.fstyp_ident.argtypes = [c_void_p, c_char_p, c_void_p]
+_libfstyp.fstyp_fini.argtypes = [c_void_p]
+_libfstyp.fstyp_strerror.argtypes = [c_void_p, c_int]
_libfstyp.fstyp_strerror.restype = c_char_p
+
def fstyp_init(fd, offset=0, module_dir=None):
- "Returns a handle that can be used with other fstyp functions"
- handle = c_void_p()
- r = _libfstyp.fstyp_init(fd, offset, module_dir, byref(handle))
- if r != 0:
- raise IOError(r, _libfstyp.fstyp_strerror(r))
- return handle
+ "Returns a handle that can be used with other fstyp functions"
+ handle = c_void_p()
+ r = _libfstyp.fstyp_init(fd, offset, module_dir, byref(handle))
+ if r != 0:
+ raise IOError(r, _libfstyp.fstyp_strerror(r))
+ return handle
+
def fstyp_ident(handle, name=None):
- result = c_char_p(0)
- r = _libfstyp.fstyp_ident(handle, name, byref(result))
- if r == 1: # No Match Found
- return None
- elif r != 0:
- raise IOError(r, _libfstyp.fstyp_strerror(handle, r))
- return result.value
+ result = c_char_p(0)
+ r = _libfstyp.fstyp_ident(handle, name, byref(result))
+ if r == 1: # No Match Found
+ return None
+ elif r != 0:
+ raise IOError(r, _libfstyp.fstyp_strerror(handle, r))
+ return result.value
+
def fstyp_fini(handle):
- _libfstyp.fstyp_fini(handle)
+ _libfstyp.fstyp_fini(handle)
# ================================[ isalist ]=================================
@@ -527,17 +542,18 @@
SI_ISALIST = 514 # return supported isa list
ISALIST_LEN = 257 # max buffer size, as per manpage
-_libc.sysinfo.argtypes = [ c_int, c_char_p, c_long ]
+_libc.sysinfo.argtypes = [c_int, c_char_p, c_long]
_libc.sysinfo.restype = c_int
+
def isalist():
- "Returns a list of ISAs supported on the currently-running system"
+ "Returns a list of ISAs supported on the currently-running system"
- b = create_string_buffer(ISALIST_LEN)
- r = _libc.sysinfo(SI_ISALIST, b, ISALIST_LEN)
- if r < 0:
- raise OSError(get_errno(), os.strerror(get_errno()))
- return b.value.split()
+ b = create_string_buffer(ISALIST_LEN)
+ r = _libc.sysinfo(SI_ISALIST, b, ISALIST_LEN)
+ if r < 0:
+ raise OSError(get_errno(), os.strerror(get_errno()))
+ return b.value.split()
# =================================[ libscf ]=================================
@@ -545,13 +561,13 @@
SCF_STATE_STRING_ONLINE = 'online'
_libscf = CDLL('libscf.so.1', use_errno=True)
-_libscf.smf_get_state.argtypes = [ c_char_p ]
+_libscf.smf_get_state.argtypes = [c_char_p]
_libscf.smf_get_state.restype = c_void_p # Why c_void_p ? See comment below.
-_libscf.smf_enable_instance.argtypes = [ c_char_p, c_int ]
+_libscf.smf_enable_instance.argtypes = [c_char_p, c_int]
_libscf.smf_enable_instance.restype = c_int
_libscf.scf_error.argtypes = None
_libscf.scf_error.restype = c_int
-_libscf.scf_strerror.argtypes = [ c_int ]
+_libscf.scf_strerror.argtypes = [c_int]
_libscf.scf_strerror.restype = c_char_p
@@ -595,56 +611,60 @@
_libzfs = CDLL('libzfs.so.1', use_errno=True)
_libzfs.libzfs_init.restype = c_void_p
_libzfs.zfs_open.restype = c_void_p
-_libzfs.zfs_open.argtypes = [ c_void_p, c_char_p, c_int ]
-_libzfs.zfs_close.argtypes = [ c_void_p ]
+_libzfs.zfs_open.argtypes = [c_void_p, c_char_p, c_int]
+_libzfs.zfs_close.argtypes = [c_void_p]
zif_callback = CFUNCTYPE(c_int, c_void_p, c_void_p)
-_libzfs.zfs_iter_filesystems.argtypes = [ c_void_p, zif_callback, c_void_p ]
+_libzfs.zfs_iter_filesystems.argtypes = [c_void_p, zif_callback, c_void_p]
ZFS_TYPE_FILESYSTEM = 1
ZFS_TYPE_SNAPSHOT = 2
ZFS_TYPE_VOLUME = 4
ZFS_TYPE_POOL = 8
+
def libzfs_init():
- hdl = _libzfs.libzfs_init()
- if hdl.value is None:
- raise IOError(0, _msgs[LIBZFS_INIT_FAILURE])
- return hdl
+ hdl = _libzfs.libzfs_init()
+ if hdl.value is None:
+ raise IOError(0, _msgs[LIBZFS_INIT_FAILURE])
+ return hdl
-def zfs_open(handle, devpath, type=ZFS_TYPE_FILESYSTEM): pass
+
+def zfs_open(handle, devpath, type=ZFS_TYPE_FILESYSTEM):
+ pass
+
def libzfs_fini(handle):
- _libzfs.libzfs_fini(handle)
+ _libzfs.libzfs_fini(handle)
-__all__ = [ "statvfs",
- "mnttab_open",
- "mnttab_close",
- "getmntent",
- "getmntany",
- "getextmntent",
- "resetmnttab",
- "DI_MAKE_LINK",
- "DI_PRIMARY_LINK",
- "DI_SECONDARY_LINK",
- "DI_WALK_CONTINUE",
- "DI_WALK_TERMINATE",
- "di_devlink_init",
- "di_devlink_path",
- "di_devlink_walk",
- "di_devlink_fini",
- "DDI_NT_BLOCK",
- "DINFOPATH",
- "DINFOCPYALL",
- "di_init",
- "di_minor_is_block",
- "di_minor_name",
- "di_devfs_path",
- "di_minor_next",
- "di_walk_minor",
- "di_fini",
- "devfs_bootdev_get_list",
- "fstyp_init",
- "fstyp_ident",
- "fstyp_fini",
- "isalist" ]
+__all__ = ["statvfs",
+ "mnttab_open",
+ "mnttab_close",
+ "getmntent",
+ "getmntany",
+ "getextmntent",
+ "resetmnttab",
+ "DI_MAKE_LINK",
+ "DI_PRIMARY_LINK",
+ "DI_SECONDARY_LINK",
+ "DI_WALK_CONTINUE",
+ "DI_WALK_TERMINATE",
+ "di_devlink_init",
+ "di_devlink_path",
+ "di_devlink_walk",
+ "di_devlink_fini",
+ "DDI_NT_BLOCK",
+ "DINFOPATH",
+ "DINFOCPYALL",
+ "di_init",
+ "di_minor_is_block",
+ "di_minor_name",
+ "di_devfs_path",
+ "di_minor_next",
+ "di_walk_minor",
+ "di_fini",
+ "devfs_bootdev_get_list",
+ "fstyp_init",
+ "fstyp_ident",
+ "fstyp_fini",
+ "isalist"]
--- a/usr/src/lib/install_boot/test/test_boot.py Fri May 13 16:43:12 2011 -0700
+++ b/usr/src/lib/install_boot/test/test_boot.py Mon May 16 17:24:57 2011 -0700
@@ -175,7 +175,7 @@
# For the purposes of having a sane environment for the
# test case, use the active BE. This allows pybootmgt
# initialisation to locate all the bits it expects.
- for self.be_name, be_pool, be_root_ds in be_list():
+ for self.be_name, be_pool, be_root_ds, default in be_list():
be_fs = Filesystem(be_root_ds)
if be_fs.get('mounted') == 'yes' and \
be_fs.get('mountpoint') == '/':