1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-02 19:21:53 +03:00
Commit Graph

17070 Commits

Author SHA1 Message Date
David Herrmann
fb835651af shared: make container_of() use unique variable names
If you stack container_of() macros, you will get warnings due to shadowing
variables of the parent context. To avoid this, use unique names for
variables.

Two new helpers are added:
  UNIQ: This evaluates to a truly unique value never returned by any
        evaluation of this macro. It's a shortcut for __COUNTER__.
  UNIQ_T: Takes two arguments and concatenates them. It is a shortcut for
          CONCATENATE, but meant to defined typed local variables.

As you usually want to use variables that you just defined, you need to
reference the same unique value at least two times. However, UNIQ returns
a new value on each evaluation, therefore, you have to pass the unique
values into the macro like this:

    #define my_macro(a, b) __max_macro(UNIQ, UNIQ, (a), (b))
    #define __my_macro(uniqa, uniqb, a, b) ({
                typeof(a) UNIQ_T(A, uniqa) = (a);
                typeof(b) UNIQ_T(B, uniqb) = (b);
                MY_UNSAFE_MACRO(UNIQ_T(A, uniqa), UNIQ_T(B, uniqb));
        })

This way, MY_UNSAFE_MACRO() can safely evaluate it's arguments multiple
times as they are local variables. But you can also stack invocations to
the macro my_macro() without clashing names.

This is the same as if you did:

    #define my_macro(a, b) __max_macro(__COUNTER__, __COUNTER__, (a), (b))
    #define __my_macro(prefixa, prefixb, a, b) ({
                typeof(a) CONCATENATE(A, prefixa) = (a);
                typeof(b) CONCATENATE(B, prefixb) = (b);
                MY_UNSAFE_MACRO(CONCATENATE(A, prefixa), CONCATENATE(B, prefixb));
        })

...but in my opinion, the first macro is easier to write and read.

This patch starts by converting container_of() to use this new helper.
Other macros may follow (like MIN, MAX, CLAMP, ...).
2014-08-27 18:42:28 +02:00
David Herrmann
418bcb0ce3 shared: drop UNIQUE()
The UNIQUE() macro works fine if used in un-stacked macros. However, once
you stack them like:
        MAX(MIN(a, b),
            CLAMP(MAX(c, d), e, f))
you will get warnings due to shadowing other variables. gcc uses the last
line of a macro expansion as value for __LINE__, therefore, we cannot even
avoid this by splitting the expressions across lines.

Remove the only user of UNIQUE() so we introduce a new helper in
follow-ups.
2014-08-27 18:42:28 +02:00
Tom Gundersen
285e8c126b TODO 2014-08-27 18:17:16 +02:00
Tom Gundersen
aeb50ff0bd tmpfiles: make resolv.conf entry conditional on resolved support 2014-08-27 18:17:16 +02:00
Lukas Nykryn
81fc054dc7 systemctl: fix broken list-unit-files with --root 2014-08-27 11:48:48 +02:00
Martin Pitt
e512e8a255 keymap: Adjust for more Samsung 900X4 series
Reportedly also applies to NP900X4B, so relax the match to apply to all models
of this series.

https://launchpad.net/bugs/902332
2014-08-27 08:41:10 +02:00
Piotr Drąg
1977376274 po: update Polish translation
https://bugs.freedesktop.org/show_bug.cgi?id=83015
2014-08-27 01:00:56 -04:00
Andrei Borzenkov
bf2e0ece85 Document "...|..." udev match syntax 2014-08-27 01:00:56 -04:00
Zbigniew Jędrzejewski-Szmek
36f5ace2db man: reword sd-hibernate-resume description and add link
"each device" was suggesting that this service might be instantiated
multiple times. "hibernation resume" was too jargon-y.
2014-08-26 21:14:11 -04:00
Ivan Shapovalov
d2c68822c4 hibernate-resume-generator: add a generator for instantiating the resume unit.
hibernate-resume-generator understands resume= kernel command line parameter
and instantiates the systemd-resume@.service accordingly if it is passed.

This enables resume from hibernation using device specified on the kernel
command line, and it may be specified either as "/dev/disk/by-foo/bar"
or "FOO=bar", not only "/dev/sdXY" which is understood by the in-kernel
implementation.

So now resume= is brought on par with root= in terms of possible ways to
specify a device.
2014-08-26 22:19:56 +02:00
Ivan Shapovalov
42483a7474 hibernate-resume: add a tool to write a device node's major:minor to /sys/power/resume.
This can be used to initiate a resume from hibernation by path to a swap
device containing the hibernation image.

The respective templated unit is also added. It is instantiated using
path to the desired resume device.
2014-08-26 22:19:54 +02:00
Ivan Shapovalov
66f311206e units: order systemd-fsck@.service after local-fs-pre.target.
With this change, it becomes possible to order a unit to activate before any
modifications to the file systems. This is especially useful for supporting
resume from hibernation.
2014-08-26 22:19:50 +02:00
Ben Wolsieffer
3c56cab441 logind: add HandleLidSwitchDocked= option to logind.conf + documentation
https://bugs.freedesktop.org/show_bug.cgi?id=82485
2014-08-26 22:08:02 +02:00
Lennart Poettering
36202fd2bc sd-journal: never log anything by default from a library 2014-08-26 21:47:46 +02:00
Lennart Poettering
1b6d7fa742 util: make use of newly added reset_signal_mask() call wherever appropriate 2014-08-26 21:12:54 +02:00
Lennart Poettering
1dedb74a2e util: reset signals when we fork off agents
If we invoke agents, we should make sure we actually can kill them
again. I mean, it's probably not our job to cleanup the signals if our
tools are invoked in weird contexts, but at least we should make sure,
that the subprocesses we invoke and intend to control work as intended.

Also see:

http://lists.freedesktop.org/archives/systemd-devel/2014-August/022460.html
2014-08-26 21:12:47 +02:00
Lennart Poettering
24a5d6b04e util: make sure reset_all_signal_handlers() continues with all other signal handlers when one sigaction() fails
After all, we usually don't check for failures here, and it is better to
do as much as we can...
2014-08-26 21:03:23 +02:00
Hristo Venev
f2322f0b64 sd-bus: don't include internal header memfd.h in public header sd-bus.h
https://bugs.freedesktop.org/show_bug.cgi?id=83097
2014-08-26 20:40:35 +02:00
Sjoerd Simons
498cfc230a systemctl: Correct error message printed when bus_process_wait fails
Actually use the variable containing the return code of bus_process_wait when
printing the error message as a result of it failing.
2014-08-26 20:37:05 +02:00
Lennart Poettering
bb19cb1707 sd-bus: remove unused call bus_kernel_create_monitor()
Noticed by Djalal Harouni
2014-08-26 20:35:44 +02:00
Filipe Brandenburger
684fc8927e test-util: use assert_se() for call to safe_mkdir with side effect
Otherwise it gets optimized out when CPPFLAGS='-DNDEBUG' is used.

Tested:
- make check TESTS='test-util' CPPFLAGS='-DNDEBUG'
2014-08-26 20:31:33 +02:00
Filipe Brandenburger
8d95631ea6 test-path-util: use assert_se in all assertions
Otherwise they get optimized out when CPPFLAGS='-DNDEBUG' is used, and that
causes the tests to fail.

Tested:
- make check TESTS='test-path-util' CPPFLAGS='-DNDEBUG'
2014-08-26 20:31:31 +02:00
Filipe Brandenburger
52754725e1 test-compress: make sure asserts with side effects use assert_se()
Otherwise the test fails when built with CPPFLAGS='-DNDEBUG' which disables
assertions.

Tested:
- make check TESTS='test-compress' CPPFLAGS='-DNDEBUG'
2014-08-26 20:31:27 +02:00
Łukasz Stelmach
32dfe42c66 networkd-wait-online: add missing short option 'i' to optstring 2014-08-26 20:29:59 +02:00
Michael Olbrich
7965435e58 missing: add BPF_XOR
BPF_XOR was introduced in kernel 3.7
2014-08-26 20:27:17 +02:00
Ansgar Burchardt
daa05349df NEWS: Fix typos. 2014-08-26 20:27:09 +02:00
Lennart Poettering
8dac15b6e9 update TODO 2014-08-26 20:24:04 +02:00
Kay Sievers
77cf759ea0 udev: hwdb - do not look at "usb_device" parents
Based on a patch from Simon McVittie <simon.mcvittie@collabora.co.uk>.

Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=758050
2014-08-26 18:27:36 +02:00
Lennart Poettering
4fc13f521a Revert "systemctl: fix broken list-unit-files with --root"
This reverts commit 41a451cc29.

This breaks checks for masking of units file, since we invoke
null_or_empty_path() on the resulting path.
2014-08-26 04:09:22 +02:00
Lennart Poettering
42aeb14a4a update TODO 2014-08-26 04:09:22 +02:00
Tom Gundersen
6d148a842e sd-event: sd_event_prepare - stay in PREPARED if sd_event_wait() indicates that no sources are pending 2014-08-26 00:22:06 +02:00
Tom Gundersen
c45a5a7446 sd-event: split run into prepare/wait/dispatch
This will allow sd-event to be integrated into an external event loop, which
in turn will allow (say) glib-based applications to use our various libraries,
without manually integrating each of them (bus, rtnl, dhcp, ...).

The external event-loop should integrate sd-event int he following way:

Every iteration must start with a call to sd_event_prepare(), which will
return 0 if no event sources are ready to be processed, a positive value if
they are and a negative value on error. sd_event_prepare() may only be called
following sd_event_dispatch(); a call to sd_event_wait() indicating that no
sources are ready to be dispatched; or a failed call to sd_event_dispatch() or
sd_event_wait().

