PageRenderTime 10ms CodeModel.GetById 8ms RepoModel.GetById 0ms app.codeStats 0ms

/filesystems/unixfs/ancientfs/ancientfs_cpio_newc.h

http://macfuse.googlecode.com/
C Header | 72 lines | 54 code | 10 blank | 8 comment | 0 complexity | 52e68cf44b790cba828b9d2fe78c9b64 MD5 | raw file
Possible License(s): Apache-2.0, BSD-3-Clause, GPL-2.0
  1. /*
  2. * Ancient UNIX File Systems for MacFUSE
  3. * Amit Singh
  4. * http://osxbook.com
  5. */
  6. #ifndef _ANCIENTFS_CPIO_NEWC_H_
  7. #define _ANCIENTFS_CPIO_NEWC_H_
  8. #include "unixfs_internal.h"
  9. #include "ancientfs.h"
  10. #define ROOTINO 1
  11. struct filsys
  12. {
  13. uint32_t s_fsize;
  14. uint32_t s_files;
  15. uint32_t s_directories;
  16. uint32_t s_lastino;
  17. uint32_t s_dataoffset;
  18. uint32_t s_needsswap;
  19. struct inode* s_rootip;
  20. };
  21. #define CPIO_NEWC_BLOCK 512
  22. #define CPIO_NEWC_MAGIC "070701"
  23. #define CPIO_NEWCRC_MAGIC "070702"
  24. #define CPIO_NEWC_MAGLEN 6
  25. #define CPIO_NEWC_TRAILER "TRAILER!!!"
  26. #define CPIO_NEWC_TRAILER_LEN (sizeof(CPIO_NEWC_TRAILER)/sizeof(unsigned char))
  27. struct cpio_newc_header {
  28. char c_magic[6];
  29. char c_ino[8];
  30. char c_mode[8];
  31. char c_uid[8];
  32. char c_gid[8];
  33. char c_nlink[8];
  34. char c_mtime[8];
  35. char c_filesize[8];
  36. char c_devmajor[8];
  37. char c_devminor[8];
  38. char c_rdevmajor[8];
  39. char c_rdevminor[8];
  40. char c_namesize[8];
  41. char c_check[8];
  42. /* char c_name[c_namesize rounded to 4 bytes]; */
  43. /* char c_data[c_filesize rounded to 4 bytes]; */
  44. } __attribute__((packed));
  45. struct cpio_newc_node_info {
  46. struct inode* ci_self;
  47. struct cpio_newc_node_info* ci_parent;
  48. struct cpio_newc_node_info* ci_children;
  49. struct cpio_newc_node_info* ci_next_sibling;
  50. char* ci_name;
  51. char* ci_linktargetname;
  52. };
  53. /* modes */
  54. #define IALLOC 0100000 /* i-node is allocated */
  55. #define ILARG 010000 /* large file */
  56. #define IFMT 0170000 /* type of file */
  57. static inline mode_t
  58. ancientfs_cpio_newc_mode(mode_t mode, uint32_t flags)
  59. {
  60. return mode & (uint16_t)~(IALLOC & ILARG);
  61. }
  62. #endif /* _ANCIENTFS_CPIO_NEWC_H_ */