Mini Shell
3
{)c% � @ s� d dl Z d dlmZ ddlmZ ddlmZ ddlmZ ddlmZ dd lm Z d
Z
ee j�G dd� de jej
��ZG d
d� de�ZG dd� de�ZG dd� de�ZG dd� de�ZG dd� de�ZG dd� de�ZG dd� dej�ZdS )� N)�
add_metaclass� )�FSError)�util� )�availability)�fstask)�taskzUnknown return code: %dc @ sB e Zd ZdZdZejdd�Zejdd� �Z e
dd� �Zd d
� ZdS )�FSCKzkAn abstract class that represents actions associated with
checking consistency of a filesystem.
Zfsckz%Options for invoking the application.)�docc C s
t � �dS )a Error message corresponding to rc.
:param int rc: the fsck program return code
:returns: an error message corresponding to the code, or None
:rtype: str or NoneType
A return value of None indicates no error.
N)�NotImplementedError)�self�rc� r �/usr/lib/python3.6/fsck.py�_error_message1 s
zFSCK._error_messagec C s t | j�g| j | jjg S )zmThe command to check the filesystem.
:return: the command
:rtype: list of str
)�str�ext�options�fs�device)r
r r r �
_fsck_command= s zFSCK._fsck_commandc C s� | j }|rtdj|���ytj| j�}W n. tk
rV } ztd| ��W Y dd}~X nX | j|�}|dk r�d| jj | jj
d� }t|| ��dS )zG Check the filesystem.
:raises FSError: on failure
�
zfilesystem check failed: %sNz1%(type)s filesystem check failure on %(device)s: )�typer )Zavailability_errorsr �joinr Zrun_programr �OSErrorr r r r )r
Z
error_msgsr �eZ error_msgZhdrr r r �do_taskF s
zFSCK.do_taskN)
�__name__�
__module__�__qualname__�__doc__�description�abc�abstractpropertyr �abstractmethodr �propertyr r r r r r r
$ s r
c @ s* e Zd Zddd�ZejZdgZdd� ZdS )�DosFSCKzZRecoverable errors have been detected or dosfsck has discovered an internal inconsistency.zUsage error.)r r z-nc C s4 |dk rd S y
| j | S tk
r. t| S X d S )Nr )�_fsck_errors�KeyError�_UNKNOWN_RC_MSG)r
r r r r r d s
zDosFSCK._error_messageN) r r r r( r ZDOSFSCK_APPr r r r r r r r'