/filesystems/unixfs/ancientfs/ancientfs_2.9bsd.h

http://macfuse.googlecode.com/ · C Header · 171 lines · 127 code · 20 blank · 24 comment · 5 complexity · 2b968169f22950e82e73bde9596f3212 MD5 · raw file

  1. /*
  2. * Ancient UNIX File Systems for MacFUSE
  3. * Amit Singh
  4. * http://osxbook.com
  5. */
  6. #ifndef _ANCIENTFS_29BSD_H_
  7. #define _ANCIENTFS_29BSD_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_long 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. #define UCB_NKB 1
  21. #if UCB_NKB == 1
  22. #undef CLSIZE
  23. #define CLSIZE 2 /* number of blocks / cluster */
  24. #define BSIZE 1024 /* size of secondary block (bytes) */
  25. #define NINDIR (BSIZE/sizeof(a_daddr_t))
  26. #define BMASK 01777 /* BSIZE - 1 */
  27. #define BSHIFT 10 /* LOG2(BSIZE) */
  28. #define NMASK 0377 /* NINDIR - 1 */
  29. #define NSHIFT 8 /* LOG2(NINDIR) */
  30. #else
  31. #define BSIZE 512 /* size of secondary block (bytes) */
  32. #define NINDIR (BSIZE/sizeof(a_daddr_t))
  33. #define BMASK 0777 /* BSIZE - 1 */
  34. #define BSHIFT 9 /* LOG2(BSIZE) */
  35. #define NMASK 0177 /* NINDIR - 1 */
  36. #define NSHIFT 7 /* LOG2(NINDIR) */
  37. #endif
  38. #define ROOTINO 2 /* i number of all roots */
  39. #define DIRSIZ 14 /* max characters per directory */
  40. #define NICINOD 100 /* number of super block inodes */
  41. #define NICFREE 50 /* number of super block free blocks */
  42. /*
  43. * Definition of the unix super block.
  44. */
  45. struct filsys
  46. {
  47. a_ushort s_isize; /* size in blocks of i-list */
  48. a_daddr_t s_fsize; /* size in blocks of entire volume */
  49. a_short s_nfree; /* number of addresses in s_free */
  50. a_daddr_t s_free[NICFREE]; /* free block list */
  51. a_short s_ninode; /* number of i-nodes in s_inode */
  52. a_ino_t s_inode[NICINOD]; /* free i-node list */
  53. char s_flock; /* lock during free list manipulation */
  54. char s_ilock; /* lock during i-list manipulation */
  55. char s_fmod; /* super block modified flag */
  56. char s_ronly; /* mounted read-only flag */
  57. time_t s_time; /* last super block update */
  58. /* remainder not maintained by this version of the system */
  59. a_daddr_t s_tfree; /* total free blocks*/
  60. a_ino_t s_tinode; /* total free inodes */
  61. a_short s_dinfo[2]; /* interleave stuff */
  62. #define s_m s_dinfo[0]
  63. #define s_n s_dinfo[1]
  64. char s_fsmnt[12]; /* ordinary file mounted on */
  65. ino_t s_lasti; /* start place for circular search */
  66. ino_t s_nbehind; /* est # free inodes before s_lasti */
  67. } __attribute__((packed));
  68. /*
  69. * Inode struct as it appears on a disk block.
  70. */
  71. struct dinode
  72. {
  73. a_ushort di_mode; /* mode and type of file */
  74. a_short di_nlink; /* number of links to file */
  75. a_short di_uid; /* owner's user id */
  76. a_short di_gid; /* owner's group id */
  77. a_off_t di_size; /* number of bytes in file */
  78. char di_addr[40]; /* disk block addresses */
  79. a_time_t di_atime; /* time last accessed */
  80. a_time_t di_mtime; /* time last modified */
  81. a_time_t di_ctime; /* time created */
  82. } __attribute__((packed));
  83. #if UCB_NKB == 1
  84. #define INOPB 16 /* 16 inodes per block */
  85. /*
  86. * 21 of the address bytes are used;
  87. * 7 addresses of 3 bytes each.
  88. */
  89. #else
  90. #define INOPB 8 /* 8 inodes per block */
  91. /*
  92. * 39 of the address bytes are used;
  93. * 13 addresses of 3 bytes each.
  94. */
  95. #endif
  96. /* inumber to disk address */
  97. #if UCB_NKB == 1
  98. #define itod(x) ((a_daddr_t)((((a_uint)(x) + 2 * INOPB - 1) / INOPB)))
  99. #else
  100. #define itod(x) (a_daddr_t)((((a_uint)(x) + 15) >> 3))
  101. #endif
  102. /* inumber to disk offset */
  103. #if UCB_NKB == 1
  104. #define itoo(x) ((a_int)(((x) + 2 * INOPB - 1) % INOPB))
  105. #else
  106. #define itoo(x) (a_int)(((x) + 15) & 07)
  107. #endif
  108. #if UCB_NKB == 1
  109. #define NADDR 7
  110. #define NINDEX 6
  111. #else
  112. #define NADDR 13
  113. #define NINDEX 15
  114. #endif
  115. /* flags */
  116. #define ILOCK 01 /* inode is locked */
  117. #define IUPD 02 /* inode has been modified */
  118. #define IACC 04 /* inode access time to be updated */
  119. #define IMOUNT 010 /* inode is mounted on */
  120. #define IWANT 020 /* some process waiting on lock */
  121. #define ITEXT 040 /* inode is pure text prototype */
  122. #define ICHG 0100 /* inode has been changed */
  123. #define IPIPE 0200 /* inode is a pipe */
  124. #ifdef UCB_QUOTAS
  125. #define IQUOT 0400 /* directory that has original quota pointer */
  126. #endif
  127. /* modes */
  128. #define IFMT 0170000 /* type of file */
  129. #define IFDIR 0040000 /* directory */
  130. #define IFCHR 0020000 /* character special */
  131. #define IFMPC 0030000 /* multiplexed char special */
  132. #define IFBLK 0060000 /* block special, 0 is regular */
  133. #define IFMPB 0070000 /* multiplexed block special */
  134. #define IFREG 0100000 /* regular */
  135. #define IFLNK 0120000 /* symbolic link */
  136. #define IFQUOT 0140000 /* quota */
  137. #define ISUID 04000 /* set user id on execution */
  138. #define ISGID 02000 /* set group id on execution */
  139. #define ISVTX 01000 /* save swapped text even after use */
  140. #define IREAD 0400 /* read, write, execute permissions */
  141. #define IRWRITE 0200
  142. #define IEXEC 0100
  143. struct dent {
  144. a_ino_t u_ino; /* inode table pointer */
  145. char u_name[DIRSIZ]; /* component name */
  146. } __attribute__((packed));
  147. struct fblk {
  148. a_short df_nfree;
  149. a_daddr_t df_free[NICFREE];
  150. } __attribute__((packed));
  151. #endif /* _ANCIENTFS_29BSD_H_ */