summaryrefslogtreecommitdiff
path: root/src/fstab-generator
AgeCommit message (Collapse)Author
2017-02-13fstab-generator: quiesce false-positive -Werror=format-nonliteral (#5336)Martin Pitt
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.
2017-02-13fstab-generator: add x-systemd.before and x-systemd.after fstab options (#5330)Ruslan Bilovol
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
2017-02-08fstab-generator: also convert % → %% for What=Lennart Poettering
Same reasons as the previous patch.
2017-02-08fstab-generator: Options= applies specifier expansionLennart Poettering
Let's document that this is the case, and properly escape % when we generate Options= in the generator. Fixes: #5086
2016-12-21verity: add support for setting up verity-protected root disks in the initrdLennart Poettering
This adds a generator and a small service that will look for "roothash=" on the kernel command line and use it for setting up a very partition for the root device. This provides similar functionality to nspawn's existing --roothash= switch.
2016-12-21fstab-generator: add support for volatile bootsLennart Poettering
This adds support for a new kernel command line option "systemd.volatile=" that provides the same functionality that systemd-nspawn's --volatile= switch provides, but for host systems (i.e. systems booting with a kernel). It takes the same parameter and has the same effect. In order to implement systemd.volatile=yes a new service systemd-volatile-root.service is introduced that only runs in the initrd and rearranges the root directory as needed to become a tmpfs instance. Note that systemd.volatile=state is implemented different: it simply generates a var.mount unit file that is part of the normal boot and has no effect on the initrd execution. The way this is implemented ensures that other explicit configuration for /var can always override the effect of these options. Specifically, the var.mount unit is generated in the "late" generator directory, so that it only is in effect if nothing else overrides it.
2016-12-21util-lib: various improvements to kernel command line parsingLennart Poettering
This improves kernel command line parsing in a number of ways: a) An kernel option "foo_bar=xyz" is now considered equivalent to "foo-bar-xyz", i.e. when comparing kernel command line option names "-" and "_" are now considered equivalent (this only applies to the option names though, not the option values!). Most of our kernel options used "-" as word separator in kernel command line options so far, but some used "_". With this change, which was a source of confusion for users (well, at least of one user: myself, I just couldn't remember that it's systemd.debug-shell, not systemd.debug_shell). Considering both as equivalent is inspired how modern kernel module loading normalizes all kernel module names to use underscores now too. b) All options previously using a dash for separating words in kernel command line options now use an underscore instead, in all documentation and in code. Since a) has been implemented this should not create any compatibility problems, but normalizes our documentation and our code. c) All kernel command line options which take booleans (or are boolean-like) have been reworked so that "foobar" (without argument) is now equivalent to "foobar=1" (but not "foobar=0"), thus normalizing the handling of our boolean arguments. Specifically this means systemd.debug-shell and systemd_debug_shell=1 are now entirely equivalent. d) All kernel command line options which take an argument, and where no argument is specified will now result in a log message. e.g. passing just "systemd.unit" will no result in a complain that it needs an argument. This is implemented in the proc_cmdline_missing_value() function. e) There's now a call proc_cmdline_get_bool() similar to proc_cmdline_get_key() that parses booleans (following the logic explained in c). f) The proc_cmdline_parse() call's boolean argument has been replaced by a new flags argument that takes a common set of bits with proc_cmdline_get_key(). g) All kernel command line APIs now begin with the same "proc_cmdline_" prefix. h) There are now tests for much of this. Yay!
2016-11-11fstab-generator: add x-systemd.mount-timeout (#4603)Christian Hesse
This adds a new systemd fstab option x-systemd.mount-timeout. The option adds a timeout value that specifies how long systemd waits for the mount command to finish. It allows to mount huge btrfs volumes without issues. This is equivalent to adding option TimeoutSec= to [Mount] section in a mount unit file. fixes #4055
2016-10-23tree-wide: drop NULL sentinel from strjoinZbigniew Jędrzejewski-Szmek
This makes strjoin and strjoina more similar and avoids the useless final argument. spatch -I . -I ./src -I ./src/basic -I ./src/basic -I ./src/shared -I ./src/shared -I ./src/network -I ./src/locale -I ./src/login -I ./src/journal -I ./src/journal -I ./src/timedate -I ./src/timesync -I ./src/nspawn -I ./src/resolve -I ./src/resolve -I ./src/systemd -I ./src/core -I ./src/core -I ./src/libudev -I ./src/udev -I ./src/udev/net -I ./src/udev -I ./src/libsystemd/sd-bus -I ./src/libsystemd/sd-event -I ./src/libsystemd/sd-login -I ./src/libsystemd/sd-netlink -I ./src/libsystemd/sd-network -I ./src/libsystemd/sd-hwdb -I ./src/libsystemd/sd-device -I ./src/libsystemd/sd-id128 -I ./src/libsystemd-network --sp-file coccinelle/strjoin.cocci --in-place $(git ls-files src/*.c) git grep -e '\bstrjoin\b.*NULL' -l|xargs sed -i -r 's/strjoin\((.*), NULL\)/strjoin(\1)/' This might have missed a few cases (spatch has a really hard time dealing with _cleanup_ macros), but that's no big issue, they can always be fixed later.
2016-10-22tree-wide: make parse_proc_cmdline() strip "rd." prefix automaticallyZbigniew Jędrzejewski-Szmek
This stripping is contolled by a new boolean parameter. When the parameter is true, it means that the caller does not care about the distinction between initrd and real root, and wants to act on both rd-dot-prefixed and unprefixed parameters in the initramfs, and only on the unprefixed parameters in real root. If the parameter is false, behaviour is the same as before. Changes by caller: log.c (systemd.log_*): changed to accept rd-dot-prefix params pid1: no change, custom logic cryptsetup-generator: no change, still accepts rd-dot-prefix params debug-generator: no change, does not accept rd-dot-prefix params fsck: changed to accept rd-dot-prefix params fstab-generator: no change, custom logic gpt-auto-generator: no change, custom logic hibernate-resume-generator: no change, does not accept rd-dot-prefix params journald: changed to accept rd-dot-prefix params modules-load: no change, still accepts rd-dot-prefix params quote-check: no change, does not accept rd-dot-prefix params udevd: no change, still accepts rd-dot-prefix params I added support for "rd." params in the three cases where I think it's useful: logging, fsck options, journald forwarding options.
2016-10-22tree-wide: allow state to be passed through to parse_proc_cmdline_itemZbigniew Jędrzejewski-Szmek
No functional change.
2016-07-22Use "return log_error_errno" in more places"Zbigniew Jędrzejewski-Szmek
2016-06-24fstab-generator: minor simplificationLennart Poettering
2016-06-24fstab-generator: skip fsck for /usr on non-device file systemsLennart Poettering
We do the same already for the root device, hence follow the scheme for /usr too. (Also add some explanatory comments.)
2016-06-24fstab-generator: don't skip /usr handling if root handling didn't work correctlyLennart Poettering
Let's follow the same logic for all mounts here: log errors, and exit the process uncleanly ultimately, but do not skip further mounts if we encounter a problem with an earlier one. Fixes: #2344
2016-06-24fstab-generator: fix checking of fstab_node_to_udev_node() resultLennart Poettering
We have to check for OOM here, let's add that. There's really no point in checking for path_is_absolute() on the result however, as there's no particular reason why that should be refused. Also, we don't have similar checks for the other mount devices the generator deals with, hence don't bother with it here either. Let's remove that check. (And it shouldn't return made-up errors like "-1" in this case anyway.)
2016-06-24fstab-generator: document why we copy the root device into the usr device if ↵Lennart Poettering
unset Let's a comment about this, to avoid questions popping up like in #2344.
2016-06-24fstab-generator: let's use path_equal() for comparing pathsLennart Poettering
2016-06-23fstab-generator: ignore root=/dev/nfs (#3591)Harald Hoyer
root=/dev/nfs is a legacy option for the kernel to handle root on NFS. Documentation for this kernel command line option can be found in the kernel source tree: Documentation/filesystems/nfs/nfsroot.txt
2016-06-07fstab-generator: don't process root= if it happens to be "gpt-auto" (#3452)Lennart Poettering
As that's handled by "gpt-auto-generator". Fixes: #3404
2016-05-12Create initrd-root-device.target synchronization point (#3239)Daniel Drake
Add a synchronization point so that custom initramfs units can run after the root device becomes available, before it is fsck'd and mounted. This is useful for custom initramfs units that may modify the root disk partition table, where the root device is not known in advance (it's dynamically selected by the generators).
2016-05-02fstab-generator: add newline before we start a new unit file sectionLennart Poettering
We already did this for the [Mount] section, let's do the same for [Automount].
2016-03-04fstab-generator: fix automount option and don't start associated mount unit ↵Franck Bui
at boot Without this patch applied the mount unit with 'automount' option was still pulled by local-fs.target and thus was activated during the boot process which defeats the purpose of the 'automount' option: $ grep /mnt /etc/fstab /dev/vdb1 /mnt ext2 defaults,x-systemd.automount 0 0 $ reboot ... $ mount | grep mnt systemd-1 on /mnt type autofs (rw,relatime,fd=34,pgrp=1,timeout=0,minproto=5,maxproto=5,direct) /dev/vdb1 on /mnt type ext2 (rw,relatime) $ systemctl status mnt.mount | grep Active Active: active (mounted) since Thu 2016-03-03 21:36:22 CET; 42s ago With the patch applied: $ reboot ... $ mount | grep mnt systemd-1 on /mnt type autofs (rw,relatime,fd=22,pgrp=1,timeout=0,minproto=5,maxproto=5,direct) $ systemctl status mnt.mount | grep Active Active: inactive (dead) $ ls /mnt lost+found $ systemctl status mnt.mount | grep Active Active: active (mounted) since Thu 2016-03-03 21:47:32 CET; 4s ago
2016-02-10tree-wide: remove Emacs lines from all filesDaniel Mack
This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
2016-01-17fstab-generator: fix ordering of /sysroot/usr mountnmartensen
According to bootup(7) and the behavior when /usr is specified in /etc/fstab, the /sysroot/usr mount should be before initrd-fs.target, not before initrd-root-fs.target.
2016-01-15fstab-generator: remove bogus conditionnmartensen
The sysroot mount is already taken care of by the add_sysroot_mount function. With this condition left in, we can get something like this: initrd-root-fs.target.requires `-- usr.mount -> /run/systemd/generator/usr.mount in the main system (i.e., not in the initramfs). In the initramfs, the previous condition already kicks in.
2015-11-25fstab-gen: post can't be NULLFranck Bui
2015-10-27util-lib: split out allocation calls into alloc-util.[ch]Lennart Poettering
2015-10-27util-lib: move /proc/cmdline parsing code to proc-cmdline.[ch]Lennart Poettering
2015-10-27util-lib: split stat()/statfs()/stavfs() related calls into stat-util.[ch]Lennart Poettering
2015-10-27util-lib: move mount related utility calls to mount-util.[ch]Lennart Poettering
2015-10-27util-lib: move more file I/O related calls into fileio.[ch]Lennart Poettering
2015-10-27util-lib: split string parsing related calls from util.[ch] into parse-util.[ch]Lennart Poettering
2015-10-25util-lib: split out fd-related operations into fd-util.[ch]Lennart Poettering
There are more than enough to deserve their own .c file, hence move them over.
2015-10-24util-lib: split our string related calls from util.[ch] into its own file ↵Lennart Poettering
string-util.[ch] There are more than enough calls doing string manipulations to deserve its own files, hence do something about it. This patch also sorts the #include blocks of all files that needed to be updated, according to the sorting suggestions from CODING_STYLE. Since pretty much every file needs our string manipulation functions this effectively means that most files have sorted #include blocks now. Also touches a few unrelated include files.
2015-09-07basic: rework virtualization detection APILennart Poettering
Introduce a proper enum, and don't pass around string ids anymore. This simplifies things quite a bit, and makes virtualization detection more similar to architecture detection.
2015-05-25swap: use swapon -oKarel Zak
This patch simplify swapon usage in systemd. The command swapon(8) since util-linux v2.26 supports "-o <list>". The idea is exactly the same like for mount(8). The -o specifies options in fstab-compatible way. For systemd it means that it does not have to care about things like "discard" or another swapon specific options. swapon -o <options-from-fstab> For backward compatibility the code cares about "Priority:" swap unit field (for a case when Priority: is set, but pri= in the Options: is missing). References: http://lists.freedesktop.org/archives/systemd-devel/2014-October/023576.html
2015-05-18fstab-generator: add x-systemd.requires and x-systemd.requires-mounts-forKarel Zak
Currently we have no way how to specify dependencies between fstab entries (or another units) in the /etc/fstab. It means that users are forced to bypass fstab and write .mount units manually. The patch introduces new systemd fstab options: x-systemd.requires=<PATH> - to specify dependence an another mount (PATH is translated to unit name) x-systemd.requires=<UNIT> - to specify dependence on arbitrary UNIT x-systemd.requires-mounts-for=<PATH ...> - to specify dependence on another paths, implemented by RequiresMountsFor=. The option may be specified more than once. For example two bind mounts where B depends on A: /mnt/test/A /mnt/test/A none bind,defaults /mnt/test/A /mnt/test/B none bind,x-systemd.requires=/mnt/test/A More complex example with overlay FS where one mount point depends on "low" and "upper" directories: /dev/sdc1 /mnt/low ext4 defaults /dev/sdc2 /mnt/high ext4 defaults overlay /mnt/merged overlay lowerdir=/mnt/low,upperdir=/mnt/high/data,workdir=/mnt/high/work,x-systemd.requires-mounts-for=/mnt/low,x-systemd.requires-mounts-for=mnt/high https://bugzilla.redhat.com/show_bug.cgi?id=812826 https://bugzilla.redhat.com/show_bug.cgi?id=1164334
2015-05-16Use fflush_and_check() in more placesZbigniew Jędrzejewski-Szmek
2015-05-05core: rework unit name validation and manipulation logicLennart Poettering
A variety of changes: - Make sure all our calls distuingish OOM from other errors if OOM is not the only error possible. - Be much stricter when parsing escaped paths, do not accept trailing or leading escaped slashes. - Change unit validation to take a bit mask for allowing plain names, instance names or template names or an combination thereof. - Refuse manipulating invalid unit name
2015-05-04generators: rename add_{root,usr}_mount to add_{sysroot,sysroot_usr}_mountZbigniew Jędrzejewski-Szmek
This makes it obvious that those functions are only usable in the initramfs. Also, add a warning when noauto, nofail, or automount is used for the root fs, instead of silently ignoring. Using those options would be a sign of significant misconfiguration, and if we bother to check for them, than let's go all the way and complain. Other various small cleanups and reformattings elsewhere.
2015-05-02fstab-generator: fix memleakZbigniew Jędrzejewski-Szmek
filtered was used to store an allocated string twice. The first allocation was thus lost. The string is not needed for anything, so simply skip the allocation. Fixup for deb0a77cf0b409141c4.
2015-04-21automount: add expire supportMichael Olbrich
2015-04-08fstab-generator: don't continue on OOMLennart Poettering
2015-03-25fstab-generator: don't accept missing root=, but accept root=noneTobias Hunger
And other non-device entries (like fstab does). Mount whatever the user asked to be mounted on / on the kernel command line. Do less sanity check and do *not* bail out when the mount device looks strange or does not exist. This basically makes the changes for deviceless filesystems from yesterday unnecessary and is in line with what we do for filesystems set up in fstab. Remove some code that is now dead (reverting fb02a2775a65 and b0438462). [tomegun: - change patch title/description a bit. - don't touch the /usr logic, that would be a separate change and we don't currently have a convincing use-case for that. - don't bail out on /sys ro. This only makes sense in containers, where we would not be doing this anyway. If there is a use-case we could consider that as a separate patch.]
2015-03-24fstab-generator: Support root on tmpfs (or other deviceless FS)Tobias Hunger
This allows for stateless systems.
2015-03-21fstab-generator: ignore invalid swap priorityZbigniew Jędrzejewski-Szmek
A failed priority is not something worth stopping boot over. Most people have only one swap device, in which case priority is irrelevant, and even if there is more than one swap device, they are all usable, and ignoring the priority field should only result in some loss of performance. The kernel will report the priority as -1 if not set, so it's easy for people to make this mistake. https://bugzilla.redhat.com/show_bug.cgi?id=1204336
2015-02-23remove unused includesThomas Hindoe Paaboel Andersen
This patch removes includes that are not used. The removals were found with include-what-you-use which checks if any of the symbols from a header is in use.
2015-02-03util: rework strappenda(), and rename it strjoina()Lennart Poettering
After all it is now much more like strjoin() than strappend(). At the same time, add support for NULL sentinels, even if they are normally not necessary.
2015-01-11Support negated fstab optionsZbigniew Jędrzejewski-Szmek
We would ignore options like "fail" and "auto", and for any option which takes a value the first assignment would win. Repeated and options equivalent to the default are rarely used, but they have been documented forever, and people might use them. Especially on the kernel command line it is easier to append a repeated or negated option at the end.