public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-user] mtp cannot create directories on SD card on cellphone
@ 2024-05-15 21:28 Walter Dnes
  2024-05-15 22:06 ` Mark Knecht
  2024-05-16 15:34 ` [gentoo-user] " Dr Rainer Woitok
  0 siblings, 2 replies; 9+ messages in thread
From: Walter Dnes @ 2024-05-15 21:28 UTC (permalink / raw
  To: Gentoo Users List

  What I *CAN* do... upload/download/create/delete *FILES* on SD card

  What I *CANNOT* do... create new *DIRECTORIES* on SD card

[x8940][waltdnes][~/tablet/sdcard1] mkdir data
mkdir: cannot create directory ‘data’: Input/output error

  This happens with both "jmtps" and "simple-mtpfs", so I think it's
probably a systemic issue that affects all implementions.  For now I'm
using the "screenshots" directory for transferring miscellaneous files,
but I'd really like to solve the core problem.  Any ideas?

-- 
Roses are red
Roses are blue
Depending on their velocity
Relative to you


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [gentoo-user] mtp cannot create directories on SD card on cellphone
  2024-05-15 21:28 [gentoo-user] mtp cannot create directories on SD card on cellphone Walter Dnes
@ 2024-05-15 22:06 ` Mark Knecht
  2024-05-15 23:38   ` Walter Dnes
  2024-05-16  5:29   ` Walter Dnes
  2024-05-16 15:34 ` [gentoo-user] " Dr Rainer Woitok
  1 sibling, 2 replies; 9+ messages in thread
From: Mark Knecht @ 2024-05-15 22:06 UTC (permalink / raw
  To: gentoo-user

[-- Attachment #1: Type: text/plain, Size: 924 bytes --]

On Wed, May 15, 2024 at 2:29 PM Walter Dnes <waltdnes@waltdnes.org> wrote:
>
>   What I *CAN* do... upload/download/create/delete *FILES* on SD card
>
>   What I *CANNOT* do... create new *DIRECTORIES* on SD card
>
> [x8940][waltdnes][~/tablet/sdcard1] mkdir data
> mkdir: cannot create directory ‘data’: Input/output error
>
>   This happens with both "jmtps" and "simple-mtpfs", so I think it's
> probably a systemic issue that affects all implementions.  For now I'm
> using the "screenshots" directory for transferring miscellaneous files,
> but I'd really like to solve the core problem.  Any ideas?

Have you checked that the directory where you are attempting to
do this is one that your account owns? I generally have to su - to
root, create a directory at the top level, change it so that I own it and
have rwx permissions, and then exit root. After that I can do what I want.

HTH,
Mark

[-- Attachment #2: Type: text/html, Size: 1195 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [gentoo-user] mtp cannot create directories on SD card on cellphone
  2024-05-15 22:06 ` Mark Knecht
@ 2024-05-15 23:38   ` Walter Dnes
  2024-05-16  2:16     ` Mark Knecht
  2024-05-16  5:29   ` Walter Dnes
  1 sibling, 1 reply; 9+ messages in thread
From: Walter Dnes @ 2024-05-15 23:38 UTC (permalink / raw
  To: gentoo-user

> Have you checked that the directory where you are attempting to do
> this is one that your account owns? I generally have to su - to root,
> create a directory at the top level, change it so that I own it and
> have rwx permissions, and then exit root. After that I can do what
> I want.

  So I did "su" and tried changing ownership... failed

x8940 /home/waltdnes/tablet # chown waltdnes:users sdcard1
chown: changing ownership of 'sdcard1': Function not implemented

  Let's try "chmod"... failed silently

[x8940][root][/home/waltdnes/tablet] chmod 777 sdcard1
[x8940][root][/home/waltdnes/tablet] ll
total 24
drwxr-xr-x   4 root     root      0 Dec 31  1969 .
drwxr-xr-x 144 waltdnes users 24576 May 15 18:17 ..
drwxr-xr-x   5 root     root      0 Nov 16  4456932 sdcard
drwxr-xr-x   6 root     root      0 Apr 22  4456932 sdcard1

  root can't chmod sdcard1.

[x8940][root][/home/waltdnes/tablet] mkdir sdcard1/data
mkdir: cannot create directory ‘sdcard1/data’: Input/output error

  and root can't create a directory!!!  Let's try top level...

[x8940][root][~] cd /home/waltdnes/tablet
[x8940][root][/home/waltdnes/tablet] mkdir data
mkdir: cannot create directory ‘data’: Read-only file system

  A suggestion at https://ubuntuforums.org/showthread.php?p=7317638

> The permissions for non-linux filesystems are defined for the whole
> partition at the time it's mounted, and you can change them by
> configuring the drive in /etc/fstab.

  So I added a line to /etc/fstab, but no luck...

/sys/fs/fuse/connections /home/waltdnes/tablet auto noauto,users,noatime,nodiratime,async,rw 0 0

  No luck.

-- 
Roses are red
Roses are blue
Depending on their velocity
Relative to you


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [gentoo-user] mtp cannot create directories on SD card on cellphone
  2024-05-15 23:38   ` Walter Dnes
@ 2024-05-16  2:16     ` Mark Knecht
  0 siblings, 0 replies; 9+ messages in thread
From: Mark Knecht @ 2024-05-16  2:16 UTC (permalink / raw
  To: gentoo-user

[-- Attachment #1: Type: text/plain, Size: 3462 bytes --]

On Wed, May 15, 2024 at 4:38 PM Walter Dnes <waltdnes@waltdnes.org> wrote:
>
> > Have you checked that the directory where you are attempting to do
> > this is one that your account owns? I generally have to su - to root,
> > create a directory at the top level, change it so that I own it and
> > have rwx permissions, and then exit root. After that I can do what
> > I want.
>
>   So I did "su" and tried changing ownership... failed
>
> x8940 /home/waltdnes/tablet # chown waltdnes:users sdcard1
> chown: changing ownership of 'sdcard1': Function not implemented
>
>   Let's try "chmod"... failed silently
>
> [x8940][root][/home/waltdnes/tablet] chmod 777 sdcard1
> [x8940][root][/home/waltdnes/tablet] ll
> total 24
> drwxr-xr-x   4 root     root      0 Dec 31  1969 .
> drwxr-xr-x 144 waltdnes users 24576 May 15 18:17 ..
> drwxr-xr-x   5 root     root      0 Nov 16  4456932 sdcard
> drwxr-xr-x   6 root     root      0 Apr 22  4456932 sdcard1
>
>   root can't chmod sdcard1.
>
> [x8940][root][/home/waltdnes/tablet] mkdir sdcard1/data
> mkdir: cannot create directory ‘sdcard1/data’: Input/output error
>
>   and root can't create a directory!!!  Let's try top level...
>
> [x8940][root][~] cd /home/waltdnes/tablet
> [x8940][root][/home/waltdnes/tablet] mkdir data
> mkdir: cannot create directory ‘data’: Read-only file system
>
<SNIP>

So it seems very strange to me that, per the initial message, you
can create and delete files, which implies the file system
is not read only, but the mkdir command thinks it is read only.

And from what I've read there is no read-only switch on this
SD card, correct? It's just something like a chip that plugs into
a Raspberry Pi or a camera, correct?

I am not exactly clear from rereading what the actual SD card is
or how it's attached, and you are using file system types I know
nothing about. However, if only for clarity, what I've had to do
even with ext3/4 is essentially the following:

1) su - and enter root password.

2) As root navigate to /home/walter/tablet or whatever the
location is where you believe you are really ON the SD card

3) Create a file using vi, save the file, make sure it's there
and make sure it's owned root:root.

4) Exit the su and make sure the file is there. Unmount the
SD card, remount the SD card and check that it's really
there. Put the SD card in some other system where you
can see the file, if possible.

5) Assuming all of that makes sense, remount the CD
card, su there again, and chown the file to walter:walter
or walter:user or whatever is appropriate. Make sure
you can edit the file from some other terminal process.

6) As root in the su, then try to create a directory. If it's
still read only then this is way above my pay grade. However
if you can create the directory, which I've always been able
to do as root, then chown -R the directory to your user
ID.

It is important to ensure that OS believes you have
read/write access all the way up and down the chain so
you might need to chown -R walter:walter AS ROOT
from your home directory into the mount point, which if
I understand, is /home/walter/tablet, so I'd be root and
doing the command sitting in /home/walter.

Sorry. Wish I could be more helpful but this has been
a problem on my systems ever since I started using
Linux 25-30 years ago and I struggle with it maybe once
a year.

Good luck,
Mark

[-- Attachment #2: Type: text/html, Size: 4372 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [gentoo-user] mtp cannot create directories on SD card on cellphone
  2024-05-15 22:06 ` Mark Knecht
  2024-05-15 23:38   ` Walter Dnes
@ 2024-05-16  5:29   ` Walter Dnes
  2024-05-16  9:42     ` [gentoo-user] " Nuno Silva
  1 sibling, 1 reply; 9+ messages in thread
From: Walter Dnes @ 2024-05-16  5:29 UTC (permalink / raw
  To: gentoo-user

On Wed, May 15, 2024 at 03:06:50PM -0700, Mark Knecht wrote
> 
> Have you checked that the directory where you are attempting to
> do this is one that your account owns? I generally have to su - to
> root, create a directory at the top level, change it so that I own it and
> have rwx permissions, and then exit root. After that I can do what I want.

  I have a short script ~/bin/tabon

[x8940][waltdnes][~] cat bin/tabon
#!/bin/bash
sudo /usr/bin/jmtpfs /home/waltdnes/tablet -o allow_other,auto_unmount,rw
#
# Only needed once
#sudo /bin/chown -R waltdnes:users /home/waltdnes/tablet

  The last (commented out) line *USED TO WORK*.  Now it spits out a
whole slew of...

/bin/chown: changing ownership of '/home/waltdnes/tablet/sdcard1/blah_blah_blah': Function not implemented

...one for each direcory and file.  I believe the phone formats the card
as either FAT32 or XFAT.

-- 
Roses are red
Roses are blue
Depending on their velocity
Relative to you


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [gentoo-user] Re: mtp cannot create directories on SD card on cellphone
  2024-05-16  5:29   ` Walter Dnes
@ 2024-05-16  9:42     ` Nuno Silva
  2024-05-16 14:58       ` Michael
  2024-05-16 15:11       ` Walter Dnes
  0 siblings, 2 replies; 9+ messages in thread
From: Nuno Silva @ 2024-05-16  9:42 UTC (permalink / raw
  To: gentoo-user

On 2024-05-16, Walter Dnes wrote:

> On Wed, May 15, 2024 at 03:06:50PM -0700, Mark Knecht wrote
>> 
>> Have you checked that the directory where you are attempting to
>> do this is one that your account owns? I generally have to su - to
>> root, create a directory at the top level, change it so that I own it and
>> have rwx permissions, and then exit root. After that I can do what I want.
>
>   I have a short script ~/bin/tabon
>
> [x8940][waltdnes][~] cat bin/tabon
> #!/bin/bash
> sudo /usr/bin/jmtpfs /home/waltdnes/tablet -o allow_other,auto_unmount,rw
> #
> # Only needed once
> #sudo /bin/chown -R waltdnes:users /home/waltdnes/tablet
>
>   The last (commented out) line *USED TO WORK*.  Now it spits out a
> whole slew of...
>
> /bin/chown: changing ownership of '/home/waltdnes/tablet/sdcard1/blah_blah_blah': Function not implemented
>
> ...one for each direcory and file.  I believe the phone formats the card
> as either FAT32 or XFAT.

Did anything change? Any tablet software upgrade? Did the MTP tool on
the computer side change? Or perhaps the kernel, if it can influence
this FUSE interaction somehow?

At this point I'd consider testing with known good versions if possible
(those that can run chown without that error). Is mkdir something that
used to work too?

The "Function not implemented" looks off for something that used to work
before. (Or was it failing silently before? If this is FAT* or exFAT,
wouldn't ownership be a thing for the FUSE tool to set itself? Or does
exFAT have the concept of ownership?)

-- 
Nuno Silva



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [gentoo-user] Re: mtp cannot create directories on SD card on cellphone
  2024-05-16  9:42     ` [gentoo-user] " Nuno Silva
@ 2024-05-16 14:58       ` Michael
  2024-05-16 15:11       ` Walter Dnes
  1 sibling, 0 replies; 9+ messages in thread
From: Michael @ 2024-05-16 14:58 UTC (permalink / raw
  To: gentoo-user

[-- Attachment #1: Type: text/plain, Size: 3189 bytes --]

On Thursday, 16 May 2024 10:42:16 BST Nuno Silva wrote:
> On 2024-05-16, Walter Dnes wrote:
> > On Wed, May 15, 2024 at 03:06:50PM -0700, Mark Knecht wrote
> > 
> >> Have you checked that the directory where you are attempting to
> >> do this is one that your account owns? I generally have to su - to
> >> root, create a directory at the top level, change it so that I own it and
> >> have rwx permissions, and then exit root. After that I can do what I
> >> want.
> >> 
> >   I have a short script ~/bin/tabon
> > 
> > [x8940][waltdnes][~] cat bin/tabon
> > #!/bin/bash
> > sudo /usr/bin/jmtpfs /home/waltdnes/tablet -o allow_other,auto_unmount,rw
> > #
> > # Only needed once
> > #sudo /bin/chown -R waltdnes:users /home/waltdnes/tablet
> > 
> >   The last (commented out) line *USED TO WORK*.  Now it spits out a
> > 
> > whole slew of...
> > 
> > /bin/chown: changing ownership of
> > '/home/waltdnes/tablet/sdcard1/blah_blah_blah': Function not implemented
> > 
> > ...one for each direcory and file.  I believe the phone formats the card
> > as either FAT32 or XFAT.
> 
> Did anything change? Any tablet software upgrade? Did the MTP tool on
> the computer side change? Or perhaps the kernel, if it can influence
> this FUSE interaction somehow?
> 
> At this point I'd consider testing with known good versions if possible
> (those that can run chown without that error). Is mkdir something that
> used to work too?
> 
> The "Function not implemented" looks off for something that used to work
> before. (Or was it failing silently before? If this is FAT* or exFAT,
> wouldn't ownership be a thing for the FUSE tool to set itself? Or does
> exFAT have the concept of ownership?)

FAT/exFAT do not support filesystem level user permissions and consequently 
you would get a "Function not implemented" error with chown.

When a USB device with a FAT/exFAT fs, is mounted with udisksctl they show up 
as:

$ lsblk -o PATH,TYPE,FSTYPE,OWNER,GROUP,MODE,MOUNTPOINT /dev/sdb1
PATH      TYPE FSTYPE OWNER GROUP MODE       MOUNTPOINT
/dev/sdb1 part vfat   root  disk  brw-rw---- /run/media/michael/CRUCIAL-8G

and the fs is mounted with the sticky bit so it writeable by the user:

$ ls -la /run/media/michael/CRUCIAL-8G/
total 2500976
drwxr-xr-x  2 michael michael      16384 Jan  1  1970  .
drwxr-x---+ 3 root    root            60 May 16 15:52  ..


exFAT looks the same if you have enabled the exFAT kernel driver, as opposed 
to using FUSE.

I don't have a device using MTP here to check how it is mounted over FUSE, but 
FUSE is meant to mount a device with the permissions of the user who mounts it 
AND the user can only mount on a mountpoint for which they have write 
permission.

However, there is a kernel bug if the default_permissions mount option has not 
been used, whereby results of the first permission check performed by the file 
system for a directory entry are cached and reused - even if the permissions 
have since changed - see here:

https://github.com/libfuse/libfuse

I do remember having some trouble creating directories on an SD card in a 
GARMIN GPS device.  I had to remove it and mount it on Linux to be able to 
work on it, but can't recall the details. 

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [gentoo-user] Re: mtp cannot create directories on SD card on cellphone
  2024-05-16  9:42     ` [gentoo-user] " Nuno Silva
  2024-05-16 14:58       ` Michael
@ 2024-05-16 15:11       ` Walter Dnes
  1 sibling, 0 replies; 9+ messages in thread
From: Walter Dnes @ 2024-05-16 15:11 UTC (permalink / raw
  To: gentoo-user

On Thu, May 16, 2024 at 10:42:16AM +0100, Nuno Silva wrote

> Did anything change? Any tablet software upgrade? Did the MTP tool on
> the computer side change? Or perhaps the kernel, if it can influence
> this FUSE interaction somehow?

  Just the usual updates to world.
 
> At this point I'd consider testing with known good versions if possible
> (those that can run chown without that error).

  There are no "known good versions".

>  Is mkdir something that used to work too?

  I did some more dicking around, and it gets "curiouser and curiouser".
I mount the phone on /home/waltdnes/tablet then...

cd sdcard1

mkdir subdir
mkdir: cannot create directory ‘subdir’: Input/output error

  This happens even as root.. *BUT* even as a regular user I can
"cd /home/waltdnes/tablet/screenshots" and create+delete subdirectories
as well as files.  To summarize, I can do what I want in the "DCIM" and
"screenshots" subdirectories ("ownership" notwithstanding), but not in
the top-level "sdcard1" directory

=======================================================================

[x8940][waltdnes][~] tabon
Device 0 (VID=1bbb and PID=f003) is a Alcatel OneTouch 6034R.
Android device detected, assigning default bug flags
[x8940][waltdnes][~] cd /home/waltdnes/tablet
[x8940][waltdnes][~/tablet] ll
total 24
drwxr-xr-x   4 root     root      0 Dec 31  1969 .
drwxr-xr-x 144 waltdnes users 24576 May 16 10:40 ..
drwxr-xr-x   5 root     root      0 Aug 30  4438198 sdcard
drwxr-xr-x   6 root     root      0 Jun 21  4438201 sdcard1
[x8940][waltdnes][~/tablet] cd sdcard1
[x8940][waltdnes][~/tablet/sdcard1] ll
total 0
drwxr-xr-x 6 root root 0 Jun 21  4438201 .
drwxr-xr-x 4 root root 0 Dec 31  1969 ..
drwxr-xr-x 3 root root 0 Oct 10  2033 DCIM
drwxr-xr-x 2 root root 0 May 18  1950 LOST.DIR
drwxr-xr-x 2 root root 0 Sep 25  2019 screenshots
drwxr-xr-x 2 root root 0 Aug 19  1950 wlan_logs
[x8940][waltdnes][~/tablet/sdcard1] cd screenshots/
[x8940][waltdnes][~/tablet/sdcard1/screenshots] ll
total 0
drwxr-xr-x 2 root root        0 Sep 25  2019 .
drwxr-xr-x 6 root root        0 Jun 21  4438201 ..
-rw-r--r-- 1 root root 21669139 Aug  8  1934 walter.pdf
[x8940][waltdnes][~/tablet/sdcard1/screenshots] mkdir subdir
[x8940][waltdnes][~/tablet/sdcard1/screenshots] ll
total 0
drwxr-xr-x 3 root root        0 Sep 25  2019 .
drwxr-xr-x 6 root root        0 Dec 31  1969 ..
drwxr-xr-x 2 root root        0 Dec 31  1969 subdir
-rw-r--r-- 1 root root 21669139 Aug  8  1934 walter.pdf
[x8940][waltdnes][~/tablet/sdcard1/screenshots] cd
[x8940][waltdnes][~] taboff

=======================================================================

-- 
Roses are red
Roses are blue
Depending on their velocity
Relative to you


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [gentoo-user] mtp cannot create directories on SD card on cellphone
  2024-05-15 21:28 [gentoo-user] mtp cannot create directories on SD card on cellphone Walter Dnes
  2024-05-15 22:06 ` Mark Knecht
@ 2024-05-16 15:34 ` Dr Rainer Woitok
  1 sibling, 0 replies; 9+ messages in thread
From: Dr Rainer Woitok @ 2024-05-16 15:34 UTC (permalink / raw
  To: gentoo-user, Walter Dnes

Walter,

On Wednesday, 2024-05-15 17:28:46 -0400, you wrote:

>   What I *CAN* do... upload/download/create/delete *FILES* on SD card
> 
>   What I *CANNOT* do... create new *DIRECTORIES* on SD card
> 
> [x8940][waltdnes][~/tablet/sdcard1] mkdir data
> mkdir: cannot create directory ‘data’: Input/output error
> 
>   This happens with both "jmtps" and "simple-mtpfs", so I think it's
> probably a systemic issue that affects all implementions.

Though I also have "simple-mtpfs" installed I'm mostly using it with the
SD cards mounted read-only.  For "real" work I'm using "adb" provided by
"dev-util/android-tools".  Among many other things like pushing files to
or pulling files from your mobile phone,  it provides a "shell" sub-com-
mand which allows executing a single shell command  on the mobile device
or opening a shell on it for issuing more commands in a row:

   $ adb shell
   herolte:/ $ cd /storage/emulated/0
   herolte:/storage/emulated/0 $ ls -ld .
   drwxrwx--x 27 root sdcard_rw 4096 2024-05-16 08:01 .
   herolte:/storage/emulated/0 $ touch xxx
   herolte:/storage/emulated/0 $ ls -l xxx
   -rw-rw---- 1 root sdcard_rw 0 2024-05-16 16:13 xxx
   herolte:/storage/emulated/0 $ mkdir yyy
   herolte:/storage/emulated/0 $ ls -ld yyy
   drwxrwx--x 2 root sdcard_rw 4096 2024-05-16 16:13 yyy
   herolte:/storage/emulated/0 $ rmdir yyy
   herolte:/storage/emulated/0 $ rm xxx
   herolte:/storage/emulated/0 $ cd /storage/5BC5-805B
   herolte:/storage/5BC5-805B $ ls -ld .
   drwxrwx--x 7 root sdcard_rw 32768 2024-02-21 20:20 .
   herolte:/storage/5BC5-805B $ touch xxx
   herolte:/storage/5BC5-805B $ ls -l xxx
   -rwxrwx--x 1 root sdcard_rw 0 2024-05-16 16:14 xxx
   herolte:/storage/5BC5-805B $ mkdir yyy
   herolte:/storage/5BC5-805B $ ls -ld yyy
   drwxrwx--x 2 root sdcard_rw 32768 2024-05-16 16:15 yyy
   herolte:/storage/5BC5-805B $ rmdir yyy
   herolte:/storage/5BC5-805B $ rm xxx
   herolte:/storage/5BC5-805B $ exit

Three additional remarks:

- The mobile phone is not required to be rooted.

- But to get "adb" working requires "USB Debugging" to be enabled on the
  mobile device.   On your mobile  device this option can be found under
  "Settings -> Developer Options" (if the "Developer Options"  are still
  hidden in the "Settings" menu,  make them visible  once and forever by
  opening "Settings -> About Device -> Software Information" and tapping
  "Build Number" seven times).

- For security reasons (for instance  when charging your phone at a pub-
  lic charging station)  you should only enable  "USB Debugging" on your
  own phone while connecting it with your own computer for file transfer
  or similar work.

Sincerely,
  Rainer


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-05-16 15:35 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-15 21:28 [gentoo-user] mtp cannot create directories on SD card on cellphone Walter Dnes
2024-05-15 22:06 ` Mark Knecht
2024-05-15 23:38   ` Walter Dnes
2024-05-16  2:16     ` Mark Knecht
2024-05-16  5:29   ` Walter Dnes
2024-05-16  9:42     ` [gentoo-user] " Nuno Silva
2024-05-16 14:58       ` Michael
2024-05-16 15:11       ` Walter Dnes
2024-05-16 15:34 ` [gentoo-user] " Dr Rainer Woitok

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox