archive_entry_private.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /*-
  2. * Copyright (c) 2003-2007 Tim Kientzle
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions
  7. * are met:
  8. * 1. Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * 2. Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in the
  12. * documentation and/or other materials provided with the distribution.
  13. *
  14. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
  15. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  16. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  17. * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
  18. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  19. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  20. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  21. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  23. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. *
  25. * $FreeBSD: head/lib/libarchive/archive_entry_private.h 201096 2009-12-28 02:41:27Z kientzle $
  26. */
  27. #ifndef __LIBARCHIVE_BUILD
  28. #error This header is only to be used internally to libarchive.
  29. #endif
  30. #ifndef ARCHIVE_ENTRY_PRIVATE_H_INCLUDED
  31. #define ARCHIVE_ENTRY_PRIVATE_H_INCLUDED
  32. #include "archive_acl_private.h"
  33. #include "archive_string.h"
  34. struct ae_xattr {
  35. struct ae_xattr *next;
  36. char *name;
  37. void *value;
  38. size_t size;
  39. };
  40. struct ae_sparse {
  41. struct ae_sparse *next;
  42. int64_t offset;
  43. int64_t length;
  44. };
  45. /*
  46. * Description of an archive entry.
  47. *
  48. * Basically, this is a "struct stat" with a few text fields added in.
  49. *
  50. * TODO: Add "comment", "charset", and possibly other entries
  51. * that are supported by "pax interchange" format. However, GNU, ustar,
  52. * cpio, and other variants don't support these features, so they're not an
  53. * excruciatingly high priority right now.
  54. *
  55. * TODO: "pax interchange" format allows essentially arbitrary
  56. * key/value attributes to be attached to any entry. Supporting
  57. * such extensions may make this library useful for special
  58. * applications (e.g., a package manager could attach special
  59. * package-management attributes to each entry). There are tricky
  60. * API issues involved, so this is not going to happen until
  61. * there's a real demand for it.
  62. *
  63. * TODO: Design a good API for handling sparse files.
  64. */
  65. struct archive_entry {
  66. struct archive *archive;
  67. /*
  68. * Note that ae_stat.st_mode & AE_IFMT can be 0!
  69. *
  70. * This occurs when the actual file type of the object is not
  71. * in the archive. For example, 'tar' archives store
  72. * hardlinks without marking the type of the underlying
  73. * object.
  74. */
  75. /*
  76. * We have a "struct aest" for holding file metadata rather than just
  77. * a "struct stat" because on some platforms the "struct stat" has
  78. * fields which are too narrow to hold the range of possible values;
  79. * we don't want to lose information if we read an archive and write
  80. * out another (e.g., in "tar -cf new.tar @old.tar").
  81. *
  82. * The "stat" pointer points to some form of platform-specific struct
  83. * stat; it is declared as a void * rather than a struct stat * as
  84. * some platforms have multiple varieties of stat structures.
  85. */
  86. void *stat;
  87. int stat_valid; /* Set to 0 whenever a field in aest changes. */
  88. struct aest {
  89. int64_t aest_atime;
  90. uint32_t aest_atime_nsec;
  91. int64_t aest_ctime;
  92. uint32_t aest_ctime_nsec;
  93. int64_t aest_mtime;
  94. uint32_t aest_mtime_nsec;
  95. int64_t aest_birthtime;
  96. uint32_t aest_birthtime_nsec;
  97. int64_t aest_gid;
  98. int64_t aest_ino;
  99. uint32_t aest_nlink;
  100. uint64_t aest_size;
  101. int64_t aest_uid;
  102. /*
  103. * Because converting between device codes and
  104. * major/minor values is platform-specific and
  105. * inherently a bit risky, we only do that conversion
  106. * lazily. That way, we will do a better job of
  107. * preserving information in those cases where no
  108. * conversion is actually required.
  109. */
  110. int aest_dev_is_broken_down;
  111. dev_t aest_dev;
  112. dev_t aest_devmajor;
  113. dev_t aest_devminor;
  114. int aest_rdev_is_broken_down;
  115. dev_t aest_rdev;
  116. dev_t aest_rdevmajor;
  117. dev_t aest_rdevminor;
  118. } ae_stat;
  119. int ae_set; /* bitmap of fields that are currently set */
  120. #define AE_SET_HARDLINK 1
  121. #define AE_SET_SYMLINK 2
  122. #define AE_SET_ATIME 4
  123. #define AE_SET_CTIME 8
  124. #define AE_SET_MTIME 16
  125. #define AE_SET_BIRTHTIME 32
  126. #define AE_SET_SIZE 64
  127. #define AE_SET_INO 128
  128. #define AE_SET_DEV 256
  129. /*
  130. * Use aes here so that we get transparent mbs<->wcs conversions.
  131. */
  132. struct archive_mstring ae_fflags_text; /* Text fflags per fflagstostr(3) */
  133. unsigned long ae_fflags_set; /* Bitmap fflags */
  134. unsigned long ae_fflags_clear;
  135. struct archive_mstring ae_gname; /* Name of owning group */
  136. struct archive_mstring ae_hardlink; /* Name of target for hardlink */
  137. struct archive_mstring ae_pathname; /* Name of entry */
  138. struct archive_mstring ae_symlink; /* symlink contents */
  139. struct archive_mstring ae_uname; /* Name of owner */
  140. /* Not used within libarchive; useful for some clients. */
  141. struct archive_mstring ae_sourcepath; /* Path this entry is sourced from. */
  142. #define AE_ENCRYPTION_NONE 0
  143. #define AE_ENCRYPTION_DATA 1
  144. #define AE_ENCRYPTION_METADATA 2
  145. char encryption;
  146. void *mac_metadata;
  147. size_t mac_metadata_size;
  148. /* ACL support. */
  149. struct archive_acl acl;
  150. /* extattr support. */
  151. struct ae_xattr *xattr_head;
  152. struct ae_xattr *xattr_p;
  153. /* sparse support. */
  154. struct ae_sparse *sparse_head;
  155. struct ae_sparse *sparse_tail;
  156. struct ae_sparse *sparse_p;
  157. /* Miscellaneous. */
  158. char strmode[12];
  159. };
  160. #endif /* ARCHIVE_ENTRY_PRIVATE_H_INCLUDED */