[APP] midnight-commander 4.7.0.3 for Android (updated to 4.7.5.4, with APK Installer)

Search This thread

viulian

Inactive Recognized Developer
Apr 6, 2011
419
411
hex.ro
Introduction

Here's the classic Midnight Commander for Android!

mc_4.7.0.3-arm.png


Features

a) Function keys work (F3 - view, F5 - copy, F8 - delete, F10 - exit, etc...)
b) Very stable, doesn't crash.
c) Much easier installation than the previous one version (which needed an additional apt-get clone, named ipkg, etc). More about this below.
d) comes bundled with xterm (terminfo) and syntax highlighting for major languages.
e) I kept the wrapper script 4.6.2 but updated it so that function keys work.

Reasons

There is an one year old version floating around (version 4.6.2) and even if does start, it crashed every time I pressed the arrow keys in the search panels:

Code:
/system/xbin/mc.real: libc/misc/ctype/ctype.c: 290: tolower: Assertion `((((unsigned int)((c) - 0)) <= ((127 * 2 + 1) - 0)) || ((c) == (-1)))' failed.

Not only this, but I had to restart Putty, since the whole screen became garbled.

Installation

You need a rooted phone with busybox.

Installation is easy:

click Install and allow root access.​

If everything is ok, you will see an output like in the screenshot below:

20111008103603.png


To use mc, you could connect with a terminal emulator (but it looks ugly). A good alternative is if you use DroidSSHd as SSH server on the phone and Putty as client from your PC (or connect-bot as client on the phone).

For now, there is no uninstaller for the native MC that is extracted on the phone. Thus, feel free to uninstall the app as you don't need it anymore once MC native is copied to the phone.

Download

Use it at your own risk! (License is GPLv2)

NativnuxInstaller_1.1.apk
 
Last edited:

dancer_69

Senior Member
Jan 2, 2007
1,961
248
cp cannot create 'mc-4.0.7................
read only file system.
How to solve this ?
I tried to remount /system as rw but didn´t help.
How to get write access to / ?

I tried to extract the archive on a linux machine and copy the folders to device via QtADB but when I tried to run mc from terminal emulator I get error run xterm.
So I think there was some permission errors.
 
Last edited:

viulian

Inactive Recognized Developer
Apr 6, 2011
419
411
hex.ro
1. Become super user:

su

2. Check output of current mounts:

cat /proc/mounts

You will see something like:

Code:
...
/dev/block/mtdblock0 /system yaffs2 rw,relatime 0 0

Remember the number after mtdblock! Important. In case above is 0, but it might be 3 also etc...

3. Execute command:

mount -o rw,remount -t yaffs2 /dev/block/mtdblock[PUT_HERE_THE_NUMBER] /
 

dancer_69

Senior Member
Jan 2, 2007
1,961
248
1. Become super user:

su

2. Check output of current mounts:

cat /proc/mounts

You will see something like:

Code:
...
/dev/block/mtdblock0 /system yaffs2 rw,relatime 0 0

Remember the number after mtdblock! Important. In case above is 0, but it might be 3 also etc...

3. Execute command:

mount -o rw,remount -t yaffs2 /dev/block/mtdblock[PUT_HERE_THE_NUMBER] /

Seems that /system is in /dev/block/mmcblk0p12 . I tried your command with mmcblk0p12 but again I get the same error. So, something I'm doing wrong. Here is the output of cat /proc/mounts:

Code:
# cat /proc/mounts
rootfs / rootfs ro,relatime 0 0
tmpfs /dev tmpfs rw,relatime,mode=755 0 0
devpts /dev/pts devpts rw,relatime,mode=600 0 0
proc /proc proc rw,relatime 0 0
sysfs /sys sysfs rw,relatime 0 0
/dev/block/mmcblk0p12 /system ext3 rw,relatime,errors=continue,data=writeback 0 0
/dev/block/mmcblk0p13 /data ext3 rw,nosuid,nodev,relatime,errors=continue,data=ordered 0 0
/dev/block/mmcblk0p6 /cache ext3 rw,nosuid,nodev,relatime,errors=continue,data=ordered 0 0
/dev/block/mmcblk0p1 /cust_backup vfat ro,relatime,fmask=0000,dmask=0000,allow_utime=0022,codepage=cp437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro 0 0
/dev/block/mmcblk0p14 /HWUserData vfat rw,relatime,fmask=0000,dmask=0000,allow_utime=0022,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 0
tmpfs /mnt/asec tmpfs rw,relatime,mode=755,gid=1000 0 0
tmpfs /mnt/obb tmpfs rw,relatime,mode=755,gid=1000 0 0
/dev/block/vold/179:17 /mnt/sdcard vfat rw,dirsync,nosuid,nodev,noexec,relatime,uid=1000,gid=1015,fmask=0602,dmask=0602,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 0
/dev/block/vold/179:17 /mnt/secure/asec vfat rw,dirsync,nosuid,nodev,noexec,relatime,uid=1000,gid=1015,fmask=0602,dmask=0602,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 0
tmpfs /mnt/sdcard/.android_secure tmpfs ro,relatime,size=0k,mode=000 0 0
/dev/block/dm-0 /mnt/asec/com.junglesoft.calc-1 vfat ro,dirsync,nosuid,nodev,relatime,uid=1000,fmask=0222,dmask=0222,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 0
/dev/block/dm-1 /mnt/asec/com.aldiko.android-1 vfat ro,dirsync,nosuid,nodev,relatime,uid=1000,fmask=0222,dmask=0222,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 0
/dev/block/dm-2 /mnt/asec/com.jiubang.android.euphorialite-1 vfat ro,dirsync,nosuid,nodev,relatime,uid=1000,fmask=0222,dmask=0222,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 0
/dev/block/dm-3 /mnt/asec/com.gamestar.idiottest-1 vfat ro,dirsync,nosuid,nodev,relatime,uid=1000,fmask=0222,dmask=0222,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 0
/dev/block/dm-4 /mnt/asec/com.svox.classic.langpack.ell_grc_fem-1 vfat ro,dirsync,nosuid,nodev,relatime,uid=1000,fmask=0222,dmask=0222,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 0

Can this helps you to give me, a specific to my system, command?
Thanks in advance
 

dancer_69

Senior Member
Jan 2, 2007
1,961
248
No, this doesn't work eather, I've already tried.
I figure it out myself though, needed to remount rw my / partition which is rootfs.
After that the extarction worked without any error.
But still I get:
Error opening terminal: xterm
when I try to execute mc.
 
Last edited:

viulian

Inactive Recognized Developer
Apr 6, 2011
419
411
hex.ro
Make sure you have the following file copied over from the .tar.gz archive:

/etc/terminfo/x/xterm

I suggest to copy all files (/etc/mc and /system/share .. ) because they contain a lot of .ini files / syntax etc, without which mc will look black and white :D

Better if you untar in / directly ...
 

viulian

Inactive Recognized Developer
Apr 6, 2011
419
411
hex.ro
Please post screenshot of the following commands executed in same terminal:

Code:
cls
ls -l /etc/terminfo/x/xterm
cat /system/xbin/mc
ls -l /system/xbin/mc.real
 

dancer_69

Senior Member
Jan 2, 2007
1,961
248
I execute them via adb:
Code:
# ls -l /etc/terminfo/x/xterm
-rw-r--r--    1 system   system        3213 Jul  5  2010 /etc/terminfo/x/xterm
# cat /system/xbin/mc
#!/system/bin/sh
export TMPDIR=/data/local/tmp
if [ ! -e $TMPDIR ]; then
  mkdir $TMPDIR
fi
# So that F1, ... works
export TERM=xterm
/system/xbin/mc.real $*
# ls -l /system/xbin/mc.real
-rwxr-xr-x    1 system   system     3508114 Aug 31 19:51 /system/xbin/mc.real
 

viulian

Inactive Recognized Developer
Apr 6, 2011
419
411
hex.ro
Try copying over your Linux /etc/terminfo (or depending on the distro, it might be somewhere else - my Ubuntu says to check /lib/terminfo then /usr/share/terminfo).

Copy all the single letter folder onto /etc/terminfo on the phone, and then change /system/xbin/mc to export a different type of terminal, for example:

export TERM=linux

Of course, make sure that /etc/terminfo/l/linux is there before this.

With TERM=linux, the function keys do not seem to work in my case, they are rendered like ~13 etc .. However, it might work in your case ?
 

krzych

Senior Member
Jul 29, 2009
1,141
301
Warsaw
As you can see, your device has ext3 type partition, unlike mine which has yaffs2.

Your custom command is:

mount -o rw,remount -t ext3 /dev/block/mmcblk0p12 /

In future, please search your device specific forum for device specific :) questions - I found the answer myself here: http://forum.xda-developers.com/archive/index.php/t-928727.html

To be strict - you don't have to use anything but this:

mount mountpoint -o remount,rw

which means in this case:

mount / -o remount,rw

Writing the filesystem type or device name for such a command in a guide for everyone is quite an error.

And to be complete - only thing you have to write to see all mounted filesystems is: mount<enter>
Cat'ting /proc is NOT safe (one of the reasons: it can be switched off, whole proc filesystem, and there are many more reasons to be honest)
 
Last edited:

s0l

New member
Jan 15, 2009
2
0
Make sure you have the following file copied over from the .tar.gz archive:
/etc/terminfo/x/xterm

it's not correct place ) /usr/share/terminfo is compiled inside mc.real binary(to ensure strings -a mc.real | grep terminfo or winhex it), so to run we need to create /usr/share/terminfo/x/xterm, but it's not possibly to create such path on any device. the easest way to fix - recompile mc with hacked terminfo path. if you could compile mc can't you please? :)

ps: my english is baaad, sorry )

ok, it's solution - add export TERMINFO_DIRS=/system/etc/terminfo to mc script :)
 
Last edited:

viulian

Inactive Recognized Developer
Apr 6, 2011
419
411
hex.ro
Nice find.

I remember specifying the prefix to be /system and I removed /system/etc/terminfo and it failed to start, then I put it back and it executed.

There might also be some hardcoded paths too that strings finds, some failover defaults.

On my phone, /etc is a link to /system/etc in fact.

I will double later a bit, no access to PC now
 

Top Liked Posts

  • There are no posts matching your filters.
  • 35
    Introduction

    Here's the classic Midnight Commander for Android!

    mc_4.7.0.3-arm.png


    Features

    a) Function keys work (F3 - view, F5 - copy, F8 - delete, F10 - exit, etc...)
    b) Very stable, doesn't crash.
    c) Much easier installation than the previous one version (which needed an additional apt-get clone, named ipkg, etc). More about this below.
    d) comes bundled with xterm (terminfo) and syntax highlighting for major languages.
    e) I kept the wrapper script 4.6.2 but updated it so that function keys work.

    Reasons

    There is an one year old version floating around (version 4.6.2) and even if does start, it crashed every time I pressed the arrow keys in the search panels:

    Code:
    /system/xbin/mc.real: libc/misc/ctype/ctype.c: 290: tolower: Assertion `((((unsigned int)((c) - 0)) <= ((127 * 2 + 1) - 0)) || ((c) == (-1)))' failed.

    Not only this, but I had to restart Putty, since the whole screen became garbled.

    Installation

    You need a rooted phone with busybox.

    Installation is easy:

    click Install and allow root access.​

    If everything is ok, you will see an output like in the screenshot below:

    20111008103603.png


    To use mc, you could connect with a terminal emulator (but it looks ugly). A good alternative is if you use DroidSSHd as SSH server on the phone and Putty as client from your PC (or connect-bot as client on the phone).

    For now, there is no uninstaller for the native MC that is extracted on the phone. Thus, feel free to uninstall the app as you don't need it anymore once MC native is copied to the phone.

    Download

    Use it at your own risk! (License is GPLv2)

    NativnuxInstaller_1.1.apk
    2
    mc working with selinux enforcing mode (lollipop)

    Midnight commander runs fine on Android 5.02 (Moto E 2nd with SuperSU):

    • mc: install nativnux installer from play store
    • busybox: install sshelper from play store
    • terminal to run mc on the mobile device: install android terminal emulator from play store
    sshelper app comes with busybox (which is required to install mc). Then terminal emulator can run mc or a ssh client like sshjuice can connect to sshelper on 127.0.0.1:2222 (see attachment; a bluetooth keyboard was in use). - Edit: needs selinux policy modification using supolicy (which is part of supersu): see below.

    Installation:
    Run sshd provided by sshhelper, ssh to the mobile device, switch to user root with command su (confirm SuperSU popup). Then copy busybox to /system/xbin and create symbolic links for awk and tar pointing to busybox.
    • mount -o remount,rw /system
    • cd /data/data/com.arachnoid.sshelper/bin/
    • cp busybox /system/xbin/
    • cd /system/xbin
    • ln -s busybox awk
    • ln -s busybox tar
    Next step is to run gui mc installer. - In /system/xbin/mc the last line should end with [email protected] On the moto e 2nd 4G /sdcard/tmp is a working temporary directory and xterm has been chosen as terminal type.
    Code:
    #!/system/bin/sh
    #!/system/bin/sh
    export TMPDIR=/sdcard/tmp
    if [ ! -e $TMPDIR ]; then
      mkdir $TMPDIR
    fi
    # So that F1, ... works
    export TERM=xterm 
    export TERMINFO=/etc/terminfo
    /system/xbin/mc.real [email protected]
    Addendum: If mc displays empty directory listings, the binary mc.real is not the current binary available in play store (which is a very reasonably priced non free app).

    Enable proper terminal access in selinux enforcing mode:
    • su -c " supolicy --live 'allow untrusted_app untrusted_app_devpts chr_file setattr' "
    • The supolicy command shown above adds the missing permission. - To display the current selinux setting use:
    • su -c " supolicy --dumpav |grep 'untrusted_app-->untrusted_app_devpts' "
    • Workaround, not recommend: disable selinux:
    • Either on the mobile device: Create a connection in juicessh of type local terminal, open this connection, run command su and confirm SuperSU popup to grant privileges. Now run: setenforce 0. (getenforce displays current mode; setenforce 1 restores enforcing mode)
    • From computer: ssh -T -p 2222 ip_of_mobile_device. Then run su -c setenforce 0
    You might want to put the following lines into /data/data/com.arachnoid.sshelper/home/.profile and in /data/data/jackpal.androidterm/app_HOME/.profile (terminal emulator settings: startup command: source $HOME/.profile)
    Code:
    # place user customizations here
    # selinux policy already patched?
    echo -n "please wait, checking selinux policy for /dev/pts ..."
    if ! su -c "supolicy --dumpav |grep 'untrusted_app-->untrusted_app_devpts' |grep -q setattr"; then
      su -c "supolicy --live 'allow untrusted_app untrusted_app_devpts chr_file setattr'"
      echo "****************************************************************************"
      echo "* Log out (might need ctrl+c) and connect again to get a working terminal. *"
      echo "****************************************************************************"
    else
      echo "done"
    fi
    echo $OSDATA                                 
    export PS1='[email protected]$BOARD:$PWD $( (($USER_ID)) && echo \$ || echo \#) '
    sh -i
    2
    Thanks

    Thanks viulian! I'm planning on donating today. Your MC helped me a lot. I extracted the installation to *.tar.gz archives. Here is the result.

    http://kosiara87.blogspot.com/2014/03/install-midnight-commander-mc-on.html
    1
    I've crosscompiled MC to version 4.7.5.4 (latest) and also created a GUI installer (which requires busybox and needs root access to extract everything to correct locations).

    Please check first post in the this thread.

    As always, I'm very curious for feedback :)

    I've only tested it on my two phones (Arc and X10 mini).
    1
    Just installed your mc using your apk package and got an error of

    Code:
    /system/bin/mc: /system/xbin/mc.real: not found

    After unpacking your tarball from the apk, I located the problem. The fix I found is to edit /system/bin/mc and change the last line from:

    Code:
    /system/xbin/mc.real $*

    to

    Code:
    /system/bin/mc.real $*

    There is no /system/xbin files in your tarball and the mc.real is actually installed to /system/bin. Is it possible to update this apk file with the correct script so we don't have to manually adjust this in the future with installs?

    Thanks again for this, it's awesome to finally have mc working on my phone! It is working great with WiFi ADB and the gnome terminal on debain squeeze.

    -Mike