summaryrefslogtreecommitdiff
path: root/src/core/mount.c
Commit message (Collapse)AuthorAgeFilesLines
* basic: create new basic/initrd-util.[ch] for initrd-related functionsZbigniew Jędrzejewski-Szmek2022-11-081-0/+1
| | | | | | | | | I changed imports of util.h to initrd-util.h, or added an import of initrd-util.h, to keep compilation working. It turns out that many files didn't import util.h directly. When viewing the patch, don't be confused by git rename detection logic: a new .c file is added and two functions moved into it.
* basic/mountpoint-util: skip dependency on quota services for some filesystemsThomas Blume2022-10-141-3/+1
|
* mount: replace UNIT_DEPENDENCY_MOUNTINFO_OR_FILE with ↵Franck Bui2022-10-051-23/+23
| | | | | | | | | | | | | | | UNIT_DEPENDENCY_MOUNTINFO/UNIT_DEPENDENCY_MOUNT_FILE UNIT_DEPENDENCY_MOUNTINFO_OR_FILE was a bit strange as unlike the other flags we don't know where the dependency came from exactly. Indeed its origin could have been from the mount unit file or from /proc/self/mountinfo. Instead this patch replaces UNIT_DEPENDENCY_MOUNTINFO_OR_FILE with 2 new dependency flags: UNIT_DEPENDENCY_MOUNT_FILE and UNIT_DEPENDENCY_MOUNTINFO. The former indicates that the dep is created from the unit file but unlike UNIT_DEPENDENCY_FILE, it will be replaced by a dep with the UNIT_DEPENDENCY_MOUNTINFO flag as soon as the kernel will make the mount available in /proc/self/mountinfo.
* mount: drop UNIT_DEPENDENCY_MOUNTINFO_IMPLICIT and ↵Franck Bui2022-10-051-5/+4
| | | | | | UNIT_DEPENDENCY_MOUNTINFO_DEFAULT They're not used anymore.
* mount: always use UNIT_DEPENDENCY_FILE in mount_add_quota_dependencies()Franck Bui2022-10-051-5/+4
| | | | | | The quota options have always been read from the unit file and ignored if only present in /proc/self/mountinfo. IOW the quota services are not (automagically) pulled in for mounts initiated by the user running mount(8).
* tree-wide: use ASSERT_PTR moreDavid Tardon2022-09-131-5/+2
|
* core/mount: voidify unit_acquire_invocation_id()Yu Watanabe2022-08-251-1/+1
| | | | | | Follow-up for 01400460ae16c6522d11d08dd9a4b0928e7980d9. Fixes CID#1491960.
* tree-wide: port things dirname_malloc() → path_extract_directory()Lennart Poettering2022-08-231-3/+3
|
* Merge pull request #23893 from yuwata/core-mount-re-read-mountinfoLuca Boccassi2022-08-231-10/+45
|\ | | | | core/mount: adjust deserialized state based on if the corresponding mountinfo entry exists or not
| * core/mount: adjust deserialized state based on /proc/self/mountinfoYu Watanabe2022-07-201-10/+45
| | | | | | | | | | Fixes #23796. Replaces #23803 and #23851.
* | core/mount: make device deps from /proc/self/mountinfo and .mount unit file ↵Yu Watanabe2022-08-051-25/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | exclusive Before this commit, when a .mount unit file is loaded, the device dependencies from the unit file are automatically added. If a device that is different from which specified in .mount unit file is mounted on the path, then the device dependencies about the device are also added. Hence, the unit has device dependencies about two (or more) different devices. Hence, if one of the devices are unplugged, even if another one is mounted on the path, then the path is unmounted. This commit makes device dependencies from two different sources exclusive, and always regenerate the dependencies when one of the information is updated. Fixes #19983 and #23552.
* | core/mount: also remove default deps from /proc/self/mountinfo when it is ↵Yu Watanabe2022-08-051-2/+2
| | | | | | | | | | | | | | | | | | updated The dependencies tagged with UNIT_DEPENDENCY_MOUNTINFO_DEFAULT depend on both /proc/self/mountinfo and corresponding .mount unit file. Hence, if some information from mountinfo is updated, e.g. device mounted on the path, we need to update the dependencies.
* | core/mount: set Mount.from_proc_self_mountinfo flag before adding default ↵Yu Watanabe2022-08-051-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | dependencies When the function mount_setup_new_unit() is called, the corresponding .mount unit file is not loaded. Hence, Mount.from_fragment is false. To add default dependencies to e.g. .device units, it is necessary that the Mount.from_proc_self_mountinfo flag is set. However, the flag was not set even the unit has information from /proc/self/mountinfo. Partially fixes #19983.
* | core: unit_name_from_path() does not return -ENAMETOOLONG anymoreYu Watanabe2022-08-051-27/+4
| | | | | | | | | | Follow-ups for a7fb1f2eae3314c28d451822302283a7ab1bc1c0 and 1d0727e76fd5e9a07cc9991ec9a10ea1d78a99c7.
* | core/mount: use set_put_strdup_full()Yu Watanabe2022-08-051-11/+5
| |
* | core/mount: downgrade log level about several mkdir failuresYu Watanabe2022-07-271-2/+6
| |
* | Revert "core/mount: fail early if directory cannot be created"Yu Watanabe2022-07-271-3/+1
|/ | | | | | | | | This reverts commit e4de58c8231e47509ffeb3aa47620ca42f22d7f6. If mkdir() fails and the path does exist, then the later mount command fails anyway. Hence, it is not necessary to fail here. Fixes #24120.
* core: wrap some long commentsZbigniew Jędrzejewski-Szmek2022-06-071-7/+7
|
* Merge pull request #23558 from msekletar/issue-20329-followupYu Watanabe2022-05-311-3/+0
|\ | | | | Actually delay running of mount start jobs when /p/s/mountinfo is rate limited
| * unit: check for mount rate limiting before checking active stateMichal Sekletar2022-05-301-3/+0
| | | | | | | | | | | | | | | | | | | | | | Having this check as part of mount_can_start() is too late because UNIT(u)->can_start() virtual method is called after checking the active state of unit in unit_start(). We need to hold off running mount start jobs when /p/s/mountinfo monitor is rate limited even when given mount unit is already active. Fixes #20329
* | core: Add trace logging to mount_add_device_dependencies()Daan De Meyer2022-05-121-7/+31
|/ | | | | To help debug missing implicit device deps in https://github.com/systemd/systemd/issues/13775#issuecomment-1122969810.
* core/device: Use DEVICE_NOT_FOUND instead of 0.Daan De Meyer2022-05-071-1/+1
| | | | | Use the enum name instead of the value zero. This is a noop change as DEVICE_NOT_FOUND == 0.
* core: shorten long unit names that are based on paths and append path hash ↵Michal Sekletar2022-04-081-0/+3
| | | | | | at the end Fixes #18077
* list: declare iterator of LIST_FOREACH() in the loopYu Watanabe2022-03-191-1/+0
|
* core/mount: fail early if directory cannot be createdYu Watanabe2022-02-021-1/+3
| | | | Prompted by #22334.
* Merge pull request #20598 from tomty89/order_noautoZbigniew Jędrzejewski-Szmek2021-12-111-9/+1
|\ | | | | fstab-generator, core/mount: Avoid special fs target before dependency only if nofail is used
| * core/mount: also add default before dependency for automount mount unitsTom Yan2021-09-021-9/+1
| | | | | | | | | | The dependency should not prevent automount from working as expected, and we do not want them to be stopped too early if they are active.
* | tree-wide: check for NULLs in more placesFrantisek Sumsal2021-12-061-0/+6
| | | | | | | | | | Fixes issues pointed out by the `cpp/inconsistent-null-check` LGTM query.
* | unit: add jobs that were skipped because of ratelimit back to run_queueMichal Sekletar2021-11-301-0/+9
| | | | | | | | | | | | | | | | | | | | | | Assumption in edc027b was that job we first skipped because of active ratelimit is still in run_queue. Hence we trigger the queue and dispatch it in the next iteration. Actually we remove jobs from run_queue in job_run_and_invalidate() before we call unit_start(). Hence if we want to attempt to run the job again in the future we need to add it back to run_queue. Fixes #21458
* | shared: clean up mkdir.h/label.h situationLennart Poettering2021-11-161-1/+1
| | | | | | | | | | | | | | | | | | | | Previously the mkdir_label() family of calls was implemented in src/shared/mkdir-label.c but its functions partly declared ins src/shared/label.h and partly in src/basic/mkdir.h (!!). That's weird (and wrong). Let's clean this up, and add a proper mkdir-label.h matching the .c file.
* | pid1: add a manager_trigger_run_queue() helperLennart Poettering2021-11-121-6/+3
| | | | | | | | | | | | | | | | We have two different places where we re-trigger the run queue now. let's unify it under a common function, that is part of the Manager code. Follow-up for #20953
* | mount: retrigger run queue after ratelimit expired to run delayed mount ↵Michal Sekletar2021-11-111-0/+21
| | | | | | | | | | | | start jobs Fixes #20329
* | mount: make mount units start jobs not runnable if /p/s/mountinfo ratelimit ↵Michal Sekletar2021-11-111-0/+3
| | | | | | | | is in effect
* | core: rename/generalize UNIT(u)->test_start_limit() hookMichal Sekletar2021-11-111-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | Up until now the main reason why we didn't proceed with starting the unit was exceed start limit burst. However, for unit types like mounts the other reason could be effective ratelimit on /proc/self/mountinfo event source. That means our mount unit state may not reflect current kernel state. Hence, we need to attempt to re-run the start job again after ratelimit on event source expires. As we will be introducing another reason than start limit let's rename the virtual function that implements the check.
* | tree-wide: port various places to use TAKE_PID()Lennart Poettering2021-11-031-2/+1
| |
* | core/mount: add implicit unit dependencies even if when mount unit is ↵Yu Watanabe2021-09-291-0/+4
|/ | | | | | generated from /proc/self/mountinfo Hopefully fixes #20566.
* core: Check unit start rate limiting earlierDaan De Meyer2021-08-251-6/+17
| | | | | | | | | | | | | Fixes #17433. Currently, if any of the validations we do before we check start rate limiting fail, we can still enter a busy loop as no rate limiting gets applied. A common occurence of this scenario is path units triggering a service that fails a condition check. To fix the issue, we simply move up start rate limiting checks to be the first thing we do when starting a unit. To achieve this, we add a new method to the unit vtable and implement it for the relevant unit types so that we can do the start rate limit checks earlier on.
* Drop the text argument from assert_not_reached()Zbigniew Jędrzejewski-Szmek2021-08-031-4/+4
| | | | | | | | | | | | | | | | | In general we almost never hit those asserts in production code, so users see them very rarely, if ever. But either way, we just need something that users can pass to the developers. We have quite a few of those asserts, and some have fairly nice messages, but many are like "WTF?" or "???" or "unexpected something". The error that is printed includes the file location, and function name. In almost all functions there's at most one assert, so the function name alone is enough to identify the failure for a developer. So we don't get much extra from the message, and we might just as well drop them. Dropping them makes our code a tiny bit smaller, and most importantly, improves development experience by making it easy to insert such an assert in the code without thinking how to phrase the argument.
* core: align string tablesZbigniew Jędrzejewski-Szmek2021-07-191-8/+8
|
* tree-wide: add FORMAT_TIMESPAN()Zbigniew Jędrzejewski-Szmek2021-07-091-2/+1
|
* Merge pull request #20030 from keszybz/exec_fd-event-sourceZbigniew Jędrzejewski-Szmek2021-07-011-4/+4
|\ | | | | exec_fd event source rework
| * core: disable event sources before unreffing themZbigniew Jędrzejewski-Szmek2021-05-121-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This mirrors the change done for systemd-resolved in 97935302283729c9206b84f5e00b1aff0f78ad19. Quoting that patch: > We generally operate on the assumption that a source is "gone" as soon as we > unref it. This is generally true because we have the only reference. But if > something else holds the reference, our unref doesn't really stop the source > and it could fire again. In particular, we take temporary references from sd-event code, and when called from an sd-event callback, we could temporarily see this elevated reference count. This patch doesn't seem to change anything, but I think it's nicer to do the same change as in other places and not rely on _unref() immediately disabling the source.
* | tree-wide: add missing whitespace at the end of commentsYu Watanabe2021-06-151-1/+1
| |
* | core: do not serialize mounts and automounts for switch-rootZbigniew Jędrzejewski-Szmek2021-06-081-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When e.g. tmp.mount is present in the initrd, and we serialize it, switch root, and deserialize, the new systemd is confused because it thinks /tmp is mounted. In general, it doesn't make sense to serialize anything that refers to paths in the old root file system. This fixes two errors for me: 1. tmp.mount was not mounted properly before local-fs.target. It would be mounted as some point (I guess when we re-read /proc/self/mountinfo for some other reason). In effect systemd-tmpfiles-setup.service would see one fs, and some other units started later a different one. In particular gdm.service would fail because the pre-created /tmp/.X11-unix with proper permissions would not exist at time it was started. 2. # systemd[1]: proc-sys-fs-binfmt_misc.automount: Got hangup/error on autofs pipe from kernel. Likely our automount point has been unmounted by someone or something else? # systemd[1]: proc-sys-fs-binfmt_misc.automount: Failed with result 'unmounted'. # systemd[1]: Mounting proc-sys-fs-binfmt_misc.mount... # systemd[1]: Mounted proc-sys-fs-binfmt_misc.mount. # systemd[1]: Starting systemd-binfmt.service... # systemd[1]: Finished systemd-binfmt.service. # systemd[1]: proc-sys-fs-binfmt_misc.automount: Path /proc/sys/fs/binfmt_misc is already a mount point, refusing start. # systemd[1]: Failed to set up automount proc-sys-fs-binfmt_misc.automount. # systemd[1]: proc-sys-fs-binfmt_misc.automount: Path /proc/sys/fs/binfmt_misc is already a mount point, refusing start. # systemd[1]: Failed to set up automount proc-sys-fs-binfmt_misc.automount. # systemd[1]: proc-sys-fs-binfmt_misc.automount: Path /proc/sys/fs/binfmt_misc is already a mount point, refusing start. # systemd[1]: Failed to set up automount proc-sys-fs-binfmt_misc.automount. # systemd[1]: Stopping systemd-binfmt.service... # systemd[1]: systemd-binfmt.service: Deactivated successfully. # systemd[1]: Stopped systemd-binfmt.service. I couldn't understand the error here, but in retrospect the first line is entirely correct: "someone or something else" was the old systemd unmounting the old root.
* | mount: be more descriptive when logging about overly long mount point pathsLennart Poettering2021-06-011-1/+8
| | | | | | | | | | This is prompted by #17684: let's very explicitly say that the name is too long for us, and that we'll ignore it.
* | tree-wide: always drop unnecessary dot in pathYu Watanabe2021-05-281-1/+1
| |
* | core: use StopPropagatedFrom= as default for .mount → .device unit ↵Lennart Poettering2021-05-251-24/+47
|/ | | | | | | | | dependencies Let's make use of the new dependency type for .mount/.device units, after all we added it for this purpose. Fixes: #9869
* shared/fstab-util: teach fstab_filter_options() a mode where all values are ↵Zbigniew Jędrzejewski-Szmek2021-03-111-1/+1
| | | | | | | | | | returned Apart from tests, the new argument isn't used anywhere, so there should be no functional change. Note that the two arms of the big conditional are switched, so the diff is artificially inflated. The actual code change is rather small. I dropped the path which extracts ret_value manually, because it wasn't supporting unescaping of the escape character properly.
* tree-wide: propagate error in xxx_from-string()Yu Watanabe2021-02-121-8/+10
|
* Avoid error when bind mount source already existsStefan Agner2021-01-251-1/+3
|