FORUMS

How to Root the LG G4 and Install TWRP Recovery – XDA TV

A rooting method has finally been found for the flagship LG G4. In this … more

New Xposed for Lollipop 5.0 Update Fixes Major Bugs

Senior Recognized Developer rovo89 has patched Xposed for Lollipop 5.0 to … more

Download Sony’s new AOSP-like concept for Xperia Z3

Over in our forums, Recognized Contributor Jozinek has posted a very … more

OnePlus 2 vs Moto X Style: Which is The Better Flagship?

Two big industry names have announced their newest flagship phones within the … more

[Tool]File(1) command for Android (ver 5.11)

22 posts
Thanks Meter: 17
 
By samveen, Junior Member on 22nd April 2012, 11:46 AM
Post Reply Subscribe to Thread Email Thread
After wandering around looking for an android build of the file command, I finally went ahead and compiled it myself.

The attached package contains the file binary (v5.11), the libmagic.so shared library, the associated magic files and the build specific files that I needed (over and above the source) to build it. The paths of the files are relative to '/'.

Refs:
source: file website (www_darwinsys_com/file/)
compiling: Native Vim on Android (gdr_geekhood_net/gdrwpl/vim-android.php)

Note: Add the location of libmagic.so to LD_LIBRARY_PATH to get rid of the "CANNOT LINK EXECUTABLE" error. (I use /data/local/lib)
Attached Files
File Type: gz file-5.11-arm-android_8.tar.gz - [Click for QR Code] (238.2 KB, 751 views)
Last edited by samveen; 3rd May 2012 at 12:59 PM. Reason: Display sig
The Following 5 Users Say Thank You to samveen For This Useful Post: [ View ]
 
 
24th April 2012, 08:04 PM |#2  
OP Junior Member
Thanks Meter: 17
 
More
Compiled a dynamically linked library and associated binary instead of the monolithic binary built earlier.
Last edited by samveen; 3rd May 2012 at 01:01 PM.
The Following User Says Thank You to samveen For This Useful Post: [ View ]
26th May 2012, 02:13 AM |#3  
royale1223's Avatar
Senior Member
Flag Calicut
Thanks Meter: 523
 
Donate to Me
More
Quote:
Originally Posted by samveen

After wandering around looking for an android build of the file command, I finally went ahead and compiled it myself.

The attached package contains the file binary (v5.11), the libmagic.so shared library, the associated magic files and the build specific files that I needed (over and above the source) to build it. The paths of the files are relative to '/'.

Refs:
source: file website (www_darwinsys_com/file/)
compiling: Native Vim on Android (gdr_geekhood_net/gdrwpl/vim-android.php)

Note: Add the location of libmagic.so to LD_LIBRARY_PATH to get rid of the "CANNOT LINK EXECUTABLE" error. (I use /data/local/lib)

I followed your instructions and it works perfectly.

Code:
$ echo $LD_LIBRARY_PATH
/data/local/lib:/data/local/lib:/data/local/lib:/system/lib:/vendor/lib
$ file
Usage: file [-bchikLlNnprsvz0] [--apple] [--mime-encoding] [--mime-type]
            [-e testname] [-F separator] [-f namefile] [-m magicfiles] file ...
       file -C [-m magicfiles]
       file [--help]
$ getprop  | grep device
[ro.cm.device]: [jordan]
[ro.product.device]: [umts_jordan]
I have been looking for this for a while. Man!! This post needs some serious attention. Great work.

Sent from my MB525 usiIng XDA
19th March 2014, 07:52 AM |#4  
osm0sis's Avatar
Recognized Developer / Recognized Contributor
Thanks Meter: 16,475
 
More
@samveen Any chance you could compile it with libmagic statically linked again to make it portable? Thanks for your time.
Last edited by osm0sis; 19th March 2014 at 07:58 AM.
19th March 2014, 09:40 AM |#5  
OP Junior Member
Thanks Meter: 17
 
More
Quote:
Originally Posted by osm0sis

@samveen Any chance you could compile it with libmagic statically linked again to make it portable? Thanks for your time.


@osm0sis Sure. I'll add in a statically linked binary, but it'll take a little time (2-3 days).
The Following User Says Thank You to samveen For This Useful Post: [ View ]
19th March 2014, 05:59 PM |#6  
Computoncio's Avatar
Senior Member
Flag Três Corações - MG - Brasil
Thanks Meter: 3,418
 
More
Quote:
Originally Posted by samveen

@osm0sis Sure. I'll add in a statically linked binary, but it'll take a little time (2-3 days).

I was just looking for this. Great tool.
Thanks for your work.
23rd March 2014, 07:06 PM |#7  
osm0sis's Avatar
Recognized Developer / Recognized Contributor
Thanks Meter: 16,475
 
More
Quote:
Originally Posted by samveen

@osm0sis Sure. I'll add in a statically linked binary, but it'll take a little time (2-3 days).

Any luck? I think it only needs libmagic statically linked to be portable; the other NDK/Bionic stuff can probably stay dynamic to keep the filesize down. I see file 5.17 source is available now too if you wanted to update your builds to the latest.
23rd March 2014, 07:50 PM |#8  
Computoncio's Avatar
Senior Member
Flag Três Corações - MG - Brasil
Thanks Meter: 3,418
 
More
Quote:
Originally Posted by osm0sis

Any luck? I think it only needs libmagic statically linked to be portable; the other NDK/Bionic stuff can probably stay dynamic to keep the filesize down. I see file 5.17 source is available now too if you wanted to update your builds to the latest.

If you want only the system file type, the workaround i use is this (eval $(/sbin/blkid /dev/block/mmcblk0p11 | /sbin/awk ' { print $3 } '); /sbin/busybox echo $TYPE)

In a script just add a var like this

TYPE=$(eval $(/sbin/blkid /dev/block/mmcblk0p11 | /sbin/awk ' { print $3 } '); /sbin/busybox echo $TYPE) and you will have the FS type in $TYPE.

Phone: Samsung Galaxy SII - GT-I9100
Kernel: Dorimanx kernel v10.43v99-mv3
1st ROM : SlimSaber 4.4.2 Maliv3 by fusionjack build of 20140320 (Online)
2nd ROM :
MODEM: UHMS1
MODS: Partition Fix, Hue Blue v4.4 by Kroz
23rd March 2014, 08:31 PM |#9  
osm0sis's Avatar
Recognized Developer / Recognized Contributor
Thanks Meter: 16,475
 
More
Quote:
Originally Posted by Computoncio

If you want only the system file type, the workaround i use is this (eval $(/sbin/blkid /dev/block/mmcblk0p11 | /sbin/awk ' { print $3 } '); /sbin/busybox echo $TYPE)

In a script just add a var like this

TYPE=$(eval $(/sbin/blkid /dev/block/mmcblk0p11 | /sbin/awk ' { print $3 } '); /sbin/busybox echo $TYPE) and you will have the FS type in $TYPE.

Interesting but nope; I need file to determine a filetype. Compressed archives via a script, to be specific.
24th March 2014, 02:57 PM |#10  
OP Junior Member
Thanks Meter: 17
 
More
@osm0sis I got the code compiled (both with a dynamic libmagic.so, and libmagic compiled into file) but I need a little more time to compile the magic data (it requires running file on the target device to compile the magic data into a binary datafile). Once I have that figured out (either by compiling it or by creating a script to allow the users to do it themselves, I'll post it all in one go (need one more day).
The Following 2 Users Say Thank You to samveen For This Useful Post: [ View ]
24th March 2014, 03:42 PM |#11  
osm0sis's Avatar
Recognized Developer / Recognized Contributor
Thanks Meter: 16,475
 
More
Quote:
Originally Posted by samveen

@osm0sis I got the code compiled (both with a dynamic libmagic.so, and libmagic compiled into file) but I need a little more time to compile the magic data (it requires running file on the target device to compile the magic data into a binary datafile). Once I have that figured out (either by compiling it or by creating a script to allow the users to do it themselves, I'll post it all in one go (need one more day).

Awesome! Thanks so much. The magic file isn't terribly important since you can grab one a lot of places and specify it with the -m parameter; keeps the file size down too if you were thinking of including it in the binary somehow!
Last edited by osm0sis; 24th March 2014 at 07:50 PM.

Read More
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes