spion / adbfs-rootless

Mount Android phones on Linux with adb. No root required.
Other
894 stars 73 forks source link

Doesn't work on Nexus 5 after upgrade to Android 7.0: Transport endpoint is not connected #14

Open avar opened 8 years ago

avar commented 8 years ago

I'm getting this now:

$ ./adbfs /mnt/nexus-5
--*-- exec_command: adb shell "ls"
$ ls -l /mnt/nexus-5 
ls: cannot access /mnt/nexus-5: Transport endpoint is not connected

USB debugging is enabled, this worked before on Android 6.*.

$ adb version
Android Debug Bridge version 1.0.32
spion commented 8 years ago

Can you post the output of ./adbfs -f /mnt/nexus-5 (so that the process isn't in the background)?

avar commented 8 years ago

I can do a bit better than that, it didn't have --help, didn't know about the -f option, it's segfaulting as soon as I ls the directory. Ran it under gdb, got this:

(gdb) bt
#0  __GI_____strtol_l_internal (nptr=0x41ffffffff <error: Cannot access memory at address 0x41ffffffff>, endptr=endptr@entry=0x0,
    base=base@entry=10, group=group@entry=0, loc=0x7ffff7159f20 <_nl_global_locale>) at ../stdlib/strtol_l.c:298
#1  0x00007ffff6decf22 in __GI_strtol (nptr=<optimized out>, endptr=endptr@entry=0x0, base=base@entry=10) at ../stdlib/strtol.c:108
#2  0x00007ffff6dea2d0 in atoi (nptr=<optimized out>) at atoi.c:27
#3  0x0000000000404d6a in adb_getattr (path=0x7ffff0000b00 "/", stbuf=0x7ffff6baec20) at adbfs.cpp:492
#4  0x00007ffff7baa06c in ?? () from /lib/x86_64-linux-gnu/libfuse.so.2
#5  0x00007ffff7bb4405 in ?? () from /lib/x86_64-linux-gnu/libfuse.so.2
#6  0x00007ffff7bb4895 in ?? () from /lib/x86_64-linux-gnu/libfuse.so.2
#7  0x00007ffff7bb1394 in ?? () from /lib/x86_64-linux-gnu/libfuse.so.2
#8  0x00007ffff71670a4 in start_thread (arg=0x7ffff6baf700) at pthread_create.c:309
#9  0x00007ffff6e9c87d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111
(gdb) frame 3
#3  0x0000000000404d6a in adb_getattr (path=0x7ffff0000b00 "/", stbuf=0x7ffff6baec20) at adbfs.cpp:492
492         ftime.tm_mday = atoi(ymd[2].c_str());
(gdb) p *ymd
No symbol "operator*" in current context.
(gdb) x ymd
Value can't be converted to integer.
(gdb) p ymd
$1 = std::vector of length 1, capacity 1 = {"root"}
(gdb) p ymd[0]
$2 = "root"
(gdb) p ymd[0].c_str()
$3 = 0x7ffff0003ff8 "root"
(gdb) p ymd[1].c_str()
$4 = 0x7ffff715a060 <_IO_2_1_stderr_> "\206 \255", <incomplete sequence \373>
(gdb) p ymd[2].c_str()
$5 = 0x41ffffffff <error: Cannot access memory at address 0x41ffffffff>
(gdb) p iDate
$6 = 3
(gdb) p output_chunk[iDate]
$7 = "root"
(gdb)

I.e. the "ymd" variable retrieved via iDate looks bad. I tried to monkeypatch around it with:

diff --git a/adbfs.cpp b/adbfs.cpp
index 87a035c..f32506d 100644
--- a/adbfs.cpp
+++ b/adbfs.cpp
@@ -492,3 +492,3 @@ static int adb_getattr(const char *path, struct stat *stbuf)
-    ftime.tm_mday = atoi(ymd[2].c_str());
-    ftime.tm_hour = atoi(hm[0].c_str());
-    ftime.tm_min  = atoi(hm[1].c_str());
+    ftime.tm_mday = 1;
+    ftime.tm_hour = 1;
+    ftime.tm_min  = 1;

Only to get:

