/filesystems/unixfs/ancientfs/ancientfs_itp.h

http://macfuse.googlecode.com/ · C Header · 97 lines · 75 code · 15 blank · 7 comment · 3 complexity · 8d533d749581362bc89fc0416fa8fdf0 MD5 · raw file

  1. /*
  2. * Ancient UNIX File Systems for MacFUSE
  3. * Amit Singh
  4. * http://osxbook.com
  5. */
  6. #ifndef _ANCIENTFS_ITP_H_
  7. #define _ANCIENTFS_ITP_H_
  8. #include "unixfs_internal.h"
  9. #include "ancientfs.h"
  10. #define BSIZE 512
  11. #define ROOTINO 1
  12. #define DIRSIZ 14
  13. #define PATHSIZ 48
  14. struct filsys
  15. {
  16. uint32_t s_fsize;
  17. uint32_t s_files;
  18. uint32_t s_directories;
  19. uint32_t s_lastino;
  20. struct inode* s_rootip;
  21. };
  22. struct dinode_itp { /* newer */
  23. uint8_t di_path[PATHSIZ]; /* if di_path[0] == 0, the entry is empty */
  24. uint16_t di_mode; /* type and permissions */
  25. uint8_t di_uid; /* owner's id */
  26. uint8_t di_gid; /* group's id */
  27. uint8_t di_unused1; /* unused */
  28. uint8_t di_size0; /* size */
  29. uint16_t di_size1; /* size */
  30. uint32_t di_mtime; /* file's modification time */
  31. uint16_t di_addr; /* tape block of the start of the file's contents */
  32. uint16_t di_cksum; /* sum of the 32 words of the directory is 0 */
  33. } __attribute__((packed));
  34. #define INOPB 8
  35. struct tap_node_info {
  36. struct inode* ti_self;
  37. uint8_t ti_name[DIRSIZ];
  38. struct tap_node_info* ti_parent;
  39. struct tap_node_info* ti_children;
  40. struct tap_node_info* ti_next_sibling;
  41. };
  42. /* flags */
  43. #define ILOCK 01
  44. #define IUPD 02
  45. #define IACC 04
  46. #define IMOUNT 010
  47. #define IWANT 020
  48. #define ITEXT 040
  49. /* modes */
  50. #define IALLOC 0100000 /* file is used */
  51. #define IFMT 060000 /* type of file */
  52. #define IFDIR 040000 /* directory */
  53. #define IFCHR 020000 /* character special */
  54. #define IFBLK 060000 /* block special, 0 is regular */
  55. #define ILARG 010000 /* large addressing algorithm */
  56. #define ISUID 04000 /* set user id on execution */
  57. #define ISGID 02000 /* set group id on execution */
  58. #define ISVTX 01000 /* save swapped text even after use */
  59. #define IREAD 0400 /* read, write, execute permissions */
  60. #define IRWRITE 0200
  61. #define IEXEC 0100
  62. #include <sys/stat.h>
  63. static inline mode_t
  64. ancientfs_itp_mode(mode_t mode, uint32_t flags)
  65. {
  66. mode_t newmode = 0;
  67. newmode = (int)mode & ~(IALLOC | ILARG);
  68. if ((newmode & IFMT) == 0) /* ancient regular file */
  69. newmode |= S_IFREG;
  70. return newmode;
  71. }
  72. static inline int
  73. ancientfs_itp_cksum(uint8_t* de, fs_endian_t e, uint32_t flags)
  74. {
  75. uint16_t* p = (uint16_t*)de;
  76. uint16_t cksum = 0;
  77. int i = 0;
  78. for (i = 0; i < 32; i++, p++)
  79. cksum += fs16_to_host(e, *p);
  80. return cksum;
  81. }
  82. #endif /* _ANCIENTFS_ITP_H_ */