/filesystems/unixfs/ancientfs/ancientfs_v7.h

http://macfuse.googlecode.com/ · C Header · 138 lines · 98 code · 19 blank · 21 comment · 0 complexity · 44cc561a0be04f21b1c7f4391ddef17c MD5 · raw file

  1. /*
  2. * Ancient UNIX File Systems for MacFUSE
  3. * Amit Singh
  4. * http://osxbook.com
  5. */
  6. #ifndef _ANCIENTFS_V7_H_
  7. #define _ANCIENTFS_V7_H_
  8. #include "unixfs_internal.h"
  9. typedef int16_t a_short; /* ancient short */
  10. typedef uint16_t a_ushort; /* ancient unsigned short */
  11. typedef int16_t a_int; /* ancient int */
  12. typedef uint16_t a_uint; /* ancient unsigned int */
  13. typedef int32_t a_long; /* ancient long */
  14. typedef uint32_t a_ulong; /* ancient unsigned long */
  15. typedef a_uint a_ino_t; /* ancient inode type (ancient unsigned int) */
  16. typedef a_long a_off_t; /* ancient offset type (ancient long) */
  17. typedef a_ulong a_time_t; /* ancient time type (ancient long) */
  18. typedef a_long a_daddr_t; /* ancient disk address type (ancient long) */
  19. typedef a_int a_dev_t; /* ancient device type (ancient int) */
  20. #if V10_4K
  21. #define BSIZE 4096 /* size of secondary block (bytes) */
  22. #define BMASK 07777 /* BSIZE - 1 */
  23. #define NINDIR (BSIZE/sizeof(a_daddr_t))
  24. #define NMASK 01777 /* NINDIR - 1 */
  25. #define NSHIFT 10 /* LOG2(NINDIR) */
  26. #else
  27. #define BSIZE 512 /* size of secondary block (bytes) */
  28. #define BMASK 0777 /* BSIZE - 1 */
  29. #define NINDIR (BSIZE/sizeof(a_daddr_t))
  30. #define NMASK 0177 /* NINDIR - 1 */
  31. #define NSHIFT 7 /* LOG2(NINDIR) */
  32. #endif
  33. #define ROOTINO 2 /* i number of all roots */
  34. #define SUPERB ((a_daddr_t)1) /* block number of the super block */
  35. #define DIRSIZ 14 /* max characters per directory */
  36. #define NICINOD 100 /* number of super block inodes */
  37. #define NICFREE 50 /* number of super block free blocks */
  38. /*
  39. * Definition of the unix super block.
  40. */
  41. struct filsys
  42. {
  43. a_ushort s_isize; /* size in blocks of i-list */
  44. a_daddr_t s_fsize; /* size in blocks of entire volume */
  45. a_short s_nfree; /* number of addresses in s_free */
  46. a_daddr_t s_free[NICFREE]; /* free block list */
  47. a_short s_ninode; /* number of i-nodes in s_inode */
  48. a_ino_t s_inode[NICINOD]; /* free i-node list */
  49. char s_flock; /* lock during free list manipulation */
  50. char s_ilock; /* lock during i-list manipulation */
  51. char s_fmod; /* super block modified flag */
  52. char s_ronly; /* mounted read-only flag */
  53. time_t s_time; /* last super block update */
  54. /* remainder not maintained by this version of the system */
  55. a_daddr_t s_tfree; /* total free blocks*/
  56. a_ino_t s_tinode; /* total free inodes */
  57. a_short s_m; /* interleave factor */
  58. a_short s_n; /* " " */
  59. char s_fname[6]; /* file system name */
  60. char s_fpack[6]; /* file system pack name */
  61. } __attribute__((packed));
  62. /*
  63. * Inode struct as it appears on a disk block.
  64. */
  65. struct dinode
  66. {
  67. a_ushort di_mode; /* mode and type of file */
  68. a_short di_nlink; /* number of links to file */
  69. a_short di_uid; /* owner's user id */
  70. a_short di_gid; /* owner's group id */
  71. a_off_t di_size; /* number of bytes in file */
  72. char di_addr[40]; /* disk block addresses */
  73. a_time_t di_atime; /* time last accessed */
  74. a_time_t di_mtime; /* time last modified */
  75. a_time_t di_ctime; /* time created */
  76. } __attribute__((packed));
  77. #define INOPB 8 /* 8 inodes per block */
  78. /*
  79. * the 40 address bytes:
  80. * 39 used; 13 addresses
  81. * of 3 bytes each.
  82. */
  83. /* inumber to disk address */
  84. #define itod(x) (a_daddr_t)((((a_uint)(x) + 15) >> 3))
  85. /* inumber to disk offset */
  86. #define itoo(x) (a_int)(((x) + 15) & 07)
  87. #define NADDR 13
  88. #define NINDEX 15
  89. /* flags */
  90. #define ILOCK 01 /* inode is locked */
  91. #define IUPD 02 /* inode has been modified */
  92. #define IACC 04 /* inode access time to be updated */
  93. #define IMOUNT 010 /* inode is mounted on */
  94. #define IWANT 020 /* some process waiting on lock */
  95. #define ITEXT 040 /* inode is pure text prototype */
  96. #define ICHG 0100 /* inode has been changed */
  97. /* modes */
  98. #define IFMT 0170000 /* type of file */
  99. #define IFDIR 0040000 /* directory */
  100. #define IFCHR 0020000 /* character special */
  101. #define IFBLK 0060000 /* block special, 0 is regular */
  102. #define IFREG 0100000 /* regular */
  103. #define IFMPC 0030000 /* multiplexed char special */
  104. #define IFMPB 0070000 /* multiplexed block special */
  105. #define ISUID 04000 /* set user id on execution */
  106. #define ISGID 02000 /* set group id on execution */
  107. #define ISVTX 01000 /* save swapped text even after use */
  108. #define IREAD 0400 /* read, write, execute permissions */
  109. #define IRWRITE 0200
  110. #define IEXEC 0100
  111. struct dent {
  112. a_ino_t u_ino; /* inode table pointer */
  113. char u_name[DIRSIZ]; /* component name */
  114. } __attribute__((packed));
  115. struct fblk {
  116. a_int df_nfree;
  117. a_daddr_t df_free[NICFREE];
  118. } __attribute__((packed));
  119. #endif /* _ANCIENTFS_V7_H_ */