A successful call to sd_event_prepare() indicating that no event sources are
ready to be dispatched must be followed by a call to sd_event_wait(),
which will return 0 if it timed out without event sources being ready to
be processed, a negative value on error and a positive value otherwise.
sd_event_wait() may only be called following a successful call to
sd_event_prepare() indicating that no event sources are ready to be dispatched.

If sd_event_wait() indicates that some events sources are ready to be
dispatched, it must be followed by a call to sd_event_dispatch(). This
is the only time sd_event_dispatch() may be called.
2014-08-25 21:52:36 +02:00
Lukas Nykryn
41a451cc29 systemctl: fix broken list-unit-files with --root
This patch modifies unit_file_get_list which will now return
hashmap of structures where f->path is *without* root_dir prefix.

This change should be ok, because current code either does not use
root_dir at all or calls basename() on the f->path.
2014-08-25 15:51:55 +02:00
Lennart Poettering
d74f9e8e8a update TODO 2014-08-22 18:10:31 +02:00
Lennart Poettering
d81afec1c9 core: split up "starting" manager state into "initializing" and "starting"
We'll stay in "initializing" until basic.target has reached, at which
point we will enter "starting".

This is preparation so that we can change the startip timeout to only
apply to the first phase of startup, not the full procedure.
2014-08-22 18:10:31 +02:00
Lennart Poettering
f07756bfe2 core: introduce "poweroff" as new failure action types
Also, change the default action on a system start-up timeout to powering off.
2014-08-22 18:10:31 +02:00
Lennart Poettering
c4147df156 resolved: fix typo in log message 2014-08-22 18:10:31 +02:00
Lennart Poettering
e12919e8be core: print 'startup finished' messages even if we log to console 2014-08-22 18:10:31 +02:00
Lennart Poettering
2928b0a863 core: add support for a configurable system-wide start-up timeout
When this system-wide start-up timeout is hit we execute one of the
failure actions already implemented for services that fail.

This should not only be useful on embedded devices, but also on laptops
which have the power-button reachable when the lid is closed. This
devices, when in a backpack might get powered on by accident due to the
easily reachable power button. We want to make sure that the system
turns itself off if it starts up due this after a while.

When the system manages to fully start-up logind will suspend the
machine by default if the lid is closed. However, in some cases we don't
even get as far as logind, and the boot hangs much earlier, for example
because we ask for a LUKS password that nobody ever enters.

Yeah, this is a real-life problem on my Yoga 13, which has one of those
easily accessible power buttons, even if the device is closed.
2014-08-22 18:10:31 +02:00
Daniel Mack
2de1851fe3 missing.h: add a cpp warning for __NR_memfd_create on MIPS 2014-08-22 16:10:02 +02:00
Daniel Mack
a7d611f280 missing.h: add fake __NR_memfd_create for MIPS
We don't have the correct __NR_memfd_create syscall number yet, so set it to
0xffffffff for now to prevent compile time errors.
2014-08-22 15:41:18 +02:00
David Herrmann
40a1eebde6 shared: add MAXSIZE() and use it in resolved
The MAXSIZE() macro takes two types and returns the size of the larger
one. It is much simpler to use than MAX(sizeof(A), sizeof(B)) and also
avoids any compiler-extensions, unlike CONST_MAX() and MAX() (which are
needed to avoid evaluating arguments more than once). This was suggested
by Daniele Nicolodi <daniele@grinta.net>.

Also make resolved use this macro instead of CONST_MAX(). This enhances
readability quite a bit.
2014-08-22 14:01:05 +02:00
Lennart Poettering
0975b63fb3 dbus1-generator: properly free the FILE*
Also, rework the code to make use of fflush_and_check().

Issue discovered by Simon Danner.
2014-08-22 12:44:17 +02:00
Lennart Poettering
337ce7442a update TODO 2014-08-21 19:12:53 +02:00
Lennart Poettering
4fe1be9ce2 systemctl: in list-unit-files, always show legend, even if we know about no unit files 2014-08-21 19:10:29 +02:00
Lennart Poettering
59ccf93d97 install: simplify usage of _cleanup_ macros 2014-08-21 19:08:30 +02:00
Lennart Poettering
96fb8242cc service: allow services of Type=oneshot that specify no ExecStart= commands
This is useful for services that simply want to run something on
shutdown, but not at bootup. They should only set ExecStop= but leave
ExecStart= unset.
2014-08-21 18:50:42 +02:00
Lennart Poettering
1954ea346d update TODO 2014-08-21 18:01:47 +02:00
Lennart Poettering
21b2ce39d4 service: use the right timeout for stop processes we fork 2014-08-21 18:01:22 +02:00
Lennart Poettering
f461c8073d execute: explain in a comment, why close_all_fds() is invoked the second time differently 2014-08-21 17:35:19 +02:00