Mini Shell

Direktori : /lib/python3.6/site-packages/blivet/devices/__pycache__/
Upload File :
Current File : //lib/python3.6/site-packages/blivet/devices/__pycache__/luks.cpython-36.pyc

3

�Mf%�@s�ddlmZddlmZddlmZddlmZddlm	Z	ddl
Z
e
jd�Zd	d
l
mZd	dlmZmZGdd
�d
e�ZGdd�de�ZdS)�)�crypto)�log_method_call)�Size)�availability)�DeviceError�NZblivet�)�
StorageDevice)�
DMCryptDevice�DMIntegrityDevicecs�eZdZdZdZdZdgZejgZ	d(dd	�Z
ed
d��Zedd
��Z
dd�Z�fdd�Zeee�Zedd��Zdd�Zdd�Zedd��Zedd��Zdd�Zdd�Zd)d d!�Zd"d#�Zd$d%�Z�fd&d'�Z�ZS)*�
LUKSDevicez A mapped LUKS device. z
luks/dm-cryptTZ
cryptsetupNF�c
Cstj||||||d|d�dS)a�
            :param name: the device name (generally a device node's basename)
            :type name: str
            :keyword exists: does this device exist?
            :type exists: bool
            :keyword size: the device's size
            :type size: :class:`~.size.Size`
            :keyword parents: a list of parent devices
            :type parents: list of :class:`StorageDevice`
            :keyword fmt: this device's formatting
            :type fmt: :class:`~.formats.DeviceFormat` or a subclass of it
            :keyword sysfs_path: sysfs device path
            :type sysfs_path: str
            :keyword uuid: the device UUID
            :type uuid: str
        N)�fmt�size�parents�
sysfs_path�uuid�exists)r
�__init__)�self�namerrrrrr�r�/usr/lib/python3.6/luks.pyr-szLUKSDevice.__init__cCs|jS)N)�slave)rrrr�
raw_deviceCszLUKSDevice.raw_devicecCs |jr|jdjdS|jdS)Nr)�_has_integrityr)rrrrrGszLUKSDevice.slavecCs<|js|jjtj}n"|jr2|jtd�kr2|j}n|j}|S)Nr)	rrrr�LUKS_METADATA_SIZE�	resizable�target_sizerZcurrent_size)rrrrr�	_get_sizeMszLUKSDevice._get_sizecsD|jr8|jjr8|tj|j_tt|�j|tj�ntd��dS)Nz+Cannot set size for an existing LUKS device)	rrrrr�superr�	_set_sizer)r�newsize)�	__class__rrr!VszLUKSDevice._set_sizecCs|jdjdkS)Nrzintegrity/dm-crypt)r�type)rrrrraszLUKSDevice._has_integritycCs�t|t�std��|jr<||jkr<tjd||j�td��n(|jrd||jkrdtjd||j�td��||jjt	j
kr�tjd||jj�td��|j|�|kr�td��dS)	Nznew size must be of type Sizez+requested size %s is larger than maximum %sz/size is larger than the maximum for this devicez,requested size %s is smaller than minimum %sz0size is smaller than the minimum for this devicez>requested size %s is larger than size of the backing device %sz2size is larger than the size of the backing devicez-new size would violate alignment requirements)�
isinstancer�
ValueError�max_size�log�errorZmin_sizerrrrZalign_target_size)rr"rrr�_set_target_sizees 



zLUKSDevice._set_target_sizecCs
|jjjS)N)r�formatr)rrrr�_get_target_size{szLUKSDevice._get_target_sizecCs(|jjtj}|jj}|r$t||�S|S)zs The maximum size this luks device can be. Maximum is based on the
            maximum size of the backing device. )rr'rrr+�min)rZmax_luksZ
max_formatrrrr'~szLUKSDevice.max_sizecCs$|jo"|jo"|jjo"|jjo"|jS)z Can this device be resized? )�
_resizablerr+rrr)rrrrr�szLUKSDevice.resizablecCst||j|jd�dS)N)�status)rrr/)rrrr�resize�szLUKSDevice.resizecCs|jjj|_tj|�dS)N)rr+�map_namerr	�_post_create)rrrrr2�szLUKSDevice._post_createcCs"|s|j|d�tj||d�dS)N)�	recursive)�teardown_parentsr	�_post_teardown)rr3rrrr5�szLUKSDevice._post_teardowncCs`|jr
dS|jr\|jdjdkr\|jj|jdj�r\d|jdj}tjd|j|�||_dS)Nr�	partitionzluks-%sz<updating luks name after partition name change from %s to %s)rrr$r�endswithr(�debug)r�new_namerrr�update_name�s,
zLUKSDevice.update_namecCstd|jjjg�S)Nzrd.luks.uuid=luks-%s)�setrr+r)rrrr�dracut_setup_args�szLUKSDevice.dracut_setup_argscs&|jj|�d|_tt|�j|�dS)NT)r�populate_ksdataZ	encryptedr r)r�data)r#rrr=�szLUKSDevice.populate_ksdata)NNNFr
N)F)�__name__�
__module__�__qualname__�__doc__�_typer.�	_packagesrZBLOCKDEV_CRYPTO_PLUGIN�_external_dependenciesr�propertyrrrr!rrr*r,r'rr0r2r5r:r<r=�
__classcell__rr)r#rr%s.
		

rcs|eZdZdZdZdZdgZejgZ	ddd�Z
ed	d
��Zedd��Z
d
d�Z�fdd�Zeee�Zddd�Zdd�Z�ZS)�IntegrityDevicez A mapped integrity device. zintegrity/dm-cryptFZintegritysetupNr
c
Cstj||||||d|d�dS)a�
            :param name: the device name (generally a device node's basename)
            :type name: str
            :keyword exists: does this device exist?
            :type exists: bool
            :keyword size: the device's size
            :type size: :class:`~.size.Size`
            :keyword parents: a list of parent devices
            :type parents: list of :class:`StorageDevice`
            :keyword fmt: this device's formatting
            :type fmt: :class:`~.formats.DeviceFormat` or a subclass of it
            :keyword sysfs_path: sysfs device path
            :type sysfs_path: str
            :keyword uuid: the device UUID
            :type uuid: str
        N)rrrrrr)rr)rrrrrrrrrrrr�szIntegrityDevice.__init__cCs
|jdS)Nr)r)rrrrr�szIntegrityDevice.raw_devicecCstj|jj|jjj�S)N)rZ!calculate_integrity_metadata_sizerrr+�	algorithm)rrrr�
metadata_size�s
zIntegrityDevice.metadata_sizecCs |js|jj|j}n|j}|S)N)rrrrJZ_size)rrrrrr�szIntegrityDevice._get_sizecsD|jr8|jjr8||j|j_tt|�j||j�ntd��dS)Nz0Cannot set size for an existing integrity device)rrrJrr rHr!r)rr")r#rrr!�szIntegrityDevice._set_sizecCs"|s|j|d�tj||d�dS)N)r3)r4r	r5)rr3rrrr5�szIntegrityDevice._post_teardowncCs|jjj|_tj|�dS)N)rr+r1rr	r2)rrrrr2�szIntegrityDevice._post_create)NNNFr
N)F)r?r@rArBrCr.rDrZ BLOCKDEV_CRYPTO_PLUGIN_INTEGRITYrErrFrrJrr!rr5r2rGrr)r#rrH�s
	

rH)Z
devicelibsrZstorage_logrrrZtasksr�errorsrZloggingZ	getLoggerr(Zstorager	Zdmr
rrrHrrrr�<module>s