Commit Graph

89 Commits

Author SHA1 Message Date
Lennart Poettering 00b4ffdecb fstab-generator: use more appropriate checks for swap and device availability
We always should use the same checks when deciding whether swap support
and mounting of devices is supported. Hence, let's make
fstab-generator's logic more similar to the usual logic we follow:

a) Look for /proc/swaps and no container support before activating
swaps.

b) Look for /sys being writable befire supporting device mounts.
2015-01-05 12:35:08 +01:00
Michael Marineau eb5800026d fstab-generator: Allow mount.usr without mount.usrflags, honor rw/ro
There is no need to require mount.usrflags. The original implementation
assumed that a btrfs subvolume would always be needed but that is not
applicable to systems that do not use btrfs for /usr.

Similar to using rootflags= for the default of mount.usrflags=, append
the classic 'ro' and 'rw' flags to the mount options.
2014-12-09 02:24:26 +01:00
Lennart Poettering 59cfa62f20 fstab-generator: free all allocated strings 2014-12-09 02:22:44 +01:00
Michal Schmidt 4a62c710b6 treewide: another round of simplifications
Using the same scripts as in f647962d64 "treewide: yet more log_*_errno
+ return simplifications".
2014-11-28 19:57:32 +01:00
Michal Schmidt 56f64d9576 treewide: use log_*_errno whenever %m is in the format string
If the format string contains %m, clearly errno must have a meaningful
value, so we might as well use log_*_errno to have ERRNO= logged.

Using:
find . -name '*.[ch]' | xargs sed -r -i -e \
's/log_(debug|info|notice|warning|error|emergency)\((".*%m.*")/log_\1_errno(errno, \2/'

Plus some whitespace, linewrap, and indent adjustments.
2014-11-28 19:49:27 +01:00
Michal Schmidt 23bbb0de4e treewide: more log_*_errno + return simplifications 2014-11-28 18:24:30 +01:00
Michal Schmidt da927ba997 treewide: no need to negate errno for log_*_errno()
It corrrectly handles both positive and negative errno values.
2014-11-28 13:29:21 +01:00
Michal Schmidt 0a1beeb642 treewide: auto-convert the simple cases to log_*_errno()
As a followup to 086891e5c1 "log: add an "error" parameter to all
low-level logging calls and intrdouce log_error_errno() as log calls
that take error numbers", use sed to convert the simple cases to use
the new macros:

find . -name '*.[ch]' | xargs sed -r -i -e \
's/log_(debug|info|notice|warning|error|emergency)\("(.*)%s"(.*), strerror\(-([a-zA-Z_]+)\)\);/log_\1_errno(-\4, "\2%m"\3);/'

Multi-line log_*() invocations are not covered.
And we also should add log_unit_*_errno().
2014-11-28 12:04:41 +01:00
Zbigniew Jędrzejewski-Szmek 5607d856b8 swap: restore support for nofail
systemd stops adding automatic dependencies on swap.target to swap
units. If a dependency is required, it has to be added by unit
configuration. fstab-generator did that already, except that now it is
modified to create a Requires or Wants type dependency, depending on
whether nofail is specified in /etc/fstab. This makes .swap units
obey the nofail/noauto options more or less the same as .mount units.

Documentation is extended to clarify that, and to make
systemd.mount(5) and system.swap(5) more similar. The gist is not
changed, because current behaviour actually matches existing
documentation.

https://bugs.freedesktop.org/show_bug.cgi?id=86488
2014-11-26 15:17:07 -05:00
Lennart Poettering b5884878a2 util: simplify proc_cmdline() to reuse get_process_cmdline()
Also, make all parsing of the kernel cmdline non-fatal.
2014-11-07 01:19:56 +01:00
Harald Hoyer 3f85ef0f05 s/commandline/command line/g 2014-11-06 15:34:18 +01:00
Lennart Poettering 47cb901e38 swap: replace Discard= setting by a more generic Options= setting
For now, it's systemd itself that parses the options string, but as soon
as util-linux' swapon can take the option string directly with -o we
should pass it on unmodified.
2014-10-28 14:31:25 +01:00
Tobias Hunger 9f103625b1 fstab-generator: Honor mount.usr*= on kernel command line
This allows to configure boot loader entries for systems where the
root and usr filesystems are in different subvolumes (or even on
different drives).
2014-10-10 12:57:19 +02:00
Tobias Hunger f88dc3edeb fstab-generator: Small cleanup 2014-10-03 20:42:09 -04:00
Zbigniew Jędrzejewski-Szmek 4f52d3fe2d fstab-generator: properly deal with discard as non-last option
Previous code would only return correct results when discard
was the last option.

While at it, avoid incorrect behaviour for (invalid) 'pri' option
not followed by '=...', and also do not return -1 as the error code.
2014-09-29 11:08:12 -04:00
Jan Synacek 86b23b07c9 swap: introduce Discard property
Process possible "discard" values from /etc/fstab.
2014-09-29 11:08:12 -04:00
Dave Reisner 8085f163c5 util: allow strappenda to take any number of args
This makes strappenda3 redundant, so we remove its usage and
definition. Add a few tests along the way for sanity.
2014-08-13 20:41:41 -04:00
Zbigniew Jędrzejewski-Szmek 126cc76074 fstab-generator: fix trivial leak 2014-07-07 18:36:55 -04:00
Zbigniew Jędrzejewski-Szmek b3208b6629 fstab-generator: allow x-systemd.device-timeout for swap units 2014-06-30 18:39:45 -04:00
Zbigniew Jędrzejewski-Szmek 2968644080 Move x-systemd-device.timeout handling from core to fstab-generator
Instead of adjusting job timeouts in the core, let fstab-generator
write out a dropin snippet with the appropriate JobTimeout.
x-systemd-device.timeout option is removed from Options= line
in the generated unit.

The functions to write dropins are moved from core/unit.c to
shared/dropin.c, to make them available outside of core.

generator.c is moved to libsystemd-label, because it now uses
functions defined in dropin.c, which are in libsystemd-label.
2014-06-30 18:39:45 -04:00
Zbigniew Jędrzejewski-Szmek 75a59316ea fstab-generator: simplify add_root_mount 2014-06-23 23:14:54 -04:00
Lennart Poettering 8501384436 stop complaining about unknown kernel cmdline options
Also stop warning about unknown kernel cmdline options in the various
tools, not just in PID 1
2014-06-19 16:55:20 +02:00
Lennart Poettering 689aede8c6 fstab-generator: when running in a container, ignore fstab entries referring to device nodes
Since these device nodes will never appear in the container anyway
there's no point in waiting for them.

This makes it easier to boot images generated with general purpose
installers like Anaconda which unconditionally populate /etc/fstab to
boot in containers.
2014-03-11 18:02:27 +01:00
Lennart Poettering 5ecdcf41cb fstab-generator: the root partition is not optional 2014-03-07 02:40:24 +01:00
Lennart Poettering 6db615c17e fstab-generator: merge /proc/cmdline parsing loops into one 2014-03-07 02:40:24 +01:00
Lennart Poettering c3834f9b88 generators: add Documentation= fields that point to the generator man pages 2014-03-06 18:48:22 +01:00
Lennart Poettering 059cb3858a util: move more intellegince into parse_proc_cmdline()
Already split variable assignments before invoking the callback. And
drop "rd." settings if we are not in an initrd.
2014-03-06 18:48:22 +01:00
Lennart Poettering e48fdd8443 generators: rework mount generators
- Add support for finding and mounting /srv based on GPT data, similar
  to how we already handly /home.

- Share the fsck logic between GPT, EFI and fstab generators

- Make sure we never run the EFI generator inside containers

- Drop DefaultDependencies=no from EFI mount units

- Other fixes
2014-03-06 04:00:41 +01:00
Zbigniew Jędrzejewski-Szmek 141a79f491 Extract looping over /proc/cmdline into a shared function
In cryptsetup-generator automatic cleanup had to be replaced
with manual cleanup, and the code gets a bit longer. But existing
code had the issue that it returned negative values from main(),
which was wrong, so should be reworked anyway.
2014-02-17 02:26:22 -05:00
Colin Guthrie 63a1b905d8 fstab-generator: Create fsck-root symlink with correct path
This was noticed in Brussels at the hackfest. The fstab-generator currently
creates a broken symlink pointing to itself in
/run/systemd/generator/local-fs.target.wants/ for systemd-fsck-root.service
2014-02-10 11:59:07 +01:00
Thomas Bächler e2f123b97b fstab-generator: Do not try to fsck non-devices
This fixes a regression introduced in 64e70e4 where the mount fails
when fstab is misconfigured with fs_passno > 0 on a virtual file
system like nfs, and the type is specified as "auto".
2013-12-21 22:52:56 -05:00
Zbigniew Jędrzejewski-Szmek 4e8da52959 fstab-generator: use RequiresOverridable for fsck units
This allows the user to disable fsck's by masking.

If fsck fails, emergency target is started, the user might mount the
unit using mount and disable fsck by masking the unit. In this case,
.mount will be active because the mount is detect through
/proc/self/mountinfo, but systemd-fsck@.service will still be in
failed mode. This results in a funny situation where

$ systemctl show -p ActiveState local-fs.target yyy.mount
ActiveState=active
ActiveState=active

$ sudo systemctl start local-fs.target
[sudo] password for test:
Failed to start local-fs.target: Unit systemd-fsck@xxx.service is masked.
2013-11-15 22:53:14 -05:00
Zbigniew Jędrzejewski-Szmek 94192cdaf6 fsck,fstab-generator: be lenient about missing fsck.<type>
If fstab contains 1 for passno, treat this as an error, but only warn
briefly. If fstab doesn't contain this information, don't complain at
all.

Patch is complicated a bit by the fact that we might have the fstype specified
in fstab or on /proc/cmdline, in which case we can check if we have the appropriate
fsck tool, or not specified, or specified as auto, in which case we have to look
and check the type of the filesystem ourselves. It cannot be done before the
device appears, so it is too early in the generator phase, and it must be done
directly in fsck service.
2013-11-15 22:53:14 -05:00
Lennart Poettering 74df0fca09 util: unify reading of /proc/cmdline
Instead of individually checking for containers in each user do this
once in a new call proc_cmdline() that read the file only if we are not
in a container.
2013-11-06 03:15:16 +01:00
Tom Gundersen a7623afb7a fsck-root: only run when requested in fstab
fsck-root is redundant in case an initrd is used, or in case the rootfs
is never remounted 'rw', so the new default is the correct behavior for
most users. For the rest, they should enable it in fstab.
2013-10-19 12:23:17 +02:00
Thomas Bächler 64e70e4b86 fstab-generator: Generate explicit dependencies on systemd-fsck@.service instead of using FsckPassNo
[tomegun:
  * order all fsck instances after fsck-root
  * check for OOM
  * added notes in the manpages]
2013-10-19 12:23:17 +02:00
Thomas Bächler 7f5806d709 fstab-generator: When parsing the root= cmdline option, set FsckPassNo to 1
[tomegun: without this we would never fsck the rootfs if it was directly
mounted 'rw' from the initrd. We now risk fsck'ing it twice in the case it
is mounted 'ro', so that should be addressed in a separate patch.]
2013-10-19 12:23:17 +02:00
Zbigniew Jędrzejewski-Szmek 5862d652ba Introduce _cleanup_endmntent_ 2013-10-03 22:13:55 -04:00
Zbigniew Jędrzejewski-Szmek 1dc2ced464 Remove six unused variables and add annotation
clang FTW!
2013-09-17 19:08:51 -04:00
Tom Gundersen 4e82fe5213 swap: create .wants symlink to 'auto' swap devices
As we load unit files lazily, we need to make sure something pulls in swap
units that should be started automatically, otherwise the default dependencies
will never be applied.

This partially reinstates code removed in
commit 64347fc2b9.

Also don't order swap devices after swap.target when they are 'nofail'.
2013-09-16 01:11:52 +02:00
Tom Gundersen 64347fc2b9 swap: handle nofail/noauto in core 2013-09-11 14:43:24 +02:00
Tom Gundersen 5073f89f10 mount: move device links handling from generator
This makes mount units work like swap units: when the backing device appears
the mount unit will be started.

v2: the device should want the mount unconditionally, not only for DefaultDependencies=yes
2013-09-11 14:40:59 +02:00
Tom Gundersen 80c3b720bf fstab-generator: use DefaultDependencies=yes
This removes some redundancy between the generator and the core mount handling.
2013-09-11 14:40:59 +02:00
WANG Chao 01264ad1cc fstab-generator: log_oom() if automount_name is null 2013-08-14 22:38:09 -04:00
WANG Chao ef53700c20 fstab-generator: read rd.fstab=on/off switch correctly 2013-08-09 18:09:44 +02:00
WANG Chao 21d1a67863 fstab-generator: respect noauto/nofail when adding sysroot mount
Currently we don't respect noauto/nofail root mount options (from
rootflags kernel cmdline). We should map these two flags to the
corresponding boolean variable noauto and nofail when calling
add_mount().
2013-08-09 02:04:51 +02:00
Harald Hoyer 7fd1b19bc9 move _cleanup_ attribute in front of the type
http://lists.freedesktop.org/archives/systemd-devel/2013-April/010510.html
2013-04-18 09:11:22 +02:00
Zbigniew Jędrzejewski-Szmek 8333c77edf Always use errno > 0 to help gcc
gcc thinks that errno might be negative, and functions could return
something positive on error (-errno). Should not matter in practice,
but makes an -O4 build much quieter.
2013-03-29 10:12:41 -04:00
Lennart Poettering 0c17fbce55 unit: replace remote-fs-setup.target by network-online.target
https://bugzilla.redhat.com/show_bug.cgi?id=787314
2013-03-29 03:07:17 +01:00
Harald Hoyer a87586a171 fstab-generator: drop x-initrd.rootfs mount option
x-initrd.mount now has different meanings, if fstab-generator is called
in the initramfs.

initrd:/etc/fstab and x-initrd.mount defines mounts for the
initrd-root-fs.target

initrd:/sysroot/etc/fstab and x-initrd.mount defines mounts for the
initrd-fs.target
2013-03-26 15:39:29 +01:00