Commit graph

160 commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 44a6b1b680 Add __attribute__((const, pure, format)) in various places
I'm assuming that it's fine if a _const_ or _pure_ function
calls assert. It is assumed that the assert won't trigger,
and even if it does, it can only trigger on the first call
with a given set of parameters, and we don't care if the
compiler moves the order of calls.
2013-05-02 22:52:09 -04:00
Zbigniew Jędrzejewski-Szmek afba41995d systemctl: show reverse dependencies or before/after ordering
Also update completion scripts a bit.
2013-04-24 00:25:04 -04:00
Zbigniew Jędrzejewski-Szmek ef42202ac8 Add set_consume which always takes ownership
Freeing in error path is the common pattern with set_put().
2013-04-24 00:25:04 -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
Lennart Poettering a5e4972c89 systemctl: drop usage of "internally loaded modules"
I wouldn't know what "internally" is supposed to mean hear, and we use
this terminology in this context nowhere else, so let's drop this.
2013-04-18 02:10:44 +02:00
Harald Hoyer 4b6756a88d systemctl:enable_sysv_units() more _cleanup_free_ 2013-04-17 12:03:20 +02:00
Harald Hoyer 87698625aa systemctl: clarify usage of "--all" versus list-unit-files
Novice users might think, that
 $ systemctl --all
is equal to
 $ systemctl list-unit-files

https://bugzilla.redhat.com/show_bug.cgi?id=748512
2013-04-17 09:23:09 +02:00
Lennart Poettering 82da66fb75 util: replace decimal_str_max() by a typesafe macro DECIMAL_STR_WIDTH()
DECIMAL_STR_WIDTH() now works on any numeric type, and is easier to
distingish from DECIMAL_STR_MAX().

This also replaces another manual implementaiton of ulog10 by this macro.
2013-04-16 05:04:53 +02:00
Anatol Pomozov ab06eef810 Fix spelling errors using 'codespell' tool 2013-04-15 08:40:05 -04:00
Zbigniew Jędrzejewski-Szmek 991f2a3932 systemctl: new verb 'list-sockets'
LISTEN           UNIT                            ACTIVATES
/dev/initctl     systemd-initctl.socket          systemd-initctl.service
/dev/log         systemd-journald.socket         systemd-journald.service
...
[::]:19531       systemd-journal-gatewayd.socket systemd-journal-gatewayd.service
kobject-uevent 1 systemd-udevd-kernel.socket     systemd-udevd.service

17 sockets listed.
Pass --all to see loaded but inactive sockets, too.
2013-04-12 19:26:36 -04:00
Zbigniew Jędrzejewski-Szmek bcb161b023 errno is positive
Make sure we compare errno against positive error codes.
The ones in hwclock.c and install.c can have an impact, the
rest are unlikely to be hit or in code that isn't widely
used.

Also check that errno > 0, to help gcc know that we are
returning a negative error code.
2013-04-11 19:13:18 -04:00
Zbigniew Jędrzejewski-Szmek 0ad4e1a872 systemctl: show the name of failing unit in red
It makes it easier to pick out problematic unit
names from a long list.
2013-04-11 19:13:17 -04:00
Zbigniew Jędrzejewski-Szmek 20b3f379cf systemctl: allow multiple arguments to --type
This mirrors --property, and is generally useful.

New functionality is used in bash completion.

In case of zsh completion, new functionality is less useful
because of caching. Nevertheless, zsh completion for restart
is made to behave more-or-less the same as bash completion.
At least sockets can be restarted.
2013-04-11 19:11:52 -04:00
Zbigniew Jędrzejewski-Szmek 75add28aa1 systemctl: ellipsize job list only when necessary, highlight running
I was debugging systemd waiting on a missing disk, and noticed
that the job listing could use some polishing. Jobs that are
actually running are highlighted, so it's easier to see what
very actually waiting for.

Also, the needed widths are precalculated, to use available columns
more ecomically.
2013-04-10 19:46:49 -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
Lennart Poettering 5a8e9427a6 systemctl: tweak drop-in display
So far we didn't place spaces between the box drawing chars and the
values next to them. Let's be consistent here.

(Or to turn this around: if we really want to place a space there we
probably should do that in all our tree outputs, not just here...)
2013-04-05 20:19:54 +02:00
Lennart Poettering 45a4f72337 systemctl: tweak output of Listen: fields a bit
It's probably a good idea to minimize the number of field names to show
in the "systemctl status" output, in order to make them useful as a
guide for the reader how things are "grouped". This patch moves
information about the used socket technology to the end of the output
lines in brackets, rather than into the field names. This turns the used
socket technology into what it is -- peripheral meta information --
instead of something that was at the core.

New output:

