Removed using lazy mode for umount
Safer for cloud-init to not use lazy mode for unmount
This commit is contained in:
parent
f71e050f44
commit
d4f20c77ad
@ -1294,16 +1294,12 @@ def ensure_dir(path, mode=None):
|
|||||||
|
|
||||||
|
|
||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
def unmounter(umount, lazy_support=True):
|
def unmounter(umount):
|
||||||
try:
|
try:
|
||||||
yield umount
|
yield umount
|
||||||
finally:
|
finally:
|
||||||
if umount:
|
if umount:
|
||||||
# Do not use Lazy Mode on some systems (freebsd)
|
umount_cmd = ["umount", umount]
|
||||||
if lazy_support:
|
|
||||||
umount_cmd = ["umount", '-l', umount]
|
|
||||||
else:
|
|
||||||
umount_cmd = ["umount", umount]
|
|
||||||
subp(umount_cmd)
|
subp(umount_cmd)
|
||||||
|
|
||||||
|
|
||||||
@ -1386,12 +1382,7 @@ def mount_cb(device, callback, data=None, rw=False, mtype=None, sync=True):
|
|||||||
# Be nice and ensure it ends with a slash
|
# Be nice and ensure it ends with a slash
|
||||||
if not mountpoint.endswith("/"):
|
if not mountpoint.endswith("/"):
|
||||||
mountpoint += "/"
|
mountpoint += "/"
|
||||||
# Set lazy_support to false if FreeBSD
|
with unmounter(umount):
|
||||||
if device.startswith("/dev/cd"):
|
|
||||||
lazy_support = False
|
|
||||||
else:
|
|
||||||
lazy_support = True
|
|
||||||
with unmounter(umount, lazy_support):
|
|
||||||
if data is None:
|
if data is None:
|
||||||
ret = callback(mountpoint)
|
ret = callback(mountpoint)
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user