Example #1
0
// Devlinks retrieves the map of device links pointing to the device file of the udev device.
// The path is an absolute path, and starts with the device directory.
func (d *Device) Devlinks() (r map[string]struct{}) {
	d.lock()
	defer d.unlock()
	r = make(map[string]struct{})
	for l := C.udev_device_get_devlinks_list_entry(d.ptr); l != nil; l = C.udev_list_entry_get_next(l) {
		r[C.GoString(C.udev_list_entry_get_name(l))] = struct{}{}
	}
	return
}
Example #2
0
// DevlinkIterator returns an Iterator over the device links pointing to the device file of the udev device.
// The Iterator is using the github.com/jkeiser/iter package.
// Values are returned as an interface{} and should be cast to string.
func (d *Device) DevlinkIterator() iter.Iterator {
	d.lock()
	defer d.unlock()
	l := C.udev_device_get_devlinks_list_entry(d.ptr)
	return iter.Iterator{
		Next: func() (item interface{}, err error) {
			d.lock()
			defer d.unlock()
			if l != nil {
				item = C.GoString(C.udev_list_entry_get_name(l))
				l = C.udev_list_entry_get_next(l)
			} else {
				err = iter.FINISHED
			}
			return
		},
		Close: func() {
		},
	}
}
Example #3
0
File: udev.go Project: jessta/udev
func (e Enumerate) FirstDevLinks() ListEntry {
	return ListEntry{C.udev_device_get_devlinks_list_entry(e.ptr)}
}