%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/landscape/lib/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/landscape/lib/__pycache__/disk.cpython-312.pyc

�

�~�e`��|�ddlZddlZddlZddlmZegd��Zejd�Zefd�Z	d�Z
d�Zd�Zy)	�N)�_PY3)�ext�ext2�ext3�ext4�reiserfs�ntfs�msdos�dos�vfat�xfs�hpfs�jfs�ufs�hfs�hfsplus�simfs�drvfs�lxfs�zfs�btrfsz([a-z]+)[0-9]*c#�K�t|�D]�}	|j�dd\}}}trtj|d�}ntj|d�}|�||vr�Ud}	||�}|j}	|j|	z|z}
|j|	z|z}||||
|d�����y#t
$rY��wxYw#t$rY��wxYw�w)aZ
    This is a generator that yields information about mounted filesystems.

    @param mounts_file: A file with information about mounted filesystems,
        such as C{/proc/mounts}.
    @param statvfs_: A function to get file status information.
    @param filesystems_whitelist: Optionally, a list of which filesystems to
        stat.
    @return: A C{dict} with C{device}, C{mount-point}, C{filesystem},
        C{total-space} and C{free-space} keys. If the filesystem information
        is not available, C{None} is returned. Both C{total-space} and
        C{free-space} are in megabytes.
    N��unicode_escape�
string_escapei)�device�mount-point�
filesystemztotal-spacez
free-space)
�open�splitr�codecs�decode�
ValueError�OSError�f_bsize�f_blocks�f_bfree)�mounts_file�statvfs_�filesystems_whitelist�liner�mount_pointr�	megabytes�stats�
block_size�total_space�
free_spaces            �4/usr/lib/python3/dist-packages/landscape/lib/disk.py�get_mount_infor3&s�����$�[�!�
��	�.2�j�j�l�2�A�.>�+�F�K���$�m�m�K�9I�J��$�m�m�K��I��
"�-��"7�7���	�	��[�)�E��]�]�
��~�~�
�2�y�@���m�m�j�0�Y�>�
��&�$�&�$�
�	
�-
���	��	���	��	�sM�C	�A
B+�	C	�&B:�.=C	�+	B7�4C	�6B7�7C	�:	C�C	�C�C	c�
�d}tjj|�}|jd�}t	||�D]A}|djd�}|j|d�s�,|r|dt
|�|k(s�@|}�C|S)a�
    Tries to determine to which of the mounted filesystem C{path} belongs to,
    and then returns information about that filesystem or C{None} if it
    couldn't be determined.

    @param path: The path we want filesystem information about.
    @param mounts_file: A file with information about mounted filesystems,
        such as C{/proc/mounts}.
    @param statvfs_: A function to get file status information.
    @return: A C{dict} with C{device}, C{mount-point}, C{filesystem},
        C{total-space} and C{free-space} keys. If the filesystem information
        is not available, C{None} is returned. Both C{total-space} and
        C{free-space} are in megabytes.
    N�/r)�os�path�realpathr r3�
startswith�len)r7r(r)�	candidate�
path_segments�info�mount_segmentss       r2�get_filesystem_for_pathr?Ws����I�
�7�7���D�!�D��J�J�s�O�M��{�H�5�!���m�,�2�2�3�7���?�?�4�
�.�/��-�%�#�n�%�#��# �!�	�
!���c�,�tjj|�jd�ryt	|�}|syd}	t|d�5}|j
�}ddd�|j�dk(ryy#1swY�xYw#t$rYywxYw)z�
    This function returns whether a given device is removable or not by looking
    at the corresponding /sys/block/<device>/removable file

    @param device: The filesystem path to the device, e.g. /dev/sda1
    �mmcblkTFN�r�1)	r6r7�basenamer9�_get_device_removable_file_pathr�readliner$�strip)rr7�contents�fs    r2�is_device_removablerKss���
�w�w�����*�*�8�4��*�6�2�D����H��
�$��_�	$���z�z�|�H�	$�
�~�~��3����	$�	$������s*�B�
A;�B�;B�B�	B�Bc�2�tjj|�rtj|�}|j	d�dd\}t
j
|�}|sy|j�d}tjjd|d�}|S)a5
    Get a device's "removable" file path.

    This function figures out the C{/sys/block/<device>/removable} path
    associated with the given device. The file at that path contains either
    a "0" if the device is not removable, or a "1" if it is.

    @param device: File system path of the device.
    r5���Nrz/sys/block/�	removable)	r6r7�islink�readlinkr �EXTRACT_DEVICE�match�groups�join)r�device_name�matched�removable_files    r2rFrF�s~��
�w�w�~�~�f�����V�$���L�L��%�b�c�*�M�[��"�"�;�/�G����.�.�"�1�%�K��W�W�\�\�-��k�J�N��r@)
r!r6�re�landscape.lib.compatr�	frozenset�STABLE_FILESYSTEMS�compilerQr3r?rKrF�r@r2�<module>r^sP��
�	�	�%�����4����,�-��-�.
�b�8�:r@

Zerion Mini Shell 1.0