[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
--*-- exec_command: adb shell "ls"
[New Thread 0x7ffff6baf700 (LWP 19386)]
[New Thread 0x7ffff63ae700 (LWP 19387)]
--*-- exec_command: adb shell "ls -l -a -d '/.Trash'"
--*-- exec_command: adb shell "ls -l -a -d '/.Trash-1000'"
--*-- exec_command: adb shell "ls -l -a -d '/'"
--*-- exec_command: adb shell "ls -l -a '/'"
terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::compare: __pos (which is 18446744073709551604) > this->size() (which is 7)

Program received signal SIGABRT, Aborted.
[Switching to Thread 0x7ffff6baf700 (LWP 19386)]
0x00007ffff6de9067 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
56      ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  0x00007ffff6de9067 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1  0x00007ffff6dea448 in __GI_abort () at abort.c:89
#2  0x00007ffff78f3b3d in __gnu_cxx::__verbose_terminate_handler() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#3  0x00007ffff78f1bb6 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#4  0x00007ffff78f1c01 in std::terminate() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#5  0x00007ffff78f1e19 in __cxa_throw () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#6  0x00007ffff7947cdf in std::__throw_out_of_range_fmt(char const*, ...) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#7  0x00007ffff7951d32 in std::string::compare(unsigned long, unsigned long, char const*) const () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#8  0x0000000000405355 in adb_readdir (path=0x7ffff0000b00 "/", buf=0x7fffe8000990, filler=0x7ffff7ba7410, offset=0, fi=0x7ffff6baec40)
    at adbfs.cpp:555
#9  0x00007ffff7bac8d2 in fuse_fs_readdir () from /lib/x86_64-linux-gnu/libfuse.so.2
#10 0x00007ffff7baca5c in ?? () from /lib/x86_64-linux-gnu/libfuse.so.2
#11 0x00007ffff7bb3606 in ?? () from /lib/x86_64-linux-gnu/libfuse.so.2
#12 0x00007ffff7bb4895 in ?? () from /lib/x86_64-linux-gnu/libfuse.so.2
#13 0x00007ffff7bb1394 in ?? () from /lib/x86_64-linux-gnu/libfuse.so.2
#14 0x00007ffff71670a4 in start_thread (arg=0x7ffff6baf700) at pthread_create.c:309
#15 0x00007ffff6e9c87d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111
(gdb)

I.e. there seems to be some bad general data corruption/assumption in the code.

I'd be happy to debug this further with you.

avar commented 8 years ago

FWIW even though it's much slower jmtpfs still works for me so I've switched back to that.

spion commented 8 years ago

Sorry, I haven't had much spare cycles lately (and this code is in dire need of a refactor, too, so its a bit difficult to apply fixes to it)

The problem is likely that adbfs isn't quite getting what it expects from ls -l -a -d / - could you post what Android 7 outputs when given that command?

ls -l -a output would also help...

shlomiv commented 7 years ago

I experience the same exact problem on an nexus 6p with android 7

HaleTom commented 7 years ago

Same issue, Android 7.1.1:

(ins)ravi@svelte:~$ adb shell ls -lad /
drwxr-xr-x 21 root root 0 1970-01-01 13:16 /
(ins)ravi@svelte:~$ sudo umount /mnt/android
(ins)ravi@svelte:~$ sudo adbfs /mnt/android/
--*-- exec_command: adb shell "ls"
(ins)ravi@svelte:~$ sudo ls -lad /mnt/android
ls: cannot access '/mnt/android': Software caused connection abort
(ins)ravi@svelte:~[2]$ sudo ls /mnt/android
ls: cannot access '/mnt/android': Transport endpoint is not connected
(ins)ravi@svelte:~[2]$ 

Worked fine on same hardware when on Android 6.0.1

backface commented 7 years ago

same here, stopped working after phone was upgraded to Android 7.0 (Sony Xperia Z5)

ls -l -a -d / seems okay

$ adb shell ls -l -a -d /
drwxr-xr-x 24 root root 0 1970-02-02 10:44 /

adb shell ls returns a few permission errors

$ adb shell ls
ls: ./rca: Permission denied
ls: ./verity_key: Permission denied
ls: ./ueventd.rc: Permission denied
ls: ./ueventd.qcom.rc: Permission denied
ls: ./service_contexts: Permission denied
ls: ./sepolicy: Permission denied
ls: ./selinux_version: Permission denied
ls: ./seapp_contexts: Permission denied
ls: ./logo.rle: Permission denied
...

except for that, i get the same as above

kronenpj commented 7 years ago

I've started looking at this. Preliminary finding: Android 7 changed the format of ls -l -a -d such that the date is in "slot" 5 vs. 3 or 4. This makes it more consistent - no differences between the format WRT the various file types. Eg:

$ adb shell ls -l -a -d /cache
drwxrwx--- 6 system cache 4096 2017-02-06 21:45 /cache
$ adb shell ls -l -a -d /charger
lrwxrwxrwx 1 root root 13 1969-12-31 19:00 /charger -> /sbin/healthd
$ adb shell ls -l -a -d /property_contexts
-rw-r--r-- 1 root root 4661 1969-12-31 19:00 /property_contexts

However, changing iDate in adb_getattr doesn't fully fix the problem. I'm now seeing this from adb_readdir:

terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::compare: __pos (which is 18446744073709551604) > this->size() (which is 7)

From this if statement, somewhere near line 560:

                if (!output.front().compare(output.front().length() - sizeof(PERMISSION_ERR_MSG) + 1,
                                            sizeof(PERMISSION_ERR_MSG) - 1, PERMISSION_ERR_MSG)) {

So, clearly more than the format of ls has changed...

kronenpj commented 7 years ago

For comparison, my old 4.2 phone returns this data:

$ adb shell ls -l -a -d /
drwxr-xr-x root     root              1972-02-26 15:27 
$ adb shell ls -l -a -d /tombstones
lrwxrwxrwx root     root              1972-02-26 15:27 tombstones -> /data/tombstones
$ adb shell ls -l -a -d /ueventd.rc
-rw-r--r-- root     root         5670 1969-12-31 19:00 ueventd.rc
kronenpj commented 7 years ago

Android 4.2 uses "toolbox" as it's busybox implementation. It looks like Nougat changed to "toybox".

I have a partial fix - directory listings and reading files works with the attached patch... Writes fail. Also, and this should be fairly obvious, this patch will likely cause failures for Android < 7 / Nougat.

diff --git a/adbfs.cpp b/adbfs.cpp
index 11bcbf5..5556df6 100644
--- a/adbfs.cpp
+++ b/adbfs.cpp
@@ -150,7 +150,7 @@ queue<string> adb_shell(const string& command)
     actual_command.assign(command);
     //adb_shell_escape_command(actual_command);
     actual_command.insert(0, "adb shell \"");
-    actual_command.append("\"");
+    actual_command.append("\" 2>/dev/null");
     return exec_command(actual_command);
 }

@@ -428,13 +428,13 @@ static int adb_getattr(const char *path, struct stat *stbuf)

     stbuf->st_nlink = 1;   /* number of hard links */

-    foruid = getpwnam(output_chunk[1].c_str());
+    foruid = getpwnam(output_chunk[2].c_str());
     if (foruid)
        stbuf->st_uid = foruid->pw_uid;     /* user ID of owner */
     else
        stbuf->st_uid = 98; /* 98 has been chosen (poorly) so that it doesn't map to anything */

-    forgid = getgrnam(output_chunk[2].c_str());
+    forgid = getgrnam(output_chunk[3].c_str());
     if (forgid)
        stbuf->st_gid = forgid->gr_gid;     /* group ID of owner */
     else
@@ -449,7 +449,7 @@ static int adb_getattr(const char *path, struct stat *stbuf)
     switch (stbuf->st_mode & S_IFMT) {
     case S_IFBLK:
     case S_IFCHR:
-       stbuf->st_rdev = atoi(output_chunk[3].c_str()) * 256 + atoi(output_chunk[4].c_str());
+       stbuf->st_rdev = atoi(output_chunk[4].c_str()) * 256 + atoi(output_chunk[4].c_str());
        stbuf->st_size = 0;
        iDate = 5;
        break;
@@ -457,8 +457,8 @@ static int adb_getattr(const char *path, struct stat *stbuf)
        break;

     case S_IFREG:
-       stbuf->st_size = atoi(output_chunk[3].c_str());    /* total size, in bytes */
-       iDate = 4;
+       stbuf->st_size = atoi(output_chunk[4].c_str());    /* total size, in bytes */
+       iDate = 5;
        break;

     default:
@@ -467,7 +467,7 @@ static int adb_getattr(const char *path, struct stat *stbuf)
     case S_IFLNK:
     case S_IFDIR:
        stbuf->st_size = 0;
-       iDate = 3;
+       iDate = 5;
        break;
     }

@@ -551,7 +551,8 @@ static int adb_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
             // we can get e.g. "permission denied" during listing, need to check every line separately
             if (!is_valid_ls_output(output.front())) {
                 // error format: "lstat '//efs' failed: Permission denied"
-                if (!output.front().compare(output.front().length() - sizeof(PERMISSION_ERR_MSG) + 1,
+                if (output.front().length() > sizeof(PERMISSION_ERR_MSG) + 1 &&
+           !output.front().compare(output.front().length() - sizeof(PERMISSION_ERR_MSG) + 1,
                                             sizeof(PERMISSION_ERR_MSG) - 1, PERMISSION_ERR_MSG)) {
                     size_t nameStart = output.front().rfind("/") + 1;
                     const string& fname_l = output.front().substr(nameStart, output.front().find("' ") - nameStart);
diff --git a/utils.h b/utils.h
index 7e64a71..cf509c8 100644
--- a/utils.h
+++ b/utils.h
@@ -164,7 +164,7 @@ queue<string> exec_command(const string& command)
     while ( fgets( buff, sizeof buff, fp ) != NULL && !feof(fp) )
     {
         tmp_string.assign(buff);
-        tmp_string.erase(tmp_string.size()-2);
+        tmp_string.erase(tmp_string.size()-1);
         output.push(tmp_string);
     }
backface commented 7 years ago

thanks for the patch. I can confirm this works also reading data from my Nougat phone (Sony Xperia E5823) - my use case basically is just (r)syncing data from phone to laptop (Potos, Videos mainly).

IzzySoft commented 6 years ago

I've got a similar problem here with a Samsung S7 Edge (after it got updated to Nougat):

--*-- exec_command: adb shell "ls"
FUSE library version: 2.9.4
nullpath_ok: 0
nopath: 0
utime_omit_ok: 0
unique: 1, opcode: INIT (26), nodeid: 0, insize: 56, pid: 0
INIT: 7.23
flags=0x0003fffb
max_readahead=0x00020000
   INIT: 7.19
   flags=0x00000011
   max_readahead=0x00020000
   max_write=0x00020000
   max_background=0
   congestion_threshold=0
   unique: 1, success, outsize: 40
unique: 2, opcode: ACCESS (34), nodeid: 1, insize: 48, pid: 4858
access / 04
   unique: 2, success, outsize: 16
unique: 3, opcode: LOOKUP (1), nodeid: 1, insize: 47, pid: 4858
LOOKUP /.Trash
getattr /.Trash
--*-- exec_command: adb shell "ls -l -a -d '/.Trash'"
ls: /.Trash: No such file or directory
   unique: 3, error: -11 (Resource temporarily unavailable), outsize: 16
unique: 4, opcode: LOOKUP (1), nodeid: 1, insize: 52, pid: 4858
LOOKUP /.Trash-1000
getattr /.Trash-1000
--*-- exec_command: adb shell "ls -l -a -d '/.Trash-1000'"
ls: /.Trash-1000: No such file or directory
   unique: 4, error: -11 (Resource temporarily unavailable), outsize: 16

Hint: there is no such file/directory named /Trash (and without the device being rooted, I cannot create it either). As I use adbfs for multiple devices and also for write access plus for pre-Nougat devices, the patch would break it for all but the S7 in my case, so I cannot use it. Any idea – or even solution on the horizon?

avar commented 6 years ago

@kronenpj's patch works for my use case of just using this to copy files from the phone, which was all I needed, this is with a Nexus 5x on Android 8.0 (I've upgraded from 7.0 since initially filing this).

IzzySoft commented 6 years ago

That's what I understood, @avar – but as I wrote, I'm using adbfs with multiple devices here copying in both directions. So I'd rather wait for a complete fix instead of half-fixing it for one device I rarely connect while breaking it for all devices I use regularly :wink:

avar commented 6 years ago

@IzzySoft Yeah obviously a proper fix will need some sort of version detection.

apollothethird commented 6 years ago

@IzzySoft Thanks again.  The patch works, however, it loses connection when performing activity.  An example if the find command browsing all the directories.  Before it completes all the directories it loosing connection and in the example posted below.

I'm bringing my reply to this issue as suggested.

$ find ~/mnt
/home/users/l/j/ljames/mnt/config/usb_gadget/g1/os_desc/use
/home/users/l/j/ljames/mnt/config/usb_gadget/g1/strings
/home/users/l/j/ljames/mnt/config/usb_gadget/g1/strings/0x409
/home/users/l/j/ljames/mnt/config/usb_gadget/g1/strings/0x409/manufacturer
/home/users/l/j/ljames/mnt/config/usb_gadget/g1/strings/0x409/product
/home/users/l/j/ljames/mnt/config/usb_gadget/g1/strings/0x409/serialnumber
/home/users/l/j/ljames/mnt/d
/home/users/l/j/ljames/mnt/data
/home/users/l/j/ljames/mnt/default.prop
/home/users/l/j/ljames/mnt/dev
/home/users/l/j/ljames/mnt/dev/.coldboot_done
/home/users/l/j/ljames/mnt/dev/.secure_storage
find: ‘/home/users/l/j/ljames/mnt/dev/0:0:0:0’: Software caused 
connection abort
/home/users/l/j/ljames/mnt/dev/0:0:0:0
find: ‘/home/users/l/j/ljames/mnt/dev/0:0:0:1’: Transport endpoint is 
not connected
/home/users/l/j/ljames/mnt/dev/0:0:0:1
find: ‘/home/users/l/j/ljames/mnt/dev/0:0:0:2’: Transport endpoint is 
not connected
/home/users/l/j/ljames/mnt/dev/0:0:0:2
find: ‘/home/users/l/j/ljames/mnt/dev/0:0:0:3’: Transport endpoint is 
not connected
/home/users/l/j/ljames/mnt/dev/0:0:0:3
find: ‘/home/users/l/j/ljames/mnt/dev/0:0:0:49456’: Transport endpoint 
is not con

I really appreciate the word being done to resolve this issue.  I'll keep up with the progress and report any findings on this end with the updated code and patches.

If I can provide any other helpful details or test, let me know.

-- L. James

-- L. D. James ljames@apollo3.com www.apollo3.com/~ljames

IzzySoft commented 6 years ago

@spion any news on this? Next device(s) pending to be upgraded, and I don't want to lose this way to access them properly.

spion commented 6 years ago

Can anyone test if this the patch in pull request https://github.com/spion/adbfs-rootless/pull/21 is working?

apollothethird commented 6 years ago

Thanks Izzy for keeping this concern alive.  I'll work provide feedback on how the updates work with the Samsung SG8.

-- L. James

-- L. D. James ljames@apollo3.com www.apollo3.com/~ljames

On 01/16/2018 06:08 AM, Izzy wrote:

@spion https://github.com/spion any news on this? Next device(s) pending to be upgraded, and I don't want to lose this way to access them properly.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/spion/adbfs-rootless/issues/14#issuecomment-357927719, or mute the thread https://github.com/notifications/unsubscribe-auth/AToo2xVW4_HoQb9nzf9NhnMyefux0eU3ks5tLIMYgaJpZM4JyIUq.

IzzySoft commented 6 years ago

@spion Thanks for picking up! I currently have no N/O device at hand. Luckily it seems like @apollothethird will check. But from the PR's description:

Creation and writes will very likely fail and this probably breaks compatibility with Marshmallow and below.

I've got a mix of devices. If it breaks things for MM and below, that wouldn't be good. Might be possible to work around by first checking the Android version and then deciding which branch to execute? Also, it seems to be read-only support, so it would need some more work.

apollothethird commented 6 years ago

@spion It doesn't work with the Samsung Galaxy S8 under Ubuntu 16.04 LTS. It also fails to work with my Galaxy TAB A, which works with the unpatched version.

I'm wondering, which android device are you working with?

-- L. James

-- L. D. James ljames@apollo3.com www.apollo3.com/~ljames

On 01/16/2018 02:35 PM, Gorgi Kosev wrote:

Can anyone test if this patch is working?

21 https://github.com/spion/adbfs-rootless/pull/21

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/spion/adbfs-rootless/issues/14#issuecomment-358078825, or mute the thread https://github.com/notifications/unsubscribe-auth/AToo2_T5MYWUfUOn1aagA7cZqKX108s_ks5tLPn8gaJpZM4JyIUq.

spion commented 6 years ago

I still have my old LG G3, which only goes up to Android 6.0

I'll try to put some time into this project next weekend, since I might get access to an S8.

spion commented 6 years ago

Okay this should now work on Android 7.0 as of https://github.com/spion/adbfs-rootless/commit/fc00979f3b61cb9a98850a363bb2339428399de7

IzzySoft commented 6 years ago

Thanks Gorgi!!!

@apollothethird can you confirm? Does it work read/write on all Android versions (up to 7; versions before 4.x are not really that relevant I'd say – important is down to LP or maybe KK)?

apollothethird commented 6 years ago

Sorry.  I was away from my shop.  I'll check it ASAP and get back with you.

-- L. James

-- L. D. James ljames@apollo3.com www.apollo3.com/~ljames

On 01/17/2018 03:13 AM, Izzy wrote:

@apollothethird https://github.com/apollothethird can you confirm? Does it work read/write on all Android versions (up to 7; versions before 4.x are not really that relevant I'd say – important is down to LP or maybe KK)?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/spion/adbfs-rootless/issues/14#issuecomment-358229024, or mute the thread https://github.com/notifications/unsubscribe-auth/AToo2yclXbVmrCrI6HYNP0H5DGkElTodks5tLauugaJpZM4JyIUq.

apollothethird commented 6 years ago

@spion @IzzySoft It works on Both the Samsung Galaxy S8 and my Galaxy Tab A.

-- L. James

-- L. D. James ljames@apollo3.com www.apollo3.com/~ljames

IzzySoft commented 6 years ago

@apollothethird Both read and write? And which Android versions are on them? I cannot currently test as I'm not at home – but as soon as I am and find some time, I'll check for KK, LP and MM (if I'm lucky, I get a chance to check N as well).

apollothethird commented 6 years ago

@IzzySoft Read is alright. Writing isn't working. Maybe I'm doing something wrong. Tell me if there's something I can check.

From the adb shell I can do this (the lines starting with the $ are commands, the ones without is the output`:

$ cd /sdcard
$ mkdir test
$ ls -ld test
drwxrwx--x 2 root sdcard_rw 4096 2018-01-17 08:13 test

From the Ubuntu commandline of the sshfs mount I get this:

$ cd ~/mnt/sdcard
$ mkdir test1
mkdir: cannot create directory ‘test1’: Resource temporarily unavailable
$ ls -ld test*
drwxrwx--x 2 root 98 0 Jan 17 08:13 test

The Ubuntu file browser has reads, but can not write to the sshfs mount either.

If there's a method for writing to the device, let me know and I'll test those steps.

By the way, if I try to use the sudo command to write to the mount, it also fails with this error:

mkdir: cannot create directory ‘test1’: Permission denied

The Samsung GS8 is android version 7.0. The Samsung Tab A is android version 5.1.1

-- L. James

-- L. D. James ljames@apollo3.com www.apollo3.com/~ljames

spion commented 6 years ago

I wonder what the output of ./adbfs -f is for that situtaion where the directory creation fails.

I tried writes as well and they do work here.

edit: I added another fix that deals with a trouble caused by non-existent files

apollothethird commented 6 years ago

@spion I ran this ./adbfs -f ~/mnt >adbfs.out 2>&1. A few lines before and after the mkdir test1 command is:

adb_readlink
from cache /sdcard
adb_readlink lrwxrwxrwx 1 root root 21 1969-12-31 19:00 /sdcard -> /storage/self/primary
adb_getattr
--*-- exec_command: adb shell "ls -l -a -d '/storage'"
adb_getattr
--*-- exec_command: adb shell "ls -l -a -d '/storage/self'"
adb_getattr
--*-- exec_command: adb shell "ls -l -a -d '/storage/self/primary'"
adb_readlink
from cache /storage/self/primary
adb_readlink lrwxrwxrwx 1 root root 19 2017-10-13 20:50 /storage/self/primary -> /mnt/user/0/primary
adb_getattr
--*-- exec_command: adb shell "ls -l -a -d '/mnt'"
adb_getattr
--*-- exec_command: adb shell "ls -l -a -d '/mnt/user'"
adb_getattr
--*-- exec_command: adb shell "ls -l -a -d '/mnt/user/0'"
adb_getattr
--*-- exec_command: adb shell "ls -l -a -d '/mnt/user/0/primary'"
adb_readlink
from cache /mnt/user/0/primary
adb_readlink lrwxrwxrwx 1 root root 19 2018-01-16 15:42 /mnt/user/0/primary -> /storage/emulated/0
adb_getattr
--*-- exec_command: adb shell "ls -l -a -d '/storage/emulated'"
adb_getattr
--*-- exec_command: adb shell "ls -l -a -d '/storage/emulated/0'"
adb_readlink
from cache /sdcard
adb_readlink lrwxrwxrwx 1 root root 21 1969-12-31 19:00 /sdcard -> /storage/self/primary
adb_readlink
from cache /storage/self/primary
adb_readlink lrwxrwxrwx 1 root root 19 2017-10-13 20:50 /storage/self/primary -> /mnt/user/0/primary
adb_readlink
from cache /mnt/user/0/primary
adb_readlink lrwxrwxrwx 1 root root 19 2018-01-16 15:42 /mnt/user/0/primary -> /storage/emulated/0
adb_getattr
ls: /storage/emulated/0/test1: No such file or directory
--*-- exec_command: adb shell "ls -l -a -d '/storage/emulated/0/test1'"
--*-- exec_command: rm -rf /tmp/adbfs-6J8AZR/

The full output of the command is adbfs.out.txt.

-- L. James

-- L. D. James ljames@apollo3.com www.apollo3.com/~ljames

spion commented 6 years ago

strange, I don't even see an attempt to create a directory. "No such file or directory" should be followed with a mkdir.

apollothethird commented 6 years ago

FYI, both the Read and Write from the latest adbfs patch work flawlessly on the Galaxy Tab A device.

-- L. James

-- L. D. James ljames@apollo3.com www.apollo3.com/~ljames

On 01/17/2018 11:11 AM, Gorgi Kosev wrote:

strange, I don't even see an attempt to create a directory. "No such file or directory" should be followed with a mkdir.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/spion/adbfs-rootless/issues/14#issuecomment-358354507, or mute the thread https://github.com/notifications/unsubscribe-auth/AToo203UNx8rvLdqOS4Cb1BQMjrnssupks5tLhvIgaJpZM4JyIUq.

IzzySoft commented 6 years ago
IzzySoft commented 6 years ago

Sorry if I bump, but any progress on this? Having to get a new device, and that certainly comes with an Android version higher than 6. And I need r/w access :crying_cat_face:

spion commented 6 years ago

I have a new N device I just got recently, might try to pick this up again with it.

spion commented 6 years ago

By the way, is this really necessary with the newer androids? It seems like MTP works just fine for me in the latest distros...

IzzySoft commented 6 years ago

Yes, it is really necessary (IMHO). MTP is flaky. You cannot transfer files in parallel. And if a directory contains many files (not sure where the limit is, but e.g. my has over 1000 photos in the DCIM folder and there it hits), MTP simply hangs. You never get the (newest) files copied. And yes, I use an up-to-date distro (Linux Mint 18.3 here on multiple machines).

I would very much prefer to have adbfs with r/w access. Served me well up to Android 6. And you know I'm a long-time user of your implementation :wink:

apollothethird commented 6 years ago

On 06/03/2018 11:21 AM, Gorgi Kosev wrote:

By the way, is this really necessary with the newer androids? It seems like MTP works just fine for me in the latest distros...

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/spion/adbfs-rootless/issues/14#issuecomment-394169546, or mute the thread https://github.com/notifications/unsubscribe-auth/AToo2-z8Rr0tnnr4NFT_W6K4c2t-vDr5ks5t4_8FgaJpZM4JyIUq.

Being able to have a true mount of my mobile devices is very extremely valuable.  I have my own consistent backup that works better than all the other proprietary backups provided by various entities.  I'm not disputing the reliable features of other backup applications.  But for me, using the same backup of my devices as I do for my computers is great consistency and gives me lots of peace of mind.

I have used other backup/restore facilities when changing phones. For me they have fallen short.  However, I have always benefited by having all my important data backed up using my own procedure which I've been using since I stated out with my first computers back in the 1980's which is very personal and have morphed perfectly with progress.

While many people are replacing much of their computer usage with their mobile devices, I use my mobile devices as extensions of my computers, where I process the data on my computers, not the tiny keyboard and screen of the mobile devices.

I'm glad you are considering revisiting your application and fixing the bugs.

I'll most likely start a different thread on this request, but I hope you will consider adding the ability to specifying the device being mapped, rather than giving an error when there are multiple devices.  I almost always have multiple mobile devices connected to my main computer.  When it's time to map one of them, there's this inconvenience of having to disconnect them all except one just to run the adbfs program.  Otherwise the dreaded "error: more than one device/emulator" error comes up.  Adding the "-s" argument to specify the device would be great.

Thanks for such a valuable contribution to the mobile community!

-- L. James

-- L. D. James ljames@apollo3.com www.apollo3.com/~ljames

IzzySoft commented 6 years ago

rather than giving an error when there are multiple devices. I almost always have multiple mobile devices connected to my main computer. When it's time to map one of them, there's this inconvenience of having to disconnect them all except one just to run the adbfs program.

No need for that, @apollothethird – easy to fix. Here's how I have done it (using a wrapper):

case "$(adb devices|grep -v "devices"|grep -v -e '^[[:space:]]*$'|wc -l)" in
  0) echo "Nothing to mount (no device attached)" ;;
  1) export ANDROID_SERIAL=$(adb devices|grep -v "devices"|grep -v -e '^[[:space:]]*$'|awk '{print $1'})
     adbfs /mnt/droid
     ;;
  *) echo "Multiple devices found, make your choice:"
     {
       adb devices -l|grep -v "devices"|grep -v -e '^[[:space:]]*$'
       read -p "Serial: " serial
       export ANDROID_SERIAL=$serial
       adbfs /mnt/droid
     }
     ;;
esac

Though self-explaining: the returned number of the first command is the number of devices attached. So 0 means we don't have anything to mount, 1 there's exactly one device, and everything else means multiple devices. In the latter case you'll see a list of devices (serials and names) to pick from, and simply copy-paste the serial (I was to lazy to make that a menu).

apollothethird commented 6 years ago

Thanks, Izzy! I didn't know of the ANDROID_SERIAL variable. This is a great addition to my adb tool arsenal. This works perfectly:

ANDROID_SERIAL=192.168.15.93:5123 adbfs ~/droid

What used to take between 5 and 10 minutes... and sometimes longer, because there would be a mistype and I'd have to run fusermount -u ~/droid to start over. Some of my devices connect automatically and would connect while I'm trying to get one of the others connected and mounted.

I use "-s" for all my adb commands. Now now I can use the variable assignment for adbfs without conflicts.

-- L. James

-- L. D. James ljames@apollo3.com www.apollo3.com/~ljames

IzzySoft commented 6 years ago

Glad I could help, @apollothethird! Didn't know the variable also worked for ABD over TCP, so I leaned something along the lines :wink:

spion commented 6 years ago

I believe I managed to fix the writing part of this issue with the latest commit...

apollothethird commented 6 years ago

On 06/09/2018 12:48 PM, Gorgi Kosev wrote:

I believe I managed to fix the writing part of this issue with the latest commit...

Thanks!  It works fine on all my Samsung devices.

Thanks also for a very valuable tool for the mobile enviornment!

-- L. James

-- L. D. James ljames@apollo3.com www.apollo3.com/~ljames

spion commented 6 years ago

Glad to hear it worked! Apologies though - I made another modification to change the fix to be a bit more conservative - but it should still work.

xeruf commented 6 years ago

I have a Lenovo K6 on Android 7 and still get the error when accessing the directory:

~ cd droid
cd: transport endpoint is not connected: droid

However, when I mount it using sudo and execute sudo -i I can cd into the directory and ls just fine, but using the sudo shell kinda defeats the point...

dandv commented 1 year ago

Running adb shell getprop ro.build.version.release from Ubuntu 22 on my old Samsung GS7 returns 6.0.1. On that version of android, adb shell ls /data/data works perfectly fine, but when I run ./adbfs ~/droid, I get

--*-- exec_command: adb shell "ls"
fuse: failed to access mountpoint /home/arond/a: Transport endpoint is not connected
--*-- exec_command: rm -rf /tmp/adbfs-uALbj4/

This issue hasn't seen any activity in 5 years. Is there a more reliable adb shell GUI that simply parses the output of adb ls and shows it in a graphical interface?

sezuan commented 1 year ago

I mitigated that a bit by adding -o modules=subdir -o subdir=/sdcard/<dir-with-hopefully-readable-files/, since it seems that it crashes when permission problems occur.