Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

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

OP samveen

22nd April 2012, 12:46 PM   |  #1  
OP Junior Member
Thanks Meter: 17
 
22 posts
Join Date:Joined: Apr 2012
More
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, 483 views)
Last edited by samveen; 3rd May 2012 at 01:59 PM. Reason: Display sig
The Following 5 Users Say Thank You to samveen For This Useful Post: [ View ]
24th April 2012, 09:04 PM   |  #2  
OP Junior Member
Thanks Meter: 17
 
22 posts
Join Date:Joined: Apr 2012
More
Compiled a dynamically linked library and associated binary instead of the monolithic binary built earlier.
Last edited by samveen; 3rd May 2012 at 02:01 PM.
The Following User Says Thank You to samveen For This Useful Post: [ View ]
26th May 2012, 03:13 AM   |  #3  
royale1223's Avatar
Senior Member
Flag Calicut
Thanks Meter: 503
 
374 posts
Join Date:Joined: Oct 2011
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, 08:52 AM   |  #4  
osm0sis's Avatar
Recognized Developer / Recognized Contributor
Thanks Meter: 14,897
 
8,606 posts
Join Date:Joined: Mar 2012
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 08:58 AM.
19th March 2014, 10:40 AM   |  #5  
OP Junior Member
Thanks Meter: 17
 
22 posts
Join Date:Joined: Apr 2012
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, 06:59 PM   |  #6  
Computoncio's Avatar
Senior Member
Flag Três Corações - MG - Brasil
Thanks Meter: 3,248
 
1,132 posts
Join Date:Joined: May 2012
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, 08:06 PM   |  #7  
osm0sis's Avatar
Recognized Developer / Recognized Contributor
Thanks Meter: 14,897
 
8,606 posts
Join Date:Joined: Mar 2012
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, 08:50 PM   |  #8  
Computoncio's Avatar
Senior Member
Flag Três Corações - MG - Brasil
Thanks Meter: 3,248
 
1,132 posts
Join Date:Joined: May 2012
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, 09:31 PM   |  #9  
osm0sis's Avatar
Recognized Developer / Recognized Contributor
Thanks Meter: 14,897
 
8,606 posts
Join Date:Joined: Mar 2012
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, 03:57 PM   |  #10  
OP Junior Member
Thanks Meter: 17
 
22 posts
Join Date:Joined: Apr 2012
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 ]
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes