Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,741,266 Members 45,447 Now Online
XDA Developers Android and Mobile Development Forum

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

Tip us?
 
samveen
Old
(Last edited by samveen; 3rd May 2012 at 12:59 PM.) Reason: Display sig
#1  
Junior Member - OP
Thanks Meter 17
Posts: 20
Join Date: Apr 2012
Lightbulb [Tool]File(1) command for Android (ver 5.11)

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, 409 views)
Utilities for Android: GNU make 3.82, GNU grep 2.12, GNU diffutils 2.8, file 5.11, Strace 4.6(Using NDK r8c), GNU Bash 4.2(Dynamically Linked)

Current: Nexus 4 8GB(Stock 4.4 unrooted), Toshiba AC100 (2.2 by silver-alx)
Old: Huawei U8150 (Stock 2.2 rooted)
Epic Fail:Nexus S GT-I9020T (Stock 4.1.2 unrooted)
The Following 5 Users Say Thank You to samveen For This Useful Post: [ Click to Expand ]
 
samveen
Old
(Last edited by samveen; 3rd May 2012 at 01:01 PM.)
#2  
Junior Member - OP
Thanks Meter 17
Posts: 20
Join Date: Apr 2012
Compiled a dynamically linked library and associated binary instead of the monolithic binary built earlier.
Utilities for Android: GNU make 3.82, GNU grep 2.12, GNU diffutils 2.8, file 5.11, Strace 4.6(Using NDK r8c), GNU Bash 4.2(Dynamically Linked)

Current: Nexus 4 8GB(Stock 4.4 unrooted), Toshiba AC100 (2.2 by silver-alx)
Old: Huawei U8150 (Stock 2.2 rooted)
Epic Fail:Nexus S GT-I9020T (Stock 4.1.2 unrooted)
The Following User Says Thank You to samveen For This Useful Post: [ Click to Expand ]
 
royale1223
Old
#3  
royale1223's Avatar
Senior Member
Thanks Meter 500
Posts: 366
Join Date: Oct 2011
Location: Calicut

 
DONATE TO ME
Quote:
Originally Posted by samveen View Post
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:
Select 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
 
osm0sis
Old
(Last edited by osm0sis; 19th March 2014 at 07:58 AM.)
#4  
osm0sis's Avatar
Recognized Contributor
Thanks Meter 13492
Posts: 7,896
Join Date: Mar 2012
@samveen Any chance you could compile it with libmagic statically linked again to make it portable? Thanks for your time.
I do NOT answer technical questions via PM. Post your question in the correct thread if you want a response.





 
samveen
Old
#5  
Junior Member - OP
Thanks Meter 17
Posts: 20
Join Date: Apr 2012
Quote:
Originally Posted by osm0sis View Post
@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).
Utilities for Android: GNU make 3.82, GNU grep 2.12, GNU diffutils 2.8, file 5.11, Strace 4.6(Using NDK r8c), GNU Bash 4.2(Dynamically Linked)

Current: Nexus 4 8GB(Stock 4.4 unrooted), Toshiba AC100 (2.2 by silver-alx)
Old: Huawei U8150 (Stock 2.2 rooted)
Epic Fail:Nexus S GT-I9020T (Stock 4.1.2 unrooted)
The Following User Says Thank You to samveen For This Useful Post: [ Click to Expand ]
 
Computoncio
Old
#6  
Computoncio's Avatar
Senior Member
Thanks Meter 2904
Posts: 1,089
Join Date: May 2012
Location: Três Corações - MG - Brasil
Quote:
Originally Posted by samveen View Post
@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.
Phone: Samsung Galaxy SII - GT-I9100
Kernel: Dorimanx kernel v10.43v116-mv3
1st ROM : SlimSaber 4.4.2 mv3 by fusionjack build of 20140721 (Online)
2nd ROM :
MODEM: UHMS1
MODS: Partition Fix, Hue Blue v4.4 by Kroz
 
osm0sis
Old
#7  
osm0sis's Avatar
Recognized Contributor
Thanks Meter 13492
Posts: 7,896
Join Date: Mar 2012
Quote:
Originally Posted by samveen View Post
@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.
I do NOT answer technical questions via PM. Post your question in the correct thread if you want a response.





 
Computoncio
Old
#8  
Computoncio's Avatar
Senior Member
Thanks Meter 2904
Posts: 1,089
Join Date: May 2012
Location: Três Corações - MG - Brasil
Quote:
Originally Posted by osm0sis View Post
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
Phone: Samsung Galaxy SII - GT-I9100
Kernel: Dorimanx kernel v10.43v116-mv3
1st ROM : SlimSaber 4.4.2 mv3 by fusionjack build of 20140721 (Online)
2nd ROM :
MODEM: UHMS1
MODS: Partition Fix, Hue Blue v4.4 by Kroz
 
osm0sis
Old
#9  
osm0sis's Avatar
Recognized Contributor
Thanks Meter 13492
Posts: 7,896
Join Date: Mar 2012
Quote:
Originally Posted by Computoncio View Post
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.
I do NOT answer technical questions via PM. Post your question in the correct thread if you want a response.





 
samveen
Old
#10  
Junior Member - OP
Thanks Meter 17
Posts: 20
Join Date: Apr 2012
@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).
Utilities for Android: GNU make 3.82, GNU grep 2.12, GNU diffutils 2.8, file 5.11, Strace 4.6(Using NDK r8c), GNU Bash 4.2(Dynamically Linked)

Current: Nexus 4 8GB(Stock 4.4 unrooted), Toshiba AC100 (2.2 by silver-alx)
Old: Huawei U8150 (Stock 2.2 rooted)
Epic Fail:Nexus S GT-I9020T (Stock 4.1.2 unrooted)

The Following 2 Users Say Thank You to samveen For This Useful Post: [ Click to Expand ]
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes