mirror of
https://github.com/RGBCube/serenity
synced 2025-05-22 14:25:07 +00:00
Kernel: Make sure network adapters have unique names
Previously we'd just slap 0 onto the adapter's basename. This ensures we actually end up with unique names.
This commit is contained in:
parent
c6eff55439
commit
eb1cecc03d
1 changed files with 7 additions and 5 deletions
|
@ -220,11 +220,13 @@ void NetworkAdapter::set_ipv4_gateway(const IPv4Address& gateway)
|
||||||
|
|
||||||
void NetworkAdapter::set_interface_name(const StringView& basename)
|
void NetworkAdapter::set_interface_name(const StringView& basename)
|
||||||
{
|
{
|
||||||
// FIXME: Find a unique name for this interface, starting with $basename.
|
for (int i = 0; i < NumericLimits<int>::max(); i++) {
|
||||||
StringBuilder builder;
|
auto name = String::formatted("{}{}", basename, i);
|
||||||
builder.append(basename);
|
if (!lookup_by_name(name)) {
|
||||||
builder.append('0');
|
m_name = name;
|
||||||
m_name = builder.to_string();
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue