Compare commits
8 Commits
0ce8a9d6e5
...
c4b843473a
Author | SHA1 | Date |
---|---|---|
Дамјан Георгиевски | c4b843473a | |
Lennart Poettering | 558e5654a5 | |
Lennart Poettering | 08d3365677 | |
Frantisek Sumsal | 9ac47d9261 | |
Frantisek Sumsal | 493c965657 | |
Yu Watanabe | fc9e3b8129 | |
Kai-Chuan Hsieh | a5fe8447bf | |
Lennart Poettering | 67bd5620f6 |
4
TODO
4
TODO
|
@ -20,9 +20,9 @@ Janitorial Clean-ups:
|
||||||
|
|
||||||
Features:
|
Features:
|
||||||
|
|
||||||
* port selinux code from mallinfo() to mallinfo2() once added to glibc
|
* systemd-analyze netif that explains predictable interface (or networkctl)
|
||||||
|
|
||||||
* in fd_get_path() if we see (deleted) then do stat and check for st_nlink
|
* port selinux code from mallinfo() to mallinfo2() once added to glibc
|
||||||
|
|
||||||
* Add service setting to run a service within the specified VRF. i.e. do the
|
* Add service setting to run a service within the specified VRF. i.e. do the
|
||||||
equivalent of "ip vrf exec".
|
equivalent of "ip vrf exec".
|
||||||
|
|
|
@ -276,6 +276,12 @@ sensor:modalias:acpi:*KIOX000A*:dmi:*svn*CytrixTechnology:*pn*Complex11t:*
|
||||||
sensor:modalias:platform:HID-SENSOR-200073:dmi:*svnDell*:pnVostro5581:*
|
sensor:modalias:platform:HID-SENSOR-200073:dmi:*svnDell*:pnVostro5581:*
|
||||||
ACCEL_LOCATION=base
|
ACCEL_LOCATION=base
|
||||||
|
|
||||||
|
sensor:modalias:platform:HID-SENSOR-200073:dmi:*svnDell*:pnLatitude9520:*:ct10:*
|
||||||
|
ACCEL_LOCATION=base
|
||||||
|
|
||||||
|
sensor:modalias:platform:HID-SENSOR-200073:dmi:*svnDell*:pnLatitude7420:*
|
||||||
|
ACCEL_LOCATION=base
|
||||||
|
|
||||||
# Dell Venue 8 Pro 3845
|
# Dell Venue 8 Pro 3845
|
||||||
sensor:modalias:acpi:INVN6500*:dmi:*svnDellInc.*:pnVenue8Pro3845:*
|
sensor:modalias:acpi:INVN6500*:dmi:*svnDellInc.*:pnVenue8Pro3845:*
|
||||||
ACCEL_MOUNT_MATRIX=0, -1, 0; -1, 0, 0; 0, 0, 1
|
ACCEL_MOUNT_MATRIX=0, -1, 0; -1, 0, 0; 0, 0, 1
|
||||||
|
|
|
@ -102,6 +102,17 @@
|
||||||
<listitem><para>Sets the default boot loader entry. Takes a single boot loader entry ID string as
|
<listitem><para>Sets the default boot loader entry. Takes a single boot loader entry ID string as
|
||||||
argument. The <option>set-oneshot</option> command will set the default entry only for the next boot,
|
argument. The <option>set-oneshot</option> command will set the default entry only for the next boot,
|
||||||
the <option>set-default</option> will set it persistently for all future boots.</para></listitem>
|
the <option>set-default</option> will set it persistently for all future boots.</para></listitem>
|
||||||
|
|
||||||
|
<listitem><para>Optionally, the boot loader entry ID may be specified as one of: <option>@default</option>,
|
||||||
|
<option>@oneshot</option> or <option>@current</option>, which correspond to the current default boot loader
|
||||||
|
entry for all future boots, the current default boot loader entry for the next boot, and the currently booted
|
||||||
|
boot loader entry. These special IDs are resolved to the current values of the EFI variables
|
||||||
|
<varname>LoaderEntryDefault</varname>, <varname>LoaderEntryOneShot</varname> and <varname>LoaderEntrySelected</varname>,
|
||||||
|
see <ulink url="https://systemd.io/BOOT_LOADER_SPECIFICATION">Boot Loader Specification</ulink> for details.
|
||||||
|
These special IDs are primarily useful as a quick way to persistently make the currently booted boot loader
|
||||||
|
entry the default choice, or to upgrade the default boot loader entry for the next boot to the default boot
|
||||||
|
loader entry for all future boots, but may be used for other operations too.
|
||||||
|
</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
</variablelist>
|
</variablelist>
|
||||||
|
|
|
@ -16,11 +16,13 @@ PHASES=(${@:-SETUP RUN})
|
||||||
UBUNTU_RELEASE="$(lsb_release -cs)"
|
UBUNTU_RELEASE="$(lsb_release -cs)"
|
||||||
|
|
||||||
create_container() {
|
create_container() {
|
||||||
# create autopkgtest LXC image; this sometimes fails with "Unable to fetch
|
# Create autopkgtest LXC image; this sometimes fails with "Unable to fetch
|
||||||
# GPG key from keyserver", so retry a few times
|
# GPG key from keyserver", so retry a few times with different keyservers.
|
||||||
for retry in {1..5}; do
|
for keyserver in "" "keys.gnupg.net" "keys.openpgp.org" "keyserver.ubuntu.com"; do
|
||||||
sudo lxc-create -n $CONTAINER -t download -- -d $DISTRO -r $RELEASE -a $ARCH --keyserver hkp://keyserver.ubuntu.com:80 && break
|
for retry in {1..5}; do
|
||||||
sleep $((retry*retry))
|
sudo lxc-create -n $CONTAINER -t download -- -d $DISTRO -r $RELEASE -a $ARCH --server us.images.linuxcontainers.org ${keyserver:+--keyserver "$keyserver"} && break 2
|
||||||
|
sleep $((retry*retry))
|
||||||
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
# unconfine the container, otherwise some tests fail
|
# unconfine the container, otherwise some tests fail
|
||||||
|
|
|
@ -72,11 +72,14 @@ typedef enum {
|
||||||
FORMAT_BYTES_TRAILING_B = 1 << 2,
|
FORMAT_BYTES_TRAILING_B = 1 << 2,
|
||||||
} FormatBytesFlag;
|
} FormatBytesFlag;
|
||||||
|
|
||||||
#define FORMAT_BYTES_MAX 16
|
#define FORMAT_BYTES_MAX 16U
|
||||||
|
|
||||||
char *format_bytes_full(char *buf, size_t l, uint64_t t, FormatBytesFlag flag);
|
char *format_bytes_full(char *buf, size_t l, uint64_t t, FormatBytesFlag flag);
|
||||||
|
|
||||||
static inline char *format_bytes(char *buf, size_t l, uint64_t t) {
|
static inline char *format_bytes(char *buf, size_t l, uint64_t t) {
|
||||||
return format_bytes_full(buf, l, t, FORMAT_BYTES_USE_IEC | FORMAT_BYTES_BELOW_POINT | FORMAT_BYTES_TRAILING_B);
|
return format_bytes_full(buf, l, t, FORMAT_BYTES_USE_IEC | FORMAT_BYTES_BELOW_POINT | FORMAT_BYTES_TRAILING_B);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline char *format_bytes_cgroup_protection(char *buf, size_t l, uint64_t t) {
|
static inline char *format_bytes_cgroup_protection(char *buf, size_t l, uint64_t t) {
|
||||||
if (t == CGROUP_LIMIT_MAX) {
|
if (t == CGROUP_LIMIT_MAX) {
|
||||||
(void) snprintf(buf, l, "%s", "infinity");
|
(void) snprintf(buf, l, "%s", "infinity");
|
||||||
|
|
|
@ -63,10 +63,10 @@ typedef enum TimestampStyle {
|
||||||
|
|
||||||
/* We assume a maximum timezone length of 6. TZNAME_MAX is not defined on Linux, but glibc internally initializes this
|
/* We assume a maximum timezone length of 6. TZNAME_MAX is not defined on Linux, but glibc internally initializes this
|
||||||
* to 6. Let's rely on that. */
|
* to 6. Let's rely on that. */
|
||||||
#define FORMAT_TIMESTAMP_MAX (3+1+10+1+8+1+6+1+6+1)
|
#define FORMAT_TIMESTAMP_MAX (3U+1U+10U+1U+8U+1U+6U+1U+6U+1U)
|
||||||
#define FORMAT_TIMESTAMP_WIDTH 28 /* when outputting, assume this width */
|
#define FORMAT_TIMESTAMP_WIDTH 28U /* when outputting, assume this width */
|
||||||
#define FORMAT_TIMESTAMP_RELATIVE_MAX 256
|
#define FORMAT_TIMESTAMP_RELATIVE_MAX 256U
|
||||||
#define FORMAT_TIMESPAN_MAX 64
|
#define FORMAT_TIMESPAN_MAX 64U
|
||||||
|
|
||||||
#define TIME_T_MAX (time_t)((UINTMAX_C(1) << ((sizeof(time_t) << 3) - 1)) - 1)
|
#define TIME_T_MAX (time_t)((UINTMAX_C(1) << ((sizeof(time_t) << 3) - 1)) - 1)
|
||||||
|
|
||||||
|
|
|
@ -1661,6 +1661,31 @@ static int verb_is_installed(int argc, char *argv[], void *userdata) {
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int parse_loader_entry_target_arg(const char *arg1, char16_t **ret_target, size_t *ret_target_size) {
|
||||||
|
int r;
|
||||||
|
if (streq(arg1, "@current")) {
|
||||||
|
r = efi_get_variable(EFI_VENDOR_LOADER, "LoaderEntrySelected", NULL, (void *) ret_target, ret_target_size);
|
||||||
|
if (r < 0)
|
||||||
|
return log_error_errno(r, "Failed to get EFI variable 'LoaderEntrySelected': %m");
|
||||||
|
} else if (streq(arg1, "@oneshot")) {
|
||||||
|
r = efi_get_variable(EFI_VENDOR_LOADER, "LoaderEntryOneShot", NULL, (void *) ret_target, ret_target_size);
|
||||||
|
if (r < 0)
|
||||||
|
return log_error_errno(r, "Failed to get EFI variable 'LoaderEntryOneShot': %m");
|
||||||
|
} else if (streq(arg1, "@default")) {
|
||||||
|
r = efi_get_variable(EFI_VENDOR_LOADER, "LoaderEntryDefault", NULL, (void *) ret_target, ret_target_size);
|
||||||
|
if (r < 0)
|
||||||
|
return log_error_errno(r, "Failed to get EFI variable 'LoaderEntryDefault': %m");
|
||||||
|
} else {
|
||||||
|
char16_t *encoded = NULL;
|
||||||
|
encoded = utf8_to_utf16(arg1, strlen(arg1));
|
||||||
|
if (!encoded)
|
||||||
|
return log_oom();
|
||||||
|
*ret_target = encoded;
|
||||||
|
*ret_target_size = char16_strlen(encoded) * 2 + 2;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int verb_set_default(int argc, char *argv[], void *userdata) {
|
static int verb_set_default(int argc, char *argv[], void *userdata) {
|
||||||
const char *name;
|
const char *name;
|
||||||
int r;
|
int r;
|
||||||
|
@ -1693,17 +1718,17 @@ static int verb_set_default(int argc, char *argv[], void *userdata) {
|
||||||
if (isempty(argv[1])) {
|
if (isempty(argv[1])) {
|
||||||
r = efi_set_variable(EFI_VENDOR_LOADER, name, NULL, 0);
|
r = efi_set_variable(EFI_VENDOR_LOADER, name, NULL, 0);
|
||||||
if (r < 0 && r != -ENOENT)
|
if (r < 0 && r != -ENOENT)
|
||||||
return log_error_errno(r, "Failed to remove EFI variale: %m");
|
return log_error_errno(r, "Failed to remove EFI variable '%s': %m", name);
|
||||||
} else {
|
} else {
|
||||||
_cleanup_free_ char16_t *encoded = NULL;
|
_cleanup_free_ char16_t *target = NULL;
|
||||||
|
size_t target_size = 0;
|
||||||
|
|
||||||
encoded = utf8_to_utf16(argv[1], strlen(argv[1]));
|
r = parse_loader_entry_target_arg(argv[1], &target, &target_size);
|
||||||
if (!encoded)
|
|
||||||
return log_oom();
|
|
||||||
|
|
||||||
r = efi_set_variable(EFI_VENDOR_LOADER, name, encoded, char16_strlen(encoded) * 2 + 2);
|
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Failed to update EFI variable: %m");
|
return r;
|
||||||
|
r = efi_set_variable(EFI_VENDOR_LOADER, name, target, target_size);
|
||||||
|
if (r < 0)
|
||||||
|
return log_error_errno(r, "Failed to update EFI variable '%s': %m", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -586,7 +586,7 @@ static void display(Hashmap *a) {
|
||||||
Group **array;
|
Group **array;
|
||||||
signed path_columns;
|
signed path_columns;
|
||||||
unsigned rows, n = 0, j, maxtcpu = 0, maxtpath = 3; /* 3 for ellipsize() to work properly */
|
unsigned rows, n = 0, j, maxtcpu = 0, maxtpath = 3; /* 3 for ellipsize() to work properly */
|
||||||
char buffer[MAX3(21, FORMAT_BYTES_MAX, FORMAT_TIMESPAN_MAX)];
|
char buffer[MAX3(21U, FORMAT_BYTES_MAX, FORMAT_TIMESPAN_MAX)];
|
||||||
|
|
||||||
assert(a);
|
assert(a);
|
||||||
|
|
||||||
|
|
|
@ -347,7 +347,7 @@ static int output_timestamp_monotonic(FILE *f, sd_journal *j, const char *monoto
|
||||||
}
|
}
|
||||||
|
|
||||||
static int output_timestamp_realtime(FILE *f, sd_journal *j, OutputMode mode, OutputFlags flags, const char *realtime) {
|
static int output_timestamp_realtime(FILE *f, sd_journal *j, OutputMode mode, OutputFlags flags, const char *realtime) {
|
||||||
char buf[MAX(FORMAT_TIMESTAMP_MAX, 64)];
|
char buf[MAX(FORMAT_TIMESTAMP_MAX, 64U)];
|
||||||
struct tm *(*gettime_r)(const time_t *, struct tm *);
|
struct tm *(*gettime_r)(const time_t *, struct tm *);
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
uint64_t x;
|
uint64_t x;
|
||||||
|
|
|
@ -3,11 +3,73 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include "alloc-util.h"
|
#include "alloc-util.h"
|
||||||
|
#include "bus-error.h"
|
||||||
|
#include "bus-util.h"
|
||||||
#include "device-private.h"
|
#include "device-private.h"
|
||||||
#include "path-util.h"
|
#include "path-util.h"
|
||||||
#include "udevadm-util.h"
|
#include "udevadm-util.h"
|
||||||
#include "unit-name.h"
|
#include "unit-name.h"
|
||||||
|
|
||||||
|
static int find_device_from_path(const char *path, sd_device **ret) {
|
||||||
|
if (path_startswith(path, "/sys/"))
|
||||||
|
return sd_device_new_from_syspath(ret, path);
|
||||||
|
|
||||||
|
if (path_startswith(path, "/dev/")) {
|
||||||
|
struct stat st;
|
||||||
|
|
||||||
|
if (stat(path, &st) < 0)
|
||||||
|
return -errno;
|
||||||
|
|
||||||
|
return device_new_from_stat_rdev(ret, &st);
|
||||||
|
}
|
||||||
|
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int find_device_from_unit(const char *unit_name, sd_device **ret) {
|
||||||
|
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
|
||||||
|
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
|
||||||
|
_cleanup_free_ char *unit_path = NULL, *syspath = NULL;
|
||||||
|
int r;
|
||||||
|
|
||||||
|
if (!unit_name_is_valid(unit_name, UNIT_NAME_PLAIN))
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
if (unit_name_to_type(unit_name) != UNIT_DEVICE)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
r = bus_connect_system_systemd(&bus);
|
||||||
|
if (r < 0) {
|
||||||
|
_cleanup_free_ char *path = NULL;
|
||||||
|
|
||||||
|
log_debug_errno(r, "Failed to open connection to systemd, using unit name as syspath: %m");
|
||||||
|
|
||||||
|
r = unit_name_to_path(unit_name, &path);
|
||||||
|
if (r < 0)
|
||||||
|
return log_debug_errno(r, "Failed to convert \"%s\" to a device path: %m", unit_name);
|
||||||
|
|
||||||
|
return find_device_from_path(path, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
unit_path = unit_dbus_path_from_name(unit_name);
|
||||||
|
if (!unit_path)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
r = sd_bus_get_property_string(
|
||||||
|
bus,
|
||||||
|
"org.freedesktop.systemd1",
|
||||||
|
unit_path,
|
||||||
|
"org.freedesktop.systemd1.Device",
|
||||||
|
"SysFSPath",
|
||||||
|
&error,
|
||||||
|
&syspath);
|
||||||
|
if (r < 0)
|
||||||
|
return log_debug_errno(r, "Failed to get SysFSPath= dbus property for %s: %s",
|
||||||
|
unit_name, bus_error_message(&error, r));
|
||||||
|
|
||||||
|
return sd_device_new_from_syspath(ret, syspath);
|
||||||
|
}
|
||||||
|
|
||||||
int find_device(const char *id, const char *prefix, sd_device **ret) {
|
int find_device(const char *id, const char *prefix, sd_device **ret) {
|
||||||
_cleanup_free_ char *path = NULL;
|
_cleanup_free_ char *path = NULL;
|
||||||
int r;
|
int r;
|
||||||
|
@ -24,26 +86,10 @@ int find_device(const char *id, const char *prefix, sd_device **ret) {
|
||||||
} else {
|
} else {
|
||||||
/* In cases where the argument is generic (no prefix specified),
|
/* In cases where the argument is generic (no prefix specified),
|
||||||
* check if the argument looks like a device unit name. */
|
* check if the argument looks like a device unit name. */
|
||||||
if (unit_name_is_valid(id, UNIT_NAME_PLAIN) &&
|
r = find_device_from_unit(id, ret);
|
||||||
unit_name_to_type(id) == UNIT_DEVICE) {
|
if (r >= 0)
|
||||||
r = unit_name_to_path(id, &path);
|
return r;
|
||||||
if (r < 0)
|
|
||||||
return log_debug_errno(r, "Failed to convert \"%s\" to a device path: %m", id);
|
|
||||||
id = path;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (path_startswith(id, "/sys/"))
|
return find_device_from_path(id, ret);
|
||||||
return sd_device_new_from_syspath(ret, id);
|
|
||||||
|
|
||||||
if (path_startswith(id, "/dev/")) {
|
|
||||||
struct stat st;
|
|
||||||
|
|
||||||
if (stat(id, &st) < 0)
|
|
||||||
return -errno;
|
|
||||||
|
|
||||||
return device_new_from_stat_rdev(ret, &st);
|
|
||||||
}
|
|
||||||
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue