summaryrefslogtreecommitdiff
path: root/src/fstab-generator
Commit message (Collapse)AuthorAgeFilesLines
...
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-091-1/+1
|
* fstab-generator: add 'nofail' when NFS 'bg' option is usedFranck Bui2020-09-151-1/+1
| | | | | Otherwise a 'Before=remote-fs.target' dependency is added to the mount unit which defeats the purpose of 'bg' option.
* fstab-generator: introduce an helper to write extra dependencies specified ↵Franck Bui2020-07-011-14/+26
| | | | | | via the mount options No functional change.
* fstab-generator: extra dependencies specified in fstab should be applied to ↵Franck Bui2020-07-011-16/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | the mount unit If an entry in fstab uses "x-systemd.automount" option and also asks for additionnal dependencies via x-systemd.requires or such, then the dependencies were applied to the automount unit. But this unlikely to do the right thing and is inconsistent with what's done for network mounts. Indeed when an fstab entries has "_netdev,x-systemd.automount" options, the dependencies against the network requested by "_netdev" are (correctly) applied to the mount unit only and the automount unit remains ordered against local-fs.target. The same logic should be followed when extra deps are specified via the mount options as automount units should always be ordered against local-fs.target. Note: in general explicit deps specified via mount options should be used with care and should be used to specify dependencies on other mount units only as it can easily create ordering cycles otherwise like it's been seen in https://github.com/systemd/systemd-stable/issues/69. Mount units (as well as automount ones) are ordered before local-fs.target by default which is a low-level target that most other units depend on.
* tree-wide: use DISABLE_WARNING_FORMAT_NONLITERAL where appropriateLennart Poettering2020-05-251-3/+3
|
* Merge pull request #15661 from hundeboll/mount-read-write-onlyZbigniew Jędrzejewski-Szmek2020-05-201-2/+7
|\ | | | | Mount read write only
| * fstab-generator: add x-systemd.rw-only option supportMartin Hundebøll2020-05-201-2/+7
| | | | | | | | | | Support enabling the ReadwriteOnly= unit setting from fstab using 'x-systemd.rw-only'
* | Merge pull request #15265 from fbuihuu/mount-fixesLennart Poettering2020-05-151-11/+0
|\ \ | | | | | | Mount fixes
| * | automount: fix handling of default dependencies for automount unitsFranck Bui2020-04-091-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * | mount: let pid1 alone handle the default dependencies for mount unitsFranck Bui2020-04-091-9/+0
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | fstab-generator was also handling the default ordering dependencies for mount units setup in initrd. To do that it was turning the defaults dependencies off completely and ordered the mount unit against either local-fs.target or initrd-fs.target or initrd-root-fs.target itself. But it had the bad side effect to also remove all other default dependencies as well. Thus if an initrd mount was using _netdev, the network dependencies were missing. In general fstab-generator shouldn't use DefaultDependecies=no because it can handle only a small set of the default dependencies the rest are dealt by pid1. So this patch makes pid1 handle all default dependencies.
* | tree-wide: add size limits for tmpfs mountsTopi Miettinen2020-05-131-1/+1
|/ | | | | | | | | | | | | | | | | Limit size of various tmpfs mounts to 10% of RAM, except volatile root and /var to 25%. Another exception is made for /dev (also /devs for PrivateDevices) and /sys/fs/cgroup since no (or very few) regular files are expected to be used. In addition, since directories, symbolic links, device specials and xattrs are not counted towards the size= limit, number of inodes is also limited correspondingly: 4MB size translates to 1k of inodes (assuming 4k each), 10% of RAM (using 16GB of RAM as baseline) translates to 400k and 25% to 1M inodes. Because nr_inodes option can't use ratios like size option, there's an unfortunate side effect that with small memory systems the limit may be on the too large side. Also, on an extremely small device with only 256MB of RAM, 10% of RAM for /run may not be enough for re-exec of PID1 because 16MB of free space is required.
* fstab-generator: handle systemd.swap= command-line argumentnabijaczleweli2020-03-121-0/+14
| | | | | | | | | | | | Don't generate swap units if set to false The inverse of this argument is present as "noswap" on Debian sysvinit Ref: https://salsa.debian.org/debian/sysvinit/blob/4422988cb41c3022eee7444378cac3b2e36eac28/debian/vars.sh#L34 https://salsa.debian.org/debian/sysvinit/blob/4422988cb41c3022eee7444378cac3b2e36eac28/debian/src/initscripts/etc/init.d/mountall.sh#L78 Fixes https://github.com/systemd/systemd/issues/6686
* units: introduce blockdev@.target for properly ordering mounts/swaps against ↵Lennart Poettering2020-01-211-6/+20
| | | | | | | | | cryptsetup Let's hook it into both cryptsetup-generator and gpt-auto-generator with a shared implementation in generator.c Fixes: #8472
* fstab-generator: line break a bit more systematicallyLennart Poettering2020-01-211-5/+16
|
* Implemented x-systemd.{required,wanted}-by= optionsAntonio Russo2020-01-211-8/+37
| | | | | | | | | | | | Teaches systemd-fstab-generator these two unit options, creating appropriate dependencies on the generated .mount units. When used, they override any other automatically generated dependencies, such as local-fs.target, and are NOT suppressed by noauto. The new options are ignored for /, in the same way that noauto is ignored. Fixes: #14380 Signed-off-by: Antonio Russo <antonio.e.russo@gmail.com>
* Allow overriding /etc/fstab with $SYSTEMD_FSTABZbigniew Jędrzejewski-Szmek2019-11-131-13/+15
|
* tree-wide: drop mntent.h when fstab-util.h is includedYu Watanabe2019-11-041-1/+0
|
* tree-wide: drop string.h when string-util.h or friends are includedYu Watanabe2019-11-041-1/+0
|
* various tools: be more explicit when a glob is passed when not supportedZbigniew Jędrzejewski-Szmek2019-10-251-1/+1
| | | | | | | | | | | | See https://bugzilla.redhat.com/show_bug.cgi?id=1763488: when we say that 'foo@*.service' is not a valid unit name, this is not clear enough. Let's include the name of the operation that does not support globbing in the error message: $ build/systemctl enable 'foo@*.service' Glob pattern passed to enable, but globs are not supported for this. Invalid unit name "foo@*.service" escaped as "foo@\x2a.service". ...
* basic/fs-util: change CHASE_OPEN flag into a separate output parameterZbigniew Jędrzejewski-Szmek2019-10-241-1/+1
| | | | | | | | | | | | | chase_symlinks() would return negative on error, and either a non-negative status or a non-negative fd when CHASE_OPEN was given. This made the interface quite complicated, because dependning on the flags used, we would get two different "types" of return object. Coverity was always confused by this, and flagged every use of chase_symlinks() without CHASE_OPEN as a resource leak (because it would this that an fd is returned). This patch uses a saparate output parameter, so there is no confusion. (I think it is OK to have functions which return either an error or an fd. It's only returning *either* an fd or a non-fd that is confusing.)
* fstab-generator: Prevent double free of reused FILE*Wieland Hoffmann2019-05-031-1/+1
| | | | | | | | | | When the .automount unit file already existed for any reason in the `normal-dir` passed to `systemd-fstab-generator`, but the normal .mount unit file did not, `f` was closed (but _not_ set to NULL). The call to `generator_open_unit_file(..., automount_name, &f)` then failed because the .mount unit file already existed. Now `f` did not point to an open FILE and the later cleanup from the `_cleanup_fclose_` attribute failed with a double free. Reset `f` to NULL before reusing it.
* Make fopen_temporary and fopen_temporary_label unlockedZbigniew Jędrzejewski-Szmek2019-04-121-1/+0
| | | | | | | | This is partially a refactoring, but also makes many more places use unlocked operations implicitly, i.e. all users of fopen_temporary(). AFAICT, the uses are always for short-lived files which are not shared externally, and are just used within the same context. Locking is not necessary.
* fstab-generator: use DefaultDependencies=no for /sysroot mountsJonathan Lebon2019-04-111-0/+6
| | | | | | | | | Otherwise we can end up with an ordering cycle. Since d54bab90, all local mounts now gain a default `Before=local-fs.target` dependency. This doesn't make sense for `/sysroot` mounts in the initrd though, since those happen later in the boot process. Closes: #12231
* fstab-generator: do not print double headerZbigniew Jędrzejewski-Szmek2019-03-151-2/+1
| | | | | | | | | | $ /run/systemd/generator/dev-mapper-fedora_krowka\x2dswap.swap # Automatically generated by systemd-fstab-generator # Automatically generated by systemd-fstab-generator [Unit] ...
* 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.