You are not logged in.

#26 2023-01-18 11:13:51

seth
Member
Registered: 2012-09-03
Posts: 34,931

Re: Automatic mounting of an MTP device

Nope. Dead end.
Can you copy and paste the windows dialog (into google translate)?

Offline

#27 2023-01-18 13:50:35

alexanderzhirov
Member
Registered: 2022-05-12
Posts: 36
Website

Re: Automatic mounting of an MTP device

seth wrote:

Nope. Dead end.
Can you copy and paste the windows dialog (into google translate)?

Here error

Offline

#28 2023-01-18 14:23:12

seth
Member
Registered: 2012-09-03
Posts: 34,931

Re: Automatic mounting of an MTP device

As blend and generic as it gets - but you're accessing this via SMB?
That's where I'd look - ideally using smbclient, hoping that it'll be a bit more explicit about the access issues.

And in this context, I'd not even rule out the timestamp to be critical.
https://github.com/phatina/simple-mtpfs/issues/39

Btw: MTP+SMB, did you lose some bet or is this a masochist kink? tongue

Offline

#29 2023-01-18 16:11:46

alexanderzhirov
Member
Registered: 2022-05-12
Posts: 36
Website

Re: Automatic mounting of an MTP device

seth wrote:

As blend and generic as it gets - but you're accessing this via SMB?
That's where I'd look - ideally using smbclient, hoping that it'll be a bit more explicit about the access issues.

And how can this be done from under Windows? Try to mount as a network resource?

seth wrote:

Btw: MTP+SMB, did you lose some bet or is this a masochist kink? tongue

No, I don't mount via SMB smile Maybe FreeRDP does it, I can't say. I'm just passing this path there as an argument.

Offline

#30 2023-01-18 17:27:45

seth
Member
Registered: 2012-09-03
Posts: 34,931

Re: Automatic mounting of an MTP device

The error message looks like  a standard SMB error, I've no idea what FreeRDP does or how the share is created on the server - https://archlinux.org/packages/communit … 4/freerdp/ does not seem to depend on samba and there's no strict relation between the two protocols (one is a remote desktop protocol, the other a remote filesystem - and to spread viruses)

smbclient comes w/ https://archlinux.org/packages/extra/x86_64/smbclient/ - you'd try to access the share from some linux host.

Edit: why is using aft-mtp-mount not an option?

Last edited by seth (2023-01-18 17:28:31)

Offline

#31 2023-01-24 16:24:29

alexanderzhirov
Member
Registered: 2022-05-12
Posts: 36
Website

Re: Automatic mounting of an MTP device

seth wrote:

Edit: why is using aft-mtp-mount not an option?

In the end, I did just that big_smile

But I ran into a new problem. Now it is necessary to understand what to do in this situation.
I'm trying to use all this assembly on another Linux distribution.
When I connect my phone, I get all the necessary information about the device. The problem is that when the "remove" event occurs, I don't have this data, such as ID_MODEL and so on. The only parameter that is available for the "add" and "remove" events is the PRODUCT parameter.

PRODUCT=18d1/4ee1/440

This data is the same as the variables that are present at the "add" event:

ID_VENDOR_ID=18d1
ID_MODEL_ID=4ee1
ID_REVISION=0440

According to this data, in principle, it is possible to identify any device, especially if 2 or 3 of them are connected at the same time.
But I mount by the name of the device (which, of course, is not entirely true). This name is recognized in the ID_MODEL variable.
But this variable is missing when the device is disconnected and the "remove" event, which prevents the device from being properly unmounted. Here lies the catch. How would I get around this point? Or temporarily store the device name in some variable and identify it at the "remove" event...

Maybe I'm overcomplicating and there is an easier way?

Offline

#32 2023-01-24 23:05:11

seth
Member
Registered: 2012-09-03
Posts: 34,931

Re: Automatic mounting of an MTP device

You could add the usb device to the mountpoint and when the device is removed find it this way.
This also keeps the mountpoint name unique when two equal devices are attached.

Offline

#33 2023-01-25 05:22:51

alexanderzhirov
Member
Registered: 2022-05-12
Posts: 36
Website

Re: Automatic mounting of an MTP device

seth wrote:

You could add the usb device to the mountpoint and when the device is removed find it this way.

Until now, I have found the mounted device by its name, because with the "remove" event, I could get this device name and, knowing the path where I previously mounted it with this name, I was also able to unmount it without any problems.

Now in this Linux build there is no such possibility, because I can't get this device name. At least with the "remove" event.

The idea comes to my mind to replace the "/" symbol in the PRODUCT variable with the "_" symbol, and then mount the device with the resulting string. It will turn out something like "/mnt/usbdevices/18d1_4ee1_440". But at the same time I will be able to unmount it as well.

Only here the path does not have any meaningful name. A set of characters (VendorID/ProductID). I thought that when connecting, I could save the name, for example "Wileyfox_Swift_2" and mount it to a directory with that name. But this name is only available when added.

Last edited by alexanderzhirov (2023-01-25 05:25:28)

Offline

#34 2023-01-25 09:20:58

seth
Member
Registered: 2012-09-03
Posts: 34,931

Re: Automatic mounting of an MTP device

I'm trying to use all this assembly on another Linux distribution.
Now in this Linux build there is no such possibility

What other distribution, what do you get for "udevadm monitor" there?
The id's are resolved from /usr/lib/udev/hwdb.d/20-* which is likely missing in otherdistrothatsnotarchandprobablynotsystemdandyoureabusingthisboard™

Offline

#35 2023-01-25 09:39:33

alexanderzhirov
Member
Registered: 2022-05-12
Posts: 36
Website

Re: Automatic mounting of an MTP device

I will try to describe in detail the process of what I do and what I want.

I am attaching the device to the computer:

# udevadm monitor -p
monitor will print the received events for:
UDEV - the event which udev sends out after rule processing
KERNEL - the kernel uevent

KERNEL[65375.775791] add      /devices/pci0000:00/0000:00:15.0/usb1/1-2 (usb)
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:15.0/usb1/1-2
SUBSYSTEM=usb
DEVNAME=/dev/bus/usb/001/012
DEVTYPE=usb_device
PRODUCT=5c6/1/318
TYPE=0/0/0
BUSNUM=001
DEVNUM=012
SEQNUM=2081
MAJOR=189
MINOR=11

KERNEL[65375.778102] add      /devices/pci0000:00/0000:00:15.0/usb1/1-2/1-2:1.0 (usb)
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:15.0/usb1/1-2/1-2:1.0
SUBSYSTEM=usb
DEVTYPE=usb_interface
PRODUCT=5c6/1/318
TYPE=0/0/0
INTERFACE=255/255/0
MODALIAS=usb:v05C6p0001d0318dc00dsc00dp00icFFiscFFip00in00
SEQNUM=2082

KERNEL[65375.778188] bind     /devices/pci0000:00/0000:00:15.0/usb1/1-2 (usb)
ACTION=bind
DEVPATH=/devices/pci0000:00/0000:00:15.0/usb1/1-2
SUBSYSTEM=usb
DEVNAME=/dev/bus/usb/001/012
DEVTYPE=usb_device
DRIVER=usb
PRODUCT=5c6/1/318
TYPE=0/0/0
BUSNUM=001
DEVNUM=012
SEQNUM=2083
MAJOR=189
MINOR=11

UDEV  [65376.296245] add      /devices/pci0000:00/0000:00:15.0/usb1/1-2 (usb)
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:15.0/usb1/1-2
SUBSYSTEM=usb
DEVNAME=/dev/bus/usb/001/012
DEVTYPE=usb_device
PRODUCT=5c6/1/318
TYPE=0/0/0
BUSNUM=001
DEVNUM=012
SEQNUM=2081
USEC_INITIALIZED=65375779808
ID_VENDOR=Wileyfox
ID_VENDOR_ENC=Wileyfox
ID_VENDOR_ID=05c6
ID_MODEL=Swift_2_Plus
ID_MODEL_ENC=Swift\x202\x20Plus
ID_MODEL_ID=0001
ID_REVISION=0318
ID_SERIAL=Wileyfox_Swift_2_Plus_1c42defa
ID_SERIAL_SHORT=1c42defa
ID_BUS=usb
ID_USB_INTERFACES=:ffff00:
ID_VENDOR_FROM_DATABASE=Qualcomm, Inc.
adb_user=yes
ID_PATH=pci-0000:00:15.0-usb-0:2
ID_PATH_TAG=pci-0000_00_15_0-usb-0_2
ID_FOR_SEAT=usb-pci-0000_00_15_0-usb-0_2
MAJOR=189
MINOR=11
DEVLINKS=/dev/android /dev/android2
TAGS=:seat:uaccess:

UDEV  [65376.305001] add      /devices/pci0000:00/0000:00:15.0/usb1/1-2/1-2:1.0 (usb)
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:15.0/usb1/1-2/1-2:1.0
SUBSYSTEM=usb
DEVTYPE=usb_interface
PRODUCT=5c6/1/318
TYPE=0/0/0
INTERFACE=255/255/0
MODALIAS=usb:v05C6p0001d0318dc00dsc00dp00icFFiscFFip00in00
SEQNUM=2082
USEC_INITIALIZED=65376297373
ID_VENDOR_FROM_DATABASE=Qualcomm, Inc.
ID_PATH=pci-0000:00:15.0-usb-0:2:1.0
ID_PATH_TAG=pci-0000_00_15_0-usb-0_2_1_0

UDEV  [65376.357447] bind     /devices/pci0000:00/0000:00:15.0/usb1/1-2 (usb)
ACTION=bind
DEVPATH=/devices/pci0000:00/0000:00:15.0/usb1/1-2
SUBSYSTEM=usb
DEVNAME=/dev/bus/usb/001/012
DEVTYPE=usb_device
DRIVER=usb
PRODUCT=5c6/1/318
TYPE=0/0/0
BUSNUM=001
DEVNUM=012
SEQNUM=2083
USEC_INITIALIZED=65375779808
ID_VENDOR=Wileyfox
ID_VENDOR_ENC=Wileyfox
ID_VENDOR_ID=05c6
ID_MODEL=Swift_2_Plus
ID_MODEL_ENC=Swift\x202\x20Plus
ID_MODEL_ID=0001
ID_REVISION=0318
ID_SERIAL=Wileyfox_Swift_2_Plus_1c42defa
ID_SERIAL_SHORT=1c42defa
ID_BUS=usb
ID_USB_INTERFACES=:ffff00:
ID_VENDOR_FROM_DATABASE=Qualcomm, Inc.
adb_user=yes
ID_PATH=pci-0000:00:15.0-usb-0:2
ID_PATH_TAG=pci-0000_00_15_0-usb-0_2
ID_FOR_SEAT=usb-pci-0000_00_15_0-usb-0_2
MAJOR=189
MINOR=11
DEVLINKS=/dev/android /dev/android2
TAGS=:seat:uaccess:

I call my processing script. I create a catalog based on the data available above:

...
$currentDevice=/mnt/usbdevices/$ID_VENDOR\_$ID_MODEL
mkdir $currentDevice
...

Then I mount the device into the created directory, also in the script:

...
/bin/aft-mtp-mount $currentDevice
...

After that I disconnect my phone:

KERNEL[65731.397555] remove   /devices/pci0000:00/0000:00:15.0/usb1/1-2/1-2:1.0 (usb)
ACTION=remove
DEVPATH=/devices/pci0000:00/0000:00:15.0/usb1/1-2/1-2:1.0
SUBSYSTEM=usb
DEVTYPE=usb_interface
PRODUCT=5c6/1/318
TYPE=0/0/0
INTERFACE=255/255/0
MODALIAS=usb:v05C6p0001d0318dc00dsc00dp00icFFiscFFip00in00
SEQNUM=2084

KERNEL[65731.399025] unbind   /devices/pci0000:00/0000:00:15.0/usb1/1-2 (usb)
ACTION=unbind
DEVPATH=/devices/pci0000:00/0000:00:15.0/usb1/1-2
SUBSYSTEM=usb
DEVNAME=/dev/bus/usb/001/012
DEVTYPE=usb_device
PRODUCT=5c6/1/318
TYPE=0/0/0
BUSNUM=001
DEVNUM=012
SEQNUM=2085
MAJOR=189
MINOR=11

KERNEL[65731.399265] remove   /devices/pci0000:00/0000:00:15.0/usb1/1-2 (usb)
ACTION=remove
DEVPATH=/devices/pci0000:00/0000:00:15.0/usb1/1-2
SUBSYSTEM=usb
DEVNAME=/dev/bus/usb/001/012
DEVTYPE=usb_device
PRODUCT=5c6/1/318
TYPE=0/0/0
BUSNUM=001
DEVNUM=012
SEQNUM=2086
MAJOR=189
MINOR=11

UDEV  [65731.407579] remove   /devices/pci0000:00/0000:00:15.0/usb1/1-2/1-2:1.0 (usb)
ACTION=remove
DEVPATH=/devices/pci0000:00/0000:00:15.0/usb1/1-2/1-2:1.0
SUBSYSTEM=usb
DEVTYPE=usb_interface
PRODUCT=5c6/1/318
TYPE=0/0/0
INTERFACE=255/255/0
MODALIAS=usb:v05C6p0001d0318dc00dsc00dp00icFFiscFFip00in00
SEQNUM=2084
USEC_INITIALIZED=65376297373
ID_VENDOR_FROM_DATABASE=Qualcomm, Inc.
ID_PATH=pci-0000:00:15.0-usb-0:2:1.0
ID_PATH_TAG=pci-0000_00_15_0-usb-0_2_1_0

UDEV  [65731.416352] unbind   /devices/pci0000:00/0000:00:15.0/usb1/1-2 (usb)
ACTION=unbind
DEVPATH=/devices/pci0000:00/0000:00:15.0/usb1/1-2
SUBSYSTEM=usb
DEVNAME=/dev/bus/usb/001/012
DEVTYPE=usb_device
PRODUCT=5c6/1/318
TYPE=0/0/0
BUSNUM=001
DEVNUM=012
SEQNUM=2085
USEC_INITIALIZED=65375779808
ID_PATH=pci-0000:00:15.0-usb-0:2
ID_PATH_TAG=pci-0000_00_15_0-usb-0_2
MAJOR=189
MINOR=11

