Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/dist-packages/landscape/lib/
Upload File :
Current File : //usr/lib/python2.7/dist-packages/landscape/lib/disk.pyc


Tc@ sddlmZddlZddlZddlZeddddddd	d
ddd
ddddgZejdZedZ	dZ
dZdZdS(i(tdivisionNtexttext2text3text4treiserfstntfstmsdostdostvfattxfsthpfstjfstufsthfsthfspluss([a-z]+)[0-9]*cc sxt|D]}y,|jd \}}}|jd}Wntk
rUq
nX|d	k	rt||krtq
nd
}y||}Wntk
rq
nX|tj}	|tj|	|}
|tj	|	|}i|d6|d6|d6|
d6|d6Vq
Wd	S(sZ
    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.
    is
string-escapeitdevicesmount-pointt
filesystemstotal-spaces
free-spaceNi(
topentsplittdecodet
ValueErrortNonetOSErrortstatvfstF_BSIZEtF_BLOCKStF_BFREE(tmounts_filetstatvfs_tfilesystems_whitelisttlineRtmount_pointRt	megabyteststatst
block_sizettotal_spacet
free_space((s6/usr/lib/python2.7/dist-packages/landscape/lib/disk.pytget_mount_infos(


cC sd}tjj|}|jd}xft||D]U}|djd}|j|dr7|s|t| |kr|}qq7q7W|S(s
    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.
    @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.
    t/smount-pointN(RtostpathtrealpathRR&t
startswithtlen(R)RRt	candidatet
path_segmentstinfotmount_segments((s6/usr/lib/python2.7/dist-packages/landscape/lib/disk.pytget_filesystem_for_path6scC stjj|jdrtSt|}|s5tSd}y(t|d}|j	}WdQXWnt
k
rwtSX|jdkrtStS(s
    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
    tmmcblktrNt1(R(R)tbasenameR+tTruet_get_device_removable_file_pathtFalseRRtreadlinetIOErrortstrip(RR)tcontentstf((s6/usr/lib/python2.7/dist-packages/landscape/lib/disk.pytis_device_removableSs	
cC stjj|r$tj|}n|jdd\}tj|}|sSdS|jd}tjj	d|d}|S(s5
    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.
    R'iis/sys/block/t	removableN(
R(R)tislinktreadlinkRtEXTRACT_DEVICEtmatchRtgroupstjoin(Rtdevice_nametmatchedtremovable_file((s6/usr/lib/python2.7/dist-packages/landscape/lib/disk.pyR7ps(
t
__future__RR(Rtret	frozensettSTABLE_FILESYSTEMStcompileRBR&R1R>R7(((s6/usr/lib/python2.7/dist-packages/landscape/lib/disk.pyt<module>s$