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

Discussion in 'Wii - Hacking' started by Wiimm, Sep 19, 2012.

  1. Wiimm
    OP

    Member Wiimm Developer

    Joined:
    Aug 11, 2009
    Messages:
    2,052
    Location:
    Germany
    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.
     
    1 person likes this.
  2. PsyBlade

    Member PsyBlade Snake Charmer

    Joined:
    Jul 30, 2009
    Messages:
    2,204
    Location:
    Sol III
    Country:
    Germany
    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
     
  3. Wiimm
    OP

    Member Wiimm Developer

    Joined:
    Aug 11, 2009
    Messages:
    2,052
    Location:
    Germany
    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.
     
  4. Wiimm
    OP

    Member Wiimm Developer

    Joined:
    Aug 11, 2009
    Messages:
    2,052
    Location:
    Germany
    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.
     
  5. Little Baron

    Newcomer Little Baron Member

    Joined:
    May 26, 2010
    Messages:
    26
    Country:
    Germany
    Half year ago I have made my own magic file, but this is much better. Thanks.
     

Share This Page