systemd-journald.socket - Journal Socket
         Loaded: loaded (/usr/lib/systemd/system/systemd-journald.socket; static)
         Active: active (running) since Fr 2013-03-29 02:16:30 CET; 1 weeks 0 days ago
           Docs: man:systemd-journald.service(8)
                 man:journald.conf(5)
                 man:systemd-journald.service(8)
                 man:journald.conf(5)
         Listen: /run/systemd/journal/stdout (Stream)
                 /run/systemd/journal/socket (Datagram)
                 /dev/log (Datagram)
2013-04-05 20:12:39 +02:00
Oleksii Shevchuk 76d14b876a systemctl: Add DropIn paths to status message
$ systemctl status null.target
null.target - NYAN
   Loaded: loaded (/home/alxchk/.config/systemd/user/null.target; disabled)
  Drop-In: /home/alxchk/.config/systemd/user/null.target.d
           └─ descr.conf, install-1.conf, install.conf
           /etc/systemd/user/null.target.d
           └─ test.conf
   Active: active since Пт 2013-04-05 20:42:13 EEST; 1min 58s ago
2013-04-05 20:01:42 +02:00
Zbigniew Jędrzejewski-Szmek e8853816bf systemctl: align cgroups to 'n' in 'name='
Also drop ':' in repeated Docs lines.
2013-04-05 00:17:35 -04:00
Lennart Poettering 2fa4092c28 util: make time formatting a bit smarter
Instead of outputting "5h 55s 50ms 3us" we'll now output "5h
55.050003s". Also, while outputting the accuracy is configurable.

Basically we now try use "dot notation" for all time values > 1min. For
>= 1s we use 's' as unit, otherwise for >= 1ms we use 'ms' as unit, and
finally 'us'.

This should give reasonably values in most cases.
2013-04-04 02:56:56 +02:00
Zbigniew Jędrzejewski-Szmek 1316013495 systemctl: align all status fields to common column
avahi-daemon.socket - Avahi mDNS/DNS-SD Stack Activation Socket
       Loaded: loaded (/usr/lib/systemd/system/avahi-daemon.socket; enabled)
       Active: active (listening) since Mon 2013-04-01 09:02:44 EDT; 14h ago
 ListenStream: /var/run/avahi-daemon/socket
2013-04-01 23:43:49 -04:00
Oleksii Shevchuk 6741960087 Add Listen* to dbus properties
sockets.socket - Test
	  Loaded: loaded (/home/alxchk/.config/systemd/user/sockets.socket; static)
	  Active: inactive (dead)
	  Listen: Stream: /tmp/stream1
	          Stream: @stream4
	          Stream: [::]:9999
	          Stream: 127.0.0.2:9996
	          Stream: [::1]:9996
	          Datagram: /tmp/stream2
	          Datagram: @stream5
	          Datagram: [::]:9998
	          Datagram: 127.0.0.2:9995
	          Datagram: [::1]:9995
	          SequentialPacket: @stream6
	          SequentialPacket: /tmp/stream3
	          FIFO: /tmp/fifo1
	          Special: /dev/input/event9
	          Netlink: kobject-uevent 0
	          MessageQueue: /msgqueue1

[zj: - minor cleanups,
     - free i.listen,
     - remove sorting, because the order or sockets matters.]
2013-04-01 23:43:48 -04:00
Cristian Rodríguez 9607d9470e Always use our own MAX/MIN definitions
code in src/shared/macro.h only defined MAX/MIN in case
they were not defined previously. however the MAX/MIN
macros implemented in glibc are not of the "safe" kind but defined
as:

define MIN(a,b) (((a)<(b))?(a):(b))
define MAX(a,b) (((a)>(b))?(a):(b))

Avoid nasty side effects by using our own versions instead.

Also fix the warnings derived from this change.

[zj: - modify MAX3 macro to fix warning about _a shadowing _a,
     - do bootchart/svg.c too,
     - remove unused MIN3.]
2013-04-01 23:43:48 -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
Lennart Poettering 830f01f0bc unit: no need to export variables if we can avoid it 2013-03-30 15:21:54 +01: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
Cristian Rodríguez 4ad61fd180 add --with-telinit=PATH configure option
Distributions that never shipped upstart do not have
"telinit" in /lib/upstart/..

Defaults to /lib/upstart/telinit so there is no change
for systems existing installs.
2013-03-23 01:44:56 +01:00
Michal Sekletar 1609dcb137 systemctl: remove unused variable 2013-03-13 21:05:08 -04:00
Zbigniew Jędrzejewski-Szmek 427b47c4ab initctl: catch write error, use _cleanup_
!= operator always returns something nonnegative, so the
error condition was not caught.
2013-03-13 19:53:45 -04:00
Zbigniew Jędrzejewski-Szmek 886a64fe69 logs-show: export logic to add matches for units
After that functions which add matches, show_journal_by_unit
and show_journal_by_user_unit, become nearly identical, so
I merged them into one function.
2013-03-13 19:53:29 -04:00
Harald Hoyer 1b12a7b589 pager: introduce "jump to end" option
$ journalctl -be

is what you want :)

https://bugzilla.redhat.com/show_bug.cgi?id=867841
2013-03-07 21:16:04 +01:00
Lukas Nykryn dec49d88d6 systemctl: mangle unit name in is-enabled
https://bugs.freedesktop.org/show_bug.cgi?id=56072
https://bugzilla.redhat.com/show_bug.cgi?id=880353
2013-03-07 16:25:00 +01:00
Lukas Nykryn fea9740ae4 systemctl: check if iterator was initialized succesfully 2013-03-01 16:43:57 -05:00
Lennart Poettering d6cb60c7a0 Revert "systemctl: try to reload daemon after enable/disable only when not running in a chroot"
This reverts commit 5522a1fa87.

I am an idiot, the chroot case was already filtered out, so no point in
checking this again.
2013-03-01 14:04:18 +01:00
Lennart Poettering 5522a1fa87 systemctl: try to reload daemon after enable/disable only when not running in a chroot
http://lists.freedesktop.org/archives/systemd-devel/2013-February/009208.html
2013-03-01 13:59:49 +01:00
Lennart Poettering 1f4cadad8b systemctl: fix minimal number of params for new cgroup commands 2013-02-27 18:58:56 +01:00
Lennart Poettering 26d04f86a3 unit: rework resource management API
This introduces a new static list of known attributes and their special
semantics. This means that cgroup attribute values can now be
automatically translated from user to kernel notation for command line
set settings, too.

This also adds proper support for multi-line attributes.
2013-02-27 18:50:41 +01:00
Lennart Poettering 416389f7ae systemctl: fix indentation 2013-02-27 15:01:06 +01:00
Michal Schmidt 47a0eaa60c systemctl: generalize action table to be usable in more action<->verb mappings
Should be no functional change.
2013-02-22 16:06:18 +01:00
Michal Schmidt b85bdddafb systemctl: make shutdown operations use irreversible jobs
Occasionally people report problem with reboot/poweroff operations hanging in
the middle. One known cause is when a new transaction to start a unit is
enqueued while the shutdown is going on. The start of the unit conflicts with
the shutdown jobs, so they get cancelled. The failure case can be quite unpleasant,
becase getty and sshd may already be stopped.

Fix it by using irreversible jobs for shutdown (reboot/poweroff/...) actions.
This applies to commands like "reboot", "telinit 6", "systemctl reboot". Should
someone desire to use reversible jobs, they can say "systemctl start reboot.target".`
2013-02-22 16:06:17 +01:00
Michal Schmidt 23ade460e5 core, systemctl: add support for irreversible jobs
Add a new job mode: replace-irreversibly. Jobs enqueued using this mode
cannot be implicitly canceled by later enqueued conflicting jobs.
They can however still be canceled with an explicit "systemctl cancel"
call.
2013-02-22 16:06:17 +01:00
Michal Schmidt b7cf6049a3 systemctl: make "systemctl default" use "isolate" job mode
"systemctl default" should behave identically to "telinit N" (where N is the
corresponding runlevel target number), therefore it should use isolate job mode
too.
2013-02-22 16:06:17 +01:00
Zbigniew Jędrzejewski-Szmek 033a842c36 systemctl: allow comma sepearted property lists 2013-02-16 17:36:00 -05:00
Jan Janssen d0a5cdb280 systemctl: Don't give re-activation warning if unit is masked 2013-02-16 09:53:49 -05:00
Zbigniew Jędrzejewski-Szmek 265a7a2a60 systemctl: allow status with no units
This makes 'status' behave like 'list-units':
systemctl status -> status of all units
systemctl -t error status -> status of error units
systemctl -t mount status -> etc.
2013-02-16 09:53:49 -05:00
Zbigniew Jędrzejewski-Szmek f6bb13ab8d systemctl: print wall message only if successful
systemctl would write to the wall even if unsuccessful.

https://bugs.freedesktop.org/show_bug.cgi?id=60393
2013-02-14 15:26:34 -05:00
Zbigniew Jędrzejewski-Szmek cec7eda533 systemctl: use automatic cleanup 2013-02-14 15:26:34 -05:00
Harald Hoyer a5c32cff1f honor SELinux labels, when creating and writing config files
Also split out some fileio functions to fileio.c and provide a SELinux
aware pendant in fileio-label.c

see https://bugzilla.redhat.com/show_bug.cgi?id=881577
2013-02-14 16:19:38 +01:00
Simon Peeters 1700761b06 Move systemctl dot to systemd-analyze dot 2013-02-13 14:47:05 -08:00
Marc-Antoine Perennou a38694df9c systemctl: use parse_unit_info
Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
2013-02-13 14:36:01 -08:00