Commit Graph
31 Commits
Author SHA1 Message Date
Joachim Wiberg 4fbcd1bbad Update copyright years
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-05-05 06:00:34 +02:00
Joachim Wiberg 37e3be9a0d Refactor to share err/warn log API between daemon and client code
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-09-05 09:57:45 +02:00
Joachim Wiberg 0e93dfd640 initctl: use standardized exit codes for all fatal errors
This change diversifies the exit codes used by initctl on fatal errors.
Previously only Std C codes 0 and 1 were used, with the initctl specific
255 for some cases.

Both the LSB init script codes and BSD sysexits.h codes are used.  See
util.c exitcodes[] for the full list.  The idea is to complement the
change in 9a76f08, issue #266, so that initctl can be used silently for
scripting purposes.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-05-15 11:32:06 +02:00
Joachim Wiberg 9a76f0862c initctl: let -q silence all commands
This patch introduces ERR(), ERRX(), WARN(), and WARNX() as replacements
to their lower case counterparts.  These log macros respect the 'quiet'
flag to initctl, leaving only the return code as indicator to user.

Fixes #266

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-05-15 10:34:36 +02:00
Joachim Wiberg fdf8e48c99 Minor, reduce scope of local variable
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-05-15 09:21:48 +02:00
Joachim Wiberg 108bbf56dd Update copyright years
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-19 19:35:49 +02:00
Joachim Wiberg a37037ded4 Fix #188: support without cgroups v2 support
This patch adds support for detecting if the Linux kernel Fint runs on
has support for cgroups v2.  The probe is done very early, in runlevel
S, when attempting to mount /sys/fs/cgroup.  Meaning, the log message
may be lost on systems that do not run sysklogd[1].

Here's the relevant logs from a system running myLinux on a kernel
that has cgroups v2 support disabled:

    Jan 10 20:19:40 anarchy finit[1]: myLinux 2021.11-696-g8fddaf36ed, entering runlevel S
    Jan 10 20:19:40 anarchy finit[1]: Kernel does not support cgroups v2, disabling.
    Jan 10 20:19:41 anarchy finit[1]: myLinux 2021.11-696-g8fddaf36ed, entering runlevel 2

All code paths that attempt to set or query kernel cgroups config has
been short circuited when this happens.  However, this does not apply
to any cgroup related config in the Finit .conf files -- which may of
course be omitted.  Yet, if configuration directives exist, they will
be parsed and may cause error.

Also, the initctl tool checks if /sys/fs/cgroup is mounted at runtime
and disables all status output and commands that rely on the feature.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-01-10 21:21:35 +01:00
Joachim Wiberg 280d91b9bf Add support for new libite (-lite) header namespace
Due to an unfortunate name clash with the DirectFB project LiTE, the
libite (-lite) project had to change its header namespace from

   lite/*.h -> libite/*.h

This patch adds support for the new namepace in Finit, triggered by the
define _LIBITE_LITE, from the .pc file read by pkg-config.  This should
only be needed on systems that install libite without the compatibility
symlink lite -> libite/ in the staging include directory.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-12-06 21:38:20 +01:00
Joachim Wiberg 7707c4b8e6 initctl: only show key capture in debug mode
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-04-19 15:56:39 +02:00
Joachim Wiberg 9fd860ef3c initctl: cgroup and status commands should show mem.min numeric
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-04-18 10:37:38 +02:00
Joachim Wiberg 85ada0ac99 initctl: minor, add linefeed at end of top session
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-04-18 04:47:22 +02:00
Joachim Wiberg 37eb1901f9 initctl: handle ~ECHONL properly in top command
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-04-08 14:36:15 +02:00
Joachim Wiberg 98c4e7764f initctl: fix boolean logic bug in -p top command option
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-04-08 14:27:36 +02:00
Joachim Wiberg d3e4463612 initctl: add missing signal.h include, required for musl libc
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-04-08 14:20:48 +02:00
Joachim Wiberg b1bcdc88e0 initctl: fix ordering issue for root task in ps/top/cgroup commands
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-04-08 13:17:40 +02:00
Joachim Wiberg f0bf1343b0 initctl: skip return value for uev_*_init(), optional
We have these neat extras for added value, if they should fail, for
whatever reason, we still want to present 'top' to the user, which may
have to use 'reset' if exited improperly and lost cooked/cursor.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-04-07 13:57:43 +02:00
Joachim Wiberg 2825100f77 initctl: add support for 'q' to quit from top (also signals)
- Set TTY in raw mode to be able read a single char at a time
 - Hide cursor
 - Trap 'q', Ctrl-C, Ctrl-\ and SIGTERM to restore TTY and cursor

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-04-07 10:08:13 +02:00
Joachim Wiberg 522276b80d Minor, rename internal functions/variables screen_* -> tt*
- Shorter
 - Follows old UNIX tradition
 - Lines up with next commit

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-04-07 10:06:01 +02:00
Joachim Wiberg 7bc1470a1e Minor, rearrange functions in mode order
Only moved functions around.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-04-06 14:38:24 +02:00
Joachim Wiberg d59f55b90c initctl: new command 'cgroup' to show cgroup config
This is intended to be used with the 'top' command to aid in setting up
and verifying proper limits for services.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-04-06 12:03:20 +02:00
Joachim Wiberg 02936de993 initctl: initical conversion to use libuEv for top command
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-04-05 23:56:39 +02:00
Joachim Wiberg d40b426c1b Refactor, check return value from fgets()
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-04-04 12:35:35 +02:00
Joachim Wiberg c0ae7763a6 initctl: ignore possibly missing cpu.stat in cgroup2 root
Older kernels (4.19) don't have the summary cpu.stat in the cgroup2
root, so let's ignore that problem and return zero.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-03-22 10:47:52 +01:00
Joachim Wiberg 3107027132 cgutil: new functions to query a cgroup from pid and get memory use
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-03-19 09:33:42 +01:00
Joachim Wiberg 728db73b09 cgutil: export more functions to initctl
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-03-19 09:32:36 +01:00
Joachim Wiberg fcb8ec9967 Refactor, factor out and export memsz() util function
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-03-19 09:30:52 +01:00
Joachim Wiberg 6a6f3a8291 cgroup: refactor for cgroups v2, much cleaner + unified hieararchy
Since the cgroups support in Finit is not yet officially released, we
decided to change the back-end to use cgroups v2 instead of the aging
and rather clumsy cgroups v1.  Even this initial refactor is a lot
easier to read and understand, more can still be done since there's
a lot of concepts, data values and the ilk that can now be shared
between different controllers.

Still ToDo: inotify for cgroup.events to clean up leaf nodes, which
            in cgroups v1 was handled by cgreaper.sh.  This is fixed
	    in the next commit in the series.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-03-18 18:23:35 +01:00
Joachim Wiberg 99a8cf3eb7 initctl: add -1,--once flag for top command
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-03-16 23:09:01 +01:00
Joachim Wiberg da95c7d80e initctl: ensure lines don't overflow in top command
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-03-16 23:07:14 +01:00
Joachim Wiberg a9f7f692a9 initctl: add more columns to top command; VmSize, RSS, VmLib, %MEM
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-03-16 16:49:08 +01:00
Joachim Wiberg 74a26f559d initctl: refactor, split into multiple files
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-03-16 09:23:04 +01:00