rfkill: Fix wiphy ID lookup

map_wiphy made the assumption that phy names follow the "phyN" pattern
but phys created or renamed by the "iw" command can have arbitrary
names.  It seems that /sys/class/rfkill/rfkill%u/name is not updated on
a phy rename, so we can't use it to subsequently read
/sys/class/ieee80211/<name>/index but both
/sys/class/rfkill/rfkill%u/../index and
/sys/class/rfkill/rfkill%u/device/index point to that file.
This commit is contained in:
Andrew Zaborowski 2016-07-20 02:58:41 +02:00 committed by Denis Kenzior
parent fba5ada1a1
commit f316614f59
1 changed files with 2 additions and 2 deletions

View File

@ -87,7 +87,7 @@ static struct rfkill_map_entry *map_wiphy(unsigned int rfkill_id)
unsigned int wiphy_id;
struct rfkill_map_entry *entry;
path = l_strdup_printf("/sys/class/rfkill/rfkill%u/name", rfkill_id);
path = l_strdup_printf("/sys/class/rfkill/rfkill%u/device/index", rfkill_id);
fd = TFR(open(path, O_RDONLY));
@ -104,7 +104,7 @@ static struct rfkill_map_entry *map_wiphy(unsigned int rfkill_id)
return NULL;
buf[bytes] = '\0';
if (sscanf(buf, "phy%u %n", &wiphy_id, &consumed) != 1 ||
if (sscanf(buf, "%u %n", &wiphy_id, &consumed) != 1 ||
consumed != bytes)
return NULL;