ADBFS a FUSE Filesystem for Android Debug Bridge

Android Debugging Bridge in action

Android Debug Bridge(ADB) is usually used for debugging android devices. I personally use it to move files arround because mounting your sdcard can sometimes be a bitch. moving files around in command line isn’t fun too imagine typing the following:

adb push bla /sdcard/ultRa\ Long\ Directory/AnOther\ Long\Directory/bla

not fun…. so to solve this problem i wrote ADBFS. With adbfs, i can simply drag and drop files as usual.

Requirements

  • *nix Os (or any os that support FUSE – i think windows has a port.. not sure)
  • FUSE ( macfuse for mac users – windows, i don’t know.)
  • android sdk from  Android developers site
  • git

Installation

git clone git@github.com:isieo/adbFS.git .
cd adbFS
make
mv adbfs <location of android sdk>/tools/adbfs

Usage

mkdir ~/mounted-adb
adbfs mounted-adb

done! enjoy drag and drop without needing to “mount” your sdcard to your machine.

Note: adbfs can be very very slow at times, this is because your file manager is trying to access all the files to get data from it. ADB was never designed to do this so its not fast. Also this program is a proof-of-concept if anyone have a better implementation, please suggest.

License

/*
 *      Redistribution and use in source and binary forms, with or without
 *      modification, are permitted provided that the following conditions are
 *      met:
 *      
 *      * Redistributions of source code must retain the above copyright
 *        notice, this list of conditions and the following disclaimer.
 *      * Redistributions in binary form must reproduce the above
 *        copyright notice, this list of conditions and the following disclaimer
 *        in the documentation and/or other materials provided with the
 *        distribution.
 *      * Neither the name of the  nor the names of its
 *        contributors may be used to endorse or promote products derived from
 *        this software without specific prior written permission.
 *      
 *      THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 *      "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 *      LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 *      A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 *      OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 *      SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 *      LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 *      DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 *      THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 *      (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 *      OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

Warning

Very experimental =P its usable though i use this regularly to modify my playlist file.

Android Debugger Bridge Filesystem

25 thoughts on “ADBFS a FUSE Filesystem for Android Debug Bridge

  1. Calvin,

    this seems to be very neat, just what I need.

    However, it fails on Froyo FRG83, because the needed utils are not there, or not with the needed syntax:


    laptop$ ./adb shell stat -t
    stat: permission denied
    laptop$ ./adb shell
    $ su
    # stat
    stat: not found
    ^D
    laptop$ ./adb shell ls -1a /
    -1a: No such file or directory
    config
    cache
    ...

    What kind of userspace do you have on your phone? Are these utils are shipped in some other version of Android? If these are not standard, wouldn’t it make sense to assume that the phone has busybox, and use busybox commands?

    • OK, worksfome like this:


      diff --git a/adbfs.cpp b/adbfs.cpp
      index 36d0278..acb6ac7 100644
      --- a/adbfs.cpp
      +++ b/adbfs.cpp
      @@ -74,7 +74,7 @@ queue adb_shell(string command)
      string_replacer(command,"%","\\%");
      string_replacer(command,"=","\\=");
      string_replacer(command,"~","\\~");
      - actual_command = "adb shell ";
      + actual_command = "adb shell busybox ";
      actual_command.append(command);
      //actual_command.append("'");

      You could make a mention of the utilities needed to get it running. And for ordinary people, the git command should be indeed


      git clone git://github.com/isieo/adbFS.git

  2. I have given it a try with a normal user with adbfs command. But the mount point can’t be accessed with that account, even though I try to unmount or remove it with root account.

    The file system just shows like this

    d????????? ? ? ? ? ? mounted-adb

    Nobody can access it any more. I have to kill the adbfs daemon. But it still
    can’t be accessed.

    And good advice, thanks!

    BR/JP

  3. $ adbfs -d ~/mnt/adbfs

    LOOKUP /.Trash-501
    getattr /.Trash-501
    stat -t “/.Trash-501″
    unique: 12, success, outsize: 120
    unique: 13, error: -2 (No such file or directory), outsize: 16
    unique: 14, opcode: READDIR (28), nodeid: 1, insize: 80
    unique: 14, success, outsize: 16
    unique: 15, opcode: LOOKUP (1), nodeid: 1, insize: 71
    LOOKUP /-1a: No such file or directory
    getattr /-1a: No such file or directory
    stat -t “/-1a: No such file or directory”
    Segmentation fault

    Android 2.2

    • Oh!
      that was again the “adb shell busybox ” problem.
      But the next problem is:
      $ ls adbfs/

      ls: cannot access adbfs/sbin: No such file or directory
      ls: cannot access adbfs/sdcard: No such file or directory
      ls: cannot access adbfs/sys: No such file or directory
      ls: cannot access adbfs/system: No such file or directory
      ?[0;0mdefault.prop?[0m ?[1;34m.?[0m ?[1;34mproc?[0m
      ?[0;0mEUROPA.rle?[0m ?[1;34macct?[0m ?[1;34mroot?[0m
      ?[1;32minit?[0m ?[1;34mcache?[0m ?[1;34msbin?[0m

  4. For latest GCC:

    diff –git a/Makefile b/Makefile
    index 6a2894d..be1db66 100644
    — a/Makefile
    +++ b/Makefile
    @@ -1,5 +1,5 @@
    CXXFLAGS=-Wall -D_FILE_OFFSET_BITS=64
    -LDFLAGS=-lfuse
    +LDLIBS=-lfuse

  5. Pingback: Mount Android 4 Ice Cream Sandwitch on Linux | pofHQ

  6. Your repository is ssh protected – it requires password or a key to clone! I can’t get the source… I really need it now. Can you help out?

  7. Pingback: Galaxy S3 access files in Linux | Random Rambling's…

  8. My issues are:
    1) cannot find fuse.h so I copied it locally (from /usr/include/linux)
    2) I have fused installed
    3) then: Package fuse was not found in the pkg-config search path.
    Perhaps you should add the directory containing `fuse.pc’
    to the PKG_CONFIG_PATH environment variable
    4) cannot find fuse.pc
    5) my PKG_CONFIG_PATH is /usr/local/lib/pkgconfig

    Could you please give me some pointers? It seems quite simple, just cannot find fuse library.

    Many thanks!

  9. Wonderful job and thanks. It might be a good idea to add install libfuse-dev to the instructions. I was having the problem finding fuse.h until I saw the comment.

    Now, I do have one major question. I was able to mount my rooted phone but only without SuperUser access. I would like to access /system, /data and /cache. Normally from a shell session I do “su” and I can see everything but your fs seems to not do this and there seems to be no option either. Can this be done? If not, can you add some sort of parameter.

    • FYI, I took a look at your code and adding su or sudo to the commands executed did not seem to work. In fact, it just broke it instead. I’m a PHP and Java programmer so I could see how you got this all to work but my lack of C++ knowledge prevents me from knowing what I could do to implement what I need. Would it be possible to start an adb session and stream the I/O instead of executing individual commands.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>