Re: [gentoo-user] mtp cannot create directories on SD card on cellphone

2024-05-16 Thread Dr Rainer Woitok
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



Re: [gentoo-user] mtp cannot create directories on SD card on cellphone

2024-05-15 Thread Walter Dnes
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



Re: [gentoo-user] mtp cannot create directories on SD card on cellphone

2024-05-15 Thread Mark Knecht
On Wed, May 15, 2024 at 4:38 PM Walter Dnes  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
>


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


Re: [gentoo-user] mtp cannot create directories on SD card on cellphone

2024-05-15 Thread Walter Dnes
> 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



Re: [gentoo-user] mtp cannot create directories on SD card on cellphone

2024-05-15 Thread Mark Knecht
On Wed, May 15, 2024 at 2:29 PM Walter Dnes  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


[gentoo-user] mtp cannot create directories on SD card on cellphone

2024-05-15 Thread Walter Dnes
  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