mirror of
https://github.com/systemd/systemd.git
synced 2024-12-12 11:44:13 +08:00
Merge pull request #14538 from yuwata/xyzctl-full
use table_set_width(table, 0) if --full is specified
This commit is contained in:
commit
4504f59fbd
@ -388,6 +388,15 @@
|
||||
<xi:include href="user-system-options.xml" xpointer="host" />
|
||||
<xi:include href="user-system-options.xml" xpointer="machine" />
|
||||
|
||||
<varlistentry>
|
||||
<term><option>-l</option></term>
|
||||
<term><option>--full</option></term>
|
||||
|
||||
<listitem>
|
||||
<para>Do not ellipsize the output in <command>list</command> command.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<xi:include href="standard-options.xml" xpointer="no-pager" />
|
||||
<xi:include href="standard-options.xml" xpointer="no-legend" />
|
||||
<xi:include href="standard-options.xml" xpointer="help" />
|
||||
|
@ -680,7 +680,8 @@
|
||||
<term><option>-l</option></term>
|
||||
<term><option>--full</option></term>
|
||||
|
||||
<listitem><para>Do not ellipsize process tree entries.</para>
|
||||
<listitem><para>Do not ellipsize process tree entries or table. This implies
|
||||
<option>--max-addresses=full</option>.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
@ -316,7 +316,7 @@ s - Service VLAN, m - Two-port MAC Relay (TPMR)
|
||||
<term><option>--full</option></term>
|
||||
|
||||
<listitem>
|
||||
<para>Do not ellipsize the logs in <command>status</command> command.</para>
|
||||
<para>Do not ellipsize the output.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
@ -95,6 +95,15 @@
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>-l</option></term>
|
||||
<term><option>--full</option></term>
|
||||
|
||||
<listitem>
|
||||
<para>Do not ellipsize the output when <option>--list</option> is specified.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<xi:include href="standard-options.xml" xpointer="no-pager"/>
|
||||
<xi:include href="standard-options.xml" xpointer="no-legend" />
|
||||
<xi:include href="standard-options.xml" xpointer="no-ask-password"/>
|
||||
|
@ -25,14 +25,14 @@ __contains_word () {
|
||||
|
||||
__get_machines() {
|
||||
local a b
|
||||
machinectl list --no-legend --no-pager 2>/dev/null |
|
||||
machinectl list --full --no-legend --no-pager 2>/dev/null |
|
||||
{ while read a b; do echo " $a"; done; };
|
||||
}
|
||||
|
||||
__get_busnames() {
|
||||
local mode=$1
|
||||
local a b
|
||||
COLUMNS=65535 busctl $mode list --no-legend --no-pager 2>/dev/null |
|
||||
busctl $mode list --no-legend --no-pager --full 2>/dev/null |
|
||||
{ while read a b; do echo " $a"; done; };
|
||||
}
|
||||
|
||||
@ -85,7 +85,7 @@ _busctl() {
|
||||
--show-machine --unique --acquired --activatable --list
|
||||
-q --quiet --verbose --expect-reply=no --auto-start=no
|
||||
--allow-interactive-authorization=no --augment-creds=no
|
||||
--watch-bind=yes -j'
|
||||
--watch-bind=yes -j -l --full'
|
||||
[ARG]='--address -H --host -M --machine --match --timeout --size --json
|
||||
--destination'
|
||||
)
|
||||
|
@ -27,7 +27,7 @@ __contains_word () {
|
||||
|
||||
__get_machines() {
|
||||
local a b
|
||||
(machinectl list-images --no-legend --no-pager; machinectl list --no-legend --no-pager; echo ".host") | \
|
||||
(machinectl list-images --full --no-legend --no-pager; machinectl list --full --no-legend --no-pager; echo ".host") | \
|
||||
{ while read a b; do echo " $a"; done; } | sort -u;
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ __get_all_seats () { loginctl --no-legend list-seats | { while read -r a b
|
||||
|
||||
__get_machines() {
|
||||
local a b
|
||||
machinectl list --no-legend --no-pager 2>/dev/null |
|
||||
machinectl list --full --no-legend --no-pager 2>/dev/null |
|
||||
{ while read a b; do echo " $a"; done; };
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ __contains_word() {
|
||||
|
||||
__get_machines() {
|
||||
local a b
|
||||
(machinectl list-images --no-legend --no-pager; machinectl list --no-legend --no-pager; echo ".host") | \
|
||||
(machinectl list-images --full --no-legend --no-pager; machinectl list --full --no-legend --no-pager; echo ".host") | \
|
||||
{ while read a b; do echo " $a"; done; } | sort -u;
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ __contains_word () {
|
||||
}
|
||||
|
||||
__get_links() {
|
||||
networkctl list --no-legend --no-pager --all | { while read -r a b c; do echo " $b"; done; };
|
||||
networkctl list --no-legend --no-pager --all --full | { while read -r a b c; do echo " $b"; done; };
|
||||
}
|
||||
|
||||
_networkctl() {
|
||||
|
@ -25,7 +25,7 @@ __contains_word () {
|
||||
|
||||
__get_machines() {
|
||||
local a b
|
||||
machinectl list --no-legend --no-pager 2>/dev/null |
|
||||
machinectl list --full --no-legend --no-pager 2>/dev/null |
|
||||
{ while read a b; do echo " $a"; done; };
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,7 @@ __get_all_unit_files () { { __systemctl $1 list-unit-files "$2*"; } | { while re
|
||||
|
||||
__get_machines() {
|
||||
local a b
|
||||
{ machinectl list-images --no-legend --no-pager; machinectl list --no-legend --no-pager; } | \
|
||||
{ machinectl list-images --full --no-legend --no-pager; machinectl list --full --no-legend --no-pager; } | \
|
||||
{ while read a b; do echo " $a"; done; }
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ __contains_word () {
|
||||
|
||||
__get_machines() {
|
||||
local a b
|
||||
machinectl list --no-legend --no-pager | { while read a b; do echo " $a"; done; };
|
||||
machinectl list --full --no-legend --no-pager | { while read a b; do echo " $a"; done; };
|
||||
}
|
||||
|
||||
__get_services() {
|
||||
|
@ -25,7 +25,7 @@ __contains_word() {
|
||||
|
||||
__get_machines() {
|
||||
local a b
|
||||
machinectl list --no-legend --no-pager | { while read a b; do echo " $a"; done; };
|
||||
machinectl list --full --no-legend --no-pager | { while read a b; do echo " $a"; done; };
|
||||
}
|
||||
|
||||
__get_units_have_cgroup() {
|
||||
|
@ -25,7 +25,7 @@ __contains_word() {
|
||||
|
||||
__get_machines() {
|
||||
local a b
|
||||
machinectl list --no-legend --no-pager | { while read a b; do echo " $a"; done; };
|
||||
machinectl list --full --no-legend --no-pager | { while read a b; do echo " $a"; done; };
|
||||
}
|
||||
|
||||
_systemd_cgtop() {
|
||||
|
@ -35,7 +35,7 @@ __get_slices() {
|
||||
|
||||
__get_machines() {
|
||||
local a b
|
||||
machinectl list --no-legend --no-pager | { while read a b; do echo " $a"; done; };
|
||||
machinectl list --full --no-legend --no-pager | { while read a b; do echo " $a"; done; };
|
||||
}
|
||||
|
||||
__get_env() {
|
||||
|
@ -26,7 +26,7 @@ __get_slice_units () { __systemctl $1 list-units --all -t slice \
|
||||
|
||||
__get_machines() {
|
||||
local a b
|
||||
machinectl list --no-legend --no-pager | { while read a b; do echo " $a"; done; };
|
||||
machinectl list --full --no-legend --no-pager | { while read a b; do echo " $a"; done; };
|
||||
}
|
||||
|
||||
_systemd_run() {
|
||||
|
@ -27,7 +27,7 @@ __contains_word () {
|
||||
|
||||
__get_machines() {
|
||||
local a b
|
||||
machinectl list --no-legend --no-pager | { while read a b; do echo " $a"; done; };
|
||||
machinectl list --full --no-legend --no-pager | { while read a b; do echo " $a"; done; };
|
||||
}
|
||||
|
||||
__get_interfaces(){
|
||||
|
@ -1484,7 +1484,6 @@ static int assess(const struct security_info *info, Table *overview_table, Analy
|
||||
|
||||
if (details_table) {
|
||||
const char *checkmark, *description, *color = NULL;
|
||||
TableCell *cell;
|
||||
|
||||
if (badness == UINT64_MAX) {
|
||||
checkmark = " ";
|
||||
@ -1507,13 +1506,12 @@ static int assess(const struct security_info *info, Table *overview_table, Analy
|
||||
if (d)
|
||||
description = d;
|
||||
|
||||
r = table_add_cell_full(details_table, &cell, TABLE_STRING, checkmark, 1, 1, 0, 0, 0);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add cell to table: %m");
|
||||
if (color)
|
||||
(void) table_set_color(details_table, cell, color);
|
||||
|
||||
r = table_add_many(details_table,
|
||||
TABLE_STRING, checkmark,
|
||||
TABLE_SET_MINIMUM_WIDTH, 1,
|
||||
TABLE_SET_MAXIMUM_WIDTH, 1,
|
||||
TABLE_SET_ELLIPSIZE_PERCENT, 0,
|
||||
TABLE_SET_COLOR, color,
|
||||
TABLE_STRING, a->id, TABLE_SET_URL, a->url,
|
||||
TABLE_STRING, description,
|
||||
TABLE_UINT64, a->weight, TABLE_SET_ALIGN_PERCENT, 100,
|
||||
@ -1521,7 +1519,7 @@ static int assess(const struct security_info *info, Table *overview_table, Analy
|
||||
TABLE_UINT64, a->range, TABLE_SET_ALIGN_PERCENT, 100,
|
||||
TABLE_EMPTY, TABLE_SET_ALIGN_PERCENT, 100);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add cells to table: %m");
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1597,35 +1595,26 @@ static int assess(const struct security_info *info, Table *overview_table, Analy
|
||||
|
||||
if (overview_table) {
|
||||
char buf[DECIMAL_STR_MAX(uint64_t) + 1 + DECIMAL_STR_MAX(uint64_t) + 1];
|
||||
TableCell *cell;
|
||||
_cleanup_free_ char *url = NULL;
|
||||
|
||||
r = table_add_cell(overview_table, &cell, TABLE_STRING, info->id);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add cell to table: %m");
|
||||
if (info->fragment_path) {
|
||||
_cleanup_free_ char *url = NULL;
|
||||
|
||||
r = file_url_from_path(info->fragment_path, &url);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to generate URL from path: %m");
|
||||
|
||||
(void) table_set_url(overview_table, cell, url);
|
||||
}
|
||||
|
||||
xsprintf(buf, "%" PRIu64 ".%" PRIu64, exposure / 10, exposure % 10);
|
||||
r = table_add_cell(overview_table, &cell, TABLE_STRING, buf);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add cell to table: %m");
|
||||
(void) table_set_align_percent(overview_table, cell, 100);
|
||||
|
||||
r = table_add_cell(overview_table, &cell, TABLE_STRING, badness_table[i].name);
|
||||
r = table_add_many(overview_table,
|
||||
TABLE_STRING, info->id,
|
||||
TABLE_SET_URL, url,
|
||||
TABLE_STRING, buf,
|
||||
TABLE_SET_ALIGN_PERCENT, 100,
|
||||
TABLE_STRING, badness_table[i].name,
|
||||
TABLE_SET_COLOR, strempty(badness_table[i].color),
|
||||
TABLE_STRING, special_glyph(badness_table[i].smiley));
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add cell to table: %m");
|
||||
(void) table_set_color(overview_table, cell, strempty(badness_table[i].color));
|
||||
|
||||
r = table_add_cell(overview_table, NULL, TABLE_STRING, special_glyph(badness_table[i].smiley));
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add cell to table: %m");
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -1113,13 +1113,11 @@ static int analyze_blame(int argc, char *argv[], void *userdata) {
|
||||
if (u->time <= 0)
|
||||
continue;
|
||||
|
||||
r = table_add_cell(table, NULL, TABLE_TIMESPAN_MSEC, &u->time);
|
||||
r = table_add_many(table,
|
||||
TABLE_TIMESPAN_MSEC, &u->time,
|
||||
TABLE_STRING, u->name);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = table_add_cell(table, NULL, TABLE_STRING, u->name);
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
@ -1630,7 +1628,7 @@ static int dump_exit_status(int argc, char *argv[], void *userdata) {
|
||||
TABLE_INT, (int) i,
|
||||
TABLE_STRING, exit_status_class(i));
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
else
|
||||
for (int i = 1; i < argc; i++) {
|
||||
@ -1646,7 +1644,7 @@ static int dump_exit_status(int argc, char *argv[], void *userdata) {
|
||||
TABLE_INT, status,
|
||||
TABLE_STRING, exit_status_class(status) ?: "-");
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
@ -1853,33 +1851,23 @@ static int dump_timespan(int argc, char *argv[], void *userdata) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = table_add_cell(table, NULL, TABLE_STRING, "Original:");
|
||||
r = table_add_many(table,
|
||||
TABLE_STRING, "Original:",
|
||||
TABLE_STRING, *input_timespan);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = table_add_cell(table, NULL, TABLE_STRING, *input_timespan);
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
|
||||
r = table_add_cell_stringf(table, NULL, "%ss:", special_glyph(SPECIAL_GLYPH_MU));
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
|
||||
r = table_add_cell(table, NULL, TABLE_UINT64, &output_usecs);
|
||||
r = table_add_many(table,
|
||||
TABLE_UINT64, &output_usecs,
|
||||
TABLE_STRING, "Human:",
|
||||
TABLE_TIMESPAN, &output_usecs,
|
||||
TABLE_SET_COLOR, ansi_highlight());
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = table_add_cell(table, NULL, TABLE_STRING, "Human:");
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = table_add_cell(table, &cell, TABLE_TIMESPAN, &output_usecs);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = table_set_color(table, cell, ansi_highlight());
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
|
||||
r = table_print(table, NULL);
|
||||
if (r < 0)
|
||||
@ -1925,57 +1913,42 @@ static int test_timestamp_one(const char *p) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = table_add_cell(table, NULL, TABLE_STRING, "Original form:");
|
||||
r = table_add_many(table,
|
||||
TABLE_STRING, "Original form:",
|
||||
TABLE_STRING, p,
|
||||
TABLE_STRING, "Normalized form:",
|
||||
TABLE_TIMESTAMP, &usec,
|
||||
TABLE_SET_COLOR, ansi_highlight_blue());
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = table_add_cell(table, NULL, TABLE_STRING, p);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = table_add_cell(table, NULL, TABLE_STRING, "Normalized form:");
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = table_add_cell(table, &cell, TABLE_TIMESTAMP, &usec);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = table_set_color(table, cell, ansi_highlight_blue());
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
|
||||
if (!in_utc_timezone()) {
|
||||
r = table_add_cell(table, NULL, TABLE_STRING, "(in UTC):");
|
||||
r = table_add_many(table,
|
||||
TABLE_STRING, "(in UTC):",
|
||||
TABLE_TIMESTAMP_UTC, &usec);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = table_add_cell(table, &cell, TABLE_TIMESTAMP_UTC, &usec);
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
|
||||
r = table_add_cell(table, NULL, TABLE_STRING, "UNIX seconds:");
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
|
||||
if (usec % USEC_PER_SEC == 0)
|
||||
r = table_add_cell_stringf(table, &cell, "@%"PRI_USEC,
|
||||
r = table_add_cell_stringf(table, NULL, "@%"PRI_USEC,
|
||||
usec / USEC_PER_SEC);
|
||||
else
|
||||
r = table_add_cell_stringf(table, &cell, "@%"PRI_USEC".%06"PRI_USEC"",
|
||||
r = table_add_cell_stringf(table, NULL, "@%"PRI_USEC".%06"PRI_USEC"",
|
||||
usec / USEC_PER_SEC,
|
||||
usec % USEC_PER_SEC);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = table_add_cell(table, NULL, TABLE_STRING, "From now:");
|
||||
r = table_add_many(table,
|
||||
TABLE_STRING, "From now:",
|
||||
TABLE_TIMESTAMP_RELATIVE, &usec);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = table_add_cell(table, &cell, TABLE_TIMESTAMP_RELATIVE, &usec);
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
|
||||
return table_print(table, NULL);
|
||||
}
|
||||
@ -2035,22 +2008,18 @@ static int test_calendar_one(usec_t n, const char *p) {
|
||||
return r;
|
||||
|
||||
if (!streq(t, p)) {
|
||||
r = table_add_cell(table, NULL, TABLE_STRING, "Original form:");
|
||||
r = table_add_many(table,
|
||||
TABLE_STRING, "Original form:",
|
||||
TABLE_STRING, p);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = table_add_cell(table, NULL, TABLE_STRING, p);
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
|
||||
r = table_add_cell(table, NULL, TABLE_STRING, "Normalized form:");
|
||||
r = table_add_many(table,
|
||||
TABLE_STRING, "Normalized form:",
|
||||
TABLE_STRING, t);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = table_add_cell(table, NULL, TABLE_STRING, t);
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
|
||||
for (unsigned i = 0; i < arg_iterations; i++) {
|
||||
usec_t next;
|
||||
@ -2058,17 +2027,12 @@ static int test_calendar_one(usec_t n, const char *p) {
|
||||
r = calendar_spec_next_usec(spec, n, &next);
|
||||
if (r == -ENOENT) {
|
||||
if (i == 0) {
|
||||
r = table_add_cell(table, NULL, TABLE_STRING, "Next elapse:");
|
||||
r = table_add_many(table,
|
||||
TABLE_STRING, "Next elapse:",
|
||||
TABLE_STRING, "never",
|
||||
TABLE_SET_COLOR, ansi_highlight_yellow());
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = table_add_cell(table, &cell, TABLE_STRING, "never");
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = table_set_color(table, cell, ansi_highlight_yellow());
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -2076,17 +2040,12 @@ static int test_calendar_one(usec_t n, const char *p) {
|
||||
return log_error_errno(r, "Failed to determine next elapse for '%s': %m", p);
|
||||
|
||||
if (i == 0) {
|
||||
r = table_add_cell(table, NULL, TABLE_STRING, "Next elapse:");
|
||||
r = table_add_many(table,
|
||||
TABLE_STRING, "Next elapse:",
|
||||
TABLE_TIMESTAMP, &next,
|
||||
TABLE_SET_COLOR, ansi_highlight_blue());
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = table_add_cell(table, &cell, TABLE_TIMESTAMP, &next);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = table_set_color(table, cell, ansi_highlight_blue());
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
} else {
|
||||
int k = DECIMAL_STR_WIDTH(i + 1);
|
||||
|
||||
@ -2097,34 +2056,28 @@ static int test_calendar_one(usec_t n, const char *p) {
|
||||
|
||||
r = table_add_cell_stringf(table, NULL, "Iter. #%u:", i+1);
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
|
||||
r = table_add_cell(table, &cell, TABLE_TIMESTAMP, &next);
|
||||
r = table_add_many(table,
|
||||
TABLE_TIMESTAMP, &next,
|
||||
TABLE_SET_COLOR, ansi_highlight_blue());
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = table_set_color(table, cell, ansi_highlight_blue());
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
|
||||
if (!in_utc_timezone()) {
|
||||
r = table_add_cell(table, NULL, TABLE_STRING, "(in UTC):");
|
||||
r = table_add_many(table,
|
||||
TABLE_STRING, "(in UTC):",
|
||||
TABLE_TIMESTAMP_UTC, &next);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = table_add_cell(table, NULL, TABLE_TIMESTAMP_UTC, &next);
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
|
||||
r = table_add_cell(table, NULL, TABLE_STRING, "From now:");
|
||||
r = table_add_many(table,
|
||||
TABLE_STRING, "From now:",
|
||||
TABLE_TIMESTAMP_RELATIVE, &next);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = table_add_cell(table, NULL, TABLE_TIMESTAMP_RELATIVE, &next);
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
|
||||
n = next;
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ static enum {
|
||||
} arg_json = JSON_OFF;
|
||||
static PagerFlags arg_pager_flags = 0;
|
||||
static bool arg_legend = true;
|
||||
static bool arg_full = false;
|
||||
static const char *arg_address = NULL;
|
||||
static bool arg_unique = false;
|
||||
static bool arg_acquired = false;
|
||||
@ -195,6 +196,9 @@ static int list_bus_names(int argc, char **argv, void *userdata) {
|
||||
if (!table)
|
||||
return log_oom();
|
||||
|
||||
if (arg_full)
|
||||
table_set_width(table, 0);
|
||||
|
||||
r = table_set_align_percent(table, table_get_cell(table, 0, COLUMN_PID), 100);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to set alignment: %m");
|
||||
@ -233,7 +237,7 @@ static int list_bus_names(int argc, char **argv, void *userdata) {
|
||||
TABLE_EMPTY,
|
||||
TABLE_EMPTY);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to fill line: %m");
|
||||
return table_log_add_error(r);
|
||||
|
||||
continue;
|
||||
}
|
||||
@ -250,7 +254,7 @@ static int list_bus_names(int argc, char **argv, void *userdata) {
|
||||
TABLE_INT, PTR_TO_INT(v),
|
||||
TABLE_STRING, k);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add name %s to table: %m", k);
|
||||
return table_log_add_error(r);
|
||||
|
||||
r = sd_bus_get_name_creds(
|
||||
bus, k,
|
||||
@ -279,7 +283,7 @@ static int list_bus_names(int argc, char **argv, void *userdata) {
|
||||
} else
|
||||
r = table_add_many(table, TABLE_EMPTY, TABLE_EMPTY);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add fields to table: %m");
|
||||
return table_log_add_error(r);
|
||||
|
||||
r = sd_bus_creds_get_euid(creds, &uid);
|
||||
if (r >= 0) {
|
||||
@ -293,7 +297,7 @@ static int list_bus_names(int argc, char **argv, void *userdata) {
|
||||
} else
|
||||
r = table_add_cell(table, NULL, TABLE_EMPTY, NULL);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add field to table: %m");
|
||||
return table_log_add_error(r);
|
||||
|
||||
(void) sd_bus_creds_get_unique_name(creds, &unique);
|
||||
(void) sd_bus_creds_get_unit(creds, &unit);
|
||||
@ -308,7 +312,7 @@ static int list_bus_names(int argc, char **argv, void *userdata) {
|
||||
TABLE_STRING, cn);
|
||||
}
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add fields to table: %m");
|
||||
return table_log_add_error(r);
|
||||
|
||||
if (arg_show_machine) {
|
||||
sd_id128_t mid;
|
||||
@ -321,7 +325,7 @@ static int list_bus_names(int argc, char **argv, void *userdata) {
|
||||
|
||||
r = table_add_cell(table, NULL, TABLE_STRING, sd_id128_to_string(mid, m));
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add field to table: %m");
|
||||
return table_log_add_error(r);
|
||||
|
||||
continue; /* line fully filled, no need to fill the remainder below */
|
||||
}
|
||||
@ -2251,6 +2255,7 @@ static int help(void) {
|
||||
" --version Show package version\n"
|
||||
" --no-pager Do not pipe output into a pager\n"
|
||||
" --no-legend Do not show the headers and footers\n"
|
||||
" -l --full Do not ellipsize output\n"
|
||||
" --system Connect to system bus\n"
|
||||
" --user Connect to user bus\n"
|
||||
" -H --host=[USER@]HOST Operate on remote host\n"
|
||||
@ -2323,6 +2328,7 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
{ "version", no_argument, NULL, ARG_VERSION },
|
||||
{ "no-pager", no_argument, NULL, ARG_NO_PAGER },
|
||||
{ "no-legend", no_argument, NULL, ARG_NO_LEGEND },
|
||||
{ "full", no_argument, NULL, 'l' },
|
||||
{ "system", no_argument, NULL, ARG_SYSTEM },
|
||||
{ "user", no_argument, NULL, ARG_USER },
|
||||
{ "address", required_argument, NULL, ARG_ADDRESS },
|
||||
@ -2372,6 +2378,10 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
arg_legend = false;
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
arg_full = true;
|
||||
break;
|
||||
|
||||
case ARG_USER:
|
||||
arg_user = true;
|
||||
break;
|
||||
|
@ -122,7 +122,7 @@ static int print_inhibitors(sd_bus *bus) {
|
||||
TABLE_STRING, why,
|
||||
TABLE_STRING, mode);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add table row: %m");
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
|
||||
r = sd_bus_message_exit_container(reply);
|
||||
|
@ -189,7 +189,7 @@ static int list_sessions(int argc, char *argv[], void *userdata) {
|
||||
TABLE_STRING, seat,
|
||||
TABLE_STRING, strna(tty));
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add row to table: %m");
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
|
||||
r = sd_bus_message_exit_container(reply);
|
||||
@ -246,7 +246,7 @@ static int list_users(int argc, char *argv[], void *userdata) {
|
||||
TABLE_UID, (uid_t) uid,
|
||||
TABLE_STRING, user);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add row to table: %m");
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
|
||||
r = sd_bus_message_exit_container(reply);
|
||||
@ -298,7 +298,7 @@ static int list_seats(int argc, char *argv[], void *userdata) {
|
||||
|
||||
r = table_add_cell(table, NULL, TABLE_STRING, seat);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add row to table: %m");
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
|
||||
r = sd_bus_message_exit_container(reply);
|
||||
|
@ -306,6 +306,9 @@ static int list_machines(int argc, char *argv[], void *userdata) {
|
||||
if (!table)
|
||||
return log_oom();
|
||||
|
||||
if (arg_full)
|
||||
table_set_width(table, 0);
|
||||
|
||||
r = sd_bus_message_enter_container(reply, 'a', "(ssso)");
|
||||
if (r < 0)
|
||||
return bus_log_parse_error(r);
|
||||
@ -338,7 +341,7 @@ static int list_machines(int argc, char *argv[], void *userdata) {
|
||||
0,
|
||||
"",
|
||||
" ",
|
||||
arg_addrs,
|
||||
arg_full ? ALL_IP_ADDRESSES : arg_addrs,
|
||||
&addresses);
|
||||
|
||||
r = table_add_many(table,
|
||||
@ -349,7 +352,7 @@ static int list_machines(int argc, char *argv[], void *userdata) {
|
||||
TABLE_STRING, empty_to_dash(version_id),
|
||||
TABLE_STRING, empty_to_dash(addresses));
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add table row: %m");
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
|
||||
r = sd_bus_message_exit_container(reply);
|
||||
@ -386,6 +389,9 @@ static int list_images(int argc, char *argv[], void *userdata) {
|
||||
if (!table)
|
||||
return log_oom();
|
||||
|
||||
if (arg_full)
|
||||
table_set_width(table, 0);
|
||||
|
||||
(void) table_set_align_percent(table, TABLE_HEADER_CELL(3), 100);
|
||||
|
||||
r = sd_bus_message_enter_container(reply, SD_BUS_TYPE_ARRAY, "(ssbttto)");
|
||||
@ -395,8 +401,6 @@ static int list_images(int argc, char *argv[], void *userdata) {
|
||||
for (;;) {
|
||||
uint64_t crtime, mtime, size;
|
||||
const char *name, *type;
|
||||
TableCell *cell;
|
||||
bool ro_bool;
|
||||
int ro_int;
|
||||
|
||||
r = sd_bus_message_read(reply, "(ssbttto)", &name, &type, &ro_int, &crtime, &mtime, &size, NULL);
|
||||
@ -410,27 +414,14 @@ static int list_images(int argc, char *argv[], void *userdata) {
|
||||
|
||||
r = table_add_many(table,
|
||||
TABLE_STRING, name,
|
||||
TABLE_STRING, type);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add table row: %m");
|
||||
|
||||
ro_bool = ro_int;
|
||||
r = table_add_cell(table, &cell, TABLE_BOOLEAN, &ro_bool);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add table cell: %m");
|
||||
|
||||
if (ro_bool) {
|
||||
r = table_set_color(table, cell, ansi_highlight_red());
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to set table cell color: %m");
|
||||
}
|
||||
|
||||
r = table_add_many(table,
|
||||
TABLE_STRING, type,
|
||||
TABLE_BOOLEAN, ro_int,
|
||||
TABLE_SET_COLOR, ro_int ? ansi_highlight_red() : NULL,
|
||||
TABLE_SIZE, size,
|
||||
TABLE_TIMESTAMP, crtime,
|
||||
TABLE_TIMESTAMP, mtime);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add table row: %m");
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
|
||||
r = sd_bus_message_exit_container(reply);
|
||||
|
@ -46,6 +46,7 @@ enum {
|
||||
static bool arg_no_block = false;
|
||||
static PagerFlags arg_pager_flags = 0;
|
||||
static bool arg_legend = true;
|
||||
static bool arg_full = false;
|
||||
static bool arg_ask_password = true;
|
||||
static bool arg_quiet = false;
|
||||
static BusTransport arg_transport = BUS_TRANSPORT_LOCAL;
|
||||
@ -92,6 +93,7 @@ static int help(void) {
|
||||
" --no-block Do not wait until operation finished\n"
|
||||
" --no-pager Do not pipe output into a pager\n"
|
||||
" --no-legend Do not show the headers\n"
|
||||
" -l --full Do not ellipsize output\n"
|
||||
" --no-ask-password Do not prompt for password\n"
|
||||
" -q --quiet Suppress information messages during runtime\n"
|
||||
" --user Run as user unit\n"
|
||||
@ -150,6 +152,7 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
{ "no-block", no_argument, NULL, ARG_NO_BLOCK },
|
||||
{ "no-pager", no_argument, NULL, ARG_NO_PAGER },
|
||||
{ "no-legend", no_argument, NULL, ARG_NO_LEGEND },
|
||||
{ "full", no_argument, NULL, 'l' },
|
||||
{ "no-ask-password", no_argument, NULL, ARG_NO_ASK_PASSWORD },
|
||||
{ "quiet", no_argument, NULL, 'q' },
|
||||
{ "user", no_argument, NULL, ARG_USER },
|
||||
@ -182,7 +185,7 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
if (strstr(program_invocation_short_name, "systemd-umount"))
|
||||
arg_action = ACTION_UMOUNT;
|
||||
|
||||
while ((c = getopt_long(argc, argv, "hqH:M:t:o:p:AuG", options, NULL)) >= 0)
|
||||
while ((c = getopt_long(argc, argv, "hqH:M:t:o:p:AuGl", options, NULL)) >= 0)
|
||||
|
||||
switch (c) {
|
||||
|
||||
@ -204,6 +207,10 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
arg_legend = false;
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
arg_full = true;
|
||||
break;
|
||||
|
||||
case ARG_NO_ASK_PASSWORD:
|
||||
arg_ask_password = false;
|
||||
break;
|
||||
@ -1393,6 +1400,9 @@ static int list_devices(void) {
|
||||
if (!table)
|
||||
return log_oom();
|
||||
|
||||
if (arg_full)
|
||||
table_set_width(table, 0);
|
||||
|
||||
r = table_set_sort(table, 0, SIZE_MAX);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to set sort index: %m");
|
||||
@ -1436,7 +1446,7 @@ static int list_devices(void) {
|
||||
|
||||
r = table_add_cell(table, NULL, c == COLUMN_NODE ? TABLE_PATH : TABLE_STRING, strna(x));
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add cell: %m");
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -518,6 +518,9 @@ static int list_links(int argc, char *argv[], void *userdata) {
|
||||
if (!table)
|
||||
return log_oom();
|
||||
|
||||
if (arg_full)
|
||||
table_set_width(table, 0);
|
||||
|
||||
table_set_header(table, arg_legend);
|
||||
|
||||
assert_se(cell = table_get_cell(table, 0, 0));
|
||||
@ -554,7 +557,7 @@ static int list_links(int argc, char *argv[], void *userdata) {
|
||||
TABLE_STRING, strna(setup_state),
|
||||
TABLE_SET_COLOR, on_color_setup);
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
|
||||
r = table_print(table, NULL);
|
||||
@ -729,7 +732,7 @@ static int dump_gateways(
|
||||
TABLE_EMPTY,
|
||||
TABLE_STRING, i == 0 ? "Gateway:" : "");
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
|
||||
r = in_addr_to_string(local[i].family, &local[i].address, &gateway);
|
||||
if (r < 0)
|
||||
@ -755,7 +758,7 @@ static int dump_gateways(
|
||||
} else
|
||||
r = table_add_cell(table, NULL, TABLE_STRING, with_description ?: gateway);
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -786,7 +789,7 @@ static int dump_addresses(
|
||||
TABLE_EMPTY,
|
||||
TABLE_STRING, i == 0 ? "Address:" : "");
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
|
||||
r = in_addr_to_string(local[i].family, &local[i].address, &pretty);
|
||||
if (r < 0)
|
||||
@ -809,7 +812,7 @@ static int dump_addresses(
|
||||
} else
|
||||
r = table_add_cell(table, NULL, TABLE_STRING, pretty);
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -838,7 +841,10 @@ static int dump_address_labels(sd_netlink *rtnl) {
|
||||
|
||||
table = table_new("label", "prefix/prefixlen");
|
||||
if (!table)
|
||||
return -ENOMEM;
|
||||
return log_oom();
|
||||
|
||||
if (arg_full)
|
||||
table_set_width(table, 0);
|
||||
|
||||
r = table_set_sort(table, 0, SIZE_MAX);
|
||||
if (r < 0)
|
||||
@ -883,14 +889,18 @@ static int dump_address_labels(sd_netlink *rtnl) {
|
||||
|
||||
r = table_add_cell(table, NULL, TABLE_UINT32, &label);
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
|
||||
r = table_add_cell_stringf(table, NULL, "%s/%u", pretty, prefixlen);
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
|
||||
return table_print(table, NULL);
|
||||
r = table_print(table, NULL);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to print table: %m");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int list_address_labels(int argc, char *argv[], void *userdata) {
|
||||
@ -982,7 +992,7 @@ static int dump_lldp_neighbors(Table *table, const char *prefix, int ifindex) {
|
||||
TABLE_EMPTY,
|
||||
TABLE_STRING, c == 0 ? prefix : "");
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
|
||||
(void) sd_lldp_neighbor_get_system_name(n, &system_name);
|
||||
(void) sd_lldp_neighbor_get_port_id_as_string(n, &port_id);
|
||||
@ -995,7 +1005,7 @@ static int dump_lldp_neighbors(Table *table, const char *prefix, int ifindex) {
|
||||
strempty(port_description),
|
||||
isempty(port_description) ? "" : ")");
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
|
||||
c++;
|
||||
}
|
||||
@ -1018,7 +1028,7 @@ static int dump_ifindexes(Table *table, const char *prefix, const int *ifindexes
|
||||
TABLE_STRING, c == 0 ? prefix : "",
|
||||
TABLE_IFINDEX, ifindexes[c]);
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -1037,7 +1047,7 @@ static int dump_list(Table *table, const char *prefix, char **l) {
|
||||
TABLE_STRING, i == l ? prefix : "",
|
||||
TABLE_STRING, *i);
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -1048,12 +1058,12 @@ static int dump_list(Table *table, const char *prefix, char **l) {
|
||||
TABLE_EMPTY, \
|
||||
TABLE_STRING, name ":"); \
|
||||
if (r < 0) \
|
||||
return r; \
|
||||
return table_log_add_error(r); \
|
||||
r = table_add_cell(table, NULL, \
|
||||
info->has_stats64 ? TABLE_UINT64 : TABLE_UINT32, \
|
||||
info->has_stats64 ? (void*) &info->stats64.val_name : (void*) &info->stats.val_name); \
|
||||
if (r < 0) \
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
|
||||
static int dump_statistics(Table *table, const LinkInfo *info) {
|
||||
int r;
|
||||
@ -1195,7 +1205,10 @@ static int link_status_one(
|
||||
|
||||
table = table_new("dot", "key", "value");
|
||||
if (!table)
|
||||
return -ENOMEM;
|
||||
return log_oom();
|
||||
|
||||
if (arg_full)
|
||||
table_set_width(table, 0);
|
||||
|
||||
assert_se(cell = table_get_cell(table, 0, 0));
|
||||
(void) table_set_ellipsize_percent(table, cell, 100);
|
||||
@ -1209,10 +1222,10 @@ static int link_status_one(
|
||||
TABLE_STRING, special_glyph(SPECIAL_GLYPH_BLACK_CIRCLE),
|
||||
TABLE_SET_COLOR, on_color_operational);
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
r = table_add_cell_stringf(table, &cell, "%i: %s", info->ifindex, info->name);
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
(void) table_set_align_percent(table, cell, 0);
|
||||
|
||||
r = table_add_many(table,
|
||||
@ -1230,14 +1243,14 @@ static int link_status_one(
|
||||
TABLE_EMPTY,
|
||||
TABLE_STRING, "State:");
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
r = table_add_cell_stringf(table, NULL, "%s%s%s (%s%s%s)",
|
||||
on_color_operational, strna(operational_state), off_color_operational,
|
||||
on_color_setup, strna(setup_state), off_color_setup);
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
|
||||
STRV_FOREACH(p, info->alternative_names)
|
||||
STRV_FOREACH(p, info->alternative_names) {
|
||||
if (p == info->alternative_names)
|
||||
r = table_add_many(table,
|
||||
TABLE_EMPTY,
|
||||
@ -1248,6 +1261,9 @@ static int link_status_one(
|
||||
TABLE_EMPTY,
|
||||
TABLE_EMPTY,
|
||||
TABLE_STRING, *p);
|
||||
if (r < 0)
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
|
||||
if (path) {
|
||||
r = table_add_many(table,
|
||||
@ -1255,7 +1271,7 @@ static int link_status_one(
|
||||
TABLE_STRING, "Path:",
|
||||
TABLE_STRING, path);
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
if (driver) {
|
||||
r = table_add_many(table,
|
||||
@ -1263,7 +1279,7 @@ static int link_status_one(
|
||||
TABLE_STRING, "Driver:",
|
||||
TABLE_STRING, driver);
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
if (vendor) {
|
||||
r = table_add_many(table,
|
||||
@ -1271,7 +1287,7 @@ static int link_status_one(
|
||||
TABLE_STRING, "Vendor:",
|
||||
TABLE_STRING, vendor);
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
if (model) {
|
||||
r = table_add_many(table,
|
||||
@ -1279,7 +1295,7 @@ static int link_status_one(
|
||||
TABLE_STRING, "Model:",
|
||||
TABLE_STRING, model);
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
|
||||
if (info->has_mac_address) {
|
||||
@ -1292,14 +1308,14 @@ static int link_status_one(
|
||||
TABLE_EMPTY,
|
||||
TABLE_STRING, "HW Address:");
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
r = table_add_cell_stringf(table, NULL, "%s%s%s%s",
|
||||
ether_addr_to_string(&info->mac_address, ea),
|
||||
description ? " (" : "",
|
||||
strempty(description),
|
||||
description ? ")" : "");
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
|
||||
if (info->has_permanent_mac_address) {
|
||||
@ -1312,14 +1328,14 @@ static int link_status_one(
|
||||
TABLE_EMPTY,
|
||||
TABLE_STRING, "HW Permanent Address:");
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
r = table_add_cell_stringf(table, NULL, "%s%s%s%s",
|
||||
ether_addr_to_string(&info->permanent_mac_address, ea),
|
||||
description ? " (" : "",
|
||||
strempty(description),
|
||||
description ? ")" : "");
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
|
||||
if (info->mtu > 0) {
|
||||
@ -1332,7 +1348,7 @@ static int link_status_one(
|
||||
TABLE_EMPTY,
|
||||
TABLE_STRING, "MTU:");
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
r = table_add_cell_stringf(table, NULL, "%" PRIu32 "%s%s%s%s%s%s%s",
|
||||
info->mtu,
|
||||
info->min_mtu > 0 || info->max_mtu > 0 ? " (" : "",
|
||||
@ -1343,7 +1359,7 @@ static int link_status_one(
|
||||
info->max_mtu > 0 ? max_str : "",
|
||||
info->min_mtu > 0 || info->max_mtu > 0 ? ")" : "");
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
|
||||
if (streq_ptr(info->netdev_kind, "bridge")) {
|
||||
@ -1370,7 +1386,7 @@ static int link_status_one(
|
||||
TABLE_STRING, "Multicast IGMP Version:",
|
||||
TABLE_UINT8, info->mcast_igmp_version);
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
|
||||
} else if (streq_ptr(info->netdev_kind, "vxlan")) {
|
||||
if (info->vxlan_info.vni > 0) {
|
||||
@ -1379,7 +1395,7 @@ static int link_status_one(
|
||||
TABLE_STRING, "VNI:",
|
||||
TABLE_UINT32, info->vxlan_info.vni);
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
|
||||
if (IN_SET(info->vxlan_info.group_family, AF_INET, AF_INET6)) {
|
||||
@ -1389,7 +1405,7 @@ static int link_status_one(
|
||||
info->vxlan_info.group_family == AF_INET ? TABLE_IN_ADDR : TABLE_IN6_ADDR,
|
||||
&info->vxlan_info.group);
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
|
||||
if (IN_SET(info->vxlan_info.local_family, AF_INET, AF_INET6)) {
|
||||
@ -1399,7 +1415,7 @@ static int link_status_one(
|
||||
info->vxlan_info.local_family == AF_INET ? TABLE_IN_ADDR : TABLE_IN6_ADDR,
|
||||
&info->vxlan_info.local);
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
|
||||
if (info->vxlan_info.dest_port > 0) {
|
||||
@ -1408,7 +1424,7 @@ static int link_status_one(
|
||||
TABLE_STRING, "Destination Port:",
|
||||
TABLE_UINT16, be16toh(info->vxlan_info.dest_port));
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
|
||||
if (info->vxlan_info.link > 0) {
|
||||
@ -1417,7 +1433,7 @@ static int link_status_one(
|
||||
TABLE_STRING, "Underlying Device:",
|
||||
TABLE_IFINDEX, info->vxlan_info.link);
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1429,7 +1445,7 @@ static int link_status_one(
|
||||
TABLE_EMPTY,
|
||||
TABLE_STRING, "WiFi access point:");
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
|
||||
if (info->ssid)
|
||||
esc = cescape(info->ssid);
|
||||
@ -1438,7 +1454,7 @@ static int link_status_one(
|
||||
strnull(esc),
|
||||
ether_addr_to_string(&info->bssid, buf));
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
|
||||
if (info->has_bitrates) {
|
||||
@ -1448,12 +1464,12 @@ static int link_status_one(
|
||||
TABLE_EMPTY,
|
||||
TABLE_STRING, "Bit Rate (Tx/Rx):");
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
r = table_add_cell_stringf(table, NULL, "%sbps/%sbps",
|
||||
format_bytes_full(tx, sizeof tx, info->tx_bitrate, 0),
|
||||
format_bytes_full(rx, sizeof rx, info->rx_bitrate, 0));
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
|
||||
if (info->has_tx_queues || info->has_rx_queues) {
|
||||
@ -1461,10 +1477,10 @@ static int link_status_one(
|
||||
TABLE_EMPTY,
|
||||
TABLE_STRING, "Queue Length (Tx/Rx):");
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
r = table_add_cell_stringf(table, NULL, "%" PRIu32 "/%" PRIu32, info->tx_queues, info->rx_queues);
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
|
||||
if (info->has_ethtool_link_info) {
|
||||
@ -1477,7 +1493,7 @@ static int link_status_one(
|
||||
TABLE_STRING, "Auto negotiation:",
|
||||
TABLE_BOOLEAN, info->autonegotiation == AUTONEG_ENABLE);
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
|
||||
if (info->speed > 0) {
|
||||
@ -1486,7 +1502,7 @@ static int link_status_one(
|
||||
TABLE_STRING, "Speed:",
|
||||
TABLE_BPS, (uint64_t) info->speed);
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
|
||||
if (duplex) {
|
||||
@ -1495,7 +1511,7 @@ static int link_status_one(
|
||||
TABLE_STRING, "Duplex:",
|
||||
TABLE_STRING, duplex);
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
|
||||
if (port) {
|
||||
@ -1504,7 +1520,7 @@ static int link_status_one(
|
||||
TABLE_STRING, "Port:",
|
||||
TABLE_STRING, port);
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1540,7 +1556,7 @@ static int link_status_one(
|
||||
TABLE_STRING, "Time Zone:",
|
||||
TABLE_STRING, tz);
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
|
||||
r = dump_lldp_neighbors(table, "Connected To:", info->ifindex);
|
||||
@ -1553,7 +1569,7 @@ static int link_status_one(
|
||||
|
||||
r = table_print(table, NULL);
|
||||
if (r < 0)
|
||||
return r;
|
||||
return log_error_errno(r, "Failed to print table: %m");
|
||||
|
||||
return show_logs(info);
|
||||
}
|
||||
@ -1573,7 +1589,10 @@ static int system_status(sd_netlink *rtnl, sd_hwdb *hwdb) {
|
||||
|
||||
table = table_new("dot", "key", "value");
|
||||
if (!table)
|
||||
return -ENOMEM;
|
||||
return log_oom();
|
||||
|
||||
if (arg_full)
|
||||
table_set_width(table, 0);
|
||||
|
||||
assert_se(cell = table_get_cell(table, 0, 0));
|
||||
(void) table_set_ellipsize_percent(table, cell, 100);
|
||||
@ -1590,6 +1609,8 @@ static int system_status(sd_netlink *rtnl, sd_hwdb *hwdb) {
|
||||
TABLE_STRING, "State:",
|
||||
TABLE_STRING, strna(operational_state),
|
||||
TABLE_SET_COLOR, on_color_operational);
|
||||
if (r < 0)
|
||||
return table_log_add_error(r);
|
||||
|
||||
r = dump_addresses(rtnl, table, 0);
|
||||
if (r < 0)
|
||||
@ -1620,7 +1641,7 @@ static int system_status(sd_netlink *rtnl, sd_hwdb *hwdb) {
|
||||
|
||||
r = table_print(table, NULL);
|
||||
if (r < 0)
|
||||
return r;
|
||||
return log_error_errno(r, "Failed to print table: %m");
|
||||
|
||||
return show_logs(NULL);
|
||||
}
|
||||
@ -1740,7 +1761,10 @@ static int link_lldp_status(int argc, char *argv[], void *userdata) {
|
||||
"port id",
|
||||
"port description");
|
||||
if (!table)
|
||||
return -ENOMEM;
|
||||
return log_oom();
|
||||
|
||||
if (arg_full)
|
||||
table_set_width(table, 0);
|
||||
|
||||
table_set_header(table, arg_legend);
|
||||
|
||||
@ -1829,7 +1853,7 @@ static int link_lldp_status(int argc, char *argv[], void *userdata) {
|
||||
TABLE_STRING, strna(port_id),
|
||||
TABLE_STRING, strna(port_description));
|
||||
if (r < 0)
|
||||
return r;
|
||||
return table_log_add_error(r);
|
||||
|
||||
m++;
|
||||
}
|
||||
@ -1837,7 +1861,7 @@ static int link_lldp_status(int argc, char *argv[], void *userdata) {
|
||||
|
||||
r = table_print(table, NULL);
|
||||
if (r < 0)
|
||||
return r;
|
||||
return log_error_errno(r, "Failed to print table: %m");
|
||||
|
||||
if (arg_legend) {
|
||||
lldp_capabilities_legend(all);
|
||||
|
@ -511,8 +511,6 @@ static int list_images(int argc, char *argv[], void *userdata) {
|
||||
for (;;) {
|
||||
const char *name, *type, *state;
|
||||
uint64_t crtime, mtime, usage;
|
||||
TableCell *cell;
|
||||
bool ro_bool;
|
||||
int ro_int;
|
||||
|
||||
r = sd_bus_message_read(reply, "(ssbtttso)", &name, &type, &ro_int, &crtime, &mtime, &usage, &state, NULL);
|
||||
@ -523,37 +521,16 @@ static int list_images(int argc, char *argv[], void *userdata) {
|
||||
|
||||
r = table_add_many(table,
|
||||
TABLE_STRING, name,
|
||||
TABLE_STRING, type);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add row to table: %m");
|
||||
|
||||
ro_bool = ro_int;
|
||||
r = table_add_cell(table, &cell, TABLE_BOOLEAN, &ro_bool);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add row to table: %m");
|
||||
|
||||
if (ro_bool) {
|
||||
r = table_set_color(table, cell, ansi_highlight_red());
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to set table cell color: %m");
|
||||
}
|
||||
|
||||
r = table_add_many(table,
|
||||
TABLE_STRING, type,
|
||||
TABLE_BOOLEAN, ro_int,
|
||||
TABLE_SET_COLOR, ro_int ? ansi_highlight_red() : NULL,
|
||||
TABLE_TIMESTAMP, crtime,
|
||||
TABLE_TIMESTAMP, mtime,
|
||||
TABLE_SIZE, usage);
|
||||
TABLE_SIZE, usage,
|
||||
TABLE_STRING, state,
|
||||
TABLE_SET_COLOR, !streq(state, "detached") ? ansi_highlight_green() : NULL);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add row to table: %m");
|
||||
|
||||
r = table_add_cell(table, &cell, TABLE_STRING, state);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add row to table: %m");
|
||||
|
||||
if (!streq(state, "detached")) {
|
||||
r = table_set_color(table, cell, ansi_highlight_green());
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to set table cell color: %m");
|
||||
}
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
|
||||
r = sd_bus_message_exit_container(reply);
|
||||
|
@ -118,3 +118,6 @@ const void *table_get_at(Table *t, size_t row, size_t column);
|
||||
|
||||
int table_to_json(Table *t, JsonVariant **ret);
|
||||
int table_print_json(Table *t, FILE *f, JsonFormatFlags json_flags);
|
||||
|
||||
#define table_log_add_error(r) \
|
||||
log_error_errno(r, "Failed to add cell(s) to table: %m")
|
||||
|
@ -100,7 +100,7 @@ static int print_status_info(const StatusInfo *i) {
|
||||
TABLE_STRING, "Local time:",
|
||||
TABLE_STRING, have_time && n > 0 ? a : "n/a");
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add cell(s): %m");
|
||||
return table_log_add_error(r);
|
||||
|
||||
if (have_time)
|
||||
n = strftime(a, sizeof a, "%a %Y-%m-%d %H:%M:%S UTC", gmtime_r(&sec, &tm));
|
||||
@ -109,7 +109,7 @@ static int print_status_info(const StatusInfo *i) {
|
||||
TABLE_STRING, "Universal time:",
|
||||
TABLE_STRING, have_time && n > 0 ? a : "n/a");
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add cell(s): %m");
|
||||
return table_log_add_error(r);
|
||||
|
||||
if (i->rtc_time > 0) {
|
||||
time_t rtc_sec;
|
||||
@ -122,18 +122,18 @@ static int print_status_info(const StatusInfo *i) {
|
||||
TABLE_STRING, "RTC time:",
|
||||
TABLE_STRING, i->rtc_time > 0 && n > 0 ? a : "n/a");
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add cell(s): %m");
|
||||
return table_log_add_error(r);
|
||||
|
||||
if (have_time)
|
||||
n = strftime(a, sizeof a, "%Z, %z", localtime_r(&sec, &tm));
|
||||
|
||||
r = table_add_cell(table, NULL, TABLE_STRING, "Time zone:");
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add cell(s): %m");
|
||||
return table_log_add_error(r);
|
||||
|
||||
r = table_add_cell_stringf(table, NULL, "%s (%s)", strna(i->timezone), have_time && n > 0 ? a : "n/a");
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add cell(s): %m");
|
||||
return table_log_add_error(r);
|
||||
|
||||
|
||||
/* Restore the $TZ */
|
||||
@ -154,7 +154,7 @@ static int print_status_info(const StatusInfo *i) {
|
||||
TABLE_STRING, "RTC in local TZ:",
|
||||
TABLE_BOOLEAN, i->rtc_local);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add cell(s): %m");
|
||||
return table_log_add_error(r);
|
||||
|
||||
r = table_print(table, NULL);
|
||||
if (r < 0)
|
||||
@ -429,29 +429,29 @@ static int print_ntp_status_info(NTPStatusInfo *i) {
|
||||
|
||||
r = table_add_cell(table, NULL, TABLE_STRING, "Server:");
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add cell(s): %m");
|
||||
return table_log_add_error(r);
|
||||
|
||||
r = table_add_cell_stringf(table, NULL, "%s (%s)", i->server_address, i->server_name);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add cell(s): %m");
|
||||
return table_log_add_error(r);
|
||||
|
||||
r = table_add_cell(table, NULL, TABLE_STRING, "Poll interval:");
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add cell(s): %m");
|
||||
return table_log_add_error(r);
|
||||
|
||||
r = table_add_cell_stringf(table, NULL, "%s (min: %s; max %s)",
|
||||
format_timespan(ts, sizeof(ts), i->poll_interval, 0),
|
||||
format_timespan(tmin, sizeof(tmin), i->poll_min, 0),
|
||||
format_timespan(tmax, sizeof(tmax), i->poll_max, 0));
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add cell(s): %m");
|
||||
return table_log_add_error(r);
|
||||
|
||||
if (i->packet_count == 0) {
|
||||
r = table_add_many(table,
|
||||
TABLE_STRING, "Packet count:",
|
||||
TABLE_STRING, "0");
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add cell(s): %m");
|
||||
return table_log_add_error(r);
|
||||
|
||||
r = table_print(table, NULL);
|
||||
if (r < 0)
|
||||
@ -487,44 +487,44 @@ static int print_ntp_status_info(NTPStatusInfo *i) {
|
||||
TABLE_UINT32, i->stratum,
|
||||
TABLE_STRING, "Reference:");
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add cell(s): %m");
|
||||
return table_log_add_error(r);
|
||||
|
||||
if (i->stratum <= 1)
|
||||
r = table_add_cell(table, NULL, TABLE_STRING, i->reference.str);
|
||||
else
|
||||
r = table_add_cell_stringf(table, NULL, "%" PRIX32, be32toh(i->reference.val));
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add cell(s): %m");
|
||||
return table_log_add_error(r);
|
||||
|
||||
r = table_add_cell(table, NULL, TABLE_STRING, "Precision:");
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add cell(s): %m");
|
||||
return table_log_add_error(r);
|
||||
|
||||
r = table_add_cell_stringf(table, NULL, "%s (%" PRIi32 ")",
|
||||
format_timespan(ts, sizeof(ts), DIV_ROUND_UP((nsec_t) (exp2(i->precision) * NSEC_PER_SEC), NSEC_PER_USEC), 0),
|
||||
i->precision);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add cell(s): %m");
|
||||
return table_log_add_error(r);
|
||||
|
||||
r = table_add_cell(table, NULL, TABLE_STRING, "Root distance:");
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add cell(s): %m");
|
||||
return table_log_add_error(r);
|
||||
|
||||
r = table_add_cell_stringf(table, NULL, "%s (max: %s)",
|
||||
format_timespan(ts, sizeof(ts), root_distance, 0),
|
||||
format_timespan(tmax, sizeof(tmax), i->root_distance_max, 0));
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add cell(s): %m");
|
||||
return table_log_add_error(r);
|
||||
|
||||
r = table_add_cell(table, NULL, TABLE_STRING, "Offset:");
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add cell(s): %m");
|
||||
return table_log_add_error(r);
|
||||
|
||||
r = table_add_cell_stringf(table, NULL, "%s%s",
|
||||
offset_sign ? "+" : "-",
|
||||
format_timespan(ts, sizeof(ts), offset, 0));
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add cell(s): %m");
|
||||
return table_log_add_error(r);
|
||||
|
||||
r = table_add_many(table,
|
||||
TABLE_STRING, "Delay:",
|
||||
@ -534,16 +534,16 @@ static int print_ntp_status_info(NTPStatusInfo *i) {
|
||||
TABLE_STRING, "Packet count:",
|
||||
TABLE_UINT64, i->packet_count);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add cell(s): %m");
|
||||
return table_log_add_error(r);
|
||||
|
||||
if (!i->spike) {
|
||||
r = table_add_cell(table, NULL, TABLE_STRING, "Frequency:");
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add cell(s): %m");
|
||||
return table_log_add_error(r);
|
||||
|
||||
r = table_add_cell_stringf(table, NULL, "%+.3fppm", (double) i->freq / 0x10000);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add cell(s): %m");
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
|
||||
r = table_print(table, NULL);
|
||||
|
Loading…
Reference in New Issue
Block a user