/filesystems/unixfs/ancientfs/ancientfs_tar.h

http://macfuse.googlecode.com/ · C Header · 85 lines · 65 code · 12 blank · 8 comment · 0 complexity · 170f8c6ef16eaf9eb67e5b36350f9221 MD5 · raw file

  1. /*
  2. * Ancient UNIX File Systems for MacFUSE
  3. * Amit Singh
  4. * http://osxbook.com
  5. */
  6. #ifndef _ANCIENTFS_TAR_H_
  7. #define _ANCIENTFS_TAR_H_
  8. #include "unixfs_internal.h"
  9. #include "ancientfs.h"
  10. #define TBLOCK 512
  11. #define NAMSIZ 100
  12. #define ROOTINO 1
  13. struct filsys
  14. {
  15. uint32_t s_fsize;
  16. uint32_t s_files;
  17. uint32_t s_directories;
  18. uint32_t s_lastino;
  19. uint32_t s_dataoffset;
  20. struct inode* s_rootip;
  21. };
  22. #define TMAGIC "ustar" /* space terminated (pre POSIX) or null terminated */
  23. #define TMAGLEN 6
  24. #define TVERSION "00" /* not null terminated */
  25. #define TVERSLEN 2
  26. union hblock {
  27. char dummy[TBLOCK];
  28. struct header {
  29. char name[NAMSIZ]; /* name of file */
  30. char mode[8]; /* file mode */
  31. char uid[8]; /* owner user ID */
  32. char gid[8]; /* owner group ID */
  33. char size[12]; /* length of file in bytes; no trailing null */
  34. char mtime[12]; /* modfiy time of file; no trailing null */
  35. char chksum[8]; /* checksum for header */
  36. char typeflag; /* called linkflag in pre-ustar headers */
  37. char linkname[NAMSIZ]; /* name of linked file */
  38. /* ustar below */
  39. char magic[6]; /* USTAR indicator */
  40. char version[2]; /* USTAR version; no trailing null */
  41. char uname[32]; /* owner user name */
  42. char gname[32]; /* owner group name */
  43. char devmajor[8]; /* device major number */
  44. char devminor[8]; /* device minor number */
  45. char prefix[155]; /* prefix for file name */
  46. } dbuf;
  47. };
  48. /* values of typeflag / linkflag */
  49. #define TARTYPE_REG '0' /* USTAR and old tar */
  50. #define TARTYPE_LNK '1' /* USTAR and old tar */
  51. #define TARTYPE_SYM '2' /* USTAR and old tar */
  52. #define TARTYPE_CHR '3' /* USTAR */
  53. #define TARTYPE_BLK '4' /* USTAR */
  54. #define TARTYPE_DIR '5' /* USTAR */
  55. #define TARTYPE_FIFO '6' /* USTAR */
  56. struct tar_node_info {
  57. struct inode* ti_self;
  58. struct tar_node_info* ti_parent;
  59. struct tar_node_info* ti_children;
  60. struct tar_node_info* ti_next_sibling;
  61. char* ti_name;
  62. char* ti_linktargetname;
  63. };
  64. /* modes */
  65. #define IALLOC 0100000 /* i-node is allocated */
  66. #define ILARG 010000 /* large file */
  67. #define IFMT 0170000 /* type of file */
  68. static inline mode_t
  69. ancientfs_tar_mode(mode_t mode, uint32_t flags)
  70. {
  71. return mode & (uint16_t)~(IALLOC & ILARG);
  72. }
  73. #endif /* _ANCIENTFS_TAR_H_ */