Commit Graph

27 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 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 455fa9610c tree-wide: drop string.h when string-util.h or friends are included 2019-11-04 00:30:32 +09: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
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
Renamed from src/core/umount.c (Browse further)