/filesystems/unixfs/ancientfs/ancientfs_v4,5,6.h

http://macfuse.googlecode.com/ · C Header · 98 lines · 68 code · 13 blank · 17 comment · 2 complexity · 6f72fec26f1bf3acac0993f88b7ef8c0 MD5 · raw file

  1. /*
  2. * Ancient UNIX File Systems for MacFUSE
  3. * Amit Singh
  4. * http://osxbook.com
  5. */
  6. #ifndef _ANCIENTFS_V456_H_
  7. #define _ANCIENTFS_V456_H_
  8. /*
  9. * V4 += DIRSIZ 14, size0/size1, groups, 1970 epoch with full seconds
  10. * V5 += ISVTX
  11. */
  12. #include "unixfs_internal.h"
  13. #include "ancientfs.h"
  14. typedef int16_t a_ino_t; /* ancient inode type */
  15. typedef int16_t a_int; /* ancient int */
  16. #define BSIZE 512
  17. #define ROOTINO 1 /* i number of all roots */
  18. #define SUPERB 1 /* block number of the super block */
  19. #define DIRSIZ 14 /* max characters per directory */
  20. /*
  21. * Definition of the unix super block.
  22. */
  23. struct filsys
  24. {
  25. a_int s_isize; /* size in blocks of the I list */
  26. a_int s_fsize; /* size in blocks of entire volume */
  27. a_int s_nfree; /* number of in core free blocks (0 - 100) */
  28. a_int s_free[100]; /* in core free blocks */
  29. a_int s_ninode; /* number of in core I nodes (0 - 100) */
  30. a_ino_t s_inode[100]; /* in core free I nodes */
  31. char s_flock; /* lock during free list manipulation */
  32. char s_ilock; /* lock during I list manipulation */
  33. char s_fmod; /* super block modified flag */
  34. char s_ronly; /* mounted read-only flag */
  35. a_int s_time[2]; /* current date of last update */
  36. a_int pad[50];
  37. } __attribute__((packed));
  38. /*
  39. * Inode struct as it appears on the disk.
  40. */
  41. struct dinode
  42. {
  43. a_int di_mode; /* type and permissions */
  44. char di_nlink; /* directory entries */
  45. char di_uid; /* owner */
  46. char di_gid; /* group of owner */
  47. char di_size0; /* most significant of size */
  48. a_int di_size1; /* least significant of size */
  49. a_int di_addr[8]; /* device addresses constituting file */
  50. a_int di_atime[2]; /* access time */
  51. a_int di_mtime[2]; /* modification time */
  52. } __attribute__((packed));
  53. /* flags */
  54. #define ILOCK 01 /* inode is locked */
  55. #define IUPD 02 /* inode has been modified */
  56. #define IACC 04 /* inode access time to be updated */
  57. #define IMOUNT 010 /* inode is mounted on */
  58. #define IWANT 020 /* some process waiting on lock */
  59. #define ITEXT 040 /* inode is pure text prototype */
  60. /* modes */
  61. #define IALLOC 0100000 /* file is used */
  62. #define IFMT 060000 /* type of file */
  63. #define IFDIR 040000 /* directory */
  64. #define IFCHR 020000 /* character special */
  65. #define IFBLK 060000 /* block special, 0 is regular */
  66. #define ILARG 010000 /* large addressing algorithm */
  67. #define ISUID 04000 /* set user id on execution */
  68. #define ISGID 02000 /* set group id on execution */
  69. #define ISVTX 01000 /* save swapped text even after use */
  70. #define IREAD 0400 /* read, write, execute permissions */
  71. #define IRWRITE 0200
  72. #define IEXEC 0100
  73. static inline a_int
  74. ancientfs_v456_mode(mode_t mode)
  75. {
  76. a_int newmode = (a_int)mode & ~(IALLOC | ILARG);
  77. if ((newmode & IFMT) == 0) /* ancient regular file */
  78. newmode |= S_IFREG;
  79. return newmode;
  80. }
  81. struct dent {
  82. a_ino_t u_ino; /* inode table pointer */
  83. char u_name[DIRSIZ]; /* component name */
  84. } __attribute__((packed));
  85. #endif /* _ANCIENTFS_V456_H_ */