summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorLinus Walleij <triad@df.lth.se>2010-12-01 23:00:00 +0000
committerLinus Walleij <triad@df.lth.se>2010-12-01 23:00:00 +0000
commit4f4082b6fac5d3ac61b1cc626759615b9b2813cc (patch)
treefa56b7d3fa889e5b7b0b197f867c6e0c223dc18c /util
parente1d774b20976f4ff869557c237392b49daf7baef (diff)
downloadlibmtp-4f4082b6fac5d3ac61b1cc626759615b9b2813cc.tar.gz
mtp-probe program added
Diffstat (limited to 'util')
-rw-r--r--util/Makefile.am3
-rw-r--r--util/mtp-hotplug.c2
-rw-r--r--util/mtp-probe.c48
3 files changed, 51 insertions, 2 deletions
diff --git a/util/Makefile.am b/util/Makefile.am
index 78e7015..8e2b002 100644
--- a/util/Makefile.am
+++ b/util/Makefile.am
@@ -1,6 +1,7 @@
-bin_PROGRAMS=mtp-hotplug
+bin_PROGRAMS=mtp-hotplug mtp-probe
mtp_hotplug_SOURCES=mtp-hotplug.c
+mtp_probe_SOURCES=mtp-probe.c
AM_CPPFLAGS=-I$(top_builddir)/src
LDADD=../src/libmtp.la
diff --git a/util/mtp-hotplug.c b/util/mtp-hotplug.c
index f8036ba..1266ebf 100644
--- a/util/mtp-hotplug.c
+++ b/util/mtp-hotplug.c
@@ -1,6 +1,6 @@
/**
* \file mtp-hotplug.c
- * Example program to create hotplug scripts.
+ * Program to create hotplug scripts.
*
* Copyright (C) 2005-2010 Linus Walleij <triad@df.lth.se>
* Copyright (C) 2006-2008 Marcus Meissner <marcus@jet.franken.de>
diff --git a/util/mtp-probe.c b/util/mtp-probe.c
new file mode 100644
index 0000000..7de15f8
--- /dev/null
+++ b/util/mtp-probe.c
@@ -0,0 +1,48 @@
+/**
+ * \file mtp-probe.c
+ * Program to probe newly connected device interfaces from
+ * userspace to determine if they are MTP devices, used for
+ * udev rules.
+ *
+ * Invoke the program on a sysfs device entry to check it
+ * for MTP signatures, e.g.
+ * mtp-probe /sys/devices/pci0000:00/0000:00:1d.7/usb1/1-8
+ *
+ * Exits with status code 0 if the device is an MTP device,
+ * else exits with 1.
+ *
+ * Copyright (C) 2010 Linus Walleij <triad@df.lth.se>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+#include <libmtp.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+int main (int argc, char **argv)
+{
+ char *fname;
+
+ if (argc < 2) {
+ printf("No device file to check\n");
+ exit(1);
+ }
+ fname = argv[1];
+ printf("Checking: \"%s\"...\n", fname);
+ exit (1);
+}