Hacking Unix/Linux extension for file+magic to detect ISO, WBFS, WDF and WIA

Wiimm

Developer
OP
Member
Joined
Aug 11, 2009
Messages
2,292
Trophies
1
Location
Germany
Website
wiimmfi.de
XP
1,519
Country
Germany
This topic is only for the few users who know the old unix tool "file"

In the last weeks I have played with the magic file. My plan was, that the command "file" will detect Wii ISO, WBFS, WDF and WIA file types and gives some infos about them

Example:
Code:
# file *

mkdd.iso:     GameCube ISO image 'GM4P01' Mario Kart Double Dash!
wch.iso:      Wii ISO image 'RTYP01' Wii Chess

4-games.wbfs: WBFS v1, hss 512, wss 8M, multi disc archive
mkdd.wbfs:    WBFS v1, hss 512, wss 2M, GC 'GM4P01' Mario Kart Double Dash!
wch.wbfs:     WBFS v1, hss 512, wss 2M, Wii 'RTYP01' Wii Chess

mkdd.wdf:     WDF v1, v-size 1459978240, 416 chunks, GC 'GM4P01' Mario Kart Double Dash!
wch.wdf:      WDF v1, v-size 4699979776, 27 chunks, Wii 'RTYP01' Wii Chess

mkdd.wia:     WIA v1.00 LZMA.5@20, v-size 1459978240, GC 'GM4P01' Mario Kart Double Dash!
wch.wia:      WIA v1.00 LZMA.5@20, v-size 4699979776, Wii 'RTYP01' Wii Chess
'file' will now print geometric data and also image ID and title.

And here is the magic source: http://wit.wiimm.de/download/magic.txt


How to (linux):
  1. Download by extension.
  2. Edit the file /etc/magic:
    a) Remove old versions of my extension.
    b) Append my extension at the very end of the file.
And now "file" should detect the image types because of analyzing the file content.
 
  • Like
Reactions: 1 person

PsyBlade

Snake Charmer
Member
Joined
Jul 30, 2009
Messages
2,204
Trophies
0
Location
Sol III
XP
458
Country
Gambia, The
nice work but I have some comments to the file placement

1. /usr/share/misc/magic should be a folder not a file
you can name the file anything (e.g. wii) and place it in the folder
then compile the folder with "file -C FOLDER"

2. since /usr/share/ is considered to be under the contoll of the package manager I recomend not changing anything in there
instead you can append the contend of wiimms file to the file /etc/magic which is meant to be the place for such user changes
no compilation is needed

3. if you don't have root access you can write it to the file ~/.magic
again no compilation needed (but possible for a very minor speedup) unless you alread have a compiled file (~/.magic.mgc)
then either compile or delete the old compiled file
 

Wiimm

Developer
OP
Member
Joined
Aug 11, 2009
Messages
2,292
Trophies
1
Location
Germany
Website
wiimmfi.de
XP
1,519
Country
Germany
1.) I think, its distribution dependent. On OpenSuse /usr/share/misc/magic is a file. On debian the file is /etc/magic. Best is to consult "man 1 file"

2+3.) I will try it.
 

Wiimm

Developer
OP
Member
Joined
Aug 11, 2009
Messages
2,292
Trophies
1
Location
Germany
Website
wiimmfi.de
XP
1,519
Country
Germany
I have changed the "how to"

How to (linux):
  1. Download by extension.
  2. Edit the file /etc/magic:
    a) Remove old versions of my extension.
    b) Append my extension at the very end of the file.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    K3Nv2 @ K3Nv2: Normal sandwich bread is actually pretty good for sausage depends on length of course