Compare commits
9 Commits
2a71d57f4e
...
3a712fda86
Author | SHA1 | Date |
---|---|---|
Paul Cercueil | 3a712fda86 | |
Lennart Poettering | 034d0eb962 | |
Lennart Poettering | bc3b868b42 | |
Yu Watanabe | cc17c4c9a1 | |
Yu Watanabe | 845d784e54 | |
Yu Watanabe | 5eb6ef8b45 | |
Yu Watanabe | bc568a7a35 | |
Lennart Poettering | fb08381c14 | |
Lennart Poettering | e031166e15 |
|
@ -1,7 +1,8 @@
|
||||||
<?xml version='1.0'?>
|
<?xml version='1.0'?>
|
||||||
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
||||||
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
|
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
|
||||||
<refentry id="repart.d" conditional='ENABLE_REPART'>
|
<refentry id="repart.d" conditional='ENABLE_REPART'
|
||||||
|
xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||||
|
|
||||||
<refentryinfo>
|
<refentryinfo>
|
||||||
<title>repart.d</title>
|
<title>repart.d</title>
|
||||||
|
@ -214,7 +215,7 @@
|
||||||
setting is not used for matching. It is also not used when a label is already set for an existing
|
setting is not used for matching. It is also not used when a label is already set for an existing
|
||||||
partition. It is thus only used when a partition is newly created or when an existing one had a no
|
partition. It is thus only used when a partition is newly created or when an existing one had a no
|
||||||
label set (that is: an empty label). If not specified a label derived from the partition type is
|
label set (that is: an empty label). If not specified a label derived from the partition type is
|
||||||
automatically used.</para></listitem>
|
automatically used. Simple specifier expansion is supported, see below.</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
|
@ -291,7 +292,8 @@
|
||||||
<varname>SizeMaxBytes=</varname>) otherwise. If the backing device does not provide enough space to
|
<varname>SizeMaxBytes=</varname>) otherwise. If the backing device does not provide enough space to
|
||||||
fulfill the constraints placing the partition will fail. For partitions that shall be created,
|
fulfill the constraints placing the partition will fail. For partitions that shall be created,
|
||||||
depending on the setting of <varname>Priority=</varname> (see above) the partition might be dropped
|
depending on the setting of <varname>Priority=</varname> (see above) the partition might be dropped
|
||||||
and the placing algorithm restarted. By default no size constraints are set.</para></listitem>
|
and the placing algorithm restarted. By default a minimum size constraint of 10M and no maximum size
|
||||||
|
constraint is set.</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
|
@ -315,6 +317,40 @@
|
||||||
</variablelist>
|
</variablelist>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
|
|
||||||
|
<refsect1>
|
||||||
|
<title>Specifiers</title>
|
||||||
|
|
||||||
|
<para>Specifiers may be used in the <varname>Label=</varname> setting. The following expansions are understood:</para>
|
||||||
|
<table class='specifiers'>
|
||||||
|
<title>Specifiers available</title>
|
||||||
|
<tgroup cols='3' align='left' colsep='1' rowsep='1'>
|
||||||
|
<colspec colname="spec" />
|
||||||
|
<colspec colname="mean" />
|
||||||
|
<colspec colname="detail" />
|
||||||
|
<thead>
|
||||||
|
<row>
|
||||||
|
<entry>Specifier</entry>
|
||||||
|
<entry>Meaning</entry>
|
||||||
|
<entry>Details</entry>
|
||||||
|
</row>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<xi:include href="standard-specifiers.xml" xpointer="a"/>
|
||||||
|
<xi:include href="standard-specifiers.xml" xpointer="b"/>
|
||||||
|
<xi:include href="standard-specifiers.xml" xpointer="B"/>
|
||||||
|
<xi:include href="standard-specifiers.xml" xpointer="H"/>
|
||||||
|
<xi:include href="standard-specifiers.xml" xpointer="l"/>
|
||||||
|
<xi:include href="standard-specifiers.xml" xpointer="m"/>
|
||||||
|
<xi:include href="standard-specifiers.xml" xpointer="o"/>
|
||||||
|
<xi:include href="standard-specifiers.xml" xpointer="v"/>
|
||||||
|
<xi:include href="standard-specifiers.xml" xpointer="w"/>
|
||||||
|
<xi:include href="standard-specifiers.xml" xpointer="W"/>
|
||||||
|
<xi:include href="standard-specifiers.xml" xpointer="percent"/>
|
||||||
|
</tbody>
|
||||||
|
</tgroup>
|
||||||
|
</table>
|
||||||
|
</refsect1>
|
||||||
|
|
||||||
<refsect1>
|
<refsect1>
|
||||||
<title>Examples</title>
|
<title>Examples</title>
|
||||||
|
|
||||||
|
|
|
@ -272,8 +272,8 @@ static BOOLEAN line_edit(
|
||||||
|
|
||||||
case KEYPRESS(0, 0, CHAR_LINEFEED):
|
case KEYPRESS(0, 0, CHAR_LINEFEED):
|
||||||
case KEYPRESS(0, 0, CHAR_CARRIAGE_RETURN):
|
case KEYPRESS(0, 0, CHAR_CARRIAGE_RETURN):
|
||||||
case KEYPRESS(0, CHAR_CARRIAGE_RETURN, 0):
|
case KEYPRESS(0, CHAR_CARRIAGE_RETURN, 0): /* EZpad Mini 4s firmware sends malformed events */
|
||||||
case KEYPRESS(0, CHAR_CARRIAGE_RETURN, CHAR_CARRIAGE_RETURN):
|
case KEYPRESS(0, CHAR_CARRIAGE_RETURN, CHAR_CARRIAGE_RETURN): /* Teclast X98+ II firmware sends malformed events */
|
||||||
if (StrCmp(line, line_in) != 0)
|
if (StrCmp(line, line_in) != 0)
|
||||||
*line_out = TAKE_PTR(line);
|
*line_out = TAKE_PTR(line);
|
||||||
enter = TRUE;
|
enter = TRUE;
|
||||||
|
@ -744,8 +744,8 @@ static BOOLEAN menu_run(
|
||||||
|
|
||||||
case KEYPRESS(0, 0, CHAR_LINEFEED):
|
case KEYPRESS(0, 0, CHAR_LINEFEED):
|
||||||
case KEYPRESS(0, 0, CHAR_CARRIAGE_RETURN):
|
case KEYPRESS(0, 0, CHAR_CARRIAGE_RETURN):
|
||||||
case KEYPRESS(0, CHAR_CARRIAGE_RETURN, 0):
|
case KEYPRESS(0, CHAR_CARRIAGE_RETURN, 0): /* EZpad Mini 4s firmware sends malformed events */
|
||||||
case KEYPRESS(0, CHAR_CARRIAGE_RETURN, CHAR_CARRIAGE_RETURN):
|
case KEYPRESS(0, CHAR_CARRIAGE_RETURN, CHAR_CARRIAGE_RETURN): /* Teclast X98+ II firmware sends malformed events */
|
||||||
case KEYPRESS(0, SCAN_RIGHT, 0):
|
case KEYPRESS(0, SCAN_RIGHT, 0):
|
||||||
exit = TRUE;
|
exit = TRUE;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -77,7 +77,7 @@ static int make_stableprivate_address(Link *link, const struct in6_addr *prefix,
|
||||||
rid = htole64(siphash24_finalize(&state));
|
rid = htole64(siphash24_finalize(&state));
|
||||||
|
|
||||||
memcpy(addr->s6_addr, prefix->s6_addr, l);
|
memcpy(addr->s6_addr, prefix->s6_addr, l);
|
||||||
memcpy((uint8_t *) &addr->s6_addr + l, &rid, 16 - l);
|
memcpy(addr->s6_addr + l, &rid, 16 - l);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -299,7 +299,7 @@ static int ndisc_router_generate_addresses(Link *link, unsigned prefixlen, uint3
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (j->address_generation_type == IPV6_TOKEN_ADDRESS_GENERATION_STATIC) {
|
} else if (j->address_generation_type == IPV6_TOKEN_ADDRESS_GENERATION_STATIC) {
|
||||||
memcpy(((uint8_t *)&new_address->in_addr.in6) + 8, ((uint8_t *) &j->prefix) + 8, 8);
|
memcpy(new_address->in_addr.in6.s6_addr + 8, j->prefix.s6_addr + 8, 8);
|
||||||
have_address = true;
|
have_address = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
#include "pretty-print.h"
|
#include "pretty-print.h"
|
||||||
#include "proc-cmdline.h"
|
#include "proc-cmdline.h"
|
||||||
#include "sort-util.h"
|
#include "sort-util.h"
|
||||||
|
#include "specifier.h"
|
||||||
#include "stat-util.h"
|
#include "stat-util.h"
|
||||||
#include "stdio-util.h"
|
#include "stdio-util.h"
|
||||||
#include "string-util.h"
|
#include "string-util.h"
|
||||||
|
@ -48,6 +49,12 @@
|
||||||
#include "terminal-util.h"
|
#include "terminal-util.h"
|
||||||
#include "utf8.h"
|
#include "utf8.h"
|
||||||
|
|
||||||
|
/* If not configured otherwise use a minimal partition size of 10M */
|
||||||
|
#define DEFAULT_MIN_SIZE (10*1024*1024)
|
||||||
|
|
||||||
|
/* Hard lower limit for new partition sizes */
|
||||||
|
#define HARD_MIN_SIZE 4096
|
||||||
|
|
||||||
/* Note: When growing and placing new partitions we always align to 4K sector size. It's how newer hard disks
|
/* Note: When growing and placing new partitions we always align to 4K sector size. It's how newer hard disks
|
||||||
* are designed, and if everything is aligned to that performance is best. And for older hard disks with 512B
|
* are designed, and if everything is aligned to that performance is best. And for older hard disks with 512B
|
||||||
* sector size devices were generally assumed to have an even number of sectors, hence at the worst we'll
|
* sector size devices were generally assumed to have an even number of sectors, hence at the worst we'll
|
||||||
|
@ -321,7 +328,9 @@ static uint64_t partition_min_size(const Partition *p) {
|
||||||
|
|
||||||
/* Calculate the disk space we really need at minimum for this partition. If the partition already
|
/* Calculate the disk space we really need at minimum for this partition. If the partition already
|
||||||
* exists the current size is what we really need. If it doesn't exist yet refuse to allocate less
|
* exists the current size is what we really need. If it doesn't exist yet refuse to allocate less
|
||||||
* than 4K. */
|
* than 4K.
|
||||||
|
*
|
||||||
|
* DEFAULT_MIN_SIZE is the default SizeMin= we configure if nothing else is specified. */
|
||||||
|
|
||||||
if (PARTITION_IS_FOREIGN(p)) {
|
if (PARTITION_IS_FOREIGN(p)) {
|
||||||
/* Don't allow changing size of partitions not managed by us */
|
/* Don't allow changing size of partitions not managed by us */
|
||||||
|
@ -329,11 +338,8 @@ static uint64_t partition_min_size(const Partition *p) {
|
||||||
return p->current_size;
|
return p->current_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
sz = p->current_size != UINT64_MAX ? p->current_size : 4096;
|
sz = p->current_size != UINT64_MAX ? p->current_size : HARD_MIN_SIZE;
|
||||||
if (p->size_min != UINT64_MAX)
|
return MAX(p->size_min == UINT64_MAX ? DEFAULT_MIN_SIZE : p->size_min, sz);
|
||||||
return MAX(p->size_min, sz);
|
|
||||||
|
|
||||||
return sz;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint64_t partition_max_size(const Partition *p) {
|
static uint64_t partition_max_size(const Partition *p) {
|
||||||
|
@ -857,20 +863,42 @@ static int config_parse_label(
|
||||||
void *data,
|
void *data,
|
||||||
void *userdata) {
|
void *userdata) {
|
||||||
|
|
||||||
|
static const Specifier specifier_table[] = {
|
||||||
|
{ 'm', specifier_machine_id, NULL },
|
||||||
|
{ 'b', specifier_boot_id, NULL },
|
||||||
|
{ 'H', specifier_host_name, NULL },
|
||||||
|
{ 'l', specifier_short_host_name, NULL },
|
||||||
|
{ 'v', specifier_kernel_release, NULL },
|
||||||
|
{ 'a', specifier_architecture, NULL },
|
||||||
|
{ 'o', specifier_os_id, NULL },
|
||||||
|
{ 'w', specifier_os_version_id, NULL },
|
||||||
|
{ 'B', specifier_os_build_id, NULL },
|
||||||
|
{ 'W', specifier_os_variant_id, NULL },
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
|
||||||
_cleanup_free_ char16_t *recoded = NULL;
|
_cleanup_free_ char16_t *recoded = NULL;
|
||||||
|
_cleanup_free_ char *resolved = NULL;
|
||||||
char **label = data;
|
char **label = data;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
assert(rvalue);
|
assert(rvalue);
|
||||||
assert(label);
|
assert(label);
|
||||||
|
|
||||||
if (!utf8_is_valid(rvalue)) {
|
r = specifier_printf(rvalue, specifier_table, NULL, &resolved);
|
||||||
|
if (r < 0) {
|
||||||
|
log_syntax(unit, LOG_ERR, filename, line, r,
|
||||||
|
"Failed to expand specifiers in Label=, ignoring: %s", rvalue);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!utf8_is_valid(resolved)) {
|
||||||
log_syntax(unit, LOG_WARNING, filename, line, 0,
|
log_syntax(unit, LOG_WARNING, filename, line, 0,
|
||||||
"Partition label not valid UTF-8, ignoring: %s", rvalue);
|
"Partition label not valid UTF-8, ignoring: %s", rvalue);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
recoded = utf8_to_utf16(rvalue, strlen(rvalue));
|
recoded = utf8_to_utf16(resolved, strlen(resolved));
|
||||||
if (!recoded)
|
if (!recoded)
|
||||||
return log_oom();
|
return log_oom();
|
||||||
|
|
||||||
|
@ -880,10 +908,7 @@ static int config_parse_label(
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = free_and_strdup(label, rvalue);
|
free_and_replace(*label, resolved);
|
||||||
if (r < 0)
|
|
||||||
return log_oom();
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ ln -s root.conf $D/definitions/root2.conf
|
||||||
cat >$D/definitions/home.conf <<EOF
|
cat >$D/definitions/home.conf <<EOF
|
||||||
[Partition]
|
[Partition]
|
||||||
Type=home
|
Type=home
|
||||||
|
Label=home-%v
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
cat > $D/definitions/swap.conf <<EOF
|
cat > $D/definitions/swap.conf <<EOF
|
||||||
|
@ -46,6 +47,8 @@ $repart $D/zzz --dry-run=no --seed=$SEED --definitions=$D/definitions
|
||||||
|
|
||||||
sfdisk -d $D/zzz | grep -v -e 'sector-size' -e '^$' >$D/populated
|
sfdisk -d $D/zzz | grep -v -e 'sector-size' -e '^$' >$D/populated
|
||||||
|
|
||||||
|
UNAME=`uname -r`
|
||||||
|
|
||||||
cmp $D/populated - <<EOF
|
cmp $D/populated - <<EOF
|
||||||
label: gpt
|
label: gpt
|
||||||
label-id: EF7F7EE2-47B3-4251-B1A1-09EA8BF12D5D
|
label-id: EF7F7EE2-47B3-4251-B1A1-09EA8BF12D5D
|
||||||
|
@ -53,7 +56,7 @@ device: $D/zzz
|
||||||
unit: sectors
|
unit: sectors
|
||||||
first-lba: 2048
|
first-lba: 2048
|
||||||
last-lba: 2097118
|
last-lba: 2097118
|
||||||
$D/zzz1 : start= 2048, size= 591856, type=933AC7E1-2EB4-4F13-B844-0E14E2AEF915, uuid=A6005774-F558-4330-A8E5-D6D2C01C01D6, name="home"
|
$D/zzz1 : start= 2048, size= 591856, type=933AC7E1-2EB4-4F13-B844-0E14E2AEF915, uuid=A6005774-F558-4330-A8E5-D6D2C01C01D6, name="home-$UNAME"
|
||||||
$D/zzz2 : start= 593904, size= 591856, type=4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709, uuid=CE9C76EB-A8F1-40FF-813C-11DCA6C0A55B, name="root-x86-64"
|
$D/zzz2 : start= 593904, size= 591856, type=4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709, uuid=CE9C76EB-A8F1-40FF-813C-11DCA6C0A55B, name="root-x86-64"
|
||||||
$D/zzz3 : start= 1185760, size= 591864, type=4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709, uuid=AC60A837-550C-43BD-B5C4-9CB73B884E79, name="root-x86-64-2"
|
$D/zzz3 : start= 1185760, size= 591864, type=4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709, uuid=AC60A837-550C-43BD-B5C4-9CB73B884E79, name="root-x86-64-2"
|
||||||
$D/zzz4 : start= 1777624, size= 131072, type=0657FD6D-A4AB-43C4-84E5-0933C84B4F4F, uuid=2AA78CDB-59C7-4173-AF11-C7453737A5D1, name="swap"
|
$D/zzz4 : start= 1777624, size= 131072, type=0657FD6D-A4AB-43C4-84E5-0933C84B4F4F, uuid=2AA78CDB-59C7-4173-AF11-C7453737A5D1, name="swap"
|
||||||
|
@ -86,7 +89,7 @@ device: $D/zzz
|
||||||
unit: sectors
|
unit: sectors
|
||||||
first-lba: 2048
|
first-lba: 2048
|
||||||
last-lba: 2097118
|
last-lba: 2097118
|
||||||
$D/zzz1 : start= 2048, size= 591856, type=933AC7E1-2EB4-4F13-B844-0E14E2AEF915, uuid=A6005774-F558-4330-A8E5-D6D2C01C01D6, name="home"
|
$D/zzz1 : start= 2048, size= 591856, type=933AC7E1-2EB4-4F13-B844-0E14E2AEF915, uuid=A6005774-F558-4330-A8E5-D6D2C01C01D6, name="home-$UNAME"
|
||||||
$D/zzz2 : start= 593904, size= 591856, type=4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709, uuid=CE9C76EB-A8F1-40FF-813C-11DCA6C0A55B, name="root-x86-64"
|
$D/zzz2 : start= 593904, size= 591856, type=4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709, uuid=CE9C76EB-A8F1-40FF-813C-11DCA6C0A55B, name="root-x86-64"
|
||||||
$D/zzz3 : start= 1185760, size= 591864, type=4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709, uuid=AC60A837-550C-43BD-B5C4-9CB73B884E79, name="root-x86-64-2"
|
$D/zzz3 : start= 1185760, size= 591864, type=4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709, uuid=AC60A837-550C-43BD-B5C4-9CB73B884E79, name="root-x86-64-2"
|
||||||
$D/zzz4 : start= 1777624, size= 131072, type=0657FD6D-A4AB-43C4-84E5-0933C84B4F4F, uuid=2AA78CDB-59C7-4173-AF11-C7453737A5D1, name="swap"
|
$D/zzz4 : start= 1777624, size= 131072, type=0657FD6D-A4AB-43C4-84E5-0933C84B4F4F, uuid=2AA78CDB-59C7-4173-AF11-C7453737A5D1, name="swap"
|
||||||
|
@ -104,7 +107,7 @@ device: $D/zzz
|
||||||
unit: sectors
|
unit: sectors
|
||||||
first-lba: 2048
|
first-lba: 2048
|
||||||
last-lba: 4194270
|
last-lba: 4194270
|
||||||
$D/zzz1 : start= 2048, size= 591856, type=933AC7E1-2EB4-4F13-B844-0E14E2AEF915, uuid=A6005774-F558-4330-A8E5-D6D2C01C01D6, name="home"
|
$D/zzz1 : start= 2048, size= 591856, type=933AC7E1-2EB4-4F13-B844-0E14E2AEF915, uuid=A6005774-F558-4330-A8E5-D6D2C01C01D6, name="home-$UNAME"
|
||||||
$D/zzz2 : start= 593904, size= 591856, type=4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709, uuid=CE9C76EB-A8F1-40FF-813C-11DCA6C0A55B, name="root-x86-64"
|
$D/zzz2 : start= 593904, size= 591856, type=4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709, uuid=CE9C76EB-A8F1-40FF-813C-11DCA6C0A55B, name="root-x86-64"
|
||||||
$D/zzz3 : start= 1185760, size= 591864, type=4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709, uuid=AC60A837-550C-43BD-B5C4-9CB73B884E79, name="root-x86-64-2"
|
$D/zzz3 : start= 1185760, size= 591864, type=4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709, uuid=AC60A837-550C-43BD-B5C4-9CB73B884E79, name="root-x86-64-2"
|
||||||
$D/zzz4 : start= 1777624, size= 131072, type=0657FD6D-A4AB-43C4-84E5-0933C84B4F4F, uuid=2AA78CDB-59C7-4173-AF11-C7453737A5D1, name="swap"
|
$D/zzz4 : start= 1777624, size= 131072, type=0657FD6D-A4AB-43C4-84E5-0933C84B4F4F, uuid=2AA78CDB-59C7-4173-AF11-C7453737A5D1, name="swap"
|
||||||
|
|
|
@ -14,6 +14,9 @@ int wifi_get_interface(sd_netlink *genl, int ifindex, enum nl80211_iftype *iftyp
|
||||||
sd_genl_family family;
|
sd_genl_family family;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
|
assert(genl);
|
||||||
|
assert(ifindex > 0);
|
||||||
|
|
||||||
r = sd_genl_message_new(genl, SD_GENL_NL80211, NL80211_CMD_GET_INTERFACE, &m);
|
r = sd_genl_message_new(genl, SD_GENL_NL80211, NL80211_CMD_GET_INTERFACE, &m);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_debug_errno(r, "Failed to create generic netlink message: %m");
|
return log_debug_errno(r, "Failed to create generic netlink message: %m");
|
||||||
|
@ -23,10 +26,17 @@ int wifi_get_interface(sd_netlink *genl, int ifindex, enum nl80211_iftype *iftyp
|
||||||
return log_debug_errno(r, "Could not append NL80211_ATTR_IFINDEX attribute: %m");
|
return log_debug_errno(r, "Could not append NL80211_ATTR_IFINDEX attribute: %m");
|
||||||
|
|
||||||
r = sd_netlink_call(genl, m, 0, &reply);
|
r = sd_netlink_call(genl, m, 0, &reply);
|
||||||
|
if (r == -ENODEV) {
|
||||||
|
/* For obsolete WEXT driver. */
|
||||||
|
log_debug_errno(r, "Failed to request information about wifi interface %d. "
|
||||||
|
"The device doesn't seem to have nl80211 interface. Ignoring.",
|
||||||
|
ifindex);
|
||||||
|
goto nodata;
|
||||||
|
}
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_debug_errno(r, "Failed to request information about wifi interface %d: %m", ifindex);
|
return log_debug_errno(r, "Failed to request information about wifi interface %d: %m", ifindex);
|
||||||
if (!reply)
|
if (!reply)
|
||||||
return 0;
|
goto nodata;
|
||||||
|
|
||||||
r = sd_netlink_message_get_errno(reply);
|
r = sd_netlink_message_get_errno(reply);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
|
@ -37,7 +47,7 @@ int wifi_get_interface(sd_netlink *genl, int ifindex, enum nl80211_iftype *iftyp
|
||||||
return log_debug_errno(r, "Failed to determine genl family: %m");
|
return log_debug_errno(r, "Failed to determine genl family: %m");
|
||||||
if (family != SD_GENL_NL80211) {
|
if (family != SD_GENL_NL80211) {
|
||||||
log_debug("Received message of unexpected genl family %u, ignoring.", family);
|
log_debug("Received message of unexpected genl family %u, ignoring.", family);
|
||||||
return 0;
|
goto nodata;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iftype) {
|
if (iftype) {
|
||||||
|
@ -51,11 +61,20 @@ int wifi_get_interface(sd_netlink *genl, int ifindex, enum nl80211_iftype *iftyp
|
||||||
|
|
||||||
if (ssid) {
|
if (ssid) {
|
||||||
r = sd_netlink_message_read_string_strdup(reply, NL80211_ATTR_SSID, ssid);
|
r = sd_netlink_message_read_string_strdup(reply, NL80211_ATTR_SSID, ssid);
|
||||||
if (r < 0 && r != -ENODATA)
|
if (r == -ENODATA)
|
||||||
|
goto nodata;
|
||||||
|
if (r < 0)
|
||||||
return log_debug_errno(r, "Failed to get NL80211_ATTR_SSID attribute: %m");
|
return log_debug_errno(r, "Failed to get NL80211_ATTR_SSID attribute: %m");
|
||||||
}
|
}
|
||||||
|
|
||||||
return r == -ENODATA ? 0 : 1;
|
return 1;
|
||||||
|
|
||||||
|
nodata:
|
||||||
|
if (iftype)
|
||||||
|
*iftype = 0;
|
||||||
|
if (ssid)
|
||||||
|
*ssid = NULL;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wifi_get_station(sd_netlink *genl, int ifindex, struct ether_addr *bssid) {
|
int wifi_get_station(sd_netlink *genl, int ifindex, struct ether_addr *bssid) {
|
||||||
|
@ -63,6 +82,10 @@ int wifi_get_station(sd_netlink *genl, int ifindex, struct ether_addr *bssid) {
|
||||||
sd_genl_family family;
|
sd_genl_family family;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
|
assert(genl);
|
||||||
|
assert(ifindex > 0);
|
||||||
|
assert(bssid);
|
||||||
|
|
||||||
r = sd_genl_message_new(genl, SD_GENL_NL80211, NL80211_CMD_GET_STATION, &m);
|
r = sd_genl_message_new(genl, SD_GENL_NL80211, NL80211_CMD_GET_STATION, &m);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_debug_errno(r, "Failed to create generic netlink message: %m");
|
return log_debug_errno(r, "Failed to create generic netlink message: %m");
|
||||||
|
@ -79,7 +102,7 @@ int wifi_get_station(sd_netlink *genl, int ifindex, struct ether_addr *bssid) {
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_debug_errno(r, "Failed to request information about wifi station: %m");
|
return log_debug_errno(r, "Failed to request information about wifi station: %m");
|
||||||
if (!reply)
|
if (!reply)
|
||||||
return 0;
|
goto nodata;
|
||||||
|
|
||||||
r = sd_netlink_message_get_errno(reply);
|
r = sd_netlink_message_get_errno(reply);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
|
@ -90,12 +113,18 @@ int wifi_get_station(sd_netlink *genl, int ifindex, struct ether_addr *bssid) {
|
||||||
return log_debug_errno(r, "Failed to determine genl family: %m");
|
return log_debug_errno(r, "Failed to determine genl family: %m");
|
||||||
if (family != SD_GENL_NL80211) {
|
if (family != SD_GENL_NL80211) {
|
||||||
log_debug("Received message of unexpected genl family %u, ignoring.", family);
|
log_debug("Received message of unexpected genl family %u, ignoring.", family);
|
||||||
return 0;
|
goto nodata;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = sd_netlink_message_read_ether_addr(reply, NL80211_ATTR_MAC, bssid);
|
r = sd_netlink_message_read_ether_addr(reply, NL80211_ATTR_MAC, bssid);
|
||||||
if (r < 0 && r != -ENODATA)
|
if (r == -ENODATA)
|
||||||
|
goto nodata;
|
||||||
|
if (r < 0)
|
||||||
return log_debug_errno(r, "Failed to get NL80211_ATTR_MAC attribute: %m");
|
return log_debug_errno(r, "Failed to get NL80211_ATTR_MAC attribute: %m");
|
||||||
|
|
||||||
return r == -ENODATA ? 0 : 1;
|
return 1;
|
||||||
|
|
||||||
|
nodata:
|
||||||
|
*bssid = (struct ether_addr) {};
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -370,7 +370,7 @@ static ssize_t udev_event_subst_format(
|
||||||
}
|
}
|
||||||
case FORMAT_SUBST_PARENT:
|
case FORMAT_SUBST_PARENT:
|
||||||
r = sd_device_get_parent(dev, &parent);
|
r = sd_device_get_parent(dev, &parent);
|
||||||
if (r == -ENODEV)
|
if (r == -ENOENT)
|
||||||
goto null_terminate;
|
goto null_terminate;
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
@ -437,9 +437,9 @@ null_terminate:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t udev_event_apply_format(UdevEvent *event,
|
size_t udev_event_apply_format(UdevEvent *event,
|
||||||
const char *src, char *dest, size_t size,
|
const char *src, char *dest, size_t size,
|
||||||
bool replace_whitespace) {
|
bool replace_whitespace) {
|
||||||
const char *s = src;
|
const char *s = src;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
|
@ -455,9 +455,10 @@ ssize_t udev_event_apply_format(UdevEvent *event,
|
||||||
ssize_t subst_len;
|
ssize_t subst_len;
|
||||||
|
|
||||||
r = get_subst_type(&s, false, &type, attr);
|
r = get_subst_type(&s, false, &type, attr);
|
||||||
if (r < 0)
|
if (r < 0) {
|
||||||
return log_device_warning_errno(event->dev, r, "Invalid format string, ignoring: %s", src);
|
log_device_warning_errno(event->dev, r, "Invalid format string, ignoring: %s", src);
|
||||||
if (r == 0) {
|
break;
|
||||||
|
} else if (r == 0) {
|
||||||
if (size < 2) /* need space for this char and the terminating NUL */
|
if (size < 2) /* need space for this char and the terminating NUL */
|
||||||
break;
|
break;
|
||||||
*dest++ = *s++;
|
*dest++ = *s++;
|
||||||
|
@ -466,10 +467,12 @@ ssize_t udev_event_apply_format(UdevEvent *event,
|
||||||
}
|
}
|
||||||
|
|
||||||
subst_len = udev_event_subst_format(event, type, attr, dest, size);
|
subst_len = udev_event_subst_format(event, type, attr, dest, size);
|
||||||
if (subst_len < 0)
|
if (subst_len < 0) {
|
||||||
return log_device_warning_errno(event->dev, subst_len,
|
log_device_warning_errno(event->dev, subst_len,
|
||||||
"Failed to substitute variable '$%s' or apply format '%%%c', ignoring: %m",
|
"Failed to substitute variable '$%s' or apply format '%%%c', ignoring: %m",
|
||||||
format_type_to_string(type), format_type_to_char(type));
|
format_type_to_string(type), format_type_to_char(type));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* FORMAT_SUBST_RESULT handles spaces itself */
|
/* FORMAT_SUBST_RESULT handles spaces itself */
|
||||||
if (replace_whitespace && type != FORMAT_SUBST_RESULT)
|
if (replace_whitespace && type != FORMAT_SUBST_RESULT)
|
||||||
|
|
|
@ -48,9 +48,9 @@ UdevEvent *udev_event_new(sd_device *dev, usec_t exec_delay_usec, sd_netlink *rt
|
||||||
UdevEvent *udev_event_free(UdevEvent *event);
|
UdevEvent *udev_event_free(UdevEvent *event);
|
||||||
DEFINE_TRIVIAL_CLEANUP_FUNC(UdevEvent*, udev_event_free);
|
DEFINE_TRIVIAL_CLEANUP_FUNC(UdevEvent*, udev_event_free);
|
||||||
|
|
||||||
ssize_t udev_event_apply_format(UdevEvent *event,
|
size_t udev_event_apply_format(UdevEvent *event,
|
||||||
const char *src, char *dest, size_t size,
|
const char *src, char *dest, size_t size,
|
||||||
bool replace_whitespace);
|
bool replace_whitespace);
|
||||||
int udev_check_format(const char *value, size_t *offset, const char **hint);
|
int udev_check_format(const char *value, size_t *offset, const char **hint);
|
||||||
int udev_event_spawn(UdevEvent *event,
|
int udev_event_spawn(UdevEvent *event,
|
||||||
usec_t timeout_usec,
|
usec_t timeout_usec,
|
||||||
|
|
|
@ -151,7 +151,7 @@ int test_main(int argc, char *argv[], void *userdata) {
|
||||||
ORDERED_HASHMAP_FOREACH_KEY(val, cmd, event->run_list, i) {
|
ORDERED_HASHMAP_FOREACH_KEY(val, cmd, event->run_list, i) {
|
||||||
char program[UTIL_PATH_SIZE];
|
char program[UTIL_PATH_SIZE];
|
||||||
|
|
||||||
udev_event_apply_format(event, cmd, program, sizeof(program), false);
|
(void) udev_event_apply_format(event, cmd, program, sizeof(program), false);
|
||||||
printf("run: '%s'\n", program);
|
printf("run: '%s'\n", program);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue