[arch-projects] [netcfg] [PATCH] Take rfkill switches attached to PHYs into account.
I have rfkill switches under path "/sys/class/net/$INTERFACE/phy80211/rfkill*" but not "/sys/class/net/$INTERFACE/rfkill" on two systems with iwlagn and ath9k drivers. Guess someone else also has these. Signed-off-by: Ivan Shapovalov <intelfx100@gmail.com> --- src/rfkill | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/rfkill b/src/rfkill index 12e1832..330544b 100644 --- a/src/rfkill +++ b/src/rfkill @@ -29,10 +29,18 @@ get_rf_path() { report_fail "no rfkill switch with name $RFKILL_NAME" else path="/sys/class/net/$INTERFACE/rfkill" + + # There may be many rfkill switches attached to a single PHY + # For now take the first of them + path_phy=( $(find "/sys/class/net/$INTERFACE/phy80211/" -type d -name 'rfkill*') ) + if [[ -d "$path" ]]; then echo "$path" return 0 - fi + elif [[ -n "${path_phy[0]}" ]]; then + echo "${path_phy[0]}" + return 0 + fi report_fail "no rfkill switch available on interface $INTERFACE" fi return 1 -- 1.7.12.2
On Tue, Oct 02, 2012 at 09:47:05PM +0400, Ivan Shapovalov wrote:
I have rfkill switches under path "/sys/class/net/$INTERFACE/phy80211/rfkill*" but not "/sys/class/net/$INTERFACE/rfkill" on two systems with iwlagn and ath9k drivers. Guess someone else also has these.
Signed-off-by: Ivan Shapovalov <intelfx100@gmail.com> --- src/rfkill | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/rfkill b/src/rfkill index 12e1832..330544b 100644 --- a/src/rfkill +++ b/src/rfkill @@ -29,10 +29,18 @@ get_rf_path() { report_fail "no rfkill switch with name $RFKILL_NAME" else path="/sys/class/net/$INTERFACE/rfkill" + + # There may be many rfkill switches attached to a single PHY + # For now take the first of them + path_phy=( $(find "/sys/class/net/$INTERFACE/phy80211/" -type d -name 'rfkill*') ) +
Is find really needed here? Can't this just be a glob, or do you really not know the depth of the rfkill* directory? path_phy=("/sys/class/net/$INTERFACE/phy80211/rfkill"*) If it isn't, this still isn't the proper way to read the results of a command into an array. Not sure if there's other bash4 syntax in netcfg, but I'd do something like: mapfile -t path_phy < <(find ....) else: IFS=$'\n' read -rd '' -a path_phy < <(find ....)
if [[ -d "$path" ]]; then echo "$path" return 0 - fi + elif [[ -n "${path_phy[0]}" ]]; then
And in combination with the globbing advice: elif [[ ${path_phy[0]} && -e ${path_phy[0]} ]]; then this saves you from having to enable nullglob.
+ echo "${path_phy[0]}" + return 0 + fi report_fail "no rfkill switch available on interface $INTERFACE" fi return 1 -- 1.7.12.2
On Tuesday 02 October 2012 13:57:41 Dave Reisner wrote:
On Tue, Oct 02, 2012 at 09:47:05PM +0400, Ivan Shapovalov wrote:
I have rfkill switches under path "/sys/class/net/$INTERFACE/phy80211/rfkill*" but not "/sys/class/net/$INTERFACE/rfkill" on two systems with iwlagn and ath9k drivers. Guess someone else also has these.
Signed-off-by: Ivan Shapovalov <intelfx100@gmail.com> ---
src/rfkill | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/rfkill b/src/rfkill index 12e1832..330544b 100644 --- a/src/rfkill +++ b/src/rfkill @@ -29,10 +29,18 @@ get_rf_path() {
report_fail "no rfkill switch with name $RFKILL_NAME"
else
path="/sys/class/net/$INTERFACE/rfkill"
+ + # There may be many rfkill switches attached to a single PHY + # For now take the first of them + path_phy=( $(find "/sys/class/net/$INTERFACE/phy80211/" -type d -name 'rfkill*') ) +
Is find really needed here? Can't this just be a glob, or do you really not know the depth of the rfkill* directory?
path_phy=("/sys/class/net/$INTERFACE/phy80211/rfkill"*)
If it isn't, this still isn't the proper way to read the results of a command into an array. Not sure if there's other bash4 syntax in netcfg, but I'd do something like:
mapfile -t path_phy < <(find ....)
else:
IFS=$'\n' read -rd '' -a path_phy < <(find ....)
if [[ -d "$path" ]]; then
echo "$path" return 0
- fi + elif [[ -n "${path_phy[0]}" ]]; then
And in combination with the globbing advice:
elif [[ ${path_phy[0]} && -e ${path_phy[0]} ]]; then
this saves you from having to enable nullglob.
Ok, thanks for the advice. Will do and resend the patch then.
+ echo "${path_phy[0]}" + return 0 + fi
report_fail "no rfkill switch available on interface $INTERFACE"
fi return 1
On Tue, Oct 2, 2012 at 1:47 PM, Ivan Shapovalov <intelfx100@gmail.com> wrote:
I have rfkill switches under path "/sys/class/net/$INTERFACE/phy80211/rfkill*" but not "/sys/class/net/$INTERFACE/rfkill" on two systems with iwlagn and ath9k drivers. Guess someone else also has these.
Signed-off-by: Ivan Shapovalov <intelfx100@gmail.com> --- src/rfkill | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/rfkill b/src/rfkill index 12e1832..330544b 100644 --- a/src/rfkill +++ b/src/rfkill @@ -29,10 +29,18 @@ get_rf_path() { report_fail "no rfkill switch with name $RFKILL_NAME" else path="/sys/class/net/$INTERFACE/rfkill" + + # There may be many rfkill switches attached to a single PHY + # For now take the first of them + path_phy=( $(find "/sys/class/net/$INTERFACE/phy80211/" -type d -name 'rfkill*') ) + if [[ -d "$path" ]]; then echo "$path" return 0 - fi + elif [[ -n "${path_phy[0]}" ]]; then + echo "${path_phy[0]}" + return 0 + fi report_fail "no rfkill switch available on interface $INTERFACE" fi return 1 -- 1.7.12.2
I just wanted to confirm that the rfkill path on my system also is of the form /sys/class/net/wlan0/phy80211/rfkill0 This is with kernel 3.5.4 using brcmsmac. Jason
On Tue, Oct 2, 2012 at 7:47 PM, Ivan Shapovalov <intelfx100@gmail.com> wrote:
I have rfkill switches under path "/sys/class/net/$INTERFACE/phy80211/rfkill*" but not "/sys/class/net/$INTERFACE/rfkill" on two systems with iwlagn and ath9k drivers. Guess someone else also has these.
Signed-off-by: Ivan Shapovalov <intelfx100@gmail.com>
Our rfkill code is using deprecated functionality. The 'new' ABI is documented at http://www.kernel.org/doc/Documentation/ABI/stable/sysfs-class-rfkill I am not too familiar with rfkill, so if someone could rewrite the rfkill code, that would be much appreciated. Instead of using the new sysfs structure, we could also use the rfkill userspace program, although I don't know whether that would have any practical advantages. - Jouke
participants (4)
-
Dave Reisner
-
Ivan Shapovalov
-
Jason St. John
-
Jouke Witteveen