Mini Shell

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

3

{)c��@s�ddlZddlZddlmZddlmZddlmZddlZej	d�Z
ddlmZGd	d
�d
e�Z
Gdd�de
�ZGd
d�de
�ZdS)�N�)�util)�log_method_call)�SizeZblivet�)�
StorageDevicec@sveZdZdZdZdZddd�Zedd	��Zed
d��Z	dd
�Z
ddd�Zddd�Zdd�Z
dd�Zdd�Zdd�ZdS)�
FileDevicezI A file on a filesystem.

        This exists because of swap files.
    �file�NFcCs.tjj|�std��tj||||||d�dS)a�
            :param path: full path to the file
            :type path: 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
        z$FileDevice requires an absolute path)�fmt�size�exists�parentsN)�os�path�isabs�
ValueErrorr�__init__)�selfrrrr
r�r�/usr/lib/python3.6/file.pyr-szFileDevice.__init__cCs|jS)N)�name)rrrr�
fstab_specAszFileDevice.fstab_speccCs�y |jdjj}|jdjj}Wnttfk
r<d}Yn4Xx|jd�rX|dd�}q@W|rp|dt|��}tj	j
d||jf�S)Nrr
�/rz%s%s���)r�formatZsystem_mountpoint�
mountpoint�AttributeError�
IndexError�endswith�lenrr�normpathr)r�rootrrrrrEs
zFileDevice.pathcCs:td�}|jr6tjj|j�r6tj|j�}t|tj�}|S)Nr)rr
rr�stat�ST_SIZE)rr�strrr�read_current_sizeVs
zFileDevice.read_current_sizecCs0|jr"|jjr"|jjr"|j|j_tj||d�S)N)�orig)rr
�statusr�devicer�
_pre_setup)rr'rrrr*^s
zFileDevice._pre_setupcCs0|jr"|jjr"|jjr"|j|j_tj||d�S)N)�	recursive)rr
r(rr)r�
_pre_teardown)rr+rrrr,ds
zFileDevice._pre_teardownc	Cs�t||j|jd�tj|jtjtjBtjB�}d}d}t	t
|j�|�\}}||}x"t|�D]}tj
||jd��q\W|r�||}tj
||jd��tj|�dS)z Create the device. )r(�irzutf-8Ni)rrr(r�openr�O_WRONLY�O_CREAT�O_TRUNC�divmod�intr�range�write�encode�close)	r�fdZzeroZ
block_size�countZremZzerosZ_nZsize_targetrrr�_createjszFileDevice._createcCs"t||j|jd�tj|j�dS)z Destroy the device. )r(N)rrr(r�unlinkr)rrrr�_destroy~szFileDevice._destroycCsd|ko|dko|dkS)Nr-�.z..r)rrrrr�
is_name_valid�szFileDevice.is_name_validcCsdS)Nr)rrrr�update_sysfs_path�szFileDevice.update_sysfs_path)NNFN)F)N)�__name__�
__module__�__qualname__�__doc__�_typeZ_dev_dirr�propertyrrr&r*r,r:r<r>r?rrrrr$s


rc@seZdZdZdZdd�ZdS)�SparseFileDevicezFA sparse file on a filesystem.
    This exists for sparse disk images.zsparse filecCs&t||j|jd�tj|j|j�dS)zCreate a sparse file.)r(N)rrr(rZcreate_sparse_filerr)rrrrr:�szSparseFileDevice._createN)r@rArBrCrDr:rrrrrF�srFc@seZdZdZdZdd�ZdS)�DirectoryDevicezO A directory on a filesystem.

        This exists because of bind mounts.
    Z	directorycCs"t||j|jd�tj|j�dS)z Create the device. )r(N)rrr(r�makedirsr)rrrrr:�szDirectoryDevice._createN)r@rArBrCrDr:rrrrrG�srG)rr#r
rZstorage_logrrrZloggingZ	getLogger�logZstoragerrrFrGrrrr�<module>s
g