~ubuntu-branches/ubuntu/trusty/systemd/trusty

« back to all changes in this revision

Viewing changes to src/gudev/seed-example.js

  • Committer: Package Import Robot
  • Author(s): Michael Biebl, Michael Biebl, Michael Stapelberg, Daniel Schaal, Ondrej Balaz
  • Date: 2013-09-12 00:13:11 UTC
  • mfrom: (1.1.11) (9.1.2 experimental)
  • mto: This revision was merged to the branch mainline in revision 53.
  • Revision ID: package-import@ubuntu.com-20130912001311-dz35it34wr2lbday
Tags: 204-3
[ Michael Biebl ]
* Upload to unstable.
* Use /bin/bash in debug-shell.service as Debian doesn't have /sbin/sushell.
* Only import net.ifaces cmdline property for network devices.
* Generate strict dependencies between the binary packages using a
  shlibs.local file and add an explicit versioned dependency on
  libsystemd-login0 to systemd to ensure packages are upgraded in sync.
  Closes: #719444
* Drop obsolete Replaces: libudev0 from udev package.
* Use correct paths for various binaries, like /sbin/quotaon, which are
  installed in / and not /usr in Debian.  Closes: #721347
* Don't install kernel-install(8) man page since we don't install the
  corresponding binary either.  Closes: #722180
* Cherry-pick upstream fixes to make switching runlevels and starting
  reboot via ctrl-alt-del more robust.
* Cherry-pick upstream fix to properly apply ACLs to Journal files.

[ Michael Stapelberg ]
* Make systemctl enable|disable call update-rc.d for SysV init scripts.
  Closes: #709780
* Don't mount /tmp as tmpfs by default and make it possible to enable this
  feature via "systemctl enable tmp.mount".

[ Daniel Schaal ]
* Add bug-script to systemd and udev.  Closes: #711245

[ Ondrej Balaz ]
* Recognize discard option in /etc/crypttab.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env seed
 
2
 
 
3
// seed example
 
4
 
 
5
const GLib = imports.gi.GLib;
 
6
const GUdev = imports.gi.GUdev;
 
7
 
 
8
function print_device (device) {
 
9
  print ("  subsystem:             " + device.get_subsystem ());
 
10
  print ("  devtype:               " + device.get_devtype ());
 
11
  print ("  name:                  " + device.get_name ());
 
12
  print ("  number:                " + device.get_number ());
 
13
  print ("  sysfs_path:            " + device.get_sysfs_path ());
 
14
  print ("  driver:                " + device.get_driver ());
 
15
  print ("  action:                " + device.get_action ());
 
16
  print ("  seqnum:                " + device.get_seqnum ());
 
17
  print ("  device type:           " + device.get_device_type ());
 
18
  print ("  device number:         " + device.get_device_number ());
 
19
  print ("  device file:           " + device.get_device_file ());
 
20
  print ("  device file symlinks:  " + device.get_device_file_symlinks ());
 
21
  print ("  foo: " + device.get_sysfs_attr_as_strv ("stat"));
 
22
  var keys = device.get_property_keys ();
 
23
  for (var n = 0; n < keys.length; n++) {
 
24
    print ("    " + keys[n] + "=" + device.get_property (keys[n]));
 
25
  }
 
26
}
 
27
 
 
28
function on_uevent (client, action, device) {
 
29
  print ("action " + action + " on device " + device.get_sysfs_path());
 
30
  print_device (device);
 
31
  print ("");
 
32
}
 
33
 
 
34
var client = new GUdev.Client ({subsystems: ["block", "usb/usb_interface"]});
 
35
client.signal.connect ("uevent", on_uevent);
 
36
 
 
37
var block_devices = client.query_by_subsystem ("block");
 
38
for (var n = 0; n < block_devices.length; n++) {
 
39
  print ("block device: " + block_devices[n].get_device_file ());
 
40
}
 
41
 
 
42
var d;
 
43
 
 
44
d = client.query_by_device_number (GUdev.DeviceType.BLOCK, 0x0810);
 
45
if (d == null) {
 
46
  print ("query_by_device_number 0x810 -> null");
 
47
} else {
 
48
  print ("query_by_device_number 0x810 -> " + d.get_device_file ());
 
49
  dd = d.get_parent_with_subsystem ("usb", null);
 
50
  print_device (dd);
 
51
  print ("--------------------------------------------------------------------------");
 
52
  while (d != null) {
 
53
    print_device (d);
 
54
    print ("");
 
55
    d = d.get_parent ();
 
56
  }
 
57
}
 
58
 
 
59
d = client.query_by_sysfs_path ("/sys/block/sda/sda1");
 
60
print ("query_by_sysfs_path (\"/sys/block/sda1\") -> " + d.get_device_file ());
 
61
 
 
62
d = client.query_by_subsystem_and_name ("block", "sda2");
 
63
print ("query_by_subsystem_and_name (\"block\", \"sda2\") -> " + d.get_device_file ());
 
64
 
 
65
d = client.query_by_device_file ("/dev/sda");
 
66
print ("query_by_device_file (\"/dev/sda\") -> " + d.get_device_file ());
 
67
 
 
68
d = client.query_by_device_file ("/dev/block/8:0");
 
69
print ("query_by_device_file (\"/dev/block/8:0\") -> " + d.get_device_file ());
 
70
 
 
71
var mainloop = GLib.main_loop_new ();
 
72
GLib.main_loop_run (mainloop);