home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / src / linux-headers-2.6.17-6 / include / linux / amigasfs.h < prev    next >
Encoding:
C/C++ Source or Header  |  2006-08-11  |  6.8 KB  |  277 lines

  1. #ifndef __LINUX_AMIGASFS_H
  2. #define __LINUX_AMIGASFS_H
  3.  
  4. #include <linux/types.h>
  5.  
  6. /* some helper macros... */
  7. #define ASFS_MAKE_ID(a,b,c,d) (((a)&0xff)<<24|((b)&0xff)<<16|((c)&0xff)<<8|((d)&0xff))
  8.  
  9. /* Amiga SFS block IDs */
  10. #define ASFS_ROOTID                 ASFS_MAKE_ID('S','F','S','\0')
  11. #define ASFS_OBJECTCONTAINER_ID     ASFS_MAKE_ID('O','B','J','C')
  12. #define ASFS_BNODECONTAINER_ID      ASFS_MAKE_ID('B','N','D','C')
  13. #define ASFS_NODECONTAINER_ID       ASFS_MAKE_ID('N','D','C',' ')
  14. #define ASFS_HASHTABLE_ID           ASFS_MAKE_ID('H','T','A','B')
  15. #define ASFS_SOFTLINK_ID            ASFS_MAKE_ID('S','L','N','K')
  16. #define ASFS_ADMINSPACECONTAINER_ID ASFS_MAKE_ID('A','D','M','C')
  17. #define ASFS_BITMAP_ID              ASFS_MAKE_ID('B','T','M','P')
  18. #define ASFS_TRANSACTIONFAILURE_ID  ASFS_MAKE_ID('T','R','F','A')
  19.  
  20. /* Amiga SFS defines and magic values */
  21.  
  22. #define ASFS_MAGIC 0xa0ff
  23. #define ASFS_MAXFN (105u)
  24. #define ASFS_MAXFILESIZE 0x8FFFFFFE
  25.  
  26. #define ASFS_STRUCTURE_VERISON (3)
  27. #define ASFS_BLCKFACCURACY    (5)
  28.  
  29. #define ASFS_ROOTBITS_CASESENSITIVE (128)
  30. #define ASFS_READONLY (512)
  31. #define ASFS_VOL_LOWERCASE (1024)
  32.  
  33. #define ASFS_ROOTNODE   (1)
  34. #define ASFS_RECYCLEDNODE (2)
  35.  
  36. #define OTYPE_HIDDEN      (1)
  37. #define OTYPE_HARDLINK    (32)
  38. #define OTYPE_LINK        (64)
  39. #define OTYPE_DIR         (128)
  40.  
  41. #define MSB_MASK (1ul << 31)
  42.  
  43. #define NODE_STRUCT_SIZE (10)    /* (sizeof(struct fsObjectNode)) */
  44. #define NODECONT_BLOCK_COUNT ((sb->s_blocksize - sizeof(struct fsNodeContainer)) / sizeof(u32))
  45.  
  46. #define ASFS_ALWAYSFREE (16)        /* keep this amount of blocks free */
  47.  
  48. #define ASFS_BLOCKCHUNKS (16)        /* try to allocate this number of blocks in one request */
  49.  
  50. #ifndef TRUE
  51. #define TRUE        1
  52. #endif
  53. #ifndef FALSE
  54. #define FALSE        0
  55. #endif
  56.  
  57. /* amigados protection bits */
  58.  
  59. #define FIBB_SCRIPT    6    /* program is a script (execute) file */
  60. #define FIBB_PURE      5    /* program is reentrant and rexecutable */
  61. #define FIBB_ARCHIVE   4    /* cleared whenever file is changed */
  62. #define FIBB_READ      3    /* ignored by old filesystem */
  63. #define FIBB_WRITE     2    /* ignored by old filesystem */
  64. #define FIBB_EXECUTE   1    /* ignored by system, used by Shell */
  65. #define FIBB_DELETE    0    /* prevent file from being deleted */
  66.  
  67. #define FIBF_SCRIPT    (1<<FIBB_SCRIPT)
  68. #define FIBF_PURE      (1<<FIBB_PURE)
  69. #define FIBF_ARCHIVE   (1<<FIBB_ARCHIVE)
  70. #define FIBF_READ      (1<<FIBB_READ)
  71. #define FIBF_WRITE     (1<<FIBB_WRITE)
  72. #define FIBF_EXECUTE   (1<<FIBB_EXECUTE)
  73. #define FIBF_DELETE    (1<<FIBB_DELETE)
  74.  
  75. /* name hashing macro */
  76.  
  77. #define HASHCHAIN(x) (u16)(x % (u16)(((sb->s_blocksize) - sizeof(struct fsHashTable))>>2))
  78.  
  79. /* Each block has its own header with checksum and id, its called fsBlockHeader */
  80.  
  81. struct fsBlockHeader {
  82.     u32 id;            /* 4 character id string of this block */
  83.     u32 checksum;        /* The checksum */
  84.     u32 ownblock;        /* The blocknumber of the block this block is stored at */
  85. };
  86.  
  87. /* On-disk "super block", called fsRootBlock */
  88.  
  89. struct fsRootBlock {
  90.     struct fsBlockHeader bheader;
  91.  
  92.     u16 version;        /* Version number of the filesystem block structure */
  93.     u16 sequencenumber;    /* The Root with the highest sequencenumber is valid */
  94.  
  95.     u32 datecreated;    /* Creation date (when first formatted).  Cannot be changed. */
  96.     u8 bits;        /* various settings, see defines below. */
  97.     u8 pad1;
  98.     u16 pad2;
  99.  
  100.     u32 reserved1[2];
  101.  
  102.     u32 firstbyteh;        /* The first byte of our partition from the start of the */
  103.     u32 firstbyte;        /* disk.  firstbyteh = upper 32 bits, firstbyte = lower 32 bits. */
  104.  
  105.     u32 lastbyteh;        /* The last byte of our partition, excluding this one. */
  106.     u32 lastbyte;
  107.  
  108.     u32 totalblocks;    /* size of this partition in blocks */
  109.     u32 blocksize;        /* blocksize used */
  110.  
  111.     u32 reserved2[2];
  112.     u32 reserved3[8];
  113.  
  114.     u32 bitmapbase;        /* location of the bitmap */
  115.     u32 adminspacecontainer;    /* location of first adminspace container */
  116.     u32 rootobjectcontainer;    /* location of the root objectcontainer */
  117.     u32 extentbnoderoot;    /* location of the root of the extentbnode B-tree */
  118.     u32 objectnoderoot;    /* location of the root of the objectnode tree */
  119.  
  120.     u32 reserved4[3];
  121. };
  122.  
  123. /* On disk inode, called fsObject */
  124.  
  125. struct fsObject {
  126.     u16 owneruid;
  127.     u16 ownergid;
  128.     u32 objectnode;
  129.     u32 protection;
  130.  
  131.     union {
  132.         struct {
  133.             u32 data;
  134.             u32 size;
  135.         } file;
  136.  
  137.         struct {
  138.             u32 hashtable;    /* for directories & root, 0 means no hashblock */
  139.             u32 firstdirblock;
  140.         } dir;
  141.     } object;
  142.  
  143.     u32 datemodified;
  144.     u8 bits;
  145.  
  146.     u8 name[0];
  147.     u8 comment[0];
  148. };
  149.  
  150. /* On disk block containging a number of fsObjects */
  151.  
  152. struct fsObjectContainer {
  153.     struct fsBlockHeader bheader;
  154.  
  155.     u32 parent;
  156.     u32 next;
  157.     u32 previous;        /* 0 for the first block in the directory chain */
  158.  
  159.     struct fsObject object[0];
  160. };
  161.  
  162. /* BTree structures, used to collect file data position on disk */
  163.  
  164. struct fsExtentBNode {
  165.     u32 key;        /* data! */
  166.     u32 next;
  167.     u32 prev;
  168.     u16 blocks;        /* The size in blocks of the region this Extent controls */
  169. };
  170.  
  171. struct BNode {
  172.     u32 key;
  173.     u32 data;
  174. };
  175.  
  176. struct BTreeContainer {
  177.     u16 nodecount;
  178.     u8 isleaf;
  179.     u8 nodesize;        /* Must be a multiple of 2 */
  180.  
  181.     struct BNode bnode[0];
  182. };
  183.  
  184. /* On disk block with BTreeContainer */
  185.  
  186. struct fsBNodeContainer {
  187.     struct fsBlockHeader bheader;
  188.     struct BTreeContainer btc;
  189. };
  190.  
  191. /* On disk block  with soft link data */
  192.  
  193. struct fsSoftLink {
  194.     struct fsBlockHeader bheader;
  195.     u32 parent;
  196.     u32 next;
  197.     u32 previous;
  198.     u8 string[0];
  199. };
  200.  
  201. /* On disk block with hashtable data */
  202.  
  203. struct fsHashTable {
  204.     struct fsBlockHeader bheader;
  205.     u32 parent;
  206.     u32 hashentry[0];
  207. };
  208.  
  209. /* On disk block with node index and some helper structures */
  210.  
  211. struct fsNodeContainer {
  212.     struct fsBlockHeader bheader;
  213.     u32 nodenumber;
  214.     u32 nodes;
  215.     u32 node[0];
  216. };
  217.  
  218. struct fsNode {
  219.     u32 data;
  220. };
  221.  
  222. struct fsObjectNode {
  223.     struct fsNode node;
  224.     u32 next;
  225.     u16 hash16;
  226. } __attribute__ ((packed));
  227.  
  228. /* Some adminspace and bitmap block structures */
  229.  
  230. struct fsAdminSpace {
  231.     u32 space;
  232.     u32 bits;        
  233. /* Set bits are used blocks, bit 31 is    the first block in the AdminSpace. */
  234. };
  235.  
  236. struct fsAdminSpaceContainer {
  237.     struct fsBlockHeader bheader;
  238.  
  239.     u32 next;
  240.     u32 previous;
  241.  
  242.     u8 bits;
  243.     u8 pad1;
  244.     u16 pad2;
  245.  
  246.     struct fsAdminSpace adminspace[0];
  247. };
  248.  
  249. struct fsBitmap {
  250.     struct fsBlockHeader bheader;
  251.  
  252.     u32 bitmap[0];
  253.  
  254. /* Bits are 1 if the block is free, and 0 if full.
  255.    Bitmap must consist of an integral number of longwords. */
  256. };
  257.  
  258. /* The fsRootInfo structure has all kinds of information about the format
  259.    of the disk. */
  260.  
  261. struct fsRootInfo {
  262.     u32 deletedblocks;    /* Amount in blocks which deleted files consume. */
  263.     u32 deletedfiles;    /* Number of deleted files in recycled. */
  264.     u32 freeblocks;        /* Cached number of free blocks on disk. */
  265.  
  266.     u32 datecreated;
  267.  
  268.     u32 lastallocatedblock;    /* Block which was most recently allocated */
  269.     u32 lastallocatedadminspace;    /* AdminSpaceContainer which most recently was used to allocate a block */
  270.     u32 lastallocatedextentnode;    /* ExtentNode which was most recently created */
  271.     u32 lastallocatedobjectnode;    /* ObjectNode which was most recently created */
  272.  
  273.     u32 rovingpointer;
  274. };
  275.  
  276. #endif
  277.