UDEV  [65731.424172] remove   /devices/pci0000:00/0000:00:15.0/usb1/1-2 (usb)
ACTION=remove
DEVPATH=/devices/pci0000:00/0000:00:15.0/usb1/1-2
SUBSYSTEM=usb
DEVNAME=/dev/bus/usb/001/012
DEVTYPE=usb_device
PRODUCT=5c6/1/318
TYPE=0/0/0
BUSNUM=001
DEVNUM=012
SEQNUM=2086
USEC_INITIALIZED=65375779808
ID_PATH=pci-0000:00:15.0-usb-0:2
ID_PATH_TAG=pci-0000_00_15_0-usb-0_2
MAJOR=189
MINOR=11

I need to delete the directory that I previously created. But there are no variables $ID_VENDOR and $ID_MODEL for the script, so the path is unknown.

That's why I'm asking. Is it possible to somehow import and temporarily store the identification data of $ID_VENDOR and $ID_MODEL in the form in which these variables are set when the device is first connected?

The only variable that all events have in common is PRODUCT, which I wrote about above.

Last edited by alexanderzhirov (2023-01-25 09:43:39)

Offline

#36 2023-01-25 15:02:38

seth
Member
Registered: 2012-09-03
Posts: 34,931

Re: Automatic mounting of an MTP device

I thought your issue was

Only here the path does not have any meaningful name. A set of characters (VendorID/ProductID)

And the idea was to utilize DEVPATH as indicator, or mabye DEVNAME
The tail after "usb" is significant and having it as suffix to your mount path also allows to get unique mountpaths when two devices w/ same vendor/model ID are connected at once.

Offline

#37 Yesterday 05:28:32

alexanderzhirov
Member
Registered: 2022-05-12
Posts: 36
Website

Re: Automatic mounting of an MTP device

seth wrote:

I thought your issue was

Only here the path does not have any meaningful name. A set of characters (VendorID/ProductID)

And the idea was to utilize DEVPATH as indicator, or mabye DEVNAME
The tail after "usb" is significant and having it as suffix to your mount path also allows to get unique mountpaths when two devices w/ same vendor/model ID are connected at once.

I managed to solve the unmounting problem using IMPORT{db}="ID_MODEL", IMPORT{db}="ID_VENDOR". Now, with the "remove" event, I can access data from the variables ID_MODEL and ID_VENDOR.

But now a different problem has arisen. I can't explain it even to myself.

For testing, I've simplified the mount script a bit. Now it looks like this

#!/bin/sh

. /etc/thinstation.env
. $TS_GLOBAL

if [[ $ACTION == "add" ]]; then
    echo "********************* START MOUNT *******************" | systemd-cat -p err -t "mtp"
    aft-mtp-mount /phone
    grep -oe "/phone" /proc/mounts | systemd-cat -p err -t "mtp"
    ls "/phone/Внутренний общий накопитель" | systemd-cat -p err -t "mtp"
    echo "********************** END MOUNT ********************" | systemd-cat -p err -t "mtp"
elif [[ $ACTION == "remove" ]]; then
    echo "******************** START UNMOUNT ******************" | systemd-cat -p err -t "mtp"
    umount /phone
    echo "********************* END UNMOUNT *******************" | systemd-cat -p err -t "mtp"
fi

When the "add" or "bind" event occurs, my device is mounted. At the time of execution of the script, this mounting is carried out, as can be evidenced by the command ls. But when the script works out, the mounting disappears somewhere. I captured it all on video.

At the same time, if I mount the device manually, then it is mounted and I can view it.

The other triggers are missing for this processing. I don't understand why this is happening. Can you explain it to me?

Offline

#38 Yesterday 10:54:09

alexanderzhirov
Member
Registered: 2022-05-12
Posts: 36
Website

Re: Automatic mounting of an MTP device

alexanderzhirov wrote:

The other triggers are missing for this processing. I don't understand why this is happening. Can you explain it to me?

This is either a bug or an error. When I run systemd-udevd as a daemon, the mounting works. But if the service works as part of the systemd service, then mounting does not work. video

So the problem is with systemd?

Offline

#39 Yesterday 10:56:00

seth
Member
Registered: 2012-09-03
Posts: 34,931

Re: Automatic mounting of an MTP device

When I run systemd-udevd as a daemon, the mounting works. But if the service works as part of the systemd service

I think it's time that you elaborate on "another Linux distribution"

Offline

Board footer

Powered by FluxBB