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

« back to all changes in this revision

Viewing changes to src/gudev/gjs-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 gjs-console
 
2
 
 
3
// This currently depends on the following patches to gjs
 
4
//
 
5
// http://bugzilla.gnome.org/show_bug.cgi?id=584558
 
6
// http://bugzilla.gnome.org/show_bug.cgi?id=584560
 
7
// http://bugzilla.gnome.org/show_bug.cgi?id=584568
 
8
 
 
9
const GUdev = imports.gi.GUdev;
 
10
const Mainloop = imports.mainloop;
 
11
 
 
12
function print_device (device) {
 
13
  print ("  subsystem:             " + device.get_subsystem ());
 
14
  print ("  devtype:               " + device.get_devtype ());
 
15
  print ("  name:                  " + device.get_name ());
 
16
  print ("  number:                " + device.get_number ());
 
17
  print ("  sysfs_path:            " + device.get_sysfs_path ());
 
18
  print ("  driver:                " + device.get_driver ());
 
19
  print ("  action:                " + device.get_action ());
 
20
  print ("  seqnum:                " + device.get_seqnum ());
 
21
  print ("  device type:           " + device.get_device_type ());
 
22
  print ("  device number:         " + device.get_device_number ());
 
23
  print ("  device file:           " + device.get_device_file ());
 
24
  print ("  device file symlinks:  " + device.get_device_file_symlinks ());
 
25
  print ("  foo: " + device.get_sysfs_attr_as_strv ("stat"));
 
26
  var keys = device.get_property_keys ();
 
27
  for (var n = 0; n < keys.length; n++) {
 
28
    print ("    " + keys[n] + "=" + device.get_property (keys[n]));
 
29
  }
 
30
}
 
31
 
 
32
function on_uevent (client, action, device) {
 
33
  print ("action " + action + " on device " + device.get_sysfs_path());
 
34
  print_device (device);
 
35
  print ("");
 
36
}
 
37
 
 
38
var client = new GUdev.Client ({subsystems: ["block", "usb/usb_interface"]});
 
39
client.connect ("uevent", on_uevent);
 
40
 
 
41
var block_devices = client.query_by_subsystem ("block");
 
42
for (var n = 0; n < block_devices.length; n++) {
 
43
  print ("block device: " + block_devices[n].get_device_file ());
 
44
}
 
45
 
 
46
var d;
 
47
 
 
48
d = client.query_by_device_number (GUdev.DeviceType.BLOCK, 0x0810);
 
49
if (d == null) {
 
50
  print ("query_by_device_number 0x810 -> null");
 
51
} else {
 
52
  print ("query_by_device_number 0x810 -> " + d.get_device_file ());
 
53
  var dd = d.get_parent_with_subsystem ("usb", null);
 
54
  print_device (dd);
 
55
  print ("--------------------------------------------------------------------------");
 
56
  while (d != null) {
 
57
    print_device (d);
 
58
    print ("");
 
59
    d = d.get_parent ();
 
60
  }
 
61
}
 
62
 
 
63
d = client.query_by_sysfs_path ("/sys/block/sda/sda1");
 
64
print ("query_by_sysfs_path (\"/sys/block/sda1\") -> " + d.get_device_file ());
 
65
 
 
66
d = client.query_by_subsystem_and_name ("block", "sda2");
 
67
print ("query_by_subsystem_and_name (\"block\", \"sda2\") -> " + d.get_device_file ());
 
68
 
 
69
d = client.query_by_device_file ("/dev/sda");
 
70
print ("query_by_device_file (\"/dev/sda\") -> " + d.get_device_file ());
 
71
 
 
72
d = client.query_by_device_file ("/dev/block/8:0");
 
73
print ("query_by_device_file (\"/dev/block/8:0\") -> " + d.get_device_file ());
 
74
 
 
75
Mainloop.run('udev-example');