Repository navigation
libsystemd: load the configuration directory of a mount point by itself (follow-up to #9) - #10
Merged
Merged
Conversation
libsystemd already hears every mount and unmount (dmfsi's _mount_changed dif), so the loading of <mount point>/cfg/services and cfg/rules is its own business again, not an API for a service to call: on a mount it adds the units, templates and rules to what is loaded and starts the units (dependency order, first definition of a name stays, %m = the mount point), on an unmount it runs the rules' `remove` units, then stops and drops exactly what came from there. A full reload keeps them; the units directory of libsystemd_scan() is never loaded twice. The module search path is invalidated before the units start: the new file system may hold their modules (/mnt/<label>/bin), and automount only gets to it after the mount returned. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
JohnAmadis
approved these changes
Oct 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Follow-up to #9, which was merged before its last commit: the version on
mainstill has the mount class and theremovekey but not the loading of a mount point's configuration directory.libsystemd hears every mount and unmount (dmfsi's
_mount_changeddif) and now loads<mount point>/cfg/servicesandcfg/rulesby itself - no API for anyone to call (thelibsystemd_add_config_dir()/remove_config_dir()of an earlier revision were dropped on purpose):libsystemd_scan()/libsystemd_load_rules()loaded (nothing is reloaded or restarted) and the units start in their dependency order. A unit or template whose name is taken stays the first one.%m= the mount point the unit comes from (exec=%m/bin/app.dmfc), so it stays bound to its own card.removeunits of the rules run (waited for), then everything that came from there stops and is dropped, template instances included. The unmount waits for all of it, so the units stop while their files are still there.libsystemd_scan()is never loaded twice; a mount point withoutcfg/is left alone.Dmod_InvalidateModuleSearchPaths()first:/mnt/<label>/binis on the (cached) module search path and automount only invalidates it after the mount returned - without it the module of a card's unit is not found.Stack
The dif is called in the thread that mounts - automount's. Loading a directory and starting a unit from a card there peaked at 2596 bytes of its stack on the board; automount needs 4 kB (choco-technologies/dmblock#6). Documented in
configuration.md.Testing
test_libsystemd73/73 (6 new: a mount adds, starts and an unmount removes the units ofcfg/services; a unit of two mount points stays the first one; the rules and templates of a mount point; survival of a full reload; the scanned units directory is not loaded twice; a mount withoutcfg/changes nothing),test_systemd/test_service1/1. The host loader needsDmod_InvalidateModuleSearchPaths(dmoddevelop).<card>/cfg/services/carhmi/carhmi.iniby itself; a probe unit in/ext/cfg/services:umount /ext+mountloads it (fresh instance each cycle,%m=/ext, exactly one).🤖 Generated with Claude Code