Commit graph

44 commits

Author SHA1 Message Date
Michael Biebl dcce98a4bd Avoid strict DM interface version dependencies (#5519)
Compiling against the dm-ioctl.h header as provided by the Linux kernel
will embed the DM interface version number. Running an older kernel can
result in an error like this on shutdown:

Could not detach DM dm-11: ioctl mismatch, kernel(4.34.4), user(4.35.4)

Work around this by shipping a local copy of dm-ioctl.h. We need at
least the version from 3.13 for DM_DEFERRED_REMOVE [1], so bump the
requirements in README accordingly.

[1] https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=2c140a246dc0bc085b98eddde978060fcec1080c

Fixes: #5492
2017-03-02 19:11:37 +01:00
Lennart Poettering cf139e6025 minor code beautifications 2016-12-07 18:38:41 +01:00
Giuseppe Scrivano 77531863ca Fix typo 2016-10-05 18:36:48 +02:00
Joel Holdsworth 04a9393122 core/mount: Don't unmount initramfs mounts
A mount within /run/initramfs is indicative that the mount was
created by initramfs init and will be unmounted by initramfs
shutdown.

It is unlikely that such a mount point would even be unmountable
by the the main system, for example in the case of the root file-
system being loop-mounted from a file in a /run/initramfs mount.
2016-03-04 15:16:34 +00:00
Vito Caputo 313cefa1d9 tree-wide: make ++/-- usage consistent WRT spacing
Throughout the tree there's spurious use of spaces separating ++ and --
operators from their respective operands.  Make ++ and -- operator
consistent with the majority of existing uses; discard the spaces.
2016-02-22 20:32:04 -08:00
Daniel Mack b26fa1a2fb tree-wide: remove Emacs lines from all files
This should be handled fine now by .dir-locals.el, so need to carry that
stuff in every file.
2016-02-10 13:41:57 +01:00
Thomas Hindoe Paaboel Andersen b4bbcaa9c4 tree-wide: group include of libudev.h with sd-* 2015-11-17 07:06:08 +01:00
Thomas Hindoe Paaboel Andersen cf0fbc49e6 tree-wide: sort includes
Sort the includes accoding to the new coding style.
2015-11-16 22:09:36 +01:00
Lennart Poettering b5efdb8af4 util-lib: split out allocation calls into alloc-util.[ch] 2015-10-27 13:45:53 +01:00
Jan Janssen 471b48ed2f unmount: Pass in mount options when remounting read-only
man 2 mount says that the mountflags and data parameteres should
match the original values except for the desired changes. We only
bother with the mount options since the only flags we can change
are MS_RDONLY, MS_SYNCHRONOUS and MS_MANDLOCK; which shouldn't
matter too much.

Fixes: #351
2015-10-26 15:13:28 +01:00
Lennart Poettering 3ffd4af220 util-lib: split out fd-related operations into fd-util.[ch]
There are more than enough to deserve their own .c file, hence move them
over.
2015-10-25 13:19:18 +01:00
Lennart Poettering 07630cea1f util-lib: split our string related calls from util.[ch] into its own file 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-10-24 23:05:02 +02:00
Lennart Poettering 4f5dd3943b util: split out escaping code into escape.[ch]
This really deserves its own file, given how much code this is now.
2015-10-24 23:04:42 +02:00
Lennart Poettering 75f86906c5 basic: rework virtualization detection API
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-09-07 13:42:47 +02:00
Susant Sahani 034e10d7fb core: fix CID 996302
CID 996302:  Error handling issues  (CHECKED_RETURN)
2015-06-12 10:24:26 +05:30
Lennart Poettering 527b7a421f util: rework cunescape(), improve error handling
Change cunescape() to return a normal error code, so that we can
distuingish OOM errors from parse errors.

This also adds a flags parameter to control whether "relaxed" or normal
parsing shall be done. If set no parse failures are generated, and the
only reason why cunescape() can fail is OOM.
2015-04-07 15:42:25 +02:00
Thomas Hindoe Paaboel Andersen 2eec67acbb remove unused includes
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-23 23:53:42 +01:00
Lennart Poettering 874d3404cb core,shutdown: don't bother with unmounting any mounts below /sys, /proc, /dev when shutting down
After all, mounts below these directories are pretty much guaranteed to
be virtual, and it's hence unnecessary to unmount them during shutdown.
Moreover, in less-priviliged containers we might lack the rights to
unmount them, hence don't even try.

http://lists.freedesktop.org/archives/systemd-devel/2015-January/027113.html
2015-01-23 13:47:41 +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
Ronny Chevalier e1d758033d use more _cleanup_ macro 2014-06-24 19:09:57 +02:00
Lennart Poettering c3544e8d2c umount: modernizations 2014-06-05 21:35:23 +02:00
Lennart Poettering 03e334a1c7 util: replace close_nointr_nofail() by a more useful safe_close()
safe_close() automatically becomes a NOP when a negative fd is passed,
and returns -1 unconditionally. This makes it easy to write lines like
this:

        fd = safe_close(fd);

Which will close an fd if it is open, and reset the fd variable
correctly.

By making use of this new scheme we can drop a > 200 lines of code that
was required to test for non-negative fds or to reset the closed fd
variable afterwards.
2014-03-18 19:31:34 +01:00
Jan Engelhardt a87f0f726c core: more exact test on the procfs special string "(deleted)"
In other parts of systemd, the code checks for " (deleted)",
but in one instance, it did not (yet). Make it do the same.
2014-02-17 19:03:07 -05:00
Lennart Poettering 06acf2d46a core,logind: libudev usage modernizations
Always use cleanup logic and don't eat up errors returned by libudev
2013-12-18 18:21:28 +01:00
Lennart Poettering 71fda00f32 list: make our list macros a bit easier to use by not requring type spec on each invocation
We can determine the list entry type via the typeof() gcc construct, and
so we should to make the macros much shorter to use.
2013-10-14 06:11:19 +02:00
Zbigniew Jędrzejewski-Szmek 1ca208fb4f Introduce udev object cleanup functions 2013-10-13 17:56:55 -04: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
Anatol Pomozov ab06eef810 Fix spelling errors using 'codespell' tool 2013-04-15 08:40:05 -04:00
Zbigniew Jędrzejewski-Szmek b92bea5d2a Use initalization instead of explicit zeroing
Before, we would initialize many fields twice: first
by filling the structure with zeros, and then a second
time with the real values. We can let the compiler do
the job for us, avoiding one copy.

A downside of this patch is that text gets slightly
bigger. This is because all zero() calls are effectively
inlined:

$ size build/.libs/systemd
         text    data     bss     dec     hex filename
before 897737  107300    2560 1007597   f5fed build/.libs/systemd
after  897873  107300    2560 1007733   f6075 build/.libs/systemd

… actually less than 1‰.

A few asserts that the parameter is not null had to be removed. I
don't think this changes much, because first, it is quite unlikely
for the assert to fail, and second, an immediate SEGV is almost as
good as an assert.
2013-04-05 19:50:57 -04:00
Zbigniew Jędrzejewski-Szmek e62d8c3944 Modernization
Use _cleanup_ and wrap lines to ~80 chars and such.
2013-03-31 14:36:12 -04:00
Kay Sievers e1af7092a8 shutdown: loop - convert to enumerate match 2013-01-20 16:18:00 +01:00
Kay Sievers bdffb521d0 shutdown: ignore loop devices without a backing file 2013-01-16 04:35:54 +01:00
Lennart Poettering 0c08f5cde7 shutdown: in the final umount loop don't use MNT_FORCE
MNT_FORCE is honoured by NFS and FUSE and allows unmounting of the FS
even if consumers still use it. For our brute-force loop we rely on
EBUSY being reported as long as a file system is still used by a
loopback device or suchlike. Hence, drop MNT_FORCE to make EBUSY
reliable.
2013-01-16 04:03:57 +01:00
Michal Schmidt 735e071271 shutdown, umount: use verbs consistently
Mounts are "unmounted".
Swaps are "deactivated", not "turned off" nor "disabled".
Loop and DM devices are "detached", not "deleted".

Especially the deleting sounded a bit scary.
2012-12-07 18:55:19 +01:00
Michal Schmidt bce93b7ac7 shutdown, umount: logging improvements
In bugreports about hangs during the late shutdown we are often missing
important information - what were we trying to unmount/detach when it hung.

Instead of printing what we successfully unmounted, print what we are
going to unmount/detach. And add messages to mark the completion of
categories (mount/swap/loop/DM).
2012-12-07 17:44:50 +01:00
Michal Schmidt c678406681 umount: fix check for DM changed
delete_dm() returns 0 on success. The check for "r > 0" was likely
a copy&paste error from the loopback code where "r > 0" makes sense.
2012-12-07 17:34:21 +01:00
Hermann Gausterer 5a6f9d2330 shutdown: fix typo 2012-11-28 21:22:39 +01:00
Tom Gundersen 140883405e shutdown: don't consider umounting of / and /usr failed
In the words of Homer: If you don't try, you can't fail.

This is a revert of 9279749b84.

It used to be necessary to consider the umounting failed to make sure /
and /usr were remounted read-only, but that is no longer necessary as
everything is now remounted read-only anyway.

Moreover, this avoids a warning at shutdown saying a filesystem was not
unmounted. As the umounting of / is never attempted there was no
corresponding warning message saying which fs that failed. This caused some
spurious bug-reports from concerned users.

Cc: Michael Biebl <biebl@debian.org>
2012-11-28 18:26:35 +01:00
Lennart Poettering 93bd157722 umount: always remount read-only before unmounting in final shutdown loop 2012-11-16 18:36:28 +01:00
Lennart Poettering 024f268d63 shutdown: don't attempt read-only mounts in a container 2012-09-03 18:59:04 -07:00
Lennart Poettering 8caf9d6836 umount: MS_MGC_VAL is so 90s 2012-08-13 16:30:10 +02:00
Daniel Drake 7c49259fc8 shutdown: Don't skip bind mounts on shutdown
This reverts commits d72238fcb3 and
f3accc08.

OLPC runs / as a bind-mount, so this must be remounted RO during
shutdown to avoid corruption.

As Lennert can't recall the exact reasons for making the shutdown
code skip bind mounts, revert to previous behaviour to solve the
issue for OLPC.

http://lists.freedesktop.org/archives/systemd-devel/2012-April/004957.html
2012-05-30 23:17:03 +02:00
Kay Sievers 9eb977db5b util: split-out path-util.[ch] 2012-05-08 02:33:10 +02:00
Lennart Poettering 146de8175e shutdown: move shutdown to core since it replaces PID 1 2012-04-12 14:18:36 +02:00
Renamed from src/umount.c (Browse further)