mirror of
https://github.com/RGBCube/serenity
synced 2025-05-21 15: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)
|
||||
{
|
||||
// FIXME: Find a unique name for this interface, starting with $basename.
|
||||
StringBuilder builder;
|
||||
builder.append(basename);
|
||||
builder.append('0');
|
||||
m_name = builder.to_string();
|
||||
for (int i = 0; i < NumericLimits<int>::max(); i++) {
|
||||
auto name = String::formatted("{}{}", basename, i);
|
||||
if (!lookup_by_name(name)) {
|
||||
m_name = name;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue