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:
|
||||
|
||||
* 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
|
||||
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:*
|
||||
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
|
||||
sensor:modalias:acpi:INVN6500*:dmi:*svnDellInc.*:pnVenue8Pro3845:*
|
||||
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
|
||||
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>
|
||||
|
||||
<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>
|
||||
|
||||
</variablelist>
|
||||
|
|
|
@ -16,12 +16,14 @@ PHASES=(${@:-SETUP RUN})
|
|||
UBUNTU_RELEASE="$(lsb_release -cs)"
|
||||
|
||||
create_container() {
|
||||
# create autopkgtest LXC image; this sometimes fails with "Unable to fetch
|
||||
# GPG key from keyserver", so retry a few times
|
||||
# Create autopkgtest LXC image; this sometimes fails with "Unable to fetch
|
||||
# GPG key from keyserver", so retry a few times with different keyservers.
|
||||
for keyserver in "" "keys.gnupg.net" "keys.openpgp.org" "keyserver.ubuntu.com"; do
|
||||
for retry in {1..5}; do
|
||||
sudo lxc-create -n $CONTAINER -t download -- -d $DISTRO -r $RELEASE -a $ARCH --keyserver hkp://keyserver.ubuntu.com:80 && break
|
||||
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
|
||||
|
||||
# unconfine the container, otherwise some tests fail
|
||||
echo 'lxc.apparmor.profile = unconfined' | sudo tee -a /var/lib/lxc/$CONTAINER/config
|
||||
|
|
|
@ -72,11 +72,14 @@ typedef enum {
|
|||
FORMAT_BYTES_TRAILING_B = 1 << 2,
|
||||
} 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);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
static inline char *format_bytes_cgroup_protection(char *buf, size_t l, uint64_t t) {
|
||||
if (t == CGROUP_LIMIT_MAX) {
|
||||
(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
|
||||
* to 6. Let's rely on that. */
|
||||
#define FORMAT_TIMESTAMP_MAX (3+1+10+1+8+1+6+1+6+1)
|
||||
#define FORMAT_TIMESTAMP_WIDTH 28 /* when outputting, assume this width */
|
||||
#define FORMAT_TIMESTAMP_RELATIVE_MAX 256
|
||||
#define FORMAT_TIMESPAN_MAX 64
|
||||
#define FORMAT_TIMESTAMP_MAX (3U+1U+10U+1U+8U+1U+6U+1U+6U+1U)
|
||||
#define FORMAT_TIMESTAMP_WIDTH 28U /* when outputting, assume this width */
|
||||
#define FORMAT_TIMESTAMP_RELATIVE_MAX 256U
|
||||
#define FORMAT_TIMESPAN_MAX 64U
|
||||
|
||||
#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;
|
||||
}
|
||||
|
||||
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) {
|
||||
const char *name;
|
||||
int r;
|
||||
|
@ -1693,17 +1718,17 @@ static int verb_set_default(int argc, char *argv[], void *userdata) {
|
|||
if (isempty(argv[1])) {
|
||||
r = efi_set_variable(EFI_VENDOR_LOADER, name, NULL, 0);
|
||||
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 {
|
||||
_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]));
|
||||
if (!encoded)
|
||||
return log_oom();
|
||||
|
||||
r = efi_set_variable(EFI_VENDOR_LOADER, name, encoded, char16_strlen(encoded) * 2 + 2);
|
||||
r = parse_loader_entry_target_arg(argv[1], &target, &target_size);
|
||||
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;
|
||||
|
|
|
@ -586,7 +586,7 @@ static void display(Hashmap *a) {
|
|||
Group **array;
|
||||
signed path_columns;
|
||||
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);
|
||||
|
||||
|
|
|
@ -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) {
|
||||
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 tm;
|
||||
uint64_t x;
|
||||
|
|
|
@ -3,11 +3,73 @@
|
|||
#include <errno.h>
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "bus-error.h"
|
||||
#include "bus-util.h"
|
||||
#include "device-private.h"
|
||||
#include "path-util.h"
|
||||
#include "udevadm-util.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) {
|
||||
_cleanup_free_ char *path = NULL;
|
||||
int r;
|
||||
|
@ -24,26 +86,10 @@ int find_device(const char *id, const char *prefix, sd_device **ret) {
|
|||
} else {
|
||||
/* In cases where the argument is generic (no prefix specified),
|
||||
* check if the argument looks like a device unit name. */
|
||||
if (unit_name_is_valid(id, UNIT_NAME_PLAIN) &&
|
||||
unit_name_to_type(id) == UNIT_DEVICE) {
|
||||
r = unit_name_to_path(id, &path);
|
||||
if (r < 0)
|
||||
return log_debug_errno(r, "Failed to convert \"%s\" to a device path: %m", id);
|
||||
id = path;
|
||||
}
|
||||
r = find_device_from_unit(id, ret);
|
||||
if (r >= 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
if (path_startswith(id, "/sys/"))
|
||||
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;
|
||||
return find_device_from_path(id, ret);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue