Commit Graph

43 Commits

Author SHA1 Message Date
Lennart Poettering c2bc710b24 string-util: imply NULL termination of strextend() argument list
The trailing NULL in the argument list is now implied (similar to
what we already have in place in strjoin()).
2021-01-06 17:24:46 +01:00
Yu Watanabe 273d76f4f8 tree-wide: update "that that" 2020-11-18 17:23:00 +09:00
Yu Watanabe db9ecf0501 license: LGPL-2.1+ -> LGPL-2.1-or-later 2020-11-09 13:23:58 +09:00
Lennart Poettering e55299da4d shutdown: also fsync() DM devices before going down
Similar reasons as the previous patch.
2020-09-23 18:33:48 +02:00
Lennart Poettering 32c4626c4c shutdown: also fsync() MD devices when going down
Let's make this explicit, just in case this suffers by the same issues
as the loopback devices, and drops in-flight IO when we disassemble it.
2020-09-23 18:33:48 +02:00
Lennart Poettering 1a269c4ee3 shutdown: don't compare pointers with 0 2020-09-23 18:33:48 +02:00
Lennart Poettering 4534b32c73 shutdown: fsync() before detaching loopback devices
This is a follow-up for cae1e8fb88c5a6b0960a2d0be3df8755f0c78462: we
also call the detach ioctls in the shutdown code, hence add the fsync()s
there too, just to be safe.
2020-09-23 18:33:48 +02:00
Hubert Kario 0b220a5f2a Try stopping MD RAID devices in shutdown too
Currently the systemd-shutdown command attempts to stop swaps, DM
(crypt, LVM2) and loop devices, but it doesn't attempt to stop MD
RAID devices, which means that if the RAID is set up on crypt,
loop, etc. device, it won't be able to stop those underlying devices.

This code extends the shutdown application to also attempt stopping
the MD RAID devices.

Signed-off-by: Hubert Kario <hubert@kario.pl>
2020-09-22 10:41:59 +02:00
Lennart Poettering 5fe4d1b514 shutdown: fix spacing in shutdown error message 2020-05-05 10:23:47 +02:00
Lennart Poettering 0282c0285a shutdown: unregister all binfmt_misc entries before entering shutdown loop
Apparently if the new "F" flag is used they might pin files, which
blocks us from unmounting things. Let's hence clear this up explicitly.
Before entering our umount loop.

Fixes: #14981
2020-04-23 17:14:38 +02:00
Lennart Poettering 01262d0d9e
Merge pull request #13084 from ddstreet/log_time
log: add support for prefixing console log messages with current timestamp
2020-03-30 17:57:34 +02:00
Arusekk 71180f8e57 Fall back to kexec when no kexec binary exists
This may be not a popular setup, but in case kexec resides somewhere different
than the default location for KEXEC (`/usr/sbin/kexec`), don't just reboot and
try doing `reboot(RB_KEXEC)` instead, just like what `kexec -e` normally does.
2020-03-24 09:50:11 +01:00
Dan Streetman c5673ed0de log: add support for prefixing console log messages with current timestamp 2020-02-10 07:01:30 -05:00
Lennart Poettering 4ca8072fd6 umount: when we fail to detach a loopback device, set the auto-clear flag
We might get lucky and this cleans up things later on automatically for
us.
2019-12-20 18:37:24 +01:00
Lennart Poettering b877c3b06f umount: check LO_FLAGS_AUTOCLEAR after LOOP_CLR_FD claimed success
Fixes: #14410
Replaces: #14386
2019-12-20 18:16:05 +01:00
Lennart Poettering 63135a2d8d umount: detect root loopback device the same way as we detect root DM devices
get_block_device() is just the nicer way to do it (since it also odes
btrfs). Also, let's already collect the dev_t of the loopback device
when we enumerate things, that allows us to do the checks simpler
without constantly stat()ing things over and over again.
2019-12-20 18:16:02 +01:00
Lennart Poettering 88287615e6 umount: show correct error message
We fucked up errno vs. r two times, let's correct that.

While we are at it, let's handle the error first, like we usually do,
and the clean case without indentation.
2019-12-20 18:15:59 +01:00
Lennart Poettering 610f9a42c4 umount: remove unneeded variable 2019-12-20 18:15:56 +01:00
Lennart Poettering 49f80dcec8 umount: line break comments again
break them like we usually do, taking our intended line width into
account.
2019-12-20 18:15:47 +01:00
Lennart Poettering 4e201419b7 umount: log on all errors 2019-11-15 14:58:06 +01:00
Lennart Poettering 2cdd0d612d umount: be happy if /proc/swaps doesn't exist
Kernels work without swap just fine.

