LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   simple-mtpfs - unable to delete files [permissions issue] (https://www.linuxquestions.org/questions/linux-software-2/simple-mtpfs-unable-to-delete-files-%5Bpermissions-issue%5D-4175596482/)

eco_bach 12-30-2016 03:36 PM

simple-mtpfs - unable to delete files [permissions issue]
 
Hi,
Using simple-mtpfs to treat my Android(MTP device) as a mass storage device.

I can successfully mount my camera folder, list files, mount and unmount the camera folder.

However what I cannot do is delete any existing files.

Mounting the camera as mass storage device is done simply by calling

Code:

simple-mtpfs ~/camera
where camera is a previously created folder needed as a mount point.

I then try and delete any existing photos using

Code:

sudo rm -rf ~/camera/DCIM/Camera/*
which returns a
Quote:

:Permission denied
for each .jpg in the Camera folder.

So then I try and change ownership by issuing

Code:

sudo chmod -R 755 ~/camera/DCIM/Camera
which ALSO returns a
Quote:

Permission denied
error

What gives? How can I delete files successfully?

michaelk 12-30-2016 04:24 PM

Although a fuse filesystem does "treat" your Android device like a mass storage device it is only a bridge and simple-mftpfs still uses libmtp as an interface. If gphoto2 or mtp-tools does not work then as you have posted in your other thread that it could be some protocol incompatibility. Gnome and KDE have their own mtp virtual file systems and I think you have already tried those with similar results.

It could be that libmtp does not like your Android device.

https://wiki.archlinux.org/index.php/MTP

I might write to the gphoto developers.
http://www.gphoto.org/proj/libgphoto2/support.php

Have you tried Android file transfer yet?

BW-userx 12-30-2016 05:08 PM

Quote:

Originally Posted by eco_bach (Post 5648303)
Hi,
Using simple-mtpfs to treat my Android(MTP device) as a mass storage device.

I can successfully mount my camera folder, list files, mount and unmount the camera folder.

However what I cannot do is delete any existing files.

Mounting the camera as mass storage device is done simply by calling

Code:

simple-mtpfs ~/camera
where camera is a previously created folder needed as a mount point.

I then try and delete any existing photos using

Code:

sudo rm -rf ~/camera/DCIM/Camera/*
which returns a for each .jpg in the Camera folder.

So then I try and change ownership by issuing

Code:

sudo chmod -R 755 ~/camera/DCIM/Camera
which ALSO returns a error

What gives? How can I delete files successfully?

does not your Linux System automount your phone whenever you plug it in?

mine does, and I am able to copy,move files onto it, and copy,move,delete files off of my phone whenever it is pluged in via my file manager.

I am just curious as to why you are having to mount it manually to work on your photos?

eco_bach 12-30-2016 06:56 PM

Hi
Yes, of course my phone and cameras automount as MTP devices whenever conncted via USB.
When you say you are 'able to copy,move files onto it, and copy,move,delete files off ', I assume you mean manually, not scripted in the terminal?

I need an automated solution via shell scripting. The problem with MTP mounted devices as I have noted elsewhere, is that the mount point is constantly changing making it near impossible to use standard cd, rm etc commands to navigate to your photos.

So I've tried both gphoto2 and mtp-tools which both use libmtp AFAIK to access MTP-PTP devices.
With these MTP solutions I am able to list, copy files, but not to delete them.

So now I am resorting to simple-mtpfs, which seems the most robust solution. However still need a way to delete files via scripting.

Isn't it possibly a simple-mtpfs configuration issue?

What would be the proper syntax to enable permission checking by kernel?

https://www.mankier.com/1/simple-mtpfs#Options

FUSE Options

Quote:

-o default_permissions enable permission checking by kernel

BW-userx 12-30-2016 07:23 PM

Quote:

Originally Posted by eco_bach (Post 5648364)
Hi
Yes, of course my phone and cameras automount as MTP devices whenever conncted via USB.
When you say you are 'able to copy,move files onto it, and copy,move,delete files off ', I assume you mean manually, not scripted in the terminal?

I need an automated solution via shell scripting. The problem with MTP mounted devices as I have noted elsewhere, is that the mount point is constantly changing making it near impossible to use standard cd, rm etc commands to navigate to your photos.

So I've tried both gphoto2 and mtp-tools which both use libmtp AFAIK to access MTP-PTP devices.
With these MTP solutions I am able to list, copy files, but not to delete them.

So now I am resorting to simple-mtpfs, which seems the most robust solution. However still need a way to delete files via scripting.

post your script you are using in code block so I can see exactly what you are doing.
let me install some of this 'crap' and see what I can figure out for you.

BW-userx 12-30-2016 07:34 PM

What?
Code:

userx@voider~:>> simple-mtpfs ~/mpts
userx@voider~:>> cd mpts
userx@voider~/mpts:>> ls
'Internal storage'  'SD card'

userx@voider~/mpts:>> cd 'SD card'
userx@voider~/mpts/SD card:>> ls
Android  LOST.DIR  movies  mpon

userx@voider~/mpts/SD card:>> cd movies

userx@voider~/mpts/SD card/movies:>> ls
Goldrush.mp4  paranoid-2000-jessica-alba.mp4

userx@voider~/mpts/SD card/movies:>> rm Goldrush.mp4
userx@voider~/mpts/SD card/movies:>> ls
paranoid-2000-jessica-alba.mp4

I had no problem deleting a file using simple-mtpfs in my terminal. My first time I've ever done this.

Please post your entire script so I can take a look at it for you and anyone else that might catch something within it.

michaelk 12-30-2016 07:39 PM

It is automounting via the desktop using gvfs if I remember from your other thread. Just out of curiosity can you delete files from your file browser?

As stated above simple-mtpfs also uses libmtp which is why you can not delete files using it either. android-file-transfer is not dependent upon libmtp so it might fair better. I have not used it so do not know how well it works.

In the ArchWiki link I posted there is information on how to use gvfs-mount to detect mtp devices. Have you tried using that to find your device. May not be the best long term solution due to updates or switching desktops could change how it works.

BW-userx, what is the make/model of your camera and is it on the list of known working devices?

eco_bach 12-30-2016 07:42 PM

I have 90% of a solution but will do further testing

Looking at the various FUSE options I see that there is allow_root
I also discovered that FUSE options are set when you mount the device
ie

Code:

$ simple-mtpfs ~/camera -o allow_root
However, i at first got an error with the above and first had to edit my /etc/fuse.conf and uncomment 'user_allow_other'

So then

Code:

$ simple-mtpfs ~/camera -o allow_root
$ ##chmod not necessary, we are already accessing camera as root
$ sudo rm -rf ~/camera/DCIM/Camera/*(no permissions error yeah!)

To confirm unmounted, remounted and checked mounted Camera directory. All photos gone!

Code:

$ fusermount -u ~/camera
$ simple-mtpfs ~/camera -o allow_root

This seems to work, the last remaining hurdle is that original photos on the actual camera are NOT deleted even though they seem to be when I remount the camera.
Back to square one. I assume this must be because FUSE works with a copy of the actual camera directories.

michaelk 12-30-2016 07:43 PM

Perfect.

BW-userx 12-30-2016 08:01 PM

Quote:

Originally Posted by michaelk (Post 5648382)
BW-userx, what is the make/model of your camera and is it on the list of known working devices?

I have no idea about that known working devices,I do not have a camera, he too said he was using a phone as well as a camera. I've never mounted my phone manually ever. That was the first time ever and it would have been the same mythology but he got it working. Finally.

needing root user type as I stated prior or in another post of his on this situation. gooo root!

something for the back burner:
if you ever get a device is busy and it will not unmount using fusermount -u
Code:

sudo umount -l /path/to/unmount

eco_bach 12-30-2016 09:37 PM

Testing against Nexxus 5.
My target device is Samsung Gear 360

Don't think either device are fully supported by any of my attempted solutions, mtps, gphoto2 or simple-mtpfs


If it helps others

Am having better luck with jmtpfs in regards to deleting files!

Still have an unmounting error to resolve
Quote:

fusermount: entry for /home/ubuntu-mate/camera1 not found in /etc/mtab
see this article
http://research.jacquette.com/jmtpfs...ces-and-linux/

When mounting with jmtpfs vs simple-mtpfs there is an extra directory present"Internal storage" which seems to reflect what actually exists on my device

$<home>/<mount point>/Internal storage/DCIM/Camera

ie


All times are GMT -5. The time now is 05:10 PM.