seed-example.js revision ad29a9f14fa8b1932c0e418bfcf1c10ce6a35a33
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering// seed example
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering print (" subsystem: " + device.get_subsystem ());
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering print (" devtype: " + device.get_devtype ());
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering print (" number: " + device.get_number ());
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering print (" sysfs_path: " + device.get_sysfs_path ());
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering print (" driver: " + device.get_driver ());
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering print (" action: " + device.get_action ());
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering print (" seqnum: " + device.get_seqnum ());
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering print (" device type: " + device.get_device_type ());
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering print (" device number: " + device.get_device_number ());
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering print (" device file: " + device.get_device_file ());
1b00a255225bd65bcc3f6257bd4b1e2089f231b4Tollef Fog Heen print (" device file symlinks: " + device.get_device_file_symlinks ());
e99e38bbdcca3fe5956823bdb3d38544ccf93221Lennart Poettering print (" foo: " + device.get_sysfs_attr_as_strv ("stat"));
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering print (" " + keys[n] + "=" + device.get_property (keys[n]));
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poetteringfunction on_uevent (client, action, device) {
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering print ("action " + action + " on device " + device.get_sysfs_path());
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poetteringvar client = new GUdev.Client ({subsystems: ["block", "usb/usb_interface"]});
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poetteringclient.signal.connect ("uevent", on_uevent);
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poetteringvar block_devices = client.query_by_subsystem ("block");
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poetteringfor (var n = 0; n < block_devices.length; n++) {
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering print ("block device: " + block_devices[n].get_device_file ());
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poetteringd = client.query_by_device_number (GUdev.DeviceType.BLOCK, 0x0810);
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poetteringif (d == null) {
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering print ("query_by_device_number 0x810 -> null");
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering print ("query_by_device_number 0x810 -> " + d.get_device_file ());
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering dd = d.get_parent_with_subsystem ("usb", null);
d1ab0ca07372649dad70a0348d75e394f254e1b6Lennart Poettering print ("--------------------------------------------------------------------------");
d1ab0ca07372649dad70a0348d75e394f254e1b6Lennart Poettering while (d != null) {
d1ab0ca07372649dad70a0348d75e394f254e1b6Lennart Poetteringd = client.query_by_sysfs_path ("/sys/block/sda/sda1");
d1ab0ca07372649dad70a0348d75e394f254e1b6Lennart Poetteringprint ("query_by_sysfs_path (\"/sys/block/sda1\") -> " + d.get_device_file ());
d1ab0ca07372649dad70a0348d75e394f254e1b6Lennart Poetteringd = client.query_by_subsystem_and_name ("block", "sda2");
d1ab0ca07372649dad70a0348d75e394f254e1b6Lennart Poetteringprint ("query_by_subsystem_and_name (\"block\", \"sda2\") -> " + d.get_device_file ());
d1ab0ca07372649dad70a0348d75e394f254e1b6Lennart Poetteringd = client.query_by_device_file ("/dev/sda");
d1ab0ca07372649dad70a0348d75e394f254e1b6Lennart Poetteringprint ("query_by_device_file (\"/dev/sda\") -> " + d.get_device_file ());
d1ab0ca07372649dad70a0348d75e394f254e1b6Lennart Poetteringd = client.query_by_device_file ("/dev/block/8:0");
d1ab0ca07372649dad70a0348d75e394f254e1b6Lennart Poetteringprint ("query_by_device_file (\"/dev/block/8:0\") -> " + d.get_device_file ());