atm: expose ATM device index in sysfs
Subsystems (3)
PATCH 1/1 atm: expose ATM device index in sysfs
It's current exposed only through /proc which besides requiring screen-scraping doesn't allow userspace to distinguish between two identical ATM adapters with different ATM indexes. The ATM device index is required when using PPPoATM on a system with multiple ATM adapters.
---
PS: -> stable too since it's a minimal change with no backwards incompatibility and I'd like to rely on this attribute in NetworkManager
net/atm/atm_sysfs.c +12 -0
@@ -59,6 +59,16 @@ static ssize_t show_atmaddress(struct device *cdev,return pos - buf; } +static ssize_t show_atmindex (struct device *cdev, +struct device_attribute *attr,char *buf) +{ +char *pos = buf; +struct atm_dev *adev =to_atm_dev (cdev); + + pos +=sprintf (pos,"%d\n" , adev->number); +return pos - buf; +} +static ssize_t show_carrier (struct device *cdev,struct device_attribute *attr,char *buf) {
@@ -99,6 +109,7 @@ static ssize_t show_link_rate(struct device *cdev, static DEVICE_ATTR(address, S_IRUGO, show_address, NULL); static DEVICE_ATTR(atmaddress, S_IRUGO, show_atmaddress, NULL); +static DEVICE_ATTR(atmindex, S_IRUGO, show_atmindex, NULL); static DEVICE_ATTR(carrier, S_IRUGO, show_carrier, NULL); static DEVICE_ATTR(type, S_IRUGO, show_type, NULL); static DEVICE_ATTR(link_rate, S_IRUGO, show_link_rate, NULL);
@@ -106,6 +117,7 @@ static DEVICE_ATTR(link_rate, S_IRUGO, show_link_rate, NULL);static struct device_attribute *atm_attrs[] = { &dev_attr_atmaddress, &dev_attr_address, + &dev_attr_atmindex, &dev_attr_carrier, &dev_attr_type, &dev_attr_link_rate,
Quoted 19 lines · Dan Williams
It's current exposed only through /proc which besides requiring screen-scraping doesn't allow userspace to distinguish between two identical ATM adapters with different ATM indexes. The ATM device index is required when using PPPoATM on a system with multiple ATM adapters.
Signed-off-by Dan Williams <[email protected]>---
PS: -> stable too since it's a minimal change with no backwards incompatibility and I'd like to rely on this attribute in NetworkManager
net/atm/atm_sysfs.c +0
-0@@ -59,6 +59,16 @@ static ssize_t show_atmaddress(struct device *cdev,return pos - buf; }
net/atm/atm_sysfs.c static ssize_t show_atmaddress(struct device *cdev, · line 71
Quoted 10 lines
net/atm/atm_sysfs.c +10
-0+static ssize_t show_atmindex (struct device *cdev, +struct device_attribute *attr,char *buf) +{ +char *pos = buf; +struct atm_dev *adev =to_atm_dev (cdev); + + pos +=sprintf (pos,"%d\n" , adev->number); +return pos - buf; +} +
What about :
{
struct atm_dev *adev = to_atm_dev(cdev);
return sprintf(buf, "%d\n", adev->number);
}Quoted 33 lines · Eric Dumazet
Quoted 19 lines · Dan Williams
It's current exposed only through /proc which besides requiring screen-scraping doesn't allow userspace to distinguish between two identical ATM adapters with different ATM indexes. The ATM device index is required when using PPPoATM on a system with multiple ATM adapters.
Signed-off-by Dan Williams <[email protected]>---
PS: -> stable too since it's a minimal change with no backwards incompatibility and I'd like to rely on this attribute in NetworkManager
net/atm/atm_sysfs.c +0
-0@@ -59,6 +59,16 @@ static ssize_t show_atmaddress(struct device *cdev,return pos - buf; }net/atm/atm_sysfs.c static ssize_t show_atmaddress(struct device *cdev, · line 71
Quoted 10 lines
net/atm/atm_sysfs.c +10
-0+static ssize_t show_atmindex (struct device *cdev, +struct device_attribute *attr,char *buf) +{ +char *pos = buf; +struct atm_dev *adev =to_atm_dev (cdev); + + pos +=sprintf (pos,"%d\n" , adev->number); +return pos - buf; +} +What about :
Quoted 5 lines
{
struct atm_dev *adev = to_atm_dev(cdev);
return sprintf(buf, "%d\n", adev->number);
}Sure, will send v2.
Dan
Quoted 10 lines · Dan Williams
It's current exposed only through /proc which besides requiring screen-scraping doesn't allow userspace to distinguish between two identical ATM adapters with different ATM indexes. The ATM device index is required when using PPPoATM on a system with multiple ATM adapters.
Signed-off-by Dan Williams <[email protected]>---
PS: -> stable too since it's a minimal change with no backwards incompatibility and I'd like to rely on this attribute in NetworkManager
<formletter>
This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read Documentation/stable_kernel_rules.txt for how to do this properly.
</formletter>
PATCH v2 1/1 atm: expose ATM device index in sysfs
In reply to Dan WilliamsIt's currently exposed only through /proc which, besides requiring screen-scraping, doesn't allow userspace to distinguish between two identical ATM adapters with different ATM indexes. The ATM device index is required when using PPPoATM on a system with multiple ATM adapters.
---
net/atm/atm_sysfs.c +10 -0
@@ -59,6 +59,14 @@ static ssize_t show_atmaddress(struct device *cdev,return pos - buf; } +static ssize_t show_atmindex (struct device *cdev, +struct device_attribute *attr,char *buf) +{ +struct atm_dev *adev =to_atm_dev (cdev); + +return sprintf (buf,"%d\n" , adev->number); +} +static ssize_t show_carrier (struct device *cdev,struct device_attribute *attr,char *buf) {
@@ -99,6 +107,7 @@ static ssize_t show_link_rate(struct device *cdev, static DEVICE_ATTR(address, S_IRUGO, show_address, NULL); static DEVICE_ATTR(atmaddress, S_IRUGO, show_atmaddress, NULL); +static DEVICE_ATTR(atmindex, S_IRUGO, show_atmindex, NULL); static DEVICE_ATTR(carrier, S_IRUGO, show_carrier, NULL); static DEVICE_ATTR(type, S_IRUGO, show_type, NULL); static DEVICE_ATTR(link_rate, S_IRUGO, show_link_rate, NULL);
@@ -106,6 +115,7 @@ static DEVICE_ATTR(link_rate, S_IRUGO, show_link_rate, NULL);static struct device_attribute *atm_attrs[] = { &dev_attr_atmaddress, &dev_attr_address, + &dev_attr_atmindex, &dev_attr_carrier, &dev_attr_type, &dev_attr_link_rate,
Quoted 8 lines · Dan Williams
It's currently exposed only through /proc which, besides requiring screen-scraping, doesn't allow userspace to distinguish between two identical ATM adapters with different ATM indexes. The ATM device index is required when using PPPoATM on a system with multiple ATM adapters.
Signed-off-by Dan Williams <[email protected]>---
David Woodhouse
Tested-byQuoted 11 lines · Eric Dumazet
Quoted 8 lines · Dan Williams
It's currently exposed only through /proc which, besides requiring screen-scraping, doesn't allow userspace to distinguish between two identical ATM adapters with different ATM indexes. The ATM device index is required when using PPPoATM on a system with multiple ATM adapters.
Signed-off-by Dan Williams <[email protected]>---
Reviewed-by Eric Dumazet <[email protected]>
[root@solos atm]# grep ^ /sys/class/atm/*/atmindex /sys/class/atm/solos-pci0/atmindex:0 /sys/class/atm/solos-pci1/atmindex:1
Signature · 1 line
dwmw2
From: David Woodhouse <[email protected]>
Date: Fri, 27 May 2011 16:05:41 +0100
Quoted 11 lines · Eric Dumazet
Quoted 10 lines · Dan Williams
Quoted 8 lines
It's currently exposed only through /proc which, besides requiring screen-scraping, doesn't allow userspace to distinguish between two identical ATM adapters with different ATM indexes. The ATM device index is required when using PPPoATM on a system with multiple ATM adapters.
Signed-off-by Dan Williams <[email protected]>---
Quoted 8 lines
Quoted 1 line
Reviewed-by Eric Dumazet <[email protected]>Tested-by David Woodhouse <[email protected]>[root@solos atm]# grep ^
/sys/class/atm/*/atmindex/sys/class/atm/solos-pci0/atmindex:0/sys/class/atm/solos-pci1/atmindex:1
Applied, thanks.