NetClass returns info for all net interfaces (iface) read from /sys/class/net/ .
()
| 110 | |
| 111 | // NetClass returns info for all net interfaces (iface) read from /sys/class/net/<iface>. |
| 112 | func (fs FS) NetClass() (NetClass, error) { |
| 113 | devices, err := fs.NetClassDevices() |
| 114 | if err != nil { |
| 115 | return nil, err |
| 116 | } |
| 117 | |
| 118 | path := fs.sys.Path(netclassPath) |
| 119 | netClass := NetClass{} |
| 120 | for _, devicePath := range devices { |
| 121 | interfaceClass, err := parseNetClassIface(filepath.Join(path, devicePath)) |
| 122 | if err != nil { |
| 123 | return nil, err |
| 124 | } |
| 125 | interfaceClass.Name = devicePath |
| 126 | netClass[devicePath] = *interfaceClass |
| 127 | } |
| 128 | |
| 129 | return netClass, nil |
| 130 | } |
| 131 | |
| 132 | // canIgnoreError returns true if the error is non-fatal and can be ignored. |
| 133 | // Some kernels and some devices don't expose specific attributes or return |