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
评论列表
文章目录