summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Walleij <triad@df.lth.se>2010-11-30 23:26:11 +0000
committerLinus Walleij <triad@df.lth.se>2010-11-30 23:26:11 +0000
commite52725481fb87277a10f8b7f43c7c2bb14325359 (patch)
tree497deaa1d9a15090ce163a30ddb42e03a2c82a16
parentcbfe177e2b72c790ffeddc80a830c76d60383530 (diff)
downloadlibmtp-e52725481fb87277a10f8b7f43c7c2bb14325359.tar.gz
Drop some old udev styleing
-rw-r--r--ChangeLog4
-rw-r--r--examples/hotplug.c46
2 files changed, 24 insertions, 26 deletions
diff --git a/ChangeLog b/ChangeLog
index 58b4322..dfbfc9e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2010-12-01 Linus Walleij <triad@df.lth.se>
+
+ * examples/hotplug.c: drop old udev style somewhat.
+
2010-11-24 Linus Walleij <triad@df.lth.se>
* examples/hotplug.c: set the music player environment
diff --git a/examples/hotplug.c b/examples/hotplug.c
index 94f315a..72b0abc 100644
--- a/examples/hotplug.c
+++ b/examples/hotplug.c
@@ -30,6 +30,7 @@ static void usage(void)
{
fprintf(stderr, "usage: hotplug [-u -H -i -a\"ACTION\"]\n");
fprintf(stderr, " -u: use udev syntax\n");
+ fprintf(stderr, " -o: use old udev syntax\n");
fprintf(stderr, " -H: use hal syntax\n");
fprintf(stderr, " -i: use usb.ids simple list syntax\n");
fprintf(stderr, " -a\"ACTION\": perform udev action ACTION on attachment\n");
@@ -39,6 +40,7 @@ static void usage(void)
enum style {
style_usbmap,
style_udev,
+ style_udev_old,
style_hal,
style_usbids
};
@@ -58,13 +60,16 @@ int main (int argc, char **argv)
char *action; // To hold the action actually used.
uint16_t last_vendor = 0x0000U;
- while ( (opt = getopt(argc, argv, "uUiHa:")) != -1 ) {
+ while ( (opt = getopt(argc, argv, "uoUiHa:")) != -1 ) {
switch (opt) {
case 'a':
udev_action = strdup(optarg);
case 'u':
style = style_udev;
break;
+ case 'o':
+ style = style_udev_old;
+ break;
case 'H':
style = style_hal;
break;
@@ -92,11 +97,18 @@ int main (int argc, char **argv)
printf("ACTION!=\"add\", GOTO=\"libmtp_rules_end\"\n");
printf("ENV{MAJOR}!=\"?*\", GOTO=\"libmtp_rules_end\"\n");
printf("SUBSYSTEM==\"usb\", GOTO=\"libmtp_usb_rules\"\n"
- "# The following thing will be deprecated when older kernels are phased out.\n"
- "SUBSYSTEM==\"usb_device\", GOTO=\"libmtp_usb_device_rules\"\n"
"GOTO=\"libmtp_rules_end\"\n\n"
"LABEL=\"libmtp_usb_rules\"\n\n");
break;
+ case style_udev_old:
+ printf("# UDEV-style hotplug map for libmtp\n");
+ printf("# Put this file in /etc/udev/rules.d\n\n");
+ printf("ACTION!=\"add\", GOTO=\"libmtp_rules_end\"\n");
+ printf("ENV{MAJOR}!=\"?*\", GOTO=\"libmtp_rules_end\"\n");
+ printf("SUBSYSTEM==\"usb_device\", GOTO=\"libmtp_usb_device_rules\"\n"
+ "GOTO=\"libmtp_rules_end\"\n\n"
+ "LABEL=\"libmtp_usb_device_rules\"\n\n");
+ break;
case style_usbmap:
printf("# This usermap will call the script \"libmtp.sh\" whenever a known MTP device is attached.\n\n");
break;
@@ -117,15 +129,11 @@ int main (int argc, char **argv)
LIBMTP_device_entry_t * entry = &entries[i];
switch (style) {
- case style_udev:
- {
- printf("# %s %s\n", entry->vendor, entry->product);
- // Old style directly SYSFS named.
- // printf("SYSFS{idVendor}==\"%04x\", SYSFS{idProduct}==\"%04x\", %s\n", entry->vendor_id, entry->product_id, action);
- // Newer style
- printf("ATTR{idVendor}==\"%04x\", ATTR{idProduct}==\"%04x\", %s\n", entry->vendor_id, entry->product_id, action);
- break;
- }
+ case style_udev:
+ case style_udev_old:
+ printf("# %s %s\n", entry->vendor, entry->product);
+ printf("ATTR{idVendor}==\"%04x\", ATTR{idProduct}==\"%04x\", %s\n", entry->vendor_id, entry->product_id, action);
+ break;
case style_usbmap:
printf("# %s %s\n", entry->vendor, entry->product);
printf("libmtp.sh 0x0003 0x%04x 0x%04x 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000\n", entry->vendor_id, entry->product_id);
@@ -179,20 +187,6 @@ int main (int argc, char **argv)
exit(1);
}
- // For backward comparibility with the #$!+@! ever changing
- // udev rule style...
- if (style == style_udev) {
- printf("GOTO=\"libmtp_rules_end\"\n\n");
- printf("LABEL=\"libmtp_usb_device_rules\"\n");
- for (i = 0; i < numentries; i++) {
- LIBMTP_device_entry_t * entry = &entries[i];
-
- printf("# %s %s\n", entry->vendor, entry->product);
- printf("ATTRS{idVendor}==\"%04x\", ATTRS{idProduct}==\"%04x\", %s\n", entry->vendor_id, entry->product_id, action);
- }
- printf("GOTO=\"libmtp_rules_end\"\n\n");
- }
-
// Then the footer.
switch (style) {
case style_usbmap: