11__author__ = 'desultory'
2- __version__ = '4.13.0 '
2+ __version__ = '4.13.1 '
33
44from pathlib import Path
55from zenlib .util import contains , pretty_print
@@ -433,29 +433,29 @@ def _resolve_root_dev(self) -> None:
433433@contains ('hostonly' , "Skipping root autodetection, hostonly mode is disabled." , log_level = 30 )
434434def autodetect_root (self ) -> None :
435435 """ Sets self['mounts']['root']'s source based on the host mount. """
436- if any (source_type in self ['mounts' ]['root' ] for source_type in SOURCE_TYPES ):
437- self .logger .warning ("Root mount source already set: %s" , pretty_print (self ['mounts' ]['root' ]))
438- return
439-
440436 # Sometimes the root device listed in '/proc/mounts' differs from the blkid info
441437 root_dev = self ['_mounts' ]['/' ]['device' ]
442438 if self ['resolve_root_dev' ]:
443439 root_dev = _resolve_root_dev (self )
444440 if root_dev not in self ['_blkid_info' ]:
445441 get_blkid_info (self , root_dev )
446- self [ 'mounts' ] = _autodetect_mount (self , '/' )
442+ _autodetect_mount (self , '/' )
447443
448444
449- def _autodetect_mount (self , mountpoint ) -> dict :
450- """ Returns mount config based on the mount at the specified mountpoint. """
445+ def _autodetect_mount (self , mountpoint ) -> None :
446+ """ Sets mount config for the specified mountpoint. """
451447 if mountpoint not in self ['_mounts' ]:
452448 raise FileNotFoundError ("auto_mount mountpointpoint not found in host mounts: %s" % mountpoint )
453449 if self ['_mounts' ][mountpoint ]['device' ] not in self ['_blkid_info' ]:
454450 get_blkid_info (self , self ['_mounts' ][mountpoint ]['device' ])
451+
455452 mount_device = self ['_mounts' ][mountpoint ]['device' ]
456453 mount_info = self ['_blkid_info' ][mount_device ]
457454 autodetect_mount_kmods (self , mount_device )
458455 mount_name = 'root' if mountpoint == '/' else mountpoint .removeprefix ('/' )
456+ if mount_name in self ['mounts' ] and any (s_type in self ['mounts' ][mount_name ] for s_type in SOURCE_TYPES ):
457+ return self .logger .warning ("[%s] Mount config already set: %s" % (mountpoint , pretty_print (self ['mounts' ][mount_name ])))
458+
459459 mount_config = {mount_name : {'type' : 'auto' }}
460460 if mount_type := mount_info .get ('type' ):
461461 self .logger .info ("Autodetected mount type: %s" % mount_type )
@@ -469,15 +469,15 @@ def _autodetect_mount(self, mountpoint) -> dict:
469469 else :
470470 raise ValueError ("[%s] Failed to autodetect mount source." % mountpoint )
471471
472- return mount_config
472+ self [ 'mounts' ] = mount_config
473473
474474
475475@contains ('auto_mounts' , "Skipping auto mounts, auto_mounts is empty." , log_level = 10 )
476476@contains ('hostonly' , "Skipping mount autodetection, hostonly mode is enabled." , log_level = 30 )
477477def autodetect_mounts (self ) -> None :
478478 """ Configured the mount config for a device based on the host mount config. """
479479 for mountpoint in self ['auto_mounts' ]:
480- self [ 'mounts' ] = _autodetect_mount (self , mountpoint )
480+ _autodetect_mount (self , mountpoint )
481481
482482
483483def mount_base (self ) -> list [str ]:
0 commit comments