M0Rf30/android-udev-rules

Failed to rename '/dev/android.tmp-c189:17' to '/dev/android' failed: Is a directory

terencode opened this issue · 12 comments

I'm using Archlinux, here is the udev debug log:

usb 1-4.1: new high-speed USB device number 18 using xhci_hcd
1-4.1: Device (SEQNUM=3193, ACTION=add) is queued
usb 1-4.1: New USB device found, idVendor=2a70, idProduct=4ee7, bcdDevice= 4.09
usb 1-4.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-4.1: Product: OnePlus
usb 1-4.1: Manufacturer: OnePlus
usb 1-4.1: SerialNumber: 4e51be36
Validate module index
Check if link configuration needs reloading.
Successfully forked off 'n/a' as PID 15411.
1-4.1: Worker [15411] is forked for processing SEQNUM=3193.
1-4.1: Processing device (SEQNUM=3193, ACTION=add)
1-4.1: IMPORT builtin 'usb_id' /usr/lib/udev/rules.d/40-gphoto.rules:9
1-4.1:1.0: Device (SEQNUM=3194, ACTION=add) is queued
1-4.1: Device (SEQNUM=3195, ACTION=bind) is queued
1-4.1: IMPORT builtin skip 'usb_id' /usr/lib/udev/rules.d/50-udev-default.rules:13
1-4.1: IMPORT builtin 'hwdb' /usr/lib/udev/rules.d/50-udev-default.rules:13
1-4.1: No entry found from hwdb.
1-4.1: IMPORT builtin 'hwdb' fails: No data available
1-4.1: MODE 0664 /usr/lib/udev/rules.d/50-udev-default.rules:45
1-4.1: ATTR '/sys/devices/pci0000:00/0000:00:01.3/0000:01:00.0/usb1/1-4/1-4.1/power/control' writing 'on' /etc/udev/rules.d/50-usb_power_save.rules:2
1-4.1: GROUP 993 /usr/lib/udev/rules.d/51-android.rules:10
1-4.1: MODE 0660 /usr/lib/udev/rules.d/51-android.rules:10
1-4.1: LINK 'android/4e51be36' /usr/lib/udev/rules.d/51-android.rules:10
1-4.1: LINK 'android_adb' /usr/lib/udev/rules.d/51-android.rules:407
1-4.1: GROUP 993 /usr/lib/udev/rules.d/51-android.rules:662
1-4.1: MODE 0660 /usr/lib/udev/rules.d/51-android.rules:662
1-4.1: LINK 'android' /usr/lib/udev/rules.d/51-android.rules:662
1-4.1: RUN '/usr/share/virtualbox/VBoxCreateUSBNode.sh $major $minor $attr{bDeviceClass} vboxusers' /usr/lib/udev/rules.d/60-vboxdrv.rules:6
1-4.1: PROGRAM '/usr/lib/udev/mtp-probe /sys/devices/pci0000:00/0000:00:01.3/0000:01:00.0/usb1/1-4/1-4.1 1 18' /usr/lib/udev/rules.d/69-libmtp.rules:2537
Starting '/usr/lib/udev/mtp-probe /sys/devices/pci0000:00/0000:00:01.3/0000:01:00.0/usb1/1-4/1-4.1 1 18'
Successfully forked off '(spawn)' as PID 15412.
checking bus 1, device 18: "/sys/devices/pci0000:00/0000:00:01.3/0000:01:00.0/usb1/1-4/1-4.1"
bus: 1, device: 18 was not an MTP device
'/usr/lib/udev/mtp-probe /sys/devices/pci0000:00/0000:00:01.3/0000:01:00.0/usb1/1-4/1-4.1 1 18'(out) '0'
Process '/usr/lib/udev/mtp-probe /sys/devices/pci0000:00/0000:00:01.3/0000:01:00.0/usb1/1-4/1-4.1 1 18' succeeded.
1-4.1: IMPORT builtin 'path_id' /usr/lib/udev/rules.d/71-seat.rules:58
1-4.1: RUN 'uaccess' /usr/lib/udev/rules.d/73-seat-late.rules:17
1-4.1: Handling device node '/dev/bus/usb/001/018', devnum=c189:17, mode=0660, uid=0, gid=993
1-4.1: Setting permissions /dev/bus/usb/001/018, 020660, uid=0, gid=993
1-4.1: Creating symlink '/dev/char/189:17' to '../bus/usb/001/018'
1-4.1: Creating symlink '/dev/android/4e51be36' to '../bus/usb/001/018'
1-4.1: Creating symlink '/dev/android_adb' to 'bus/usb/001/018'
1-4.1: Atomically replace '/dev/android'
1-4.1: Failed to rename '/dev/android.tmp-c189:17' to '/dev/android' failed: Is a directory
1-4.1: sd-device: Created db file '/run/udev/data/c189:17' for '/devices/pci0000:00/0000:00:01.3/0000:01:00.0/usb1/1-4/1-4.1'
Starting '/usr/share/virtualbox/VBoxCreateUSBNode.sh 189 17 00 vboxusers'
Successfully forked off '(spawn)' as PID 15413.
Process '/usr/share/virtualbox/VBoxCreateUSBNode.sh 189 17 00 vboxusers' succeeded.
1-4.1: Device (SEQNUM=3193, ACTION=add) processed
1-4.1: sd-device-monitor: Passed 746 byte to netlink monitor
1-4.1:1.0: sd-device-monitor: Passed 317 byte to netlink monitor
1-4.1:1.0: Processing device (SEQNUM=3194, ACTION=add)
1-4.1:1.0: IMPORT builtin 'usb_id' /usr/lib/udev/rules.d/40-gphoto.rules:9
1-4.1:1.0: Failed to access usb_interface: No such file or directory
1-4.1:1.0: IMPORT builtin 'usb_id' fails: No such file or directory
1-4.1:1.0: IMPORT builtin 'hwdb' /usr/lib/udev/rules.d/50-udev-default.rules:14
1-4.1:1.0: No entry found from hwdb.
1-4.1:1.0: IMPORT builtin 'hwdb' fails: No data available
1-4.1:1.0: RUN 'kmod load $env{MODALIAS}' /usr/lib/udev/rules.d/80-drivers.rules:5
1-4.1:1.0: sd-device: Created db file '/run/udev/data/+usb:1-4.1:1.0' for '/devices/pci0000:00/0000:00:01.3/0000:01:00.0/usb1/1-4/1-4.1/1-4.1:1.0'
Loading module: usb:v2A70p4EE7d0409dc00dsc00dp00icFFisc42ip01in00
Failed to find module 'usb:v2A70p4EE7d0409dc00dsc00dp00icFFisc42ip01in00'
1-4.1:1.0: Device (SEQNUM=3194, ACTION=add) processed
1-4.1:1.0: sd-device-monitor: Passed 330 byte to netlink monitor
1-4.1: sd-device-monitor: Passed 308 byte to netlink monitor
1-4.1: Processing device (SEQNUM=3195, ACTION=bind)
1-4.1: IMPORT builtin 'usb_id' /usr/lib/udev/rules.d/40-gphoto.rules:9
1-4.1: IMPORT builtin skip 'usb_id' /usr/lib/udev/rules.d/50-udev-default.rules:13
1-4.1: IMPORT builtin 'hwdb' /usr/lib/udev/rules.d/50-udev-default.rules:13
1-4.1: No entry found from hwdb.
1-4.1: IMPORT builtin 'hwdb' fails: No data available
1-4.1: LINK 'android_adb' /usr/lib/udev/rules.d/51-android.rules:407
1-4.1: GROUP 993 /usr/lib/udev/rules.d/51-android.rules:662
1-4.1: MODE 0660 /usr/lib/udev/rules.d/51-android.rules:662
1-4.1: LINK 'android' /usr/lib/udev/rules.d/51-android.rules:662
1-4.1: PROGRAM '/usr/lib/udev/mtp-probe /sys/devices/pci0000:00/0000:00:01.3/0000:01:00.0/usb1/1-4/1-4.1 1 18' /usr/lib/udev/rules.d/69-libmtp.rules:2537
Starting '/usr/lib/udev/mtp-probe /sys/devices/pci0000:00/0000:00:01.3/0000:01:00.0/usb1/1-4/1-4.1 1 18'
Successfully forked off '(spawn)' as PID 15426.
checking bus 1, device 18: "/sys/devices/pci0000:00/0000:00:01.3/0000:01:00.0/usb1/1-4/1-4.1"
bus: 1, device: 18 was not an MTP device
'/usr/lib/udev/mtp-probe /sys/devices/pci0000:00/0000:00:01.3/0000:01:00.0/usb1/1-4/1-4.1 1 18'(out) '0'
Process '/usr/lib/udev/mtp-probe /sys/devices/pci0000:00/0000:00:01.3/0000:01:00.0/usb1/1-4/1-4.1 1 18' succeeded.
1-4.1: IMPORT builtin 'path_id' /usr/lib/udev/rules.d/71-seat.rules:58
1-4.1: RUN 'uaccess' /usr/lib/udev/rules.d/73-seat-late.rules:17
1-4.1: Updating old name, '/dev/android/4e51be36' no longer belonging to '/devices/pci0000:00/0000:00:01.3/0000:01:00.0/usb1/1-4/1-4.1'
1-4.1: No reference left, removing '/dev/android/4e51be36'
1-4.1: Handling device node '/dev/bus/usb/001/018', devnum=c189:17, mode=0660, uid=0, gid=993
1-4.1: Preserve permissions of /dev/bus/usb/001/018, 020660, uid=0, gid=993
1-4.1: Preserve already existing symlink '/dev/char/189:17' to '../bus/usb/001/018'
1-4.1: Found 'c189:17' claiming '/run/udev/links/\x2fandroid_adb'
1-4.1: Preserve already existing symlink '/dev/android_adb' to 'bus/usb/001/018'
1-4.1: Found 'c189:17' claiming '/run/udev/links/\x2fandroid'
1-4.1: Creating symlink '/dev/android' to 'bus/usb/001/018'
1-4.1: sd-device: Created db file '/run/udev/data/c189:17' for '/devices/pci0000:00/0000:00:01.3/0000:01:00.0/usb1/1-4/1-4.1'
1-4.1: Device (SEQNUM=3195, ACTION=bind) processed
1-4.1: sd-device-monitor: Passed 725 byte to netlink monitor
1-4.1:1.0: Device (SEQNUM=3196, ACTION=bind) is queued
1-4.1:1.0: sd-device-monitor: Passed 331 byte to netlink monitor
1-4.1:1.0: Processing device (SEQNUM=3196, ACTION=bind)
1-4.1:1.0: IMPORT builtin 'usb_id' /usr/lib/udev/rules.d/40-gphoto.rules:9
1-4.1:1.0: Failed to access usb_interface: No such file or directory
1-4.1:1.0: IMPORT builtin 'usb_id' fails: No such file or directory
1-4.1:1.0: IMPORT builtin 'hwdb' /usr/lib/udev/rules.d/50-udev-default.rules:14
1-4.1:1.0: No entry found from hwdb.
1-4.1:1.0: IMPORT builtin 'hwdb' fails: No data available
1-4.1:1.0: sd-device: Created db file '/run/udev/data/+usb:1-4.1:1.0' for '/devices/pci0000:00/0000:00:01.3/0000:01:00.0/usb1/1-4/1-4.1/1-4.1:1.0'
1-4.1:1.0: Device (SEQNUM=3196, ACTION=bind) processed
1-4.1:1.0: sd-device-monitor: Passed 344 byte to netlink monitor

Was it fixed?

It does not have this message since 0d2c63f but then I wonder, is it because it's not detecting my device, or is it functioning correctly since removing this universal rule?

My device VID:PID is 18d1:4ee2

Trying to triangulate this problem (Apr6,2019), and using the latest version of that time (mar13,2019), and then reading the errors - there was a conflict with 51-android rules identifying device 4e51be36 (whatever that was), and then further down 73-seat-late.rules identifying the same device for itself.
Can you identify what is 4e51be36 ? - my closest guess is a radeon card or maybe a redhat bridge, by trying to search for 4e51 or be36: http://pciids.sourceforge.net/pci.ids
If that is not an android device (in developer mode), then it confirms that search routine returned a false positive.

Based on the code of that time, there were plenty of places to set false positives - for example, a dell mouse could be assigned as an android device. Several problem areas are where android devices in mtp mode should NOT be assigned, and should instead be left for mtp rules to catch and setup instead - in summary, android devices in developer mode are the only devices that should get accepted (except a couple of odd systems where there is no defining code between developer or regular mtp, audio or non-developer use).

4e51be36 is the serial number of my phone, which is a Oneplus 6.

okay - that seems to make more sense....

There are two things that could be fixed.....
The original test needs a GOTO="android_usb_rule_match" - but - this could be fixed later.

The first thing that needs attention is the confusion of codes for the oneplus.
The original code has 4ee7 for debug on the Oneplus 3, 981523a

What values would you see for the Oneplus 6 ? is 4ee7 still true for debug mode too?
What values do you see for mtp and/or ptp modes?

You can see these with: lsusb -v

I see :

  • 18d1:4ee7 for charging + debug
  • 18d1:4ee6 for PTP + debug
  • 18d1:4ee2 for MTP + debug
  • 18d1:4ee1 charging / mtp

Thanks for the quick feedback. I wasn't expecting all these codes, but I should have based on progress. I've added additional patching to pull request #189.
I also edited the google phones too - based on your info.
Give it a try - interested to hear feedback.

Next:
You'll also notice the universal code near the top is edited too - remove the #, do a reboot or a udevadm reset and try again - the original code was close, but was needing a goto to skip the other tests, and this time it should go directly to setting up the debug links. Most if not all phones will probably take this route (in debug mode), with maybe some possible exceptions like maybe Nook and some debug boards ...but I'm only guessing and it would be worth hearing feedback on those if anyone had the chance to test.

# ENV{ID_USB_INTERFACES}=="*:ff420?:*", SYMLINK+="android/$env{ID_SERIAL_SHORT}", GOTO="android_usb_rule_match"

remove '# `

# ENV{ID_USB_INTERFACES}=="*:ff420?:*", SYMLINK+="android/$env{ID_SERIAL_SHORT}", GOTO="android_usb_rule_match"

Give it a try - interested to hear feedback.

I didn't see any error but I also couldn't see any /dev/android* entries.
To be honest, I'm not sure what is the correct behaviour or what android-udev-rules enables you to do. I was not part of the adbusers group but I was still able to use adb as an unprivileged user just fine.

I don't see what is the difference when enabling the universal code, I just see this on the journal:

août 11 14:59:47 terence-desktop systemd-udevd[429]: /usr/lib/udev/rules.d/51-android.rules:108 The line takes no effect, ignoring.
août 11 14:59:47 terence-desktop systemd-udevd[429]: /usr/lib/udev/rules.d/51-android.rules:109 The line takes no effect, ignoring.
août 11 14:59:47 terence-desktop systemd-udevd[429]: /usr/lib/udev/rules.d/51-android.rules:179 The line takes no effect, ignoring.
août 11 14:59:47 terence-desktop systemd-udevd[429]: /usr/lib/udev/rules.d/51-android.rules:281 The line takes no effect, ignoring.
août 11 14:59:47 terence-desktop systemd-udevd[429]: /usr/lib/udev/rules.d/51-android.rules:339 The line takes no effect, ignoring.
août 11 14:59:47 terence-desktop systemd-udevd[429]: /usr/lib/udev/rules.d/51-android.rules:346 The line takes no effect, ignoring.
août 11 14:59:47 terence-desktop systemd-udevd[429]: /usr/lib/udev/rules.d/51-android.rules:353 The line takes no effect, ignoring.

You discovered some typographical errors......this needs patching....
example....107,108
, ENV{adb_adb}=="yes"
should have been
, ENV{adb_adb}="yes"
missed those - appears copy-n-paste errors strikes again :-(

Your catch - send a patch, if not, I'll put one together tonight.

Your catch - send a patch, if not, I'll put one together tonight.

Alright just made one 😃

Now no systemd-udev message but I still don't see what is the difference with the universal code uncommented.

Thanks for creating the patch :-) much appreciated.
I was looking at where that "android" came from.
Apparently I added "android" way back in 2016 - the original intention was just for identifying the android device (but this was when the device was NOT in debug mode).
"android_adb" came earlier, this: http://www.joescat.com/linux/android_rules.html was based on google documentation. For historic compatibility, would seem best to maintain "android_adb", while "android_fast" came later.
In the meantime appears 60-libmtp.rules came to life and is doing a great job of identifying mtp storage - something that was pretty fragile back in 2012 or earlier.

For your question, the universal code assigns "android" a serial number, but then later, further down the code "android" gets replaced by a symlink, so in effect - yes, there is nothing to see.
Reading ktnr74.blogspot.com, I get the impression the serial number was probably assigned to "~/.android/serial_number" or the google developer kit android directory, and not /dev/android

In summary - we have a bug - any suggestions?

moved to #204