summaryrefslogtreecommitdiff
path: root/src/core/automount.c
Commit message (Collapse)AuthorAgeFilesLines
* tree-wide: use parse_fd()David Tardon2023-05-051-1/+1
|
* tree-wide: introduce PIPE_EBADF macroYu Watanabe2022-12-201-1/+1
|
* tree-wide: use -EBADF also in pipe initializersZbigniew Jędrzejewski-Szmek2022-12-191-8/+8
| | | | In some places, initialization is dropped when unnecesary.
* tree-wide: use -EBADF for fd initializationZbigniew Jędrzejewski-Szmek2022-12-191-5/+5
| | | | | | | | | | | | | | | | -1 was used everywhere, but -EBADF or -EBADFD started being used in various places. Let's make things consistent in the new style. Note that there are two candidates: EBADF 9 Bad file descriptor EBADFD 77 File descriptor in bad state Since we're initializating the fd, we're just assigning a value that means "no fd yet", so it's just a bad file descriptor, and the first errno fits better. If instead we had a valid file descriptor that became invalid because of some operation or state change, the other errno would fit better. In some places, initialization is dropped if unnecessary.
* core: adjust log messageZbigniew Jędrzejewski-Szmek2022-10-111-1/+1
| | | | | "umount startup job" is rather confusing. Let's say "unmount job", which should be more meaningful for a user.
* tree-wide: Use correct format specifiersJan Janssen2022-08-301-2/+2
| | | | gcc will complain about all these with -Wformat-signedness.
* tree-wide: port things dirname_malloc() → path_extract_directory()Lennart Poettering2022-08-231-3/+4
|
* Revert "core: Propagate condition failed state to triggering units."Daan De Meyer2021-12-171-11/+5
| | | | This reverts commit 12ab94a1e4961a39c32efb60b71866ab588d3ea2.
* tree-wide: check for NULLs in more placesFrantisek Sumsal2021-12-061-0/+1
| | | | | Fixes issues pointed out by the `cpp/inconsistent-null-check` LGTM query.
* core/automount: Add ExtraOptions fieldAndrew Stone2021-11-231-3/+33
|
* 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.
* tree-wide: use new RET_NERRNO() helper at various placesLennart Poettering2021-11-161-8/+2
|
* 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.
* core: Propagate condition failed state to triggering units.Daan De Meyer2021-11-031-5/+11
| | | | | | | | Alternative to https://github.com/systemd/systemd/pull/20531. Whenever a service triggered by another unit fails condition checks, stop the triggering unit to prevent systemd busy looping trying to start the triggered unit.
* tree-wide: port all calls to alloca() to alloca_safe()Lennart Poettering2021-10-141-1/+1
|
* 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.
* core: align string tablesZbigniew Jędrzejewski-Szmek2021-07-191-4/+4
|
* 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-2/+2
|\ | | | | exec_fd event source rework
| * core: disable event sources before unreffing themZbigniew Jędrzejewski-Szmek2021-05-121-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | 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.
* | tree-wide: always drop unnecessary dot in pathYu Watanabe2021-05-281-1/+1
|/
* core/automount: drop unecessary castZbigniew Jędrzejewski-Szmek2021-05-041-1/+1
|
* tree-wide: return NULL from freeing functionsZbigniew Jędrzejewski-Szmek2021-02-161-3/+3
| | | | | | I started working on this because I wanted to change how DEFINE_TRIVIAL_CLEANUP_FUNC is defined. Even independently of that change, it's nice to make make things more consistent and predictable.
* core: use SYNTHETIC_ERRNO() macroYu Watanabe2020-11-271-12/+6
|
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-091-1/+1
|
* automount: make user unmounting for automount units more debuggableLennart Poettering2020-10-301-0/+7
| | | | | | | Let's add an explicit log message plus an error state for automount units, if users explicitly unmounted our autofs mount. Prompted by: #17448
* tree-wide: cast result of get_process_comm() to (void) where we ignore itLennart Poettering2020-10-271-1/+1
|
* tree-wide: drop if braces around single line expressions as wellFrantisek Sumsal2020-10-091-3/+1
|
* mount-util: rework umount_verbose() to take log level and flags argLennart Poettering2020-09-231-2/+2
| | | | | | Let's make umount_verbose() more like mount_verbose_xyz(), i.e. take log level and flags param. In particular the latter matters, since we typically don't actually want to follow symlinks when unmounting.
* mount-util: switch most mount_verbose() code over to not follow symlinksLennart Poettering2020-09-231-3/+2
|
* core: propagate triggered unit in more load statesLennart Poettering2020-09-141-2/+2
| | | | | | | | | | | | | | | In 4c2ef3276735ad9f7fccf33f5bdcbe7d8751e7ec we enabled propagating triggered unit state to the triggering unit for service units in more load states, so that we don't accidentally stop tracking state correctly. Do the same for our other triggering unit states: automounts, paths, and timers. Also, make this an assertion rather than a simple test. After all it should never happen that we get called for half-loaded units or units of the wrong type. The load routines should already have made this impossible.
* tree-wide: define iterator inside of the macroZbigniew Jędrzejewski-Szmek2020-09-081-3/+2
|
* tree-wide: make use of new relative time events in sd-event.hLennart Poettering2020-07-281-4/+4
|
* core: set private section name for automount unitsDan Callaghan2020-07-041-0/+1
| | | | | | | Because this was left unset, the unit_write_setting() function was refusing to write out the automount-specific TimeoutIdleSec= and DirectoryMode= settings when creating transient automount units. Set it to the proper value in line with other unit types.
* tree-wide: use set_ensure_put()Zbigniew Jędrzejewski-Szmek2020-06-221-28/+4
| | | | | | | | | Patch contains a coccinelle script, but it only works in some cases. Many parts were converted by hand. Note: I did not fix errors in return value handing. This will be done separate to keep the patch comprehensible. No functional change is intended in this patch.
* Merge pull request #15265 from fbuihuu/mount-fixesLennart Poettering2020-05-151-0/+4
|\ | | | | Mount fixes
| * automount: fix handling of default dependencies for automount unitsFranck Bui2020-04-091-0/+4
| | | | | | | | | | | | | | | | | | | | | | First After=local-fs-pre.target wasn't described in the man page although it's part of the default dependencies automatically set by pid1. Secondly, Before=local-fs.target was only set if the automount unit was generated from the fstab-generator because the dep was explicitly generated. It was also not documented as a default dependency. Fix it by managing the dep from pid1 instead.
* | pid1: convert to the new schemeZbigniew Jędrzejewski-Szmek2020-05-051-1/+0
|/ | | | | | | | In all the other cases, I think the code was clearer with the static table. Here, not so much. And because of the existing dump code, the vtables cannot be made static and need to remain exported. I still think it's worth to do the change to have the cmdline introspection, but I'm disappointed with how this came out.
* core: clearly refuse OnFailure= deps on units that can't failLennart Poettering2020-01-091-2/+4
| | | | | | | | | Similar, refuse triggering deps on units that cannot trigger. And rework how we ignore After= dependencies on device units, to work the same way. See: #14142
* pid1: order .automount units after local-fs-pre.targetZbigniew Jędrzejewski-Szmek2019-10-281-0/+4
| | | | | | | | | | | | | | | From the bug: > According to the documentation of systemd.automount if the automoint point is > automagically created if it doesn't exist yet. This ofcourse means the > filesystem underneath has to be writable, which for / means not only does > -.mount need to be started but also systemd-remount-fs.service has to be run, > which isn't guaranteed by the default automount dependencies. > > For .mount units there is an automatic default After= dependency on > local-fs-pre.target, would probably make sense to do the same for automount > units to avoid it failing on the corner-case where it has to create directory. Fixes #13306.
* core: adjust load functions for other unit types to be more like serviceZbigniew Jędrzejewski-Szmek2019-10-111-19/+24
| | | | | | | No functional change, just adjusting code to follow the same pattern everywhere. In particular, never call _verify() on an already loaded unit, but return early from the caller instead. This makes the code a bit easier to follow.
* core: turn unit_load_fragment_and_dropin_optional() into a flagZbigniew Jędrzejewski-Szmek2019-10-111-1/+1
| | | | | | | | | | unit_load_fragment_and_dropin() and unit_load_fragment_and_dropin_optional() are really the same, with one minor difference in behaviour. Let's drop the second function. "_optional" in the name suggests that it's the "dropin" part that is optional. (Which it is, but in this case, we mean the fragment to be optional.) I think the new version with a flag is easier to understand.
* src/core/automount: use DirectoryMode when calling mkdir -pDan Streetman2019-10-021-1/+1
| | | | | | | | | | | | | mkdir -p is called both when setting up the autofs mount, as well as after being notified that the real mount unit should be called. However the first mkdir -p is hardcoded with 0555, while the second uses the value specified to DirectoryMode in the automount unit; the second mkdir -p is only needed when called from coldplug, so under normal operation the dirs are incorrectly created with mode 0555. This replaces the hardcoded 0555 mode with the value of DirectoryMode. Closes #13683.
* Merge pull request #12115 from poettering/verbose-job-enqueueZbigniew Jędrzejewski-Szmek2019-03-281-2/+2
|\ | | | | add "systemctl --show-transaction start" as a more verbose "systemctl start" that shows enqueued jobs
| * core: add new API for enqueing a job with returning the transaction dataLennart Poettering2019-03-271-2/+2
| |
* | Voidify more mkdir_p callsZbigniew Jędrzejewski-Szmek2019-03-271-1/+1
|/
* core: unify code for checking whether unit to trigger is loadedLennart Poettering2019-03-181-6/+3
|
* core: rename unit_{start_limit|condition|assert}_test() to unit_test_xyz()Lennart Poettering2019-03-181-1/+1
| | | | | | | Just some renaming, no change in behaviour. Background: I'd like to add more functions unit_test_xyz() that test various things, hence let's streamline the naming a bit.
* automount: don't pass non-blocking pipe to kernel.NeilBrown2019-02-081-1/+4
| | | | | | | | | | | | | Creating a pipe with O_NONBLOCK causes both the read and the write end to be marked as non-blocking. The "write" end is passed to the kernel autofs module, and it does not expect a non-blocking pipe. If it gets -EAGAIN when trying to write (which is unlikely, but not completely impossible), it will close the write end of the pipe, which leads to unexpected errors. So change the code to only set O_NONBLOCK on the "read" end of the pipe. This is the only end that systemd interacts with, so the only end it should be configuring.