summaryrefslogtreecommitdiff
path: root/src/cgls
Commit message (Collapse)AuthorAgeFilesLines
* tree-wide: reset optind to 0 when GNU extensions in optstring are usedYu Watanabe2023-03-291-0/+3
| | | | | | | | | | Otherwise, if getopt() and friends are used before parse_argv(), then the GNU extensions may be ignored. This should not change any behavior at least now, as we usually use getopt_long() only once per invocation. But in the next commit, getopt_long() will be used for other arrays, hence this change will become necessary.
* cgls: add -x and -c optionsZbigniew Jędrzejewski-Szmek2023-03-141-16/+20
| | | | | -x is short for --xattrs=yes and -c is short for --cgroup-id=yes.
* cgls: stop showing cgroup ids and xattrs by defaultZbigniew Jędrzejewski-Szmek2023-03-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Those are rather specialized bits of information, useful mostly for debugging. I use cgls quite often but never had the need to use either of those… But they take up a significant amount of screen real estate, esp. when executed as root: -.slice ├─user.slice (#1683) │ → user.invocation_id: 74b0bd1258c5485eb969016384e0d06a │ → trusted.invocation_id: 74b0bd1258c5485eb969016384e0d06a │ └─user-1000.slice (#6488) │ → user.invocation_id: b0261a14fe74490d9a9d5266c52cceb6 │ → trusted.invocation_id: b0261a14fe74490d9a9d5266c52cceb6 │ ├─user@1000.service … (#6590) │ │ → user.invocation_id: 9e1fb54ad07940d8b92c33c81d169f11 │ │ → user.delegate: 1 │ │ → trusted.invocation_id: 9e1fb54ad07940d8b92c33c81d169f11 │ │ → trusted.delegate: 1 │ │ ├─session.slice (#6874) ... Let's not show them by default, so we can show more cgroups. (Also, on a terminal, we already highlight delegate units via underlining and an ellipsis, so 'user.delegate:1' is redundant.)
* basic: add RuntimeScope enumLennart Poettering2023-03-101-3/+4
| | | | | | | | | | | | In various tools and services we have a per-system and per-user concept. So far we sometimes used a boolean indicating whether we are in system mode, or a reversed boolean indicating whether we are in user mode, or the LookupScope enum used by the lookup path logic. Let's address that, in introduce a common enum for this, we can use all across the board. This is mostly just search/replace, no actual code changes.
* basic: move version() to build.h+cZbigniew Jędrzejewski-Szmek2022-11-081-1/+1
|
* strv: make iterator in STRV_FOREACH() declaread in the loopYu Watanabe2022-03-191-1/+0
| | | | This also avoids multiple evaluations in STRV_FOREACH_BACKWARDS()
* cgls: mangle user-provided unit namesFrantisek Sumsal2022-03-101-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | so the CLI interface is now similar to `systemctl`, i.e. if no unit name suffix is provided, assume `.service`. Fixes: #20492 Before: ``` $ systemd-cgls --unit user@1000 Failed to query unit control group path: Invalid argument Failed to list cgroup tree: Invalid argument ``` After: ``` $ build/systemd-cgls --unit user@1000 Unit user@1000.service (/user.slice/user-1000.slice/user@1000.service): ├─session.slice (#4939) │ ├─pipewire-pulse.service (#5203) │ │ └─7711 /usr/bin/pipewire-pulse ... ```
* Merge pull request #20138 from keszybz/coding-style-variable-declsLuca Boccassi2021-11-051-2/+2
|\ | | | | A coding style tweak and checking of sd_notify() calls and voidification of pager_open()
| * Make pager_open() return voidZbigniew Jędrzejewski-Szmek2021-11-031-2/+2
| |
* | tree-wide: do not print hint about -M if -M is already usedZbigniew Jędrzejewski-Szmek2021-11-041-1/+1
|/ | | | | | | | (Or when -H is used, since -H and -M are incompatible.) Note that the slightly unusual form with separate boolean variables (hint_vars, hint_addr) instead of e.g. a const char* variable to hold the message, because this way we don't trigger the warning about non-literal format.
* cgls: enable cgroupid/xattr output by default (but make it configurable)Lennart Poettering2021-10-071-17/+36
|
* Drop the text argument from assert_not_reached()Zbigniew Jędrzejewski-Szmek2021-08-031-1/+1
| | | | | | | | | | | | | | | | | In general we almost never hit those asserts in production code, so users see them very rarely, if ever. But either way, we just need something that users can pass to the developers. We have quite a few of those asserts, and some have fairly nice messages, but many are like "WTF?" or "???" or "unexpected something". The error that is printed includes the file location, and function name. In almost all functions there's at most one assert, so the function name alone is enough to identify the failure for a developer. So we don't get much extra from the message, and we might just as well drop them. Dropping them makes our code a tiny bit smaller, and most importantly, improves development experience by making it easy to insert such an assert in the code without thinking how to phrase the argument.
* tree-wide: always drop unnecessary dot in pathYu Watanabe2021-05-281-1/+1
|
* tree-wide: enable colorized logging for daemons when run in consoleYu Watanabe2021-02-011-1/+1
| | | | It may be useful when debugging daemons.
* tree-wide: Drop custom formatting for print() help messagesDaan De Meyer2021-01-311-4/+3
| | | | | | | | | | | | I think this formatting was originally used because it simplified adding new options to the help messages. However, these days, most tools their help message end with "\nSee the %s for details.\n" so the final line almost never has to be edited which eliminates the benefit of the custom formatting used for printf() help messages. Let's make things more consistent and use the same formatting for printf() help messages that we use everywhere else. Prompted by https://github.com/systemd/systemd/pull/18355#discussion_r567241580
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-091-1/+1
|
* bus: use bus_log_connect_error to print error messagefangxiuning2020-07-211-1/+1
|
* log: introduce log_parse_environment_cli() and log_setup_cli()Filipe Brandenburger2020-06-241-3/+1
| | | | | | | | | | | | | | | | Presently, CLI utilities such as systemctl will check whether they have a tty attached or not to decide whether to parse /proc/cmdline or EFI variable SystemdOptions looking for systemd.log_* entries. But this check will be misleading if these tools are being launched by a daemon, such as a monitoring daemon or automation service that runs in background. Make log handling of CLI tools uniform by never checking /proc/cmdline or EFI variables to determine the logging level. Furthermore, introduce a new log_setup_cli() shortcut to set up common options used by most command-line utilities.
* tree-wide: drop string.h when string-util.h or friends are includedYu Watanabe2019-11-041-1/+0
|
* tree-wide: replace strjoin() with path_join()Yu Watanabe2019-06-211-1/+1
|
* Enable log colors for most of tools in /usr/binZbigniew Jędrzejewski-Szmek2019-05-081-0/+1
| | | | | | | | | | When emitting the calendarspec warning we want to see some color. Follow-up for 04220fda5c. Exceptions: - systemctl, because it has a lot hand-crafted coloring - tmpfiles, sysusers, stdio-bridge, etc, because they are also used in services and I'm not sure if this wouldn't mess up something.
* systemd-cgls: typo error in help commandHugo Kindel2019-03-191-2/+2
| | | | | Correct a small typo error happening on two lines of the help command: "specifified" instead of "specified".
* coccinelle: make use of SYNTHETIC_ERRNOZbigniew Jędrzejewski-Szmek2018-11-221-4/+3
| | | | | | | | | | | Ideally, coccinelle would strip unnecessary braces too. But I do not see any option in coccinelle for this, so instead, I edited the patch text using search&replace to remove the braces. Unfortunately this is not fully automatic, in particular it didn't deal well with if-else-if-else blocks and ifdefs, so there is an increased likelikehood be some bugs in such spots. I also removed part of the patch that coccinelle generated for udev, where we returns -1 for failure. This should be fixed independently.
* Split out pretty-print.c and move pager.c and main-func.h to shared/Zbigniew Jędrzejewski-Szmek2018-11-201-1/+1
| | | | | This is high-level functionality, and fits better in shared/ (which is for our executables), than in basic/ (which is also for libraries).
* cgls: use static destructor and DEFINE_MAIN_FUNCTION() macroYu Watanabe2018-11-201-23/+17
|
* cgls: add constYu Watanabe2018-11-201-1/+1
|
* basic/pager: convert the pager options to a flags argumentZbigniew Jędrzejewski-Szmek2018-11-141-3/+3
| | | | | Pretty much everything uses just the first argument, and this doesn't make this common pattern more complicated, but makes it simpler to pass multiple options.
* tree-wide: add clickable man page link to all --help textsLennart Poettering2018-08-201-4/+16
| | | | | | | | | | This is a bit like the info link in most of GNU's --help texts, but we don't do info but man pages, and we make them properly clickable on terminal supporting that, because awesome. I think it's generally advisable to link up our (brief) --help texts and our (more comprehensive) man pages a bit, so this should be an easy and straight-forward way to do it.
* tree-wide: remove Lennart's copyright linesLennart Poettering2018-06-141-3/+0
| | | | | | | | | | | These lines are generally out-of-date, incomplete and unnecessary. With SPDX and git repository much more accurate and fine grained information about licensing and authorship is available, hence let's drop the per-file copyright notice. Of course, removing copyright lines of others is problematic, hence this commit only removes my own lines and leaves all others untouched. It might be nicer if sooner or later those could go away too, making git the only and accurate source of authorship information.
* tree-wide: drop 'This file is part of systemd' blurbLennart Poettering2018-06-141-2/+0
| | | | | | | | | | | | | | | | This part of the copyright blurb stems from the GPL use recommendations: https://www.gnu.org/licenses/gpl-howto.en.html The concept appears to originate in times where version control was per file, instead of per tree, and was a way to glue the files together. Ultimately, we nowadays don't live in that world anymore, and this information is entirely useless anyway, as people are very welcome to copy these files into any projects they like, and they shouldn't have to change bits that are part of our copyright header for that. hence, let's just get rid of this old cruft, and shorten our codebase a bit.
* path-util: introduce path_simplify()Yu Watanabe2018-06-031-1/+1
| | | | | | | | The function is similar to path_kill_slashes() but also removes initial './', trailing '/.', and '/./' in the path. When the second argument of path_simplify() is false, then it behaves as the same as path_kill_slashes(). Hence, this also replaces path_kill_slashes() with path_simplify().
* path-util: introduce empty_to_root() and use it many placesYu Watanabe2018-05-111-1/+1
|
* tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek2018-04-061-13/+0
| | | | | | | | | | Files which are installed as-is (any .service and other unit files, .conf files, .policy files, etc), are left as is. My assumption is that SPDX identifiers are not yet that well known, so it's better to retain the extended header to avoid any doubt. I also kept any copyright lines. We can probably remove them, but it'd nice to obtain explicit acks from all involved authors before doing that.
* tree-wide: voidify pager_open()Yu Watanabe2018-03-191-5/+3
| | | | | | Even if pager_open() fails, in general, we should continue the operations. All erroneous cases in pager_open() show log message in the function. So, it is not necessary to check the returned value.
* tree-wide: port all code to use safe_getcwd()Lennart Poettering2018-01-171-3/+3
|
* Add SPDX license identifiers to source files under the LGPLZbigniew Jędrzejewski-Szmek2017-11-191-0/+1
| | | | | This follows what the kernel is doing, c.f. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
* build-sys: drop automake supportZbigniew Jędrzejewski-Szmek2017-07-181-1/+0
| | | | | v2: - also mention m4
* cgroup: change cg_unified() to possibly return errors againLennart Poettering2017-02-241-1/+1
| | | | | | | | | We use our cgroup APIs in various contexts, including from our libraries sd-login, sd-bus. As we don#t control those environments we can't rely that the unified cgroup setup logic succeeds, and hence really shouldn't assert on it. This more or less reverts 415fc41ceaeada2e32639f24f134b1c248b9e43f.
* core: simplify cg_[all_]unified()Tejun Heo2017-02-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | cg_[all_]unified() test whether a specific controller or all controllers are on the unified hierarchy. While what's being asked is a simple binary question, the callers must assume that the functions may fail any time, which unnecessarily complicates their usages. This complication is unnecessary. Internally, the test result is cached anyway and there are only a few places where the test actually needs to be performed. This patch simplifies cg_[all_]unified(). * cg_[all_]unified() are updated to return bool. If the result can't be decided, assertion failure is triggered. Error handlings from their callers are dropped. * cg_unified_flush() is updated to calculate the new result synchrnously and return whether it succeeded or not. Places which need to flush the test result are updated to test for failure. This ensures that all the following cg_[all_]unified() tests succeed. * Places which expected possible cg_[all_]unified() failures are updated to call and test cg_unified_flush() before calling cg_[all_]unified(). This includes functions used while setting up mounts during boot and manager_setup_cgroup().
* cgls: look at the right variable in error path (#5234)Zbigniew Jędrzejewski-Szmek2017-02-061-3/+3
| | | CID #1370779.
* cgls: --machine= expects an argument, indicate that in log messagesLennart Poettering2017-02-021-1/+1
| | | | | We gnerally suffix file settings and cmdline options that expect ags with "=" to indicate that. Do so here, too.
* cgls: allow --unit, --user-unit to take optional argumentZbigniew Jędrzejewski-Szmek2017-02-011-14/+27
| | | | | | | | | | | | | | The following are all equivalent: --unit foo.service bar.service --unit=foo.service bar.service --unit=foo.service --unit=bar.service foo.service bar.service --unit Similarly for --user-unit. The only case that doesn't work well is when --unit and --user-unit are mixed: --unit=foo.service --user-unit=bar.service We'll treat both names as user units. I think this is OK.
* cgls: add --user-unit to show user unitsZbigniew Jędrzejewski-Szmek2017-02-011-14/+29
|
* cgls: add --unit to show unitsZbigniew Jędrzejewski-Szmek2017-02-011-8/+53
| | | | | | | | | | $ systemd-cgls -u systemd-journald.service machine.slice I opted for a "global" switch, instead of modifying the behaviour of just one argument. It seem to be a more useful setting, since usually one will want to query one or more units, and not mix unit names with paths. Closes #5156.
* shared/cgroup-show: extract funtion to query unit cgroup pathZbigniew Jędrzejewski-Szmek2017-02-011-1/+0
| | | | …and use it where possible.
* cgtop: use common function to query cgroup rootZbigniew Jędrzejewski-Szmek2017-02-011-2/+2
| | | | | | | | | | | show_cgroup_get_root_and_warn is renamed to show_cgroup_get_path_and_warn because it now optionally allows querying a non-root path. This removes duplicated code and teaches cgtop to combine -M with a root prefix: $ systemd-cgtop -M myprecious /system.slice ...
* cgls: make function to query cgroup root publicZbigniew Jędrzejewski-Szmek2017-02-011-46/+2
| | | | No functional change.
* tree-wide: drop NULL sentinel from strjoinZbigniew Jędrzejewski-Szmek2016-10-231-1/+1
| | | | | | | | | | | | | This makes strjoin and strjoina more similar and avoids the useless final argument. spatch -I . -I ./src -I ./src/basic -I ./src/basic -I ./src/shared -I ./src/shared -I ./src/network -I ./src/locale -I ./src/login -I ./src/journal -I ./src/journal -I ./src/timedate -I ./src/timesync -I ./src/nspawn -I ./src/resolve -I ./src/resolve -I ./src/systemd -I ./src/core -I ./src/core -I ./src/libudev -I ./src/udev -I ./src/udev/net -I ./src/udev -I ./src/libsystemd/sd-bus -I ./src/libsystemd/sd-event -I ./src/libsystemd/sd-login -I ./src/libsystemd/sd-netlink -I ./src/libsystemd/sd-network -I ./src/libsystemd/sd-hwdb -I ./src/libsystemd/sd-device -I ./src/libsystemd/sd-id128 -I ./src/libsystemd-network --sp-file coccinelle/strjoin.cocci --in-place $(git ls-files src/*.c) git grep -e '\bstrjoin\b.*NULL' -l|xargs sed -i -r 's/strjoin\((.*), NULL\)/strjoin(\1)/' This might have missed a few cases (spatch has a really hard time dealing with _cleanup_ macros), but that's no big issue, they can always be fixed later.
* core: rename cg_unified() to cg_all_unified()Tejun Heo2016-08-151-1/+1
| | | | | | | | | | | A following patch will update cgroup handling so that the systemd controller (/sys/fs/cgroup/systemd) can use the unified hierarchy even if the kernel resource controllers are on the legacy hierarchies. This would require distinguishing whether all controllers are on cgroup v2 or only the systemd controller is. In preparation, this patch renames cg_unified() to cg_all_unified(). This patch doesn't cause any functional changes.
* shared: drop kernel_thread bool from cgroups show codeLennart Poettering2016-04-221-5/+6
| | | | | Make this an output flag instead, so that our function prototypes can lose one parameter