fs.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:DeepSea 作者: SUSE 项目源码 文件源码
def get_mountpoint_opts(mountpoint='', **kwargs):
    """
    Determine the mount options set for a given mountpoint.

    Returns a list of mount opts or None on error.  For opts in the form 'key=val',
    convert the opt into dictionary.  Thus, our return structure may look
    something like:
      [ 'rw', 'relatime', ..., { 'subvolid': '259' }, ... ]'
    """
    opts = None

    for part in psutil.disk_partitions():
        if part.mountpoint == mountpoint:
            opts = part.opts.split(',')

    # Convert foo=bar to dictionary entries if opts is not None or not an empty list.
    opts = [o if '=' not in o else {k: v for (k, v) in [tuple(o.split('='))]}
            for o in opts] if opts else None

    if not opts:
        log.error("Failed to determine mount opts for '{}'.".format(mountpoint))

    return opts
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号