3
* Program to probe newly connected device interfaces from
4
* userspace to determine if they are MTP devices, used for
7
* Invoke the program from udev to check it for MTP signatures,
9
* ATTR{bDeviceClass}=="ff",
10
* PROGRAM="<path>/mtp-probe /sys$env{DEVPATH} $attr{busnum} $attr{devnum}",
11
* RESULT=="1", ENV{ID_MTP_DEVICE}="1", ENV{ID_MEDIA_PLAYER}="1",
12
* SYMLINK+="libmtp-%k", MODE="666"
14
* Is you issue this before testing your /var/log/messages
15
* will be more verbose:
17
* udevadm control --log-priority=debug
19
* Exits with status code 1 if the device is an MTP device,
22
* Copyright (C) 2011 Linus Walleij <triad@df.lth.se>
24
* This library is free software; you can redistribute it and/or
25
* modify it under the terms of the GNU Lesser General Public
26
* License as published by the Free Software Foundation; either
27
* version 2 of the License, or (at your option) any later version.
29
* This library is distributed in the hope that it will be useful,
30
* but WITHOUT ANY WARRANTY; without even the implied warranty of
31
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
32
* Lesser General Public License for more details.
34
* You should have received a copy of the GNU Lesser General Public
35
* License along with this library; if not, write to the
36
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
37
* Boston, MA 02111-1307, USA.
40
#error "This program should only be compiled for Linux!"
50
int main (int argc, char **argv)
58
syslog(LOG_INFO, "need device path, busnumber, device number as argument\n");
64
busno = atoi(argv[2]);
65
devno = atoi(argv[3]);
67
syslog(LOG_INFO, "checking bus %d, device %d: \"%s\"\n", busno, devno, fname);
69
ret = LIBMTP_Check_Specific_Device(busno, devno);
71
syslog(LOG_INFO, "bus: %d, device: %d was an MTP device\n", busno, devno);
74
syslog(LOG_INFO, "bus: %d, device: %d was not an MTP device\n", busno, devno);