home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 316.lha / DF / df.h < prev    next >
Encoding:
C/C++ Source or Header  |  1989-12-05  |  7.5 KB  |  221 lines

  1. #define        ENOPORT        1    /* Unable to open port         */
  2. #define        ENOIOBLK    2    /* Unable to create I/O block    */
  3. #define        ENOOPEN        3    /* Unable to open device    */
  4. #define        ENOARGS        4    /* Not enough arguments to prog */
  5. #define        EBADDEV        5    /* Bad device name        */
  6. #define        EBTOV        6    /* Bad block table overflow    */
  7. #define        ENOMEM        7    /* No dynamic memory available    */
  8. #define        EBADBB        8    /* Bad boot block on disk    */
  9. #define        EBADRB        9    /* Bad root block on disk    */
  10. #define        ENOBLKS        10    /* Out of room in used blk list    */
  11. #define        EBMAPWR        11    /* Error writing the bitmap    */
  12. #define        EBADOPT        12    /* Bad option on cmd line    */
  13. #define        ENOINH        13    /* Cannot inhibit device    */
  14. #define        ENOHDR        14    /* Cannot write file hdr block    */
  15. #define        ENEXTB        15    /* Cannot write extension blks    */
  16. #define        EBADBLK        16    /* Block number out of range    */
  17. #define     ENHDR        17    /* Cannot write bad block hdr    */
  18. #define        DEFBLKSIZE    512L    /* default block size         */
  19. #define        BADTRKSIZE    500    /* size of bad track table     */
  20.  
  21. #define        ROMFS        0    /* Constant for ROM filing sys    */
  22. #define        FFS        1    /* Constant for Fast filing sys */
  23.  
  24. #define        BAD        1    /* Indicates bad block        */
  25. #define        ROOT        2    /* Indicates root block        */
  26. #define        EXT        3    /* Indicates bmap extension blk    */
  27. #define        BMAP        4    /* Indicate bitmap block    */
  28.  
  29.  
  30. /* 
  31.   This is the structure that contains all we need to know about a 
  32.   drive to mess with it. (and then some!)
  33. */
  34. struct    disk_parm
  35.     {
  36.     UWORD    unit;        /* unit number of drive: 0,1,2 etc     */
  37.     UWORD    block_size;    /* bytes in a block             */
  38.     UWORD    disk_type;    /* used to determine filing system    */
  39.     UWORD    surfaces;    /* number of surfaces (heads)        */
  40.     UWORD     sec_block;    /* number of sectors in a block        */
  41.     UWORD    blocks_track;    /* number of blocks per track        */
  42.     UWORD    reserved;    /* sectors reserved at start of disk     */
  43.     UWORD    pre_alloc;    /* pre-allocated sectors at end of disk */
  44.     ULONG    low_cyl;    /* lowest cylinder number        */
  45.     ULONG    high_cyl;    /* highest cylinder number        */
  46.     ULONG    track_size;    /* bytes in a track: blk_size*blks_trk    */
  47.     ULONG    lower_key;    /* block number of lowest block        */
  48.     ULONG    upper_key;    /* block number of highest block    */
  49.     ULONG    root_key;    /* block number of root block        */
  50.     ULONG    boot_key;    /* block number of boot block        */
  51.     char    driver[30];    /* name of device driver        */
  52.     };
  53.  
  54.  
  55.  
  56. struct    OldBitmap
  57.     {
  58.     ULONG    BitmapExtend;    /* Bit map extension block        */
  59.     ULONG    BitmapKeys[25]; /* Bit map block numbers        */
  60.     } obm;
  61.  
  62. struct    FastBitmap
  63.     {
  64.     ULONG    BitmapKeys[25]; /* Bit map block numbers        */
  65.     ULONG    BitmapExtend;    /* Bit map extension block        */
  66.     } fbm;
  67.  
  68.  
  69. struct RootBlock
  70.     {
  71.     LONG    Type;        /* This is used to mark the type of this
  72.                    block and is set to TYPE_SHORT (2)    */
  73.     ULONG    OwnKey;        /* Not used by root, must be set to 0    */
  74.     ULONG    SeqNum;        /* Not used by root, must be set to 0    */
  75.     ULONG    HTSize;        /* Size of the hash table in longwords,    
  76.                    must be set to 72            */
  77.     ULONG    Nothing1;    /* Reserved for future use, must be 0    */
  78.     LONG    Checksum;    /* Balance to 0 checksum. When all longs
  79.                    in the block are added (ignoring 
  80.                    carry), the sum must be 0.        */
  81.     ULONG    HashTable[72];    /* Hash table containing block numbers 
  82.                    of files and directories in the root    */
  83.     LONG    BitmapFlag;    /* Flag to say whether the bitmap is
  84.                    valid or not. -1=valid, 0=invalid. 
  85.                    If a partition is mounted (or 
  86.                    uninhibited) with BitmapFlag = 0, 
  87.                        then the validator will kick in to
  88.                        rebuild the bitmap            */
  89.     
  90.     /* 
  91.       The next two fields are a union because the old filing system
  92.       has the BitmapExtend field first, and uses the BitmapKeys 
  93.       array from high to low, while the Fast filing system puts the
  94.       BitmapKeys field first, and uses them from low to high.
  95.     */
  96.  
  97.     union
  98.         {
  99.         struct     OldBitmap    obm;
  100.         struct    FastBitmap    fbm;
  101.         } bm;
  102.  
  103.     ULONG    DirAltered[3];    /* A DOS DateStamp indicating the date
  104.                        when the root block or a file in the    
  105.                    root block was last modified        */
  106.     char    Name[40];    /* Name of this volume as a BCPL string
  107.                    with the number of bytes as the first
  108.                    character. Only 30 chars are used    */
  109.     ULONG    DiskAltered[3];    /* A DOS DateStamp indicating the date
  110.                    when any file or section of the par-
  111.                    tition was modified.            */
  112.     ULONG    DiskMade[3];    /* A DOS DateStamp indicating when this
  113.                    partition was created (formatted)    */
  114.     ULONG    Nothing2;    /* Reserved for future use, must be 0    */
  115.     ULONG    Nothing3;    /* Reserved for future use, must be 0    */
  116.     ULONG    Nothing4;    /* Reserved for future use, must be 0    */
  117.     LONG    SecondaryType;    /* Qualifier to Type. Will be set to
  118.                    ST_ROOT (1)                */
  119.     };
  120.  
  121.  
  122. struct    extension_block
  123.     {
  124.     struct    extension_block    *next;
  125.     ULONG    block[127];
  126.     ULONG    next_ext;
  127.     ULONG    key;
  128.     };
  129.  
  130.  
  131. struct    FileHeaderBlock
  132.     {
  133.     LONG    Type;        /* This is used to mark the type of this
  134.                    block and is set to TYPE_SHORT (2)      */
  135.     ULONG    OwnKey;        /* Set to file headers own block number      */
  136.     ULONG    HighSeq;    /* Total blocks used in file (not updated
  137.                    by FFS, only the old file system      */
  138.     ULONG    DataSize;    /* Number of data blocks in file      */
  139.     ULONG    FirstBlock;    /* Block number of first block in file      */
  140.     LONG    Checksum;    /* Balance to 0 checksum          */
  141.     ULONG    DataBlocks[72];    /* Table of block numbers for the first 72
  142.                    blocks of data in this file. Slots are
  143.                    used from DataBlocks[71] to zero, then
  144.                    extension is used.              */
  145.     ULONG    Spare1[2];    /* Not used, must be 0              */
  146.     ULONG    Protect;    /* Protection bits bit mask          */
  147.     ULONG    ByteSize;    /* Size of file in bytes...          */
  148.     char    Comment[92];    /* Comment attached to file          */
  149.     ULONG    Date[3];    /* DOS DateStamp indicating creation date */
  150.     char    FileName[64];    /* Filename (only 30 characters used tho) */
  151.     ULONG    HashChain;    /* Next entry with same hash value      */
  152.     ULONG    Parent;        /* Block number of parent directory      */
  153.     ULONG    Extension;    /* When all data block slots are used, 
  154.                    this points to an extension block that
  155.                    has the same format as the file header
  156.                    block (but FileName and Date are not
  157.                    maintained and Type is ST_LIST (16) ).
  158.                    A block number of zero terminates the
  159.                    list                      */
  160.     LONG    SecondaryType;    /* Qualifier to type = ST_FILE (-3)      */
  161.     };
  162.  
  163.  
  164. struct    FileDataBlock
  165.     {
  166.     LONG    Type;        /* This is used to mark the type of this
  167.                    block and is set to TYPE_DATA (8). 
  168.                    There is no secondary type on this blk */
  169.     ULONG    OwnKey;        /* Set to data block's own block number      */
  170.     ULONG    SeqNumber;    /* Sequence # of this block in the file      */
  171.     ULONG    DataSize;    /* # of bytes of info used in this block  */
  172.     ULONG    NextBlock;    /* Key of next block in file          */
  173.     LONG    CheckSum;    /* Balance to 0 checksum          */
  174.     char    Data[488];    /* The actual data              */
  175.     };
  176.  
  177.  
  178. struct    DosEnvironment
  179.     {
  180.     ULONG    de_TableSize;        /* Size of env vector        */
  181.     ULONG    de_SizeBlock;        /* Block size in longwords    */
  182.     ULONG    de_SecOrg;        /* Not used; must be 0        */
  183.     ULONG    de_Surfaces;        /* Number of heads        */
  184.     ULONG    de_SecPerBlock;        /* Not used; must be 1        */
  185.     ULONG    de_BlocksPerTrack;    /* Blocks per track        */
  186.     ULONG    de_Reserved;        /* Reserved blocks at start    */
  187.     ULONG    de_PreAlloc;        /* Pre_allocated blocks at end    */
  188.     ULONG    de_Interleave;        /* Usually 0            */
  189.     ULONG    de_LowCyl;        /* Starting cylinder        */
  190.     ULONG    de_HighCyl;        /* Max cylinder            */
  191.     ULONG    de_NumBuffers;        /* Initial # of Dos buffers    */
  192.     ULONG    de_BufMemType;        /* Type of mem for buffers    */
  193.     ULONG    de_MaxTransfer;        /* Max # of bytes to transfer    */
  194.     ULONG    de_Mask;        /* Address mask            */
  195.     ULONG    de_BootPri;        /* Boot priority        */
  196.     char    de_DosType[4];        /* Dos type as ascii string    */
  197.     };
  198.                 
  199.  
  200. struct    file_ext_block
  201.     {
  202.     struct    file_ext_block    *next;
  203.     struct    FileHeaderBlock    fhb;
  204.     ULONG    key;
  205.     };
  206.  
  207. struct    bitmap_block
  208.     {
  209.     ULONG    check_sum;
  210.     ULONG    block[127];
  211.     ULONG    key;
  212.     };
  213.  
  214.  
  215. struct    bad_block
  216.     {
  217.     struct    bad_block    *next;
  218.     int    type;
  219.     ULONG    key;
  220.     };
  221.