Fixes: #13993
2019-11-15 14:57:27 +01:00
Lennart Poettering f795267e3a shutdown: make logging more useful if NULL swap/mount table files are specified
Makes the error output seen in #13993 more readable.
2019-11-15 14:56:35 +01:00
Yu Watanabe 021cdf8330 tree-wide: drop signal.h when signal-util.h is included 2019-11-04 00:30:32 +09:00
Yu Watanabe 455fa9610c tree-wide: drop string.h when string-util.h or friends are included 2019-11-04 00:30:32 +09:00
Yu Watanabe f5947a5e92 tree-wide: drop missing.h 2019-10-31 17:57:03 +09:00
Zbigniew Jędrzejewski-Szmek fdb3decaa7 util-lib: move some functions from basic/cgroup-util to shared/cgroup-setup
This way less stuff needs to be in basic. Initially, I wanted to move all the
parts of cgroup-utils.[ch] that depend on efivars.[ch] to shared, because
efivars.[ch] is in shared/. Later on, I decide to split efivars.[ch], so the
move done in this patch is not necessary anymore. Nevertheless, it is still
valid on its own. If at some point we want to expose libbasic, it is better to
to not have stuff that belong in libshared there.
2019-09-16 18:08:00 +02:00
Lennart Poettering 2ec71e439f journald: slightly bump OOM adjust for journald (#13366)
If logging disappears issues are hard to debug, hence let's give
journald a slight edge over other services when the OOM killer hits.

Here are the special adjustments we now make:

 systemd-coredump@.service.in OOMScoreAdjust=500
 systemd-journald.service.in  OOMScoreAdjust=-250
 systemd-udevd.service.in     OOMScoreAdjust=-1000

(i.e. the coredump processing is made more likely to be killed on OOM,
and udevd and journald are less likely to be killed)
2019-08-22 10:02:28 +02:00
Lennart Poettering e7ac08e4e0 shutdown: merge variable declaration lines a bit 2019-07-13 11:05:07 +02:00
Lennart Poettering 9a75c65248 shutdown: bump kmsg log level to LOG_WARNING only
Fixes: #12337
2019-07-13 11:05:07 +02:00
Lennart Poettering 477851f5d6 shutdown: rework bump_sysctl_printk_log_level() to use sysctl_writef() 2019-07-13 11:05:07 +02:00
Lennart Poettering 701f6af6b9 shutdown: use "int" for log level type
Let's remove some unnecessary confusion around signed/unsigned types for
log levels. Let's just stick to signed, because that is what glibc
generally appears to use.

While we are at it, add explicit logging for all error causes.
2019-07-13 11:05:07 +02:00
Adrian Bunk 8a8e84d297 Replace the legacy ULONG_LONG_MAX with the C99 ULLONG_MAX 2019-05-17 09:39:46 +03:00
Lennart Poettering adb7b782f8
Merge pull request #12218 from keszybz/use-libmount-more
Use libmount more
2019-04-30 19:44:17 +02:00
Ben Boeckel 5238e95759 codespell: fix spelling errors 2019-04-29 16:47:18 +02:00
Zbigniew Jędrzejewski-Szmek e2857b3d87 Add helper function for mnt_table_parse_{stream,mtab}
This wraps a few common steps. It is defined as inline function instead of in a
.c file to avoid having a .c file. With a .c file, we would have three choices:
- either link it into libshared, but then then libshared would have to be
  linked to libmount.
- or compile the .c file into each target separately. This has the disdvantage
  that configuration of every target has to be updated and stuff will be compiled
  multiple times anyway, which is not too different from keeping this in the
  header file.
- or create a new convenience library just for this. This also has the disadvantage
  that the every target would have to be updated, and a separate library for a
  10 line function seems overkill.

By keeping everything in a header file, we compile this a few times, but
otherwise it's the least painful option. The compiler can optimize most of the
function away, because it knows if 'source' is set or not.
2019-04-23 23:29:29 +02:00
Zbigniew Jędrzejewski-Szmek 13dcfe4661 shared/mount-util: convert to libmount
It seems better to use just a single parsing algorithm for /proc/self/mountinfo.

Also, unify the naming of variables in all places that use mnt_table_next_fs().
It makes it easier to compare the different call sites.
2019-04-23 23:29:29 +02:00
Yu Watanabe 01234e1fe7 tree-wide: drop several missing_*.h and import relevant headers from kernel-5.0 2019-04-11 19:00:37 +02:00
Lennart Poettering aa46c28418
Merge pull request #12153 from benjarobin/killall-show-not-killed
shutdown/killall: Show in the console the processes not yet killed
2019-04-11 18:58:43 +02:00
Benjamin Robin 827156b330 shutdown: Bump sysctl kernel.printk log level in order to see info msg 2019-04-10 19:27:38 +02:00
Zbigniew Jędrzejewski-Szmek 9d1b2b2252 pid1,shutdown: do not cunescape paths from libmount
The test added in previous commit shows that libmount does the unescaping
internally.
2019-04-09 09:07:40 +02:00
Zbigniew Jędrzejewski-Szmek fb36b1339b shared: add a single definition of libmount cleanup functions
Use a trivial header file to share mnt_free_tablep and mnt_free_iterp.
It would be nicer put this in mount-util.h, but libmount.h is not in the
default include path, and the build system would have to be adjusted to pass
pkg-config include path in various places, and it's just not worth the trouble.
A separate header file works nicely.
2019-04-05 10:18:21 +02:00
Zbigniew Jędrzejewski-Szmek ca78ad1de9 headers: remove unneeded includes from util.h
This means we need to include many more headers in various files that simply
included util.h before, but it seems cleaner to do it this way.
2019-03-27 11:53:12 +01:00
Lennart Poettering 9e71f5d983 shutdown: rearrange shutdown sources in source tree
Let's move the shutdown binary into its own subdirectory in
src/shutdown, after all it is relatively isolated from the normal PID 1
sources, being a different binary and all.

Unfortunately it's not possible to move some of the code, since it is
shared with PID 1, that I wished we could move, but I still think it's
worth it.
2019-03-05 12:21:17 +01:00