Mini Shell
3
{)c� � @ s� d dl Z d dlZddlmZ ddlmZ ddlmZ d dlZej d�Z
ddlmZ G d d
� d
e�Z
G dd� de
�ZG d
d� de
�ZdS )� N� )�util)�log_method_call)�SizeZblivet� )�
StorageDevicec @ sv e Zd ZdZdZdZddd�Zedd � �Zed
d� �Z dd
� Z
ddd�Zddd�Zdd� Z
dd� Zdd� Zdd� ZdS )�
FileDevicezI A file on a filesystem.
This exists because of swap files.
�file� NFc C s. t jj|�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__)�selfr r r r
r � r �/usr/lib/python3.6/file.pyr - s zFileDevice.__init__c C s | j S )N)�name)r r r r �
fstab_specA s zFileDevice.fstab_specc C s� y | j d jj}| j d jj}W n ttfk
r< d}Y n4X x|jd�rX|d d� }q@W |rp|d t|� � }tj j
d|| jf �S )Nr r
�/r z%s%s���)r �formatZsystem_mountpoint�
mountpoint�AttributeError�
IndexError�endswith�lenr r �normpathr )r �rootr r r r r E s
zFileDevice.pathc C s: t d�}| jr6tjj| j�r6tj| j�}t |tj �}|S )Nr )r r
r r �stat�ST_SIZE)r r �str r r �read_current_sizeV s
zFileDevice.read_current_sizec C s0 | j r"| j jr"| j j r"| j| j _tj| |d�S )N)�orig)r r
�statusr �devicer �
_pre_setup)r r'