summaryrefslogtreecommitdiffstats
path: root/src/fstab-generator (follow)
Commit message (Collapse)AuthorAgeFilesLines
* volatile-root: add overlay mode for host boots, tooLennart Poettering2019-03-011-2/+3
|
* Merge pull request #11226 from keszybz/enable-remount-fs-dynamicallyLennart Poettering2019-02-181-37/+15
|\ | | | | Enable systemd-remount-fs.service dynamically
| * Define macro for systemd-volatile-root.serviceZbigniew Jędrzejewski-Szmek2019-01-031-1/+1
| |
| * Pull in systemd-remount-fs.service only when requiredZbigniew Jędrzejewski-Szmek2019-01-031-0/+2
| | | | | | | | | | | | Instead of enabling it unconditionally and then using ConditionPathExists=/etc/fstab, and possibly masking this condition if it should be enabled for auto gpt stuff, just pull it in explicitly when required.
| * fstab-generator: simplify return code generationZbigniew Jędrzejewski-Szmek2019-01-031-20/+7
| | | | | | | | | | We just do a bunch of operations, and want to return the first failing error code. Let's do this in the most straightforward way.
| * fstab-generator: use generator_add_symlink() in one more placeZbigniew Jędrzejewski-Szmek2019-01-031-13/+4
| |
| * fstab-generator: move debug lines to a better placeZbigniew Jędrzejewski-Szmek2019-01-031-4/+2
| |
* | fstab-generator: also logs about x-systemd.growfs mount optionYu Watanabe2019-02-181-2/+2
| |
* | fstab-generator: fix debug logYu Watanabe2019-02-181-1/+1
|/
* fstab-generator: remove spurious newlineLennart Poettering2018-12-151-1/+0
|
* fstab-generator: fix check for /sysZbigniew Jędrzejewski-Szmek2018-12-121-1/+1
| | | | | | It would work when the generator was run by systemd, since generators are always started in "/", but when running the generator for debugging purposes the result would be ... different.
* generators: define custom main func definer and use it where applicableZbigniew Jędrzejewski-Szmek2018-12-121-14/+6
| | | | | | | | | | There should be no functional difference, except that the error message is changd from "three or no arguments" to "zero or three arguments". Somehow the inverted form always seemed strange. umask() call is also dropped from run-generator. I think it wasn't dropped in 053254e3cb215df3b8c905bc39b920f8817e1c7d because the run generator was merged around the same time.
* generators: configure logging before the first useZbigniew Jędrzejewski-Szmek2018-12-121-2/+2
|
* Split out part of mount-util.c into mountpoint-util.cZbigniew Jędrzejewski-Szmek2018-11-291-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The idea is that anything which is related to actually manipulating mounts is in mount-util.c, but functions for mountpoint introspection are moved to the new file. Anything which requires libmount must be in mount-util.c. This was supposed to be a preparation for further changes, with no functional difference, but it results in a significant change in linkage: $ ldd build/libnss_*.so.2 (before) build/libnss_myhostname.so.2: linux-vdso.so.1 (0x00007fff77bf5000) librt.so.1 => /lib64/librt.so.1 (0x00007f4bbb7b2000) libmount.so.1 => /lib64/libmount.so.1 (0x00007f4bbb755000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f4bbb734000) libc.so.6 => /lib64/libc.so.6 (0x00007f4bbb56e000) /lib64/ld-linux-x86-64.so.2 (0x00007f4bbb8c1000) libblkid.so.1 => /lib64/libblkid.so.1 (0x00007f4bbb51b000) libuuid.so.1 => /lib64/libuuid.so.1 (0x00007f4bbb512000) libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f4bbb4e3000) libpcre2-8.so.0 => /lib64/libpcre2-8.so.0 (0x00007f4bbb45e000) libdl.so.2 => /lib64/libdl.so.2 (0x00007f4bbb458000) build/libnss_mymachines.so.2: linux-vdso.so.1 (0x00007ffc19cc0000) librt.so.1 => /lib64/librt.so.1 (0x00007fdecb74b000) libcap.so.2 => /lib64/libcap.so.2 (0x00007fdecb744000) libmount.so.1 => /lib64/libmount.so.1 (0x00007fdecb6e7000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fdecb6c6000) libc.so.6 => /lib64/libc.so.6 (0x00007fdecb500000) /lib64/ld-linux-x86-64.so.2 (0x00007fdecb8a9000) libblkid.so.1 => /lib64/libblkid.so.1 (0x00007fdecb4ad000) libuuid.so.1 => /lib64/libuuid.so.1 (0x00007fdecb4a2000) libselinux.so.1 => /lib64/libselinux.so.1 (0x00007fdecb475000) libpcre2-8.so.0 => /lib64/libpcre2-8.so.0 (0x00007fdecb3f0000) libdl.so.2 => /lib64/libdl.so.2 (0x00007fdecb3ea000) build/libnss_resolve.so.2: linux-vdso.so.1 (0x00007ffe8ef8e000) librt.so.1 => /lib64/librt.so.1 (0x00007fcf314bd000) libcap.so.2 => /lib64/libcap.so.2 (0x00007fcf314b6000) libmount.so.1 => /lib64/libmount.so.1 (0x00007fcf31459000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fcf31438000) libc.so.6 => /lib64/libc.so.6 (0x00007fcf31272000) /lib64/ld-linux-x86-64.so.2 (0x00007fcf31615000) libblkid.so.1 => /lib64/libblkid.so.1 (0x00007fcf3121f000) libuuid.so.1 => /lib64/libuuid.so.1 (0x00007fcf31214000) libselinux.so.1 => /lib64/libselinux.so.1 (0x00007fcf311e7000) libpcre2-8.so.0 => /lib64/libpcre2-8.so.0 (0x00007fcf31162000) libdl.so.2 => /lib64/libdl.so.2 (0x00007fcf3115c000) build/libnss_systemd.so.2: linux-vdso.so.1 (0x00007ffda6d17000) librt.so.1 => /lib64/librt.so.1 (0x00007f610b83c000) libcap.so.2 => /lib64/libcap.so.2 (0x00007f610b835000) libmount.so.1 => /lib64/libmount.so.1 (0x00007f610b7d8000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f610b7b7000) libc.so.6 => /lib64/libc.so.6 (0x00007f610b5f1000) /lib64/ld-linux-x86-64.so.2 (0x00007f610b995000) libblkid.so.1 => /lib64/libblkid.so.1 (0x00007f610b59e000) libuuid.so.1 => /lib64/libuuid.so.1 (0x00007f610b593000) libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f610b566000) libpcre2-8.so.0 => /lib64/libpcre2-8.so.0 (0x00007f610b4e1000) libdl.so.2 => /lib64/libdl.so.2 (0x00007f610b4db000) (after) build/libnss_myhostname.so.2: linux-vdso.so.1 (0x00007fff0b5e2000) librt.so.1 => /lib64/librt.so.1 (0x00007fde0c328000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fde0c307000) libc.so.6 => /lib64/libc.so.6 (0x00007fde0c141000) /lib64/ld-linux-x86-64.so.2 (0x00007fde0c435000) build/libnss_mymachines.so.2: linux-vdso.so.1 (0x00007ffdc30a7000) librt.so.1 => /lib64/librt.so.1 (0x00007f06ecabb000) libcap.so.2 => /lib64/libcap.so.2 (0x00007f06ecab4000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f06eca93000) libc.so.6 => /lib64/libc.so.6 (0x00007f06ec8cd000) /lib64/ld-linux-x86-64.so.2 (0x00007f06ecc15000) build/libnss_resolve.so.2: linux-vdso.so.1 (0x00007ffe95747000) librt.so.1 => /lib64/librt.so.1 (0x00007fa56a80f000) libcap.so.2 => /lib64/libcap.so.2 (0x00007fa56a808000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fa56a7e7000) libc.so.6 => /lib64/libc.so.6 (0x00007fa56a621000) /lib64/ld-linux-x86-64.so.2 (0x00007fa56a964000) build/libnss_systemd.so.2: linux-vdso.so.1 (0x00007ffe67b51000) librt.so.1 => /lib64/librt.so.1 (0x00007ffb32113000) libcap.so.2 => /lib64/libcap.so.2 (0x00007ffb3210c000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007ffb320eb000) libc.so.6 => /lib64/libc.so.6 (0x00007ffb31f25000) /lib64/ld-linux-x86-64.so.2 (0x00007ffb3226a000) I don't quite understand what is going on here, but let's not be too picky.
* coccinelle: make use of SYNTHETIC_ERRNOZbigniew Jędrzejewski-Szmek2018-11-221-4/+3
| | | | | | | | | | | Ideally, coccinelle would strip unnecessary braces too. But I do not see any option in coccinelle for this, so instead, I edited the patch text using search&replace to remove the braces. Unfortunately this is not fully automatic, in particular it didn't deal well with if-else-if-else blocks and ifdefs, so there is an increased likelikehood be some bugs in such spots. I also removed part of the patch that coccinelle generated for udev, where we returns -1 for failure. This should be fixed independently.
* generators: drop umask callsZbigniew Jędrzejewski-Szmek2018-11-211-2/+0
| | | | | | | | | systemd already sets the umask (see e3b8d0637dd755b3426f3363b2cdad63f738116c). When running under systemd, we don't need to set it. And when *not* running under systemd, for example during development, there is no reason to override the user config. Let's just drop those calls. $ git grep -e 'umask\(' -l 'src/*generator*' |xargs perl -i -0pe 's|^[^\n]*umask\([^\n]+\n\n||gms'
* fstab-generator: use static destructor and DEFINE_MAIN_FUNCTION() macroYu Watanabe2018-11-201-13/+16
|
* generators: introduce a common implementation for the log setup boilerplateLennart Poettering2018-11-201-4/+1
|
* tree-wide: remove Lennart's copyright linesLennart Poettering2018-06-141-3/+0
| | | | | | | | | | | These lines are generally out-of-date, incomplete and unnecessary. With SPDX and git repository much more accurate and fine grained information about licensing and authorship is available, hence let's drop the per-file copyright notice. Of course, removing copyright lines of others is problematic, hence this commit only removes my own lines and leaves all others untouched. It might be nicer if sooner or later those could go away too, making git the only and accurate source of authorship information.
* tree-wide: drop 'This file is part of systemd' blurbLennart Poettering2018-06-141-2/+0
| | | | | | | | | | | | | | | | This part of the copyright blurb stems from the GPL use recommendations: https://www.gnu.org/licenses/gpl-howto.en.html The concept appears to originate in times where version control was per file, instead of per tree, and was a way to glue the files together. Ultimately, we nowadays don't live in that world anymore, and this information is entirely useless anyway, as people are very welcome to copy these files into any projects they like, and they shouldn't have to change bits that are part of our copyright header for that. hence, let's just get rid of this old cruft, and shorten our codebase a bit.
* path-util: introduce path_simplify()Yu Watanabe2018-06-031-1/+1
| | | | | | | | The function is similar to path_kill_slashes() but also removes initial './', trailing '/.', and '/./' in the path. When the second argument of path_simplify() is false, then it behaves as the same as path_kill_slashes(). Hence, this also replaces path_kill_slashes() with path_simplify().
* tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek2018-04-061-13/+0
| | | | | | | | | | Files which are installed as-is (any .service and other unit files, .conf files, .policy files, etc), are left as is. My assumption is that SPDX identifiers are not yet that well known, so it's better to retain the extended header to avoid any doubt. I also kept any copyright lines. We can probably remove them, but it'd nice to obtain explicit acks from all involved authors before doing that.
* When mangling names, optionally emit a warning (#8400)Zbigniew Jędrzejewski-Szmek2018-03-211-1/+1
| | | | | | | | | | | | | | | | | | The warning is not emitted for absolute paths like /dev/sda or /home, which are converted to .device and .mount unit names without any fuss. Most of the time it's unlikely that users use invalid unit names on purpose, so let's warn them. Warnings are silenced when --quiet is used. $ build/systemctl show -p Id hello@foo-bar/baz Invalid unit name "hello@foo-bar/baz" was escaped as "hello@foo-bar-baz" (maybe you should use systemd-escape?) Id=hello@foo-bar-baz.service $ build/systemd-run --user --slice foo-bar/baz --unit foo-bar/foo true Invalid unit name "foo-bar/foo" was escaped as "foo-bar-foo" (maybe you should use systemd-escape?) Invalid unit name "foo-bar/baz" was escaped as "foo-bar-baz" (maybe you should use systemd-escape?) Running as unit: foo-bar-foo.service Fixes #8302.
* fstab-generator: downgrade message when we can't canonicalize fstab entries ↵Lennart Poettering2018-02-271-12/+9
| | | | | | | | (#8281) Let's make this LOG_DEBUG, as this didn't used to be an issue, and shouldn't really be still. Replaces: #8132
* log: remove LOG_TARGET_SAFE pseudo log targetLennart Poettering2018-01-241-1/+2
| | | | | | | | | | | | | This removes LOG_TARGET_SAFE. It's made redundant by the new "prohibit-ipc" logging flag, as it used to have a similar effect: avoid logging to the journal/syslog, i.e. any local services in order to avoid deadlocks when we lock from PID 1 or its utility processes (such as generators). All previous users of LOG_TARGET_SAFE are switched over to the new setting. This makes things a bit safer for all, as not even the SYSTEMD_LOG_TARGET env var can be used to accidentally log to the journal anymore in these programs.
* generator: add helper function for writing unit filesZbigniew Jędrzejewski-Szmek2017-12-151-40/+14
| | | | | It doesn't save too much, but it's a common pattern so I think it's worth to factor this out.
* tree-wide: use __fsetlocking() instead of fxyz_unlocked()Lennart Poettering2017-12-141-5/+12
| | | | | | | | | | | | | | | | | | | | | | | | Let's replace usage of fputc_unlocked() and friends by __fsetlocking(f, FSETLOCKING_BYCALLER). This turns off locking for the entire FILE*, instead of doing individual per-call decision whether to use normal calls or _unlocked() calls. This has various benefits: 1. It's easier to read and easier not to forget 2. It's more comprehensive, as fprintf() and friends are covered too (as these functions have no _unlocked() counterpart) 3. Philosophically, it's a bit more correct, because it's more a property of the file handle really whether we ever pass it on to another thread, not of the operations we then apply to it. This patch reworks all pieces of codes that so far used fxyz_unlocked() calls to use __fsetlocking() instead. It also reworks all places that use open_memstream(), i.e. use stdio FILE* for string manipulations. Note that this in some way a revert of 4b61c8751135c58be043d86b9fef4c8ec7aadf18.
* fstab-generator: port some code to strextend_with_separator()Lennart Poettering2017-12-051-15/+2
|
* Add x-systemd.growfs option for fstabZbigniew Jędrzejewski-Szmek2017-11-301-5/+17
|
* Add x-systemd.makefs option for fstabZbigniew Jędrzejewski-Szmek2017-11-301-9/+23
| | | | | | | | | | I opted to completely generate a unit for both mount points and swaps. For swaps, it would be possible to use fixed template unit like systemd-mkswap@.service, because there's no information passed except the device name. For mount points, that's not possible because both the device name and file system type need to be passed. Nevertheless, I expect that options will need to passed to both mkfs and mkswap, in which case it'll be necessary to create units of both types anyway.
* fstab-generator: convert separate booleans to a flag fieldZbigniew Jędrzejewski-Szmek2017-11-301-32/+28
| | | | It's pretty unwieldy with just three flags, and I want to add more.
* generators: be more careful when writing unit settings that support ↵Lennart Poettering2017-11-291-10/+27
| | | | | | | | specifier expansion Let's always escape strings we receive from the user before writing them out to unit file settings that suppor specifier expansion, so that user strings are transported as-is.
* Add SPDX license identifiers to source files under the LGPLZbigniew Jędrzejewski-Szmek2017-11-191-0/+1
| | | | | This follows what the kernel is doing, c.f. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
* tree-wide: fput[cs]() → fput[cs]_unlocked() wherever that makes sense (#6396)Lennart Poettering2017-07-211-5/+5
| | | | | | | | As a follow-up for db3f45e2d2586d78f942a43e661415bc50716d11 let's do the same for all other cases where we create a FILE* with local scope and know that no other threads hence can have access to it. For most cases this shouldn't change much really, but this should speed dbus introspection and calender time formatting up a bit.
* Merge pull request #6266 from keszybz/drop-autotoolsLennart Poettering2017-07-201-1/+0
|\ | | | | Drop support for autotools / automake / make
| * build-sys: drop automake supportZbigniew Jędrzejewski-Szmek2017-07-181-1/+0
| | | | | | | | | | v2: - also mention m4
* | call chase_symlinks without the /sysroot prefix (#6411)Harald Hoyer2017-07-201-1/+1
|/ | | | | | | | | In case fstab-generator is called in the initrd, chase_symlinks() returns with a canonical path "/sysroot/sysroot/<mountpoint>", if the "/sysroot" prefix is present in the path. This patch skips the "/sysroot" prefix for the chase_symlinks() call, because "/sysroot" is already the root directory and chase_symlinks() prepends the root directory in the canonical path returned.
* Merge pull request #6324 from keszybz/generator-add-symlinkLennart Poettering2017-07-171-25/+14
|\ | | | | Add helper function for creation of unit symlinks in generators
| * fstab-generator: use generator_add_symlink()Zbigniew Jędrzejewski-Szmek2017-07-101-25/+14
| |
* | fstab-generator: Chase symlinks where possible (#6293)Colin Walters2017-07-111-8/+33
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | This has a long history; see see 5261ba901845c084de5a8fd06500ed09bfb0bd80 which originally introduced the behavior. Unfortunately that commit doesn't include any rationale, but IIRC the basic issue is that systemd wants to model the real mount state as units, and symlinks make canonicalization much more difficult. At the same time, on a RHEL6 system (upstart), one can make e.g. `/home` a symlink, and things work as well as they always did; but one doesn't have access to the sophistication of mount units (dependencies, introspection, etc.) Supporting symlinks here will hence make it easier for people to do upgrades to RHEL7 and beyond. The `/home` as symlink case also appears prominently for OSTree; see https://ostree.readthedocs.io/en/latest/manual/adapting-existing/ Further work has landed in the nspawn case for this; see e.g. d944dc9553009822deaddec76814f5642a6a8176 A basic limitation with doing this in the fstab generator (and that I hit while doing some testing) is that we obviously can't chase symlinks into mounts, since the generator runs early before mounts. Or at least - doing so would require multiple passes over the fstab data (as well as looking at existing mount units), and potentially doing multi-phase generation. I'm not sure it's worth doing that without a real world use case. For now, this will fix at least the OSTree + `/home` <https://bugzilla.redhat.com/show_bug.cgi?id=1382873> case mentioned above, and in general anyone who for whatever reason has symlinks in their `/etc/fstab`.
* fstab-generator: fix new NULL dereference. (#6296)NeilBrown2017-07-061-1/+1
| | | | fstype can be NULL, particularly when called from add_sysroot_mount(), so we need to use STRPTR_IN_SET().
* fstab-generator: handle NFS "bg" mounts correctly. (#6103)NeilBrown2017-07-041-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When "bg" is specified for NFS mounts, and if the server is not accessible, two behaviors are possible depending on networking details. If a definitive error is received, such a EHOSTUNREACH or ECONNREFUSED, mount.nfs will fork and continue in the background, while /bin/mount will report success. If no definitive error is reported but the connection times out instead, then the mount.nfs timeout will normally be longer than the systemd.mount timeout, so mount.nfs will be killed by systemd. In the first case the mount has appeared to succeed even though it hasn't. This can be confusing. Also the background mount.nfs will never get cleaned up, even if the mount unit is stopped. In the second case, mount.nfs is killed early and so the mount will not complete when the server comes back. Neither of these are ideal. This patch modifies the options when an NFS bg mount is detected to force an "fg" mount, but retain the default "retry" time of 10000 minutes that applies to "bg" mounts. It also imposes "nofail" behaviour and sets the TimeoutSec for the mount to "infinity" so the retry= time is allowed to complete. This provides near-identical behaviour to an NFS bg mount started directly by "mount -a". The only difference is that systemd will not wait for the first mount attempt, while "mount -a" will. Fixes #6046
* Parse "timeout=0" as infinity in various generators (#6264)Zbigniew Jędrzejewski-Szmek2017-07-031-2/+2
| | | | | | | | | | | | This extends 2d79a0bbb9f651656384a0a86ed814e6306fb5dd to the kernel command line parsing. The parsing is changed a bit to only understand "0" as infinity. If units are specified, parse normally, e.g. "0s" is just 0. This makes it possible to provide a zero timeout if necessary. Simple test is added. Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1462378.
* Merge pull request #5164 from Werkov/ordering-for-_netdev-devicesLennart Poettering2017-04-291-0/+4
|\ | | | | Ordering for _netdev devices
| * fstab-generator: Apply _netdev option also to device unitsMichal Koutný2017-04-251-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In case the device field of fstab record is an actual device (not an address) apply same dependencies to the device unit as to the mount unit, i.e. > After=network-online.target network.target > Wants=network-online.targe It makes sense to start the device expecting job only when network is actually ready (consider e.g. iSCSI devices) since it is device's implicit dependency. The eventual implementation should better obtain network flag from udev database and would also take into account device hierarchy (see [1]). This patch approximates that by taking the `_netdev` option as a hint from the user both about the filesystem and underlying device. (For local devices with network filesystems (e.g. ocfs2), this hint leads to unused dependencies.) [1] https://lists.freedesktop.org/archives/systemd-devel/2014-October/024718.html
* | fstab-generator: do not skip Before= ordering for noauto mountpoints (#5547)Ivan Shapovalov2017-04-241-1/+1
|/
* fstab-generator: quiesce false-positive -Werror=format-nonliteral (#5336)Martin Pitt2017-02-141-0/+3
| | | | | | | | | | | Commit ae3251851 changed the fprintf() format argument into a variable which triggers a gcc 6.3 warning/error: src/fstab-generator/fstab-generator.c:243:17: error: format not a string literal, argument types not checked [-Werror=format-nonliteral] fprintf(f, format, res); This is a false positive, as the function is only being called with constant (not user-definable) arguments which are valid format strings.
* fstab-generator: add x-systemd.before and x-systemd.after fstab options (#5330)Ruslan Bilovol2017-02-131-3/+30
| | | | | | | | | | | | | | | | | | | | | | Currently fstab entries with 'nofail' option are mounted asynchronously and there is no way how to specify dependencies between such fstab entry and another units. It means that users are forced to write additional dependency units manually. The patch introduces new systemd fstab options: x-systemd.before=<PATH> x-systemd.after=<PATH> - to specify another mount dependency (PATH is translated to unit name) x-systemd.before=<UNIT> x-systemd.after=<UNIT> - to specify arbitrary UNIT dependency For example mount where A should be mounted before local-fs.target unit: /dev/sdb1 /mnt/test/A none nofail,x-systemd.before=local-fs.target
* fstab-generator: also convert % → %% for What=Lennart Poettering2017-02-081-10/+24
| | | | Same reasons as the previous patch.
* fstab-generator: Options= applies specifier expansionLennart Poettering2017-02-081-4/+23
| | | | | | | Let's document that this is the case, and properly escape % when we generate Options= in the generator. Fixes: #5086