From 34f8e2213c42106b3e1568b5c5aac5565df954e3 Mon Sep 17 00:00:00 2001 From: Mina Galić Date: Mon, 2 Nov 2020 18:01:41 +0100 Subject: util: fix mounting of vfat on *BSD (#637) Fix mounting of vfat filesystems by normalizing the different names for vfat to "msdos" which works across BSDs. --- cloudinit/util.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'cloudinit/util.py') diff --git a/cloudinit/util.py b/cloudinit/util.py index 83727544..b8856af1 100644 --- a/cloudinit/util.py +++ b/cloudinit/util.py @@ -417,6 +417,11 @@ def multi_log(text, console=True, stderr=True, log.log(log_level, text) +@lru_cache() +def is_Linux(): + return 'Linux' in platform.system() + + @lru_cache() def is_BSD(): return 'BSD' in platform.system() @@ -1661,16 +1666,17 @@ def mount_cb(device, callback, data=None, mtype=None, _type=type(mtype))) # clean up 'mtype' input a bit based on platform. - platsys = platform.system().lower() - if platsys == "linux": + if is_Linux(): if mtypes is None: mtypes = ["auto"] - elif platsys.endswith("bsd"): + elif is_BSD(): if mtypes is None: - mtypes = ['ufs', 'cd9660', 'vfat'] + mtypes = ['ufs', 'cd9660', 'msdos'] for index, mtype in enumerate(mtypes): if mtype == "iso9660": mtypes[index] = "cd9660" + if mtype in ["vfat", "msdosfs"]: + mtypes[index] = "msdos" else: # we cannot do a smart "auto", so just call 'mount' once with no -t mtypes = [''] -- cgit v1.2.3