Compare commits
26 Commits
0e05be8405
...
cd6cf81b3f
Author | SHA1 | Date |
---|---|---|
Lennart Poettering | cd6cf81b3f | |
Lennart Poettering | a5292dfdf7 | |
Lennart Poettering | 4504f59fbd | |
Yu Watanabe | 12845a91b5 | |
Yu Watanabe | bd17fa8cd8 | |
Yu Watanabe | 964a7745de | |
Yu Watanabe | 679c7c7a67 | |
Yu Watanabe | 9c46b437fc | |
Yu Watanabe | d8aedafb57 | |
Yu Watanabe | e2268fa437 | |
Yu Watanabe | a65e34ccb0 | |
Yu Watanabe | 2a6c483b8c | |
Yu Watanabe | b683b82fe7 | |
Yu Watanabe | 6c64cf8859 | |
Yu Watanabe | a42d949080 | |
Yu Watanabe | a362c069a9 | |
Lennart Poettering | 6fca66a7f1 | |
Lennart Poettering | af4454cb17 | |
Lennart Poettering | eb34a981d6 | |
Lennart Poettering | 6afc31615e | |
Lennart Poettering | 6d9e0ca400 | |
Lennart Poettering | b0a94268f8 | |
Lennart Poettering | c8c535d589 | |
Lennart Poettering | 9a2ec8f7a6 | |
Lennart Poettering | 3593fa60f2 | |
Lennart Poettering | 3841fee822 |
|
@ -388,6 +388,15 @@
|
||||||
<xi:include href="user-system-options.xml" xpointer="host" />
|
<xi:include href="user-system-options.xml" xpointer="host" />
|
||||||
<xi:include href="user-system-options.xml" xpointer="machine" />
|
<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-pager" />
|
||||||
<xi:include href="standard-options.xml" xpointer="no-legend" />
|
<xi:include href="standard-options.xml" xpointer="no-legend" />
|
||||||
<xi:include href="standard-options.xml" xpointer="help" />
|
<xi:include href="standard-options.xml" xpointer="help" />
|
||||||
|
|
|
@ -680,7 +680,8 @@
|
||||||
<term><option>-l</option></term>
|
<term><option>-l</option></term>
|
||||||
<term><option>--full</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>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
|
|
@ -316,7 +316,7 @@ s - Service VLAN, m - Two-port MAC Relay (TPMR)
|
||||||
<term><option>--full</option></term>
|
<term><option>--full</option></term>
|
||||||
|
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>Do not ellipsize the logs in <command>status</command> command.</para>
|
<para>Do not ellipsize the output.</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
|
|
@ -95,6 +95,15 @@
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</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-pager"/>
|
||||||
<xi:include href="standard-options.xml" xpointer="no-legend" />
|
<xi:include href="standard-options.xml" xpointer="no-legend" />
|
||||||
<xi:include href="standard-options.xml" xpointer="no-ask-password"/>
|
<xi:include href="standard-options.xml" xpointer="no-ask-password"/>
|
||||||
|
|
|
@ -25,14 +25,14 @@ __contains_word () {
|
||||||
|
|
||||||
__get_machines() {
|
__get_machines() {
|
||||||
local a b
|
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; };
|
{ while read a b; do echo " $a"; done; };
|
||||||
}
|
}
|
||||||
|
|
||||||
__get_busnames() {
|
__get_busnames() {
|
||||||
local mode=$1
|
local mode=$1
|
||||||
local a b
|
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; };
|
{ while read a b; do echo " $a"; done; };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ _busctl() {
|
||||||
--show-machine --unique --acquired --activatable --list
|
--show-machine --unique --acquired --activatable --list
|
||||||
-q --quiet --verbose --expect-reply=no --auto-start=no
|
-q --quiet --verbose --expect-reply=no --auto-start=no
|
||||||
--allow-interactive-authorization=no --augment-creds=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
|
[ARG]='--address -H --host -M --machine --match --timeout --size --json
|
||||||
--destination'
|
--destination'
|
||||||
)
|
)
|
||||||
|
|
|
@ -27,7 +27,7 @@ __contains_word () {
|
||||||
|
|
||||||
__get_machines() {
|
__get_machines() {
|
||||||
local a b
|
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;
|
{ 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() {
|
__get_machines() {
|
||||||
local a b
|
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; };
|
{ while read a b; do echo " $a"; done; };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ __contains_word() {
|
||||||
|
|
||||||
__get_machines() {
|
__get_machines() {
|
||||||
local a b
|
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;
|
{ while read a b; do echo " $a"; done; } | sort -u;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ __contains_word () {
|
||||||
}
|
}
|
||||||
|
|
||||||
__get_links() {
|
__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() {
|
_networkctl() {
|
||||||
|
|
|
@ -25,7 +25,7 @@ __contains_word () {
|
||||||
|
|
||||||
__get_machines() {
|
__get_machines() {
|
||||||
local a b
|
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; };
|
{ 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() {
|
__get_machines() {
|
||||||
local a b
|
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; }
|
{ while read a b; do echo " $a"; done; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ __contains_word () {
|
||||||
|
|
||||||
__get_machines() {
|
__get_machines() {
|
||||||
local a b
|
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() {
|
__get_services() {
|
||||||
|
|
|
@ -25,7 +25,7 @@ __contains_word() {
|
||||||
|
|
||||||
__get_machines() {
|
__get_machines() {
|
||||||
local a b
|
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() {
|
__get_units_have_cgroup() {
|
||||||
|
|
|
@ -25,7 +25,7 @@ __contains_word() {
|
||||||
|
|
||||||
__get_machines() {
|
__get_machines() {
|
||||||
local a b
|
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() {
|
_systemd_cgtop() {
|
||||||
|
|
|
@ -35,7 +35,7 @@ __get_slices() {
|
||||||
|
|
||||||
__get_machines() {
|
__get_machines() {
|
||||||
local a b
|
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() {
|
__get_env() {
|
||||||
|
|
|
@ -26,7 +26,7 @@ __get_slice_units () { __systemctl $1 list-units --all -t slice \
|
||||||
|
|
||||||
__get_machines() {
|
__get_machines() {
|
||||||
local a b
|
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() {
|
_systemd_run() {
|
||||||
|
|
|
@ -27,7 +27,7 @@ __contains_word () {
|
||||||
|
|
||||||
__get_machines() {
|
__get_machines() {
|
||||||
local a b
|
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(){
|
__get_interfaces(){
|
||||||
|
|
|
@ -1484,7 +1484,6 @@ static int assess(const struct security_info *info, Table *overview_table, Analy
|
||||||
|
|
||||||
if (details_table) {
|
if (details_table) {
|
||||||
const char *checkmark, *description, *color = NULL;
|
const char *checkmark, *description, *color = NULL;
|
||||||
TableCell *cell;
|
|
||||||
|
|
||||||
if (badness == UINT64_MAX) {
|
if (badness == UINT64_MAX) {
|
||||||
checkmark = " ";
|
checkmark = " ";
|
||||||
|
@ -1507,13 +1506,12 @@ static int assess(const struct security_info *info, Table *overview_table, Analy
|
||||||
if (d)
|
if (d)
|
||||||
description = 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,
|
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, a->id, TABLE_SET_URL, a->url,
|
||||||
TABLE_STRING, description,
|
TABLE_STRING, description,
|
||||||
TABLE_UINT64, a->weight, TABLE_SET_ALIGN_PERCENT, 100,
|
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_UINT64, a->range, TABLE_SET_ALIGN_PERCENT, 100,
|
||||||
TABLE_EMPTY, TABLE_SET_ALIGN_PERCENT, 100);
|
TABLE_EMPTY, TABLE_SET_ALIGN_PERCENT, 100);
|
||||||
if (r < 0)
|
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) {
|
if (overview_table) {
|
||||||
char buf[DECIMAL_STR_MAX(uint64_t) + 1 + DECIMAL_STR_MAX(uint64_t) + 1];
|
char buf[DECIMAL_STR_MAX(uint64_t) + 1 + DECIMAL_STR_MAX(uint64_t) + 1];
|
||||||
TableCell *cell;
|
|
||||||
|
|
||||||
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;
|
_cleanup_free_ char *url = NULL;
|
||||||
|
|
||||||
|
if (info->fragment_path) {
|
||||||
r = file_url_from_path(info->fragment_path, &url);
|
r = file_url_from_path(info->fragment_path, &url);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Failed to generate URL from path: %m");
|
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);
|
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)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Failed to add cell to table: %m");
|
return table_log_add_error(r);
|
||||||
(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 0;
|
return 0;
|
||||||
|
|
|
@ -1113,13 +1113,11 @@ static int analyze_blame(int argc, char *argv[], void *userdata) {
|
||||||
if (u->time <= 0)
|
if (u->time <= 0)
|
||||||
continue;
|
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)
|
if (r < 0)
|
||||||
return r;
|
return table_log_add_error(r);
|
||||||
|
|
||||||
r = table_add_cell(table, NULL, TABLE_STRING, u->name);
|
|
||||||
if (r < 0)
|
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
(void) pager_open(arg_pager_flags);
|
(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_INT, (int) i,
|
||||||
TABLE_STRING, exit_status_class(i));
|
TABLE_STRING, exit_status_class(i));
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return table_log_add_error(r);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
for (int i = 1; i < argc; i++) {
|
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_INT, status,
|
||||||
TABLE_STRING, exit_status_class(status) ?: "-");
|
TABLE_STRING, exit_status_class(status) ?: "-");
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return table_log_add_error(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
(void) pager_open(arg_pager_flags);
|
(void) pager_open(arg_pager_flags);
|
||||||
|
@ -1853,33 +1851,23 @@ static int dump_timespan(int argc, char *argv[], void *userdata) {
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
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)
|
if (r < 0)
|
||||||
return r;
|
return table_log_add_error(r);
|
||||||
|
|
||||||
r = table_add_cell(table, NULL, TABLE_STRING, *input_timespan);
|
|
||||||
if (r < 0)
|
|
||||||
return r;
|
|
||||||
|
|
||||||
r = table_add_cell_stringf(table, NULL, "%ss:", special_glyph(SPECIAL_GLYPH_MU));
|
r = table_add_cell_stringf(table, NULL, "%ss:", special_glyph(SPECIAL_GLYPH_MU));
|
||||||
if (r < 0)
|
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)
|
if (r < 0)
|
||||||
return r;
|
return table_log_add_error(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;
|
|
||||||
|
|
||||||
r = table_print(table, NULL);
|
r = table_print(table, NULL);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
|
@ -1925,57 +1913,42 @@ static int test_timestamp_one(const char *p) {
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
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)
|
if (r < 0)
|
||||||
return r;
|
return table_log_add_error(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;
|
|
||||||
|
|
||||||
if (!in_utc_timezone()) {
|
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)
|
if (r < 0)
|
||||||
return r;
|
return table_log_add_error(r);
|
||||||
|
|
||||||
r = table_add_cell(table, &cell, TABLE_TIMESTAMP_UTC, &usec);
|
|
||||||
if (r < 0)
|
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
r = table_add_cell(table, NULL, TABLE_STRING, "UNIX seconds:");
|
r = table_add_cell(table, NULL, TABLE_STRING, "UNIX seconds:");
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return table_log_add_error(r);
|
||||||
|
|
||||||
if (usec % USEC_PER_SEC == 0)
|
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);
|
usec / USEC_PER_SEC);
|
||||||
else
|
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,
|
||||||
usec % USEC_PER_SEC);
|
usec % USEC_PER_SEC);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
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)
|
if (r < 0)
|
||||||
return r;
|
return table_log_add_error(r);
|
||||||
|
|
||||||
r = table_add_cell(table, &cell, TABLE_TIMESTAMP_RELATIVE, &usec);
|
|
||||||
if (r < 0)
|
|
||||||
return r;
|
|
||||||
|
|
||||||
return table_print(table, NULL);
|
return table_print(table, NULL);
|
||||||
}
|
}
|
||||||
|
@ -2035,22 +2008,18 @@ static int test_calendar_one(usec_t n, const char *p) {
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
if (!streq(t, p)) {
|
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)
|
if (r < 0)
|
||||||
return r;
|
return table_log_add_error(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:");
|
r = table_add_many(table,
|
||||||
|
TABLE_STRING, "Normalized form:",
|
||||||
|
TABLE_STRING, t);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return table_log_add_error(r);
|
||||||
|
|
||||||
r = table_add_cell(table, NULL, TABLE_STRING, t);
|
|
||||||
if (r < 0)
|
|
||||||
return r;
|
|
||||||
|
|
||||||
for (unsigned i = 0; i < arg_iterations; i++) {
|
for (unsigned i = 0; i < arg_iterations; i++) {
|
||||||
usec_t next;
|
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);
|
r = calendar_spec_next_usec(spec, n, &next);
|
||||||
if (r == -ENOENT) {
|
if (r == -ENOENT) {
|
||||||
if (i == 0) {
|
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)
|
if (r < 0)
|
||||||
return r;
|
return table_log_add_error(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;
|
|
||||||
}
|
}
|
||||||
break;
|
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);
|
return log_error_errno(r, "Failed to determine next elapse for '%s': %m", p);
|
||||||
|
|
||||||
if (i == 0) {
|
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)
|
if (r < 0)
|
||||||
return r;
|
return table_log_add_error(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;
|
|
||||||
} else {
|
} else {
|
||||||
int k = DECIMAL_STR_WIDTH(i + 1);
|
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);
|
r = table_add_cell_stringf(table, NULL, "Iter. #%u:", i+1);
|
||||||
if (r < 0)
|
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)
|
if (r < 0)
|
||||||
return r;
|
return table_log_add_error(r);
|
||||||
|
|
||||||
r = table_set_color(table, cell, ansi_highlight_blue());
|
|
||||||
if (r < 0)
|
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!in_utc_timezone()) {
|
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)
|
if (r < 0)
|
||||||
return r;
|
return table_log_add_error(r);
|
||||||
|
|
||||||
r = table_add_cell(table, NULL, TABLE_TIMESTAMP_UTC, &next);
|
|
||||||
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, &next);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return table_log_add_error(r);
|
||||||
|
|
||||||
r = table_add_cell(table, NULL, TABLE_TIMESTAMP_RELATIVE, &next);
|
|
||||||
if (r < 0)
|
|
||||||
return r;
|
|
||||||
|
|
||||||
n = next;
|
n = next;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1115,3 +1115,13 @@ bool empty_or_root(const char *root) {
|
||||||
|
|
||||||
return root[strspn(root, "/")] == 0;
|
return root[strspn(root, "/")] == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool path_strv_contains(char **l, const char *path) {
|
||||||
|
char **i;
|
||||||
|
|
||||||
|
STRV_FOREACH(i, l)
|
||||||
|
if (path_equal(*i, path))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
|
@ -71,17 +71,7 @@ static inline bool path_equal_ptr(const char *a, const char *b) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Note: the search terminates on the first NULL item. */
|
/* Note: the search terminates on the first NULL item. */
|
||||||
#define PATH_IN_SET(p, ...) \
|
#define PATH_IN_SET(p, ...) path_strv_contains(STRV_MAKE(__VA_ARGS__), p)
|
||||||
({ \
|
|
||||||
char **_s; \
|
|
||||||
bool _found = false; \
|
|
||||||
STRV_FOREACH(_s, STRV_MAKE(__VA_ARGS__)) \
|
|
||||||
if (path_equal(p, *_s)) { \
|
|
||||||
_found = true; \
|
|
||||||
break; \
|
|
||||||
} \
|
|
||||||
_found; \
|
|
||||||
})
|
|
||||||
|
|
||||||
char* path_startswith_strv(const char *p, char **set);
|
char* path_startswith_strv(const char *p, char **set);
|
||||||
#define PATH_STARTSWITH_SET(p, ...) path_startswith_strv(p, STRV_MAKE(__VA_ARGS__))
|
#define PATH_STARTSWITH_SET(p, ...) path_startswith_strv(p, STRV_MAKE(__VA_ARGS__))
|
||||||
|
@ -181,3 +171,5 @@ bool empty_or_root(const char *root);
|
||||||
static inline const char *empty_to_root(const char *path) {
|
static inline const char *empty_to_root(const char *path) {
|
||||||
return isempty(path) ? "/" : path;
|
return isempty(path) ? "/" : path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool path_strv_contains(char **l, const char *path);
|
||||||
|
|
|
@ -38,6 +38,7 @@ static enum {
|
||||||
} arg_json = JSON_OFF;
|
} arg_json = JSON_OFF;
|
||||||
static PagerFlags arg_pager_flags = 0;
|
static PagerFlags arg_pager_flags = 0;
|
||||||
static bool arg_legend = true;
|
static bool arg_legend = true;
|
||||||
|
static bool arg_full = false;
|
||||||
static const char *arg_address = NULL;
|
static const char *arg_address = NULL;
|
||||||
static bool arg_unique = false;
|
static bool arg_unique = false;
|
||||||
static bool arg_acquired = false;
|
static bool arg_acquired = false;
|
||||||
|
@ -195,6 +196,9 @@ static int list_bus_names(int argc, char **argv, void *userdata) {
|
||||||
if (!table)
|
if (!table)
|
||||||
return log_oom();
|
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);
|
r = table_set_align_percent(table, table_get_cell(table, 0, COLUMN_PID), 100);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Failed to set alignment: %m");
|
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,
|
||||||
TABLE_EMPTY);
|
TABLE_EMPTY);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Failed to fill line: %m");
|
return table_log_add_error(r);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -250,7 +254,7 @@ static int list_bus_names(int argc, char **argv, void *userdata) {
|
||||||
TABLE_INT, PTR_TO_INT(v),
|
TABLE_INT, PTR_TO_INT(v),
|
||||||
TABLE_STRING, k);
|
TABLE_STRING, k);
|
||||||
if (r < 0)
|
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(
|
r = sd_bus_get_name_creds(
|
||||||
bus, k,
|
bus, k,
|
||||||
|
@ -279,7 +283,7 @@ static int list_bus_names(int argc, char **argv, void *userdata) {
|
||||||
} else
|
} else
|
||||||
r = table_add_many(table, TABLE_EMPTY, TABLE_EMPTY);
|
r = table_add_many(table, TABLE_EMPTY, TABLE_EMPTY);
|
||||||
if (r < 0)
|
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);
|
r = sd_bus_creds_get_euid(creds, &uid);
|
||||||
if (r >= 0) {
|
if (r >= 0) {
|
||||||
|
@ -293,7 +297,7 @@ static int list_bus_names(int argc, char **argv, void *userdata) {
|
||||||
} else
|
} else
|
||||||
r = table_add_cell(table, NULL, TABLE_EMPTY, NULL);
|
r = table_add_cell(table, NULL, TABLE_EMPTY, NULL);
|
||||||
if (r < 0)
|
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_unique_name(creds, &unique);
|
||||||
(void) sd_bus_creds_get_unit(creds, &unit);
|
(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);
|
TABLE_STRING, cn);
|
||||||
}
|
}
|
||||||
if (r < 0)
|
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) {
|
if (arg_show_machine) {
|
||||||
sd_id128_t mid;
|
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));
|
r = table_add_cell(table, NULL, TABLE_STRING, sd_id128_to_string(mid, m));
|
||||||
if (r < 0)
|
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 */
|
continue; /* line fully filled, no need to fill the remainder below */
|
||||||
}
|
}
|
||||||
|
@ -2251,6 +2255,7 @@ static int help(void) {
|
||||||
" --version Show package version\n"
|
" --version Show package version\n"
|
||||||
" --no-pager Do not pipe output into a pager\n"
|
" --no-pager Do not pipe output into a pager\n"
|
||||||
" --no-legend Do not show the headers and footers\n"
|
" --no-legend Do not show the headers and footers\n"
|
||||||
|
" -l --full Do not ellipsize output\n"
|
||||||
" --system Connect to system bus\n"
|
" --system Connect to system bus\n"
|
||||||
" --user Connect to user bus\n"
|
" --user Connect to user bus\n"
|
||||||
" -H --host=[USER@]HOST Operate on remote host\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 },
|
{ "version", no_argument, NULL, ARG_VERSION },
|
||||||
{ "no-pager", no_argument, NULL, ARG_NO_PAGER },
|
{ "no-pager", no_argument, NULL, ARG_NO_PAGER },
|
||||||
{ "no-legend", no_argument, NULL, ARG_NO_LEGEND },
|
{ "no-legend", no_argument, NULL, ARG_NO_LEGEND },
|
||||||
|
{ "full", no_argument, NULL, 'l' },
|
||||||
{ "system", no_argument, NULL, ARG_SYSTEM },
|
{ "system", no_argument, NULL, ARG_SYSTEM },
|
||||||
{ "user", no_argument, NULL, ARG_USER },
|
{ "user", no_argument, NULL, ARG_USER },
|
||||||
{ "address", required_argument, NULL, ARG_ADDRESS },
|
{ "address", required_argument, NULL, ARG_ADDRESS },
|
||||||
|
@ -2372,6 +2378,10 @@ static int parse_argv(int argc, char *argv[]) {
|
||||||
arg_legend = false;
|
arg_legend = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'l':
|
||||||
|
arg_full = true;
|
||||||
|
break;
|
||||||
|
|
||||||
case ARG_USER:
|
case ARG_USER:
|
||||||
arg_user = true;
|
arg_user = true;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -12,16 +12,23 @@
|
||||||
#include "unit.h"
|
#include "unit.h"
|
||||||
|
|
||||||
static int swap_get_priority(Swap *s) {
|
static int swap_get_priority(Swap *s) {
|
||||||
if (s->from_proc_swaps)
|
assert(s);
|
||||||
|
|
||||||
|
if (s->from_proc_swaps && s->parameters_proc_swaps.priority_set)
|
||||||
return s->parameters_proc_swaps.priority;
|
return s->parameters_proc_swaps.priority;
|
||||||
if (s->from_fragment)
|
|
||||||
|
if (s->from_fragment && s->parameters_fragment.priority_set)
|
||||||
return s->parameters_fragment.priority;
|
return s->parameters_fragment.priority;
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *swap_get_options(Swap *s) {
|
static const char *swap_get_options(Swap *s) {
|
||||||
|
assert(s);
|
||||||
|
|
||||||
if (s->from_fragment)
|
if (s->from_fragment)
|
||||||
return s->parameters_fragment.options;
|
return s->parameters_fragment.options;
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -435,7 +435,7 @@ Automount.DirectoryMode, config_parse_mode, 0,
|
||||||
Automount.TimeoutIdleSec, config_parse_sec_fix_0, 0, offsetof(Automount, timeout_idle_usec)
|
Automount.TimeoutIdleSec, config_parse_sec_fix_0, 0, offsetof(Automount, timeout_idle_usec)
|
||||||
m4_dnl
|
m4_dnl
|
||||||
Swap.What, config_parse_unit_path_printf, 0, offsetof(Swap, parameters_fragment.what)
|
Swap.What, config_parse_unit_path_printf, 0, offsetof(Swap, parameters_fragment.what)
|
||||||
Swap.Priority, config_parse_int, 0, offsetof(Swap, parameters_fragment.priority)
|
Swap.Priority, config_parse_swap_priority, 0, 0
|
||||||
Swap.Options, config_parse_unit_string_printf, 0, offsetof(Swap, parameters_fragment.options)
|
Swap.Options, config_parse_unit_string_printf, 0, offsetof(Swap, parameters_fragment.options)
|
||||||
Swap.TimeoutSec, config_parse_sec_fix_0, 0, offsetof(Swap, timeout_usec)
|
Swap.TimeoutSec, config_parse_sec_fix_0, 0, offsetof(Swap, timeout_usec)
|
||||||
EXEC_CONTEXT_CONFIG_ITEMS(Swap)m4_dnl
|
EXEC_CONTEXT_CONFIG_ITEMS(Swap)m4_dnl
|
||||||
|
|
|
@ -5002,3 +5002,51 @@ int config_parse_crash_chvt(
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int config_parse_swap_priority(
|
||||||
|
const char *unit,
|
||||||
|
const char *filename,
|
||||||
|
unsigned line,
|
||||||
|
const char *section,
|
||||||
|
unsigned section_line,
|
||||||
|
const char *lvalue,
|
||||||
|
int ltype,
|
||||||
|
const char *rvalue,
|
||||||
|
void *data,
|
||||||
|
void *userdata) {
|
||||||
|
|
||||||
|
Swap *s = userdata;
|
||||||
|
int r, priority;
|
||||||
|
|
||||||
|
assert(s);
|
||||||
|
assert(filename);
|
||||||
|
assert(lvalue);
|
||||||
|
assert(rvalue);
|
||||||
|
assert(data);
|
||||||
|
|
||||||
|
if (isempty(rvalue)) {
|
||||||
|
s->parameters_fragment.priority = -1;
|
||||||
|
s->parameters_fragment.priority_set = false;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
r = safe_atoi(rvalue, &priority);
|
||||||
|
if (r < 0) {
|
||||||
|
log_syntax(unit, LOG_ERR, filename, line, r, "Invalid swap pririty '%s', ignoring.", rvalue);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (priority < -1) {
|
||||||
|
log_syntax(unit, LOG_ERR, filename, line, 0, "Sorry, swap priorities smaller than -1 may only be assigned by the kernel itself, ignoring: %s", rvalue);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (priority > 32767) {
|
||||||
|
log_syntax(unit, LOG_ERR, filename, line, 0, "Swap priority out of range, ignoring: %s", rvalue);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
s->parameters_fragment.priority = priority;
|
||||||
|
s->parameters_fragment.priority_set = true;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -121,6 +121,7 @@ CONFIG_PARSER_PROTOTYPE(config_parse_status_unit_format);
|
||||||
CONFIG_PARSER_PROTOTYPE(config_parse_output_restricted);
|
CONFIG_PARSER_PROTOTYPE(config_parse_output_restricted);
|
||||||
CONFIG_PARSER_PROTOTYPE(config_parse_crash_chvt);
|
CONFIG_PARSER_PROTOTYPE(config_parse_crash_chvt);
|
||||||
CONFIG_PARSER_PROTOTYPE(config_parse_timeout_abort);
|
CONFIG_PARSER_PROTOTYPE(config_parse_timeout_abort);
|
||||||
|
CONFIG_PARSER_PROTOTYPE(config_parse_swap_priority);
|
||||||
|
|
||||||
/* gperf prototypes */
|
/* gperf prototypes */
|
||||||
const struct ConfigPerfItem* load_fragment_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
|
const struct ConfigPerfItem* load_fragment_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
|
||||||
|
|
|
@ -1190,6 +1190,57 @@ static void normalize_mounts(const char *root_directory, MountEntry *mounts, siz
|
||||||
drop_nop(mounts, n_mounts);
|
drop_nop(mounts, n_mounts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool root_read_only(
|
||||||
|
char **read_only_paths,
|
||||||
|
ProtectSystem protect_system) {
|
||||||
|
|
||||||
|
/* Determine whether the root directory is going to be read-only given the configured settings. */
|
||||||
|
|
||||||
|
if (protect_system == PROTECT_SYSTEM_STRICT)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (path_strv_contains(read_only_paths, "/"))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool home_read_only(
|
||||||
|
char** read_only_paths,
|
||||||
|
char** inaccessible_paths,
|
||||||
|
char** empty_directories,
|
||||||
|
const BindMount *bind_mounts,
|
||||||
|
size_t n_bind_mounts,
|
||||||
|
const TemporaryFileSystem *temporary_filesystems,
|
||||||
|
size_t n_temporary_filesystems,
|
||||||
|
ProtectHome protect_home) {
|
||||||
|
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
/* Determine whether the /home directory is going to be read-only given the configured settings. Yes,
|
||||||
|
* this is a bit sloppy, since we don't bother checking for cases where / is affected by multiple
|
||||||
|
* settings. */
|
||||||
|
|
||||||
|
if (protect_home != PROTECT_HOME_NO)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (path_strv_contains(read_only_paths, "/home") ||
|
||||||
|
path_strv_contains(inaccessible_paths, "/home") ||
|
||||||
|
path_strv_contains(empty_directories, "/home"))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
for (i = 0; i < n_temporary_filesystems; i++)
|
||||||
|
if (path_equal(temporary_filesystems[i].path, "/home"))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
/* If /home is overmounted with some dir from the host it's not writable. */
|
||||||
|
for (i = 0; i < n_bind_mounts; i++)
|
||||||
|
if (path_equal(bind_mounts[i].destination, "/home"))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
int setup_namespace(
|
int setup_namespace(
|
||||||
const char* root_directory,
|
const char* root_directory,
|
||||||
const char* root_image,
|
const char* root_image,
|
||||||
|
@ -1228,13 +1279,17 @@ int setup_namespace(
|
||||||
if (root_image) {
|
if (root_image) {
|
||||||
dissect_image_flags |= DISSECT_IMAGE_REQUIRE_ROOT;
|
dissect_image_flags |= DISSECT_IMAGE_REQUIRE_ROOT;
|
||||||
|
|
||||||
if (protect_system == PROTECT_SYSTEM_STRICT &&
|
/* Make the whole image read-only if we can determine that we only access it in a read-only fashion. */
|
||||||
protect_home != PROTECT_HOME_NO &&
|
if (root_read_only(read_only_paths,
|
||||||
|
protect_system) &&
|
||||||
|
home_read_only(read_only_paths, inaccessible_paths, empty_directories,
|
||||||
|
bind_mounts, n_bind_mounts, temporary_filesystems, n_temporary_filesystems,
|
||||||
|
protect_home) &&
|
||||||
strv_isempty(read_write_paths))
|
strv_isempty(read_write_paths))
|
||||||
dissect_image_flags |= DISSECT_IMAGE_READ_ONLY;
|
dissect_image_flags |= DISSECT_IMAGE_READ_ONLY;
|
||||||
|
|
||||||
r = loop_device_make_by_path(root_image,
|
r = loop_device_make_by_path(root_image,
|
||||||
dissect_image_flags & DISSECT_IMAGE_READ_ONLY ? O_RDONLY : O_RDWR,
|
FLAGS_SET(dissect_image_flags, DISSECT_IMAGE_READ_ONLY) ? O_RDONLY : -1 /* < 0 means writable if possible, read-only as fallback */,
|
||||||
LO_FLAGS_PARTSCAN,
|
LO_FLAGS_PARTSCAN,
|
||||||
&loop_device);
|
&loop_device);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
|
|
|
@ -63,7 +63,6 @@ static void swap_unset_proc_swaps(Swap *s) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
s->parameters_proc_swaps.what = mfree(s->parameters_proc_swaps.what);
|
s->parameters_proc_swaps.what = mfree(s->parameters_proc_swaps.what);
|
||||||
|
|
||||||
s->from_proc_swaps = false;
|
s->from_proc_swaps = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,9 +116,6 @@ static void swap_init(Unit *u) {
|
||||||
s->exec_context.std_output = u->manager->default_std_output;
|
s->exec_context.std_output = u->manager->default_std_output;
|
||||||
s->exec_context.std_error = u->manager->default_std_error;
|
s->exec_context.std_error = u->manager->default_std_error;
|
||||||
|
|
||||||
s->parameters_proc_swaps.priority = s->parameters_fragment.priority = 0;
|
|
||||||
s->parameters_fragment.priority_set = false;
|
|
||||||
|
|
||||||
s->control_command_id = _SWAP_EXEC_COMMAND_INVALID;
|
s->control_command_id = _SWAP_EXEC_COMMAND_INVALID;
|
||||||
|
|
||||||
u->ignore_on_isolate = true;
|
u->ignore_on_isolate = true;
|
||||||
|
@ -772,19 +768,21 @@ static void swap_enter_activating(Swap *s) {
|
||||||
|
|
||||||
r = fstab_find_pri(s->parameters_fragment.options, &priority);
|
r = fstab_find_pri(s->parameters_fragment.options, &priority);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
log_warning_errno(r, "Failed to parse swap priority \"%s\", ignoring: %m", s->parameters_fragment.options);
|
log_unit_warning_errno(UNIT(s), r, "Failed to parse swap priority \"%s\", ignoring: %m", s->parameters_fragment.options);
|
||||||
else if (r == 1 && s->parameters_fragment.priority_set)
|
else if (r > 0 && s->parameters_fragment.priority_set)
|
||||||
log_warning("Duplicate swap priority configuration by Priority and Options fields.");
|
log_unit_warning(UNIT(s), "Duplicate swap priority configuration by Priority= and Options= fields.");
|
||||||
|
|
||||||
if (r <= 0 && s->parameters_fragment.priority_set) {
|
if (r <= 0 && s->parameters_fragment.priority_set) {
|
||||||
if (s->parameters_fragment.options)
|
if (s->parameters_fragment.options)
|
||||||
r = asprintf(&opts, "%s,pri=%i", s->parameters_fragment.options, s->parameters_fragment.priority);
|
r = asprintf(&opts, "%s,pri=%i", s->parameters_fragment.options, s->parameters_fragment.priority);
|
||||||
else
|
else
|
||||||
r = asprintf(&opts, "pri=%i", s->parameters_fragment.priority);
|
r = asprintf(&opts, "pri=%i", s->parameters_fragment.priority);
|
||||||
if (r < 0)
|
if (r < 0) {
|
||||||
|
r = -ENOMEM;
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
r = exec_command_set(s->control_command, "/sbin/swapon", NULL);
|
r = exec_command_set(s->control_command, "/sbin/swapon", NULL);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
|
@ -792,7 +790,7 @@ static void swap_enter_activating(Swap *s) {
|
||||||
|
|
||||||
if (s->parameters_fragment.options || opts) {
|
if (s->parameters_fragment.options || opts) {
|
||||||
r = exec_command_append(s->control_command, "-o",
|
r = exec_command_append(s->control_command, "-o",
|
||||||
opts ? : s->parameters_fragment.options, NULL);
|
opts ?: s->parameters_fragment.options, NULL);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
@ -808,7 +806,6 @@ static void swap_enter_activating(Swap *s) {
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
swap_set_state(s, SWAP_ACTIVATING);
|
swap_set_state(s, SWAP_ACTIVATING);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
|
|
|
@ -122,7 +122,7 @@ static int print_inhibitors(sd_bus *bus) {
|
||||||
TABLE_STRING, why,
|
TABLE_STRING, why,
|
||||||
TABLE_STRING, mode);
|
TABLE_STRING, mode);
|
||||||
if (r < 0)
|
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);
|
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, seat,
|
||||||
TABLE_STRING, strna(tty));
|
TABLE_STRING, strna(tty));
|
||||||
if (r < 0)
|
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);
|
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_UID, (uid_t) uid,
|
||||||
TABLE_STRING, user);
|
TABLE_STRING, user);
|
||||||
if (r < 0)
|
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);
|
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);
|
r = table_add_cell(table, NULL, TABLE_STRING, seat);
|
||||||
if (r < 0)
|
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);
|
r = sd_bus_message_exit_container(reply);
|
||||||
|
|
|
@ -306,6 +306,9 @@ static int list_machines(int argc, char *argv[], void *userdata) {
|
||||||
if (!table)
|
if (!table)
|
||||||
return log_oom();
|
return log_oom();
|
||||||
|
|
||||||
|
if (arg_full)
|
||||||
|
table_set_width(table, 0);
|
||||||
|
|
||||||
r = sd_bus_message_enter_container(reply, 'a', "(ssso)");
|
r = sd_bus_message_enter_container(reply, 'a', "(ssso)");
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return bus_log_parse_error(r);
|
return bus_log_parse_error(r);
|
||||||
|
@ -338,7 +341,7 @@ static int list_machines(int argc, char *argv[], void *userdata) {
|
||||||
0,
|
0,
|
||||||
"",
|
"",
|
||||||
" ",
|
" ",
|
||||||
arg_addrs,
|
arg_full ? ALL_IP_ADDRESSES : arg_addrs,
|
||||||
&addresses);
|
&addresses);
|
||||||
|
|
||||||
r = table_add_many(table,
|
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(version_id),
|
||||||
TABLE_STRING, empty_to_dash(addresses));
|
TABLE_STRING, empty_to_dash(addresses));
|
||||||
if (r < 0)
|
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);
|
r = sd_bus_message_exit_container(reply);
|
||||||
|
@ -386,6 +389,9 @@ static int list_images(int argc, char *argv[], void *userdata) {
|
||||||
if (!table)
|
if (!table)
|
||||||
return log_oom();
|
return log_oom();
|
||||||
|
|
||||||
|
if (arg_full)
|
||||||
|
table_set_width(table, 0);
|
||||||
|
|
||||||
(void) table_set_align_percent(table, TABLE_HEADER_CELL(3), 100);
|
(void) table_set_align_percent(table, TABLE_HEADER_CELL(3), 100);
|
||||||
|
|
||||||
r = sd_bus_message_enter_container(reply, SD_BUS_TYPE_ARRAY, "(ssbttto)");
|
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 (;;) {
|
for (;;) {
|
||||||
uint64_t crtime, mtime, size;
|
uint64_t crtime, mtime, size;
|
||||||
const char *name, *type;
|
const char *name, *type;
|
||||||
TableCell *cell;
|
|
||||||
bool ro_bool;
|
|
||||||
int ro_int;
|
int ro_int;
|
||||||
|
|
||||||
r = sd_bus_message_read(reply, "(ssbttto)", &name, &type, &ro_int, &crtime, &mtime, &size, NULL);
|
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,
|
r = table_add_many(table,
|
||||||
TABLE_STRING, name,
|
TABLE_STRING, name,
|
||||||
TABLE_STRING, type);
|
TABLE_STRING, type,
|
||||||
if (r < 0)
|
TABLE_BOOLEAN, ro_int,
|
||||||
return log_error_errno(r, "Failed to add table row: %m");
|
TABLE_SET_COLOR, ro_int ? ansi_highlight_red() : NULL,
|
||||||
|
|
||||||
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_SIZE, size,
|
TABLE_SIZE, size,
|
||||||
TABLE_TIMESTAMP, crtime,
|
TABLE_TIMESTAMP, crtime,
|
||||||
TABLE_TIMESTAMP, mtime);
|
TABLE_TIMESTAMP, mtime);
|
||||||
if (r < 0)
|
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);
|
r = sd_bus_message_exit_container(reply);
|
||||||
|
|
|
@ -46,6 +46,7 @@ enum {
|
||||||
static bool arg_no_block = false;
|
static bool arg_no_block = false;
|
||||||
static PagerFlags arg_pager_flags = 0;
|
static PagerFlags arg_pager_flags = 0;
|
||||||
static bool arg_legend = true;
|
static bool arg_legend = true;
|
||||||
|
static bool arg_full = false;
|
||||||
static bool arg_ask_password = true;
|
static bool arg_ask_password = true;
|
||||||
static bool arg_quiet = false;
|
static bool arg_quiet = false;
|
||||||
static BusTransport arg_transport = BUS_TRANSPORT_LOCAL;
|
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-block Do not wait until operation finished\n"
|
||||||
" --no-pager Do not pipe output into a pager\n"
|
" --no-pager Do not pipe output into a pager\n"
|
||||||
" --no-legend Do not show the headers\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"
|
" --no-ask-password Do not prompt for password\n"
|
||||||
" -q --quiet Suppress information messages during runtime\n"
|
" -q --quiet Suppress information messages during runtime\n"
|
||||||
" --user Run as user unit\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-block", no_argument, NULL, ARG_NO_BLOCK },
|
||||||
{ "no-pager", no_argument, NULL, ARG_NO_PAGER },
|
{ "no-pager", no_argument, NULL, ARG_NO_PAGER },
|
||||||
{ "no-legend", no_argument, NULL, ARG_NO_LEGEND },
|
{ "no-legend", no_argument, NULL, ARG_NO_LEGEND },
|
||||||
|
{ "full", no_argument, NULL, 'l' },
|
||||||
{ "no-ask-password", no_argument, NULL, ARG_NO_ASK_PASSWORD },
|
{ "no-ask-password", no_argument, NULL, ARG_NO_ASK_PASSWORD },
|
||||||
{ "quiet", no_argument, NULL, 'q' },
|
{ "quiet", no_argument, NULL, 'q' },
|
||||||
{ "user", no_argument, NULL, ARG_USER },
|
{ "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"))
|
if (strstr(program_invocation_short_name, "systemd-umount"))
|
||||||
arg_action = ACTION_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) {
|
switch (c) {
|
||||||
|
|
||||||
|
@ -204,6 +207,10 @@ static int parse_argv(int argc, char *argv[]) {
|
||||||
arg_legend = false;
|
arg_legend = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'l':
|
||||||
|
arg_full = true;
|
||||||
|
break;
|
||||||
|
|
||||||
case ARG_NO_ASK_PASSWORD:
|
case ARG_NO_ASK_PASSWORD:
|
||||||
arg_ask_password = false;
|
arg_ask_password = false;
|
||||||
break;
|
break;
|
||||||
|
@ -1393,6 +1400,9 @@ static int list_devices(void) {
|
||||||
if (!table)
|
if (!table)
|
||||||
return log_oom();
|
return log_oom();
|
||||||
|
|
||||||
|
if (arg_full)
|
||||||
|
table_set_width(table, 0);
|
||||||
|
|
||||||
r = table_set_sort(table, 0, SIZE_MAX);
|
r = table_set_sort(table, 0, SIZE_MAX);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Failed to set sort index: %m");
|
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));
|
r = table_add_cell(table, NULL, c == COLUMN_NODE ? TABLE_PATH : TABLE_STRING, strna(x));
|
||||||
if (r < 0)
|
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)
|
if (!table)
|
||||||
return log_oom();
|
return log_oom();
|
||||||
|
|
||||||
|
if (arg_full)
|
||||||
|
table_set_width(table, 0);
|
||||||
|
|
||||||
table_set_header(table, arg_legend);
|
table_set_header(table, arg_legend);
|
||||||
|
|
||||||
assert_se(cell = table_get_cell(table, 0, 0));
|
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_STRING, strna(setup_state),
|
||||||
TABLE_SET_COLOR, on_color_setup);
|
TABLE_SET_COLOR, on_color_setup);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return table_log_add_error(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
r = table_print(table, NULL);
|
r = table_print(table, NULL);
|
||||||
|
@ -729,7 +732,7 @@ static int dump_gateways(
|
||||||
TABLE_EMPTY,
|
TABLE_EMPTY,
|
||||||
TABLE_STRING, i == 0 ? "Gateway:" : "");
|
TABLE_STRING, i == 0 ? "Gateway:" : "");
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return table_log_add_error(r);
|
||||||
|
|
||||||
r = in_addr_to_string(local[i].family, &local[i].address, &gateway);
|
r = in_addr_to_string(local[i].family, &local[i].address, &gateway);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
|
@ -755,7 +758,7 @@ static int dump_gateways(
|
||||||
} else
|
} else
|
||||||
r = table_add_cell(table, NULL, TABLE_STRING, with_description ?: gateway);
|
r = table_add_cell(table, NULL, TABLE_STRING, with_description ?: gateway);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return table_log_add_error(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -786,7 +789,7 @@ static int dump_addresses(
|
||||||
TABLE_EMPTY,
|
TABLE_EMPTY,
|
||||||
TABLE_STRING, i == 0 ? "Address:" : "");
|
TABLE_STRING, i == 0 ? "Address:" : "");
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return table_log_add_error(r);
|
||||||
|
|
||||||
r = in_addr_to_string(local[i].family, &local[i].address, &pretty);
|
r = in_addr_to_string(local[i].family, &local[i].address, &pretty);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
|
@ -809,7 +812,7 @@ static int dump_addresses(
|
||||||
} else
|
} else
|
||||||
r = table_add_cell(table, NULL, TABLE_STRING, pretty);
|
r = table_add_cell(table, NULL, TABLE_STRING, pretty);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return table_log_add_error(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -838,7 +841,10 @@ static int dump_address_labels(sd_netlink *rtnl) {
|
||||||
|
|
||||||
table = table_new("label", "prefix/prefixlen");
|
table = table_new("label", "prefix/prefixlen");
|
||||||
if (!table)
|
if (!table)
|
||||||
return -ENOMEM;
|
return log_oom();
|
||||||
|
|
||||||
|
if (arg_full)
|
||||||
|
table_set_width(table, 0);
|
||||||
|
|
||||||
r = table_set_sort(table, 0, SIZE_MAX);
|
r = table_set_sort(table, 0, SIZE_MAX);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
|
@ -883,14 +889,18 @@ static int dump_address_labels(sd_netlink *rtnl) {
|
||||||
|
|
||||||
r = table_add_cell(table, NULL, TABLE_UINT32, &label);
|
r = table_add_cell(table, NULL, TABLE_UINT32, &label);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return table_log_add_error(r);
|
||||||
|
|
||||||
r = table_add_cell_stringf(table, NULL, "%s/%u", pretty, prefixlen);
|
r = table_add_cell_stringf(table, NULL, "%s/%u", pretty, prefixlen);
|
||||||
if (r < 0)
|
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) {
|
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_EMPTY,
|
||||||
TABLE_STRING, c == 0 ? prefix : "");
|
TABLE_STRING, c == 0 ? prefix : "");
|
||||||
if (r < 0)
|
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_system_name(n, &system_name);
|
||||||
(void) sd_lldp_neighbor_get_port_id_as_string(n, &port_id);
|
(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),
|
strempty(port_description),
|
||||||
isempty(port_description) ? "" : ")");
|
isempty(port_description) ? "" : ")");
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return table_log_add_error(r);
|
||||||
|
|
||||||
c++;
|
c++;
|
||||||
}
|
}
|
||||||
|
@ -1018,7 +1028,7 @@ static int dump_ifindexes(Table *table, const char *prefix, const int *ifindexes
|
||||||
TABLE_STRING, c == 0 ? prefix : "",
|
TABLE_STRING, c == 0 ? prefix : "",
|
||||||
TABLE_IFINDEX, ifindexes[c]);
|
TABLE_IFINDEX, ifindexes[c]);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return table_log_add_error(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
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 == l ? prefix : "",
|
||||||
TABLE_STRING, *i);
|
TABLE_STRING, *i);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return table_log_add_error(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1048,12 +1058,12 @@ static int dump_list(Table *table, const char *prefix, char **l) {
|
||||||
TABLE_EMPTY, \
|
TABLE_EMPTY, \
|
||||||
TABLE_STRING, name ":"); \
|
TABLE_STRING, name ":"); \
|
||||||
if (r < 0) \
|
if (r < 0) \
|
||||||
return r; \
|
return table_log_add_error(r); \
|
||||||
r = table_add_cell(table, NULL, \
|
r = table_add_cell(table, NULL, \
|
||||||
info->has_stats64 ? TABLE_UINT64 : TABLE_UINT32, \
|
info->has_stats64 ? TABLE_UINT64 : TABLE_UINT32, \
|
||||||
info->has_stats64 ? (void*) &info->stats64.val_name : (void*) &info->stats.val_name); \
|
info->has_stats64 ? (void*) &info->stats64.val_name : (void*) &info->stats.val_name); \
|
||||||
if (r < 0) \
|
if (r < 0) \
|
||||||
return r;
|
return table_log_add_error(r);
|
||||||
|
|
||||||
static int dump_statistics(Table *table, const LinkInfo *info) {
|
static int dump_statistics(Table *table, const LinkInfo *info) {
|
||||||
int r;
|
int r;
|
||||||
|
@ -1195,7 +1205,10 @@ static int link_status_one(
|
||||||
|
|
||||||
table = table_new("dot", "key", "value");
|
table = table_new("dot", "key", "value");
|
||||||
if (!table)
|
if (!table)
|
||||||
return -ENOMEM;
|
return log_oom();
|
||||||
|
|
||||||
|
if (arg_full)
|
||||||
|
table_set_width(table, 0);
|
||||||
|
|
||||||
assert_se(cell = table_get_cell(table, 0, 0));
|
assert_se(cell = table_get_cell(table, 0, 0));
|
||||||
(void) table_set_ellipsize_percent(table, cell, 100);
|
(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_STRING, special_glyph(SPECIAL_GLYPH_BLACK_CIRCLE),
|
||||||
TABLE_SET_COLOR, on_color_operational);
|
TABLE_SET_COLOR, on_color_operational);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return table_log_add_error(r);
|
||||||
r = table_add_cell_stringf(table, &cell, "%i: %s", info->ifindex, info->name);
|
r = table_add_cell_stringf(table, &cell, "%i: %s", info->ifindex, info->name);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return table_log_add_error(r);
|
||||||
(void) table_set_align_percent(table, cell, 0);
|
(void) table_set_align_percent(table, cell, 0);
|
||||||
|
|
||||||
r = table_add_many(table,
|
r = table_add_many(table,
|
||||||
|
@ -1230,14 +1243,14 @@ static int link_status_one(
|
||||||
TABLE_EMPTY,
|
TABLE_EMPTY,
|
||||||
TABLE_STRING, "State:");
|
TABLE_STRING, "State:");
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return table_log_add_error(r);
|
||||||
r = table_add_cell_stringf(table, NULL, "%s%s%s (%s%s%s)",
|
r = table_add_cell_stringf(table, NULL, "%s%s%s (%s%s%s)",
|
||||||
on_color_operational, strna(operational_state), off_color_operational,
|
on_color_operational, strna(operational_state), off_color_operational,
|
||||||
on_color_setup, strna(setup_state), off_color_setup);
|
on_color_setup, strna(setup_state), off_color_setup);
|
||||||
if (r < 0)
|
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)
|
if (p == info->alternative_names)
|
||||||
r = table_add_many(table,
|
r = table_add_many(table,
|
||||||
TABLE_EMPTY,
|
TABLE_EMPTY,
|
||||||
|
@ -1248,6 +1261,9 @@ static int link_status_one(
|
||||||
TABLE_EMPTY,
|
TABLE_EMPTY,
|
||||||
TABLE_EMPTY,
|
TABLE_EMPTY,
|
||||||
TABLE_STRING, *p);
|
TABLE_STRING, *p);
|
||||||
|
if (r < 0)
|
||||||
|
return table_log_add_error(r);
|
||||||
|
}
|
||||||
|
|
||||||
if (path) {
|
if (path) {
|
||||||
r = table_add_many(table,
|
r = table_add_many(table,
|
||||||
|
@ -1255,7 +1271,7 @@ static int link_status_one(
|
||||||
TABLE_STRING, "Path:",
|
TABLE_STRING, "Path:",
|
||||||
TABLE_STRING, path);
|
TABLE_STRING, path);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return table_log_add_error(r);
|
||||||
}
|
}
|
||||||
if (driver) {
|
if (driver) {
|
||||||
r = table_add_many(table,
|
r = table_add_many(table,
|
||||||
|
@ -1263,7 +1279,7 @@ static int link_status_one(
|
||||||
TABLE_STRING, "Driver:",
|
TABLE_STRING, "Driver:",
|
||||||
TABLE_STRING, driver);
|
TABLE_STRING, driver);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return table_log_add_error(r);
|
||||||
}
|
}
|
||||||
if (vendor) {
|
if (vendor) {
|
||||||
r = table_add_many(table,
|
r = table_add_many(table,
|
||||||
|
@ -1271,7 +1287,7 @@ static int link_status_one(
|
||||||
TABLE_STRING, "Vendor:",
|
TABLE_STRING, "Vendor:",
|
||||||
TABLE_STRING, vendor);
|
TABLE_STRING, vendor);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return table_log_add_error(r);
|
||||||
}
|
}
|
||||||
if (model) {
|
if (model) {
|
||||||
r = table_add_many(table,
|
r = table_add_many(table,
|
||||||
|
@ -1279,7 +1295,7 @@ static int link_status_one(
|
||||||
TABLE_STRING, "Model:",
|
TABLE_STRING, "Model:",
|
||||||
TABLE_STRING, model);
|
TABLE_STRING, model);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return table_log_add_error(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info->has_mac_address) {
|
if (info->has_mac_address) {
|
||||||
|
@ -1292,14 +1308,14 @@ static int link_status_one(
|
||||||
TABLE_EMPTY,
|
TABLE_EMPTY,
|
||||||
TABLE_STRING, "HW Address:");
|
TABLE_STRING, "HW Address:");
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return table_log_add_error(r);
|
||||||
r = table_add_cell_stringf(table, NULL, "%s%s%s%s",
|
r = table_add_cell_stringf(table, NULL, "%s%s%s%s",
|
||||||
ether_addr_to_string(&info->mac_address, ea),
|
ether_addr_to_string(&info->mac_address, ea),
|
||||||
description ? " (" : "",
|
description ? " (" : "",
|
||||||
strempty(description),
|
strempty(description),
|
||||||
description ? ")" : "");
|
description ? ")" : "");
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return table_log_add_error(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info->has_permanent_mac_address) {
|
if (info->has_permanent_mac_address) {
|
||||||
|
@ -1312,14 +1328,14 @@ static int link_status_one(
|
||||||
TABLE_EMPTY,
|
TABLE_EMPTY,
|
||||||
TABLE_STRING, "HW Permanent Address:");
|
TABLE_STRING, "HW Permanent Address:");
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return table_log_add_error(r);
|
||||||
r = table_add_cell_stringf(table, NULL, "%s%s%s%s",
|
r = table_add_cell_stringf(table, NULL, "%s%s%s%s",
|
||||||
ether_addr_to_string(&info->permanent_mac_address, ea),
|
ether_addr_to_string(&info->permanent_mac_address, ea),
|
||||||
description ? " (" : "",
|
description ? " (" : "",
|
||||||
strempty(description),
|
strempty(description),
|
||||||
description ? ")" : "");
|
description ? ")" : "");
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return table_log_add_error(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info->mtu > 0) {
|
if (info->mtu > 0) {
|
||||||
|
@ -1332,7 +1348,7 @@ static int link_status_one(
|
||||||
TABLE_EMPTY,
|
TABLE_EMPTY,
|
||||||
TABLE_STRING, "MTU:");
|
TABLE_STRING, "MTU:");
|
||||||
if (r < 0)
|
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",
|
r = table_add_cell_stringf(table, NULL, "%" PRIu32 "%s%s%s%s%s%s%s",
|
||||||
info->mtu,
|
info->mtu,
|
||||||
info->min_mtu > 0 || info->max_mtu > 0 ? " (" : "",
|
info->min_mtu > 0 || info->max_mtu > 0 ? " (" : "",
|
||||||
|
@ -1343,7 +1359,7 @@ static int link_status_one(
|
||||||
info->max_mtu > 0 ? max_str : "",
|
info->max_mtu > 0 ? max_str : "",
|
||||||
info->min_mtu > 0 || info->max_mtu > 0 ? ")" : "");
|
info->min_mtu > 0 || info->max_mtu > 0 ? ")" : "");
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return table_log_add_error(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (streq_ptr(info->netdev_kind, "bridge")) {
|
if (streq_ptr(info->netdev_kind, "bridge")) {
|
||||||
|
@ -1370,7 +1386,7 @@ static int link_status_one(
|
||||||
TABLE_STRING, "Multicast IGMP Version:",
|
TABLE_STRING, "Multicast IGMP Version:",
|
||||||
TABLE_UINT8, info->mcast_igmp_version);
|
TABLE_UINT8, info->mcast_igmp_version);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return table_log_add_error(r);
|
||||||
|
|
||||||
} else if (streq_ptr(info->netdev_kind, "vxlan")) {
|
} else if (streq_ptr(info->netdev_kind, "vxlan")) {
|
||||||
if (info->vxlan_info.vni > 0) {
|
if (info->vxlan_info.vni > 0) {
|
||||||
|
@ -1379,7 +1395,7 @@ static int link_status_one(
|
||||||
TABLE_STRING, "VNI:",
|
TABLE_STRING, "VNI:",
|
||||||
TABLE_UINT32, info->vxlan_info.vni);
|
TABLE_UINT32, info->vxlan_info.vni);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return table_log_add_error(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IN_SET(info->vxlan_info.group_family, AF_INET, AF_INET6)) {
|
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_family == AF_INET ? TABLE_IN_ADDR : TABLE_IN6_ADDR,
|
||||||
&info->vxlan_info.group);
|
&info->vxlan_info.group);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return table_log_add_error(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IN_SET(info->vxlan_info.local_family, AF_INET, AF_INET6)) {
|
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_family == AF_INET ? TABLE_IN_ADDR : TABLE_IN6_ADDR,
|
||||||
&info->vxlan_info.local);
|
&info->vxlan_info.local);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return table_log_add_error(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info->vxlan_info.dest_port > 0) {
|
if (info->vxlan_info.dest_port > 0) {
|
||||||
|
@ -1408,7 +1424,7 @@ static int link_status_one(
|
||||||
TABLE_STRING, "Destination Port:",
|
TABLE_STRING, "Destination Port:",
|
||||||
TABLE_UINT16, be16toh(info->vxlan_info.dest_port));
|
TABLE_UINT16, be16toh(info->vxlan_info.dest_port));
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return table_log_add_error(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info->vxlan_info.link > 0) {
|
if (info->vxlan_info.link > 0) {
|
||||||
|
@ -1417,7 +1433,7 @@ static int link_status_one(
|
||||||
TABLE_STRING, "Underlying Device:",
|
TABLE_STRING, "Underlying Device:",
|
||||||
TABLE_IFINDEX, info->vxlan_info.link);
|
TABLE_IFINDEX, info->vxlan_info.link);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return table_log_add_error(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1429,7 +1445,7 @@ static int link_status_one(
|
||||||
TABLE_EMPTY,
|
TABLE_EMPTY,
|
||||||
TABLE_STRING, "WiFi access point:");
|
TABLE_STRING, "WiFi access point:");
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return table_log_add_error(r);
|
||||||
|
|
||||||
if (info->ssid)
|
if (info->ssid)
|
||||||
esc = cescape(info->ssid);
|
esc = cescape(info->ssid);
|
||||||
|
@ -1438,7 +1454,7 @@ static int link_status_one(
|
||||||
strnull(esc),
|
strnull(esc),
|
||||||
ether_addr_to_string(&info->bssid, buf));
|
ether_addr_to_string(&info->bssid, buf));
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return table_log_add_error(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info->has_bitrates) {
|
if (info->has_bitrates) {
|
||||||
|
@ -1448,12 +1464,12 @@ static int link_status_one(
|
||||||
TABLE_EMPTY,
|
TABLE_EMPTY,
|
||||||
TABLE_STRING, "Bit Rate (Tx/Rx):");
|
TABLE_STRING, "Bit Rate (Tx/Rx):");
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return table_log_add_error(r);
|
||||||
r = table_add_cell_stringf(table, NULL, "%sbps/%sbps",
|
r = table_add_cell_stringf(table, NULL, "%sbps/%sbps",
|
||||||
format_bytes_full(tx, sizeof tx, info->tx_bitrate, 0),
|
format_bytes_full(tx, sizeof tx, info->tx_bitrate, 0),
|
||||||
format_bytes_full(rx, sizeof rx, info->rx_bitrate, 0));
|
format_bytes_full(rx, sizeof rx, info->rx_bitrate, 0));
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return table_log_add_error(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info->has_tx_queues || info->has_rx_queues) {
|
if (info->has_tx_queues || info->has_rx_queues) {
|
||||||
|
@ -1461,10 +1477,10 @@ static int link_status_one(
|
||||||
TABLE_EMPTY,
|
TABLE_EMPTY,
|
||||||
TABLE_STRING, "Queue Length (Tx/Rx):");
|
TABLE_STRING, "Queue Length (Tx/Rx):");
|
||||||
if (r < 0)
|
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);
|
r = table_add_cell_stringf(table, NULL, "%" PRIu32 "/%" PRIu32, info->tx_queues, info->rx_queues);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return table_log_add_error(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info->has_ethtool_link_info) {
|
if (info->has_ethtool_link_info) {
|
||||||
|
@ -1477,7 +1493,7 @@ static int link_status_one(
|
||||||
TABLE_STRING, "Auto negotiation:",
|
TABLE_STRING, "Auto negotiation:",
|
||||||
TABLE_BOOLEAN, info->autonegotiation == AUTONEG_ENABLE);
|
TABLE_BOOLEAN, info->autonegotiation == AUTONEG_ENABLE);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return table_log_add_error(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info->speed > 0) {
|
if (info->speed > 0) {
|
||||||
|
@ -1486,7 +1502,7 @@ static int link_status_one(
|
||||||
TABLE_STRING, "Speed:",
|
TABLE_STRING, "Speed:",
|
||||||
TABLE_BPS, (uint64_t) info->speed);
|
TABLE_BPS, (uint64_t) info->speed);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return table_log_add_error(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (duplex) {
|
if (duplex) {
|
||||||
|
@ -1495,7 +1511,7 @@ static int link_status_one(
|
||||||
TABLE_STRING, "Duplex:",
|
TABLE_STRING, "Duplex:",
|
||||||
TABLE_STRING, duplex);
|
TABLE_STRING, duplex);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return table_log_add_error(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (port) {
|
if (port) {
|
||||||
|
@ -1504,7 +1520,7 @@ static int link_status_one(
|
||||||
TABLE_STRING, "Port:",
|
TABLE_STRING, "Port:",
|
||||||
TABLE_STRING, port);
|
TABLE_STRING, port);
|
||||||
if (r < 0)
|
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, "Time Zone:",
|
||||||
TABLE_STRING, tz);
|
TABLE_STRING, tz);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return table_log_add_error(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
r = dump_lldp_neighbors(table, "Connected To:", info->ifindex);
|
r = dump_lldp_neighbors(table, "Connected To:", info->ifindex);
|
||||||
|
@ -1553,7 +1569,7 @@ static int link_status_one(
|
||||||
|
|
||||||
r = table_print(table, NULL);
|
r = table_print(table, NULL);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return log_error_errno(r, "Failed to print table: %m");
|
||||||
|
|
||||||
return show_logs(info);
|
return show_logs(info);
|
||||||
}
|
}
|
||||||
|
@ -1573,7 +1589,10 @@ static int system_status(sd_netlink *rtnl, sd_hwdb *hwdb) {
|
||||||
|
|
||||||
table = table_new("dot", "key", "value");
|
table = table_new("dot", "key", "value");
|
||||||
if (!table)
|
if (!table)
|
||||||
return -ENOMEM;
|
return log_oom();
|
||||||
|
|
||||||
|
if (arg_full)
|
||||||
|
table_set_width(table, 0);
|
||||||
|
|
||||||
assert_se(cell = table_get_cell(table, 0, 0));
|
assert_se(cell = table_get_cell(table, 0, 0));
|
||||||
(void) table_set_ellipsize_percent(table, cell, 100);
|
(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, "State:",
|
||||||
TABLE_STRING, strna(operational_state),
|
TABLE_STRING, strna(operational_state),
|
||||||
TABLE_SET_COLOR, on_color_operational);
|
TABLE_SET_COLOR, on_color_operational);
|
||||||
|
if (r < 0)
|
||||||
|
return table_log_add_error(r);
|
||||||
|
|
||||||
r = dump_addresses(rtnl, table, 0);
|
r = dump_addresses(rtnl, table, 0);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
|
@ -1620,7 +1641,7 @@ static int system_status(sd_netlink *rtnl, sd_hwdb *hwdb) {
|
||||||
|
|
||||||
r = table_print(table, NULL);
|
r = table_print(table, NULL);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return log_error_errno(r, "Failed to print table: %m");
|
||||||
|
|
||||||
return show_logs(NULL);
|
return show_logs(NULL);
|
||||||
}
|
}
|
||||||
|
@ -1740,7 +1761,10 @@ static int link_lldp_status(int argc, char *argv[], void *userdata) {
|
||||||
"port id",
|
"port id",
|
||||||
"port description");
|
"port description");
|
||||||
if (!table)
|
if (!table)
|
||||||
return -ENOMEM;
|
return log_oom();
|
||||||
|
|
||||||
|
if (arg_full)
|
||||||
|
table_set_width(table, 0);
|
||||||
|
|
||||||
table_set_header(table, arg_legend);
|
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_id),
|
||||||
TABLE_STRING, strna(port_description));
|
TABLE_STRING, strna(port_description));
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return table_log_add_error(r);
|
||||||
|
|
||||||
m++;
|
m++;
|
||||||
}
|
}
|
||||||
|
@ -1837,7 +1861,7 @@ static int link_lldp_status(int argc, char *argv[], void *userdata) {
|
||||||
|
|
||||||
r = table_print(table, NULL);
|
r = table_print(table, NULL);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return log_error_errno(r, "Failed to print table: %m");
|
||||||
|
|
||||||
if (arg_legend) {
|
if (arg_legend) {
|
||||||
lldp_capabilities_legend(all);
|
lldp_capabilities_legend(all);
|
||||||
|
|
|
@ -511,8 +511,6 @@ static int list_images(int argc, char *argv[], void *userdata) {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
const char *name, *type, *state;
|
const char *name, *type, *state;
|
||||||
uint64_t crtime, mtime, usage;
|
uint64_t crtime, mtime, usage;
|
||||||
TableCell *cell;
|
|
||||||
bool ro_bool;
|
|
||||||
int ro_int;
|
int ro_int;
|
||||||
|
|
||||||
r = sd_bus_message_read(reply, "(ssbtttso)", &name, &type, &ro_int, &crtime, &mtime, &usage, &state, NULL);
|
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,
|
r = table_add_many(table,
|
||||||
TABLE_STRING, name,
|
TABLE_STRING, name,
|
||||||
TABLE_STRING, type);
|
TABLE_STRING, type,
|
||||||
if (r < 0)
|
TABLE_BOOLEAN, ro_int,
|
||||||
return log_error_errno(r, "Failed to add row to table: %m");
|
TABLE_SET_COLOR, ro_int ? ansi_highlight_red() : NULL,
|
||||||
|
|
||||||
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_TIMESTAMP, crtime,
|
TABLE_TIMESTAMP, crtime,
|
||||||
TABLE_TIMESTAMP, mtime,
|
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)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Failed to add row to table: %m");
|
return table_log_add_error(r);
|
||||||
|
|
||||||
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");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
r = sd_bus_message_exit_container(reply);
|
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_to_json(Table *t, JsonVariant **ret);
|
||||||
int table_print_json(Table *t, FILE *f, JsonFormatFlags json_flags);
|
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")
|
||||||
|
|
|
@ -105,7 +105,6 @@ DEFINE_PRIVATE_STRING_TABLE_LOOKUP_TO_STRING(unit_file_type, UnitFileType);
|
||||||
|
|
||||||
static int in_search_path(const LookupPaths *p, const char *path) {
|
static int in_search_path(const LookupPaths *p, const char *path) {
|
||||||
_cleanup_free_ char *parent = NULL;
|
_cleanup_free_ char *parent = NULL;
|
||||||
char **i;
|
|
||||||
|
|
||||||
assert(path);
|
assert(path);
|
||||||
|
|
||||||
|
@ -113,11 +112,7 @@ static int in_search_path(const LookupPaths *p, const char *path) {
|
||||||
if (!parent)
|
if (!parent)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
STRV_FOREACH(i, p->search_path)
|
return path_strv_contains(p->search_path, parent);
|
||||||
if (path_equal(parent, *i))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* skip_root(const LookupPaths *p, const char *path) {
|
static const char* skip_root(const LookupPaths *p, const char *path) {
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "alloc-util.h"
|
#include "alloc-util.h"
|
||||||
|
#include "errno-util.h"
|
||||||
#include "fd-util.h"
|
#include "fd-util.h"
|
||||||
#include "fileio.h"
|
#include "fileio.h"
|
||||||
#include "loop-util.h"
|
#include "loop-util.h"
|
||||||
|
@ -157,14 +158,30 @@ int loop_device_make(
|
||||||
|
|
||||||
int loop_device_make_by_path(const char *path, int open_flags, uint32_t loop_flags, LoopDevice **ret) {
|
int loop_device_make_by_path(const char *path, int open_flags, uint32_t loop_flags, LoopDevice **ret) {
|
||||||
_cleanup_close_ int fd = -1;
|
_cleanup_close_ int fd = -1;
|
||||||
|
int r;
|
||||||
|
|
||||||
assert(path);
|
assert(path);
|
||||||
assert(ret);
|
assert(ret);
|
||||||
assert(IN_SET(open_flags, O_RDWR, O_RDONLY));
|
assert(open_flags < 0 || IN_SET(open_flags, O_RDWR, O_RDONLY));
|
||||||
|
|
||||||
fd = open(path, O_CLOEXEC|O_NONBLOCK|O_NOCTTY|open_flags);
|
/* Passing < 0 as open_flags here means we'll try to open the device writable if we can, retrying
|
||||||
|
* read-only if we cannot. */
|
||||||
|
|
||||||
|
fd = open(path, O_CLOEXEC|O_NONBLOCK|O_NOCTTY|(open_flags >= 0 ? open_flags : O_RDWR));
|
||||||
|
if (fd < 0) {
|
||||||
|
r = -errno;
|
||||||
|
|
||||||
|
/* Retry read-only? */
|
||||||
|
if (open_flags >= 0 || !(ERRNO_IS_PRIVILEGE(r) || r == -EROFS))
|
||||||
|
return r;
|
||||||
|
|
||||||
|
fd = open(path, O_CLOEXEC|O_NONBLOCK|O_NOCTTY|O_RDONLY);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return -errno;
|
return r; /* Propagate original error */
|
||||||
|
|
||||||
|
open_flags = O_RDONLY;
|
||||||
|
} else if (open_flags < 0)
|
||||||
|
open_flags = O_RDWR;
|
||||||
|
|
||||||
return loop_device_make(fd, open_flags, 0, 0, loop_flags, ret);
|
return loop_device_make(fd, open_flags, 0, 0, loop_flags, ret);
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,7 @@ static int print_status_info(const StatusInfo *i) {
|
||||||
TABLE_STRING, "Local time:",
|
TABLE_STRING, "Local time:",
|
||||||
TABLE_STRING, have_time && n > 0 ? a : "n/a");
|
TABLE_STRING, have_time && n > 0 ? a : "n/a");
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Failed to add cell(s): %m");
|
return table_log_add_error(r);
|
||||||
|
|
||||||
if (have_time)
|
if (have_time)
|
||||||
n = strftime(a, sizeof a, "%a %Y-%m-%d %H:%M:%S UTC", gmtime_r(&sec, &tm));
|
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, "Universal time:",
|
||||||
TABLE_STRING, have_time && n > 0 ? a : "n/a");
|
TABLE_STRING, have_time && n > 0 ? a : "n/a");
|
||||||
if (r < 0)
|
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) {
|
if (i->rtc_time > 0) {
|
||||||
time_t rtc_sec;
|
time_t rtc_sec;
|
||||||
|
@ -122,18 +122,18 @@ static int print_status_info(const StatusInfo *i) {
|
||||||
TABLE_STRING, "RTC time:",
|
TABLE_STRING, "RTC time:",
|
||||||
TABLE_STRING, i->rtc_time > 0 && n > 0 ? a : "n/a");
|
TABLE_STRING, i->rtc_time > 0 && n > 0 ? a : "n/a");
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Failed to add cell(s): %m");
|
return table_log_add_error(r);
|
||||||
|
|
||||||
if (have_time)
|
if (have_time)
|
||||||
n = strftime(a, sizeof a, "%Z, %z", localtime_r(&sec, &tm));
|
n = strftime(a, sizeof a, "%Z, %z", localtime_r(&sec, &tm));
|
||||||
|
|
||||||
r = table_add_cell(table, NULL, TABLE_STRING, "Time zone:");
|
r = table_add_cell(table, NULL, TABLE_STRING, "Time zone:");
|
||||||
if (r < 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_stringf(table, NULL, "%s (%s)", strna(i->timezone), have_time && n > 0 ? a : "n/a");
|
r = table_add_cell_stringf(table, NULL, "%s (%s)", strna(i->timezone), have_time && n > 0 ? a : "n/a");
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Failed to add cell(s): %m");
|
return table_log_add_error(r);
|
||||||
|
|
||||||
|
|
||||||
/* Restore the $TZ */
|
/* Restore the $TZ */
|
||||||
|
@ -154,7 +154,7 @@ static int print_status_info(const StatusInfo *i) {
|
||||||
TABLE_STRING, "RTC in local TZ:",
|
TABLE_STRING, "RTC in local TZ:",
|
||||||
TABLE_BOOLEAN, i->rtc_local);
|
TABLE_BOOLEAN, i->rtc_local);
|
||||||
if (r < 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);
|
r = table_print(table, NULL);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
|
@ -429,29 +429,29 @@ static int print_ntp_status_info(NTPStatusInfo *i) {
|
||||||
|
|
||||||
r = table_add_cell(table, NULL, TABLE_STRING, "Server:");
|
r = table_add_cell(table, NULL, TABLE_STRING, "Server:");
|
||||||
if (r < 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_stringf(table, NULL, "%s (%s)", i->server_address, i->server_name);
|
r = table_add_cell_stringf(table, NULL, "%s (%s)", i->server_address, i->server_name);
|
||||||
if (r < 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, "Poll interval:");
|
r = table_add_cell(table, NULL, TABLE_STRING, "Poll interval:");
|
||||||
if (r < 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_stringf(table, NULL, "%s (min: %s; max %s)",
|
r = table_add_cell_stringf(table, NULL, "%s (min: %s; max %s)",
|
||||||
format_timespan(ts, sizeof(ts), i->poll_interval, 0),
|
format_timespan(ts, sizeof(ts), i->poll_interval, 0),
|
||||||
format_timespan(tmin, sizeof(tmin), i->poll_min, 0),
|
format_timespan(tmin, sizeof(tmin), i->poll_min, 0),
|
||||||
format_timespan(tmax, sizeof(tmax), i->poll_max, 0));
|
format_timespan(tmax, sizeof(tmax), i->poll_max, 0));
|
||||||
if (r < 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) {
|
if (i->packet_count == 0) {
|
||||||
r = table_add_many(table,
|
r = table_add_many(table,
|
||||||
TABLE_STRING, "Packet count:",
|
TABLE_STRING, "Packet count:",
|
||||||
TABLE_STRING, "0");
|
TABLE_STRING, "0");
|
||||||
if (r < 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);
|
r = table_print(table, NULL);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
|
@ -487,44 +487,44 @@ static int print_ntp_status_info(NTPStatusInfo *i) {
|
||||||
TABLE_UINT32, i->stratum,
|
TABLE_UINT32, i->stratum,
|
||||||
TABLE_STRING, "Reference:");
|
TABLE_STRING, "Reference:");
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Failed to add cell(s): %m");
|
return table_log_add_error(r);
|
||||||
|
|
||||||
if (i->stratum <= 1)
|
if (i->stratum <= 1)
|
||||||
r = table_add_cell(table, NULL, TABLE_STRING, i->reference.str);
|
r = table_add_cell(table, NULL, TABLE_STRING, i->reference.str);
|
||||||
else
|
else
|
||||||
r = table_add_cell_stringf(table, NULL, "%" PRIX32, be32toh(i->reference.val));
|
r = table_add_cell_stringf(table, NULL, "%" PRIX32, be32toh(i->reference.val));
|
||||||
if (r < 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, "Precision:");
|
r = table_add_cell(table, NULL, TABLE_STRING, "Precision:");
|
||||||
if (r < 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_stringf(table, NULL, "%s (%" PRIi32 ")",
|
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),
|
format_timespan(ts, sizeof(ts), DIV_ROUND_UP((nsec_t) (exp2(i->precision) * NSEC_PER_SEC), NSEC_PER_USEC), 0),
|
||||||
i->precision);
|
i->precision);
|
||||||
if (r < 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, "Root distance:");
|
r = table_add_cell(table, NULL, TABLE_STRING, "Root distance:");
|
||||||
if (r < 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_stringf(table, NULL, "%s (max: %s)",
|
r = table_add_cell_stringf(table, NULL, "%s (max: %s)",
|
||||||
format_timespan(ts, sizeof(ts), root_distance, 0),
|
format_timespan(ts, sizeof(ts), root_distance, 0),
|
||||||
format_timespan(tmax, sizeof(tmax), i->root_distance_max, 0));
|
format_timespan(tmax, sizeof(tmax), i->root_distance_max, 0));
|
||||||
if (r < 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:");
|
r = table_add_cell(table, NULL, TABLE_STRING, "Offset:");
|
||||||
if (r < 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_stringf(table, NULL, "%s%s",
|
r = table_add_cell_stringf(table, NULL, "%s%s",
|
||||||
offset_sign ? "+" : "-",
|
offset_sign ? "+" : "-",
|
||||||
format_timespan(ts, sizeof(ts), offset, 0));
|
format_timespan(ts, sizeof(ts), offset, 0));
|
||||||
if (r < 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,
|
r = table_add_many(table,
|
||||||
TABLE_STRING, "Delay:",
|
TABLE_STRING, "Delay:",
|
||||||
|
@ -534,16 +534,16 @@ static int print_ntp_status_info(NTPStatusInfo *i) {
|
||||||
TABLE_STRING, "Packet count:",
|
TABLE_STRING, "Packet count:",
|
||||||
TABLE_UINT64, i->packet_count);
|
TABLE_UINT64, i->packet_count);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Failed to add cell(s): %m");
|
return table_log_add_error(r);
|
||||||
|
|
||||||
if (!i->spike) {
|
if (!i->spike) {
|
||||||
r = table_add_cell(table, NULL, TABLE_STRING, "Frequency:");
|
r = table_add_cell(table, NULL, TABLE_STRING, "Frequency:");
|
||||||
if (r < 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_stringf(table, NULL, "%+.3fppm", (double) i->freq / 0x10000);
|
r = table_add_cell_stringf(table, NULL, "%+.3fppm", (double) i->freq / 0x10000);
|
||||||
if (r < 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);
|
r = table_print(table, NULL);
|
||||||
|
|
Loading…
Reference in New Issue