archive_entry_private.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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: src/lib/libarchive/archive_entry_private.h,v 1.6 2008/09/30 03:53:03 kientzle Exp $
  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_string.h"
  33. /*
  34. * Handle wide character (i.e., Unicode) and non-wide character
  35. * strings transparently.
  36. */
  37. struct aes {
  38. struct archive_string aes_mbs;
  39. struct archive_string aes_utf8;
  40. const wchar_t *aes_wcs;
  41. /* Bitmap of which of the above are valid. Because we're lazy
  42. * about malloc-ing and reusing the underlying storage, we
  43. * can't rely on NULL pointers to indicate whether a string
  44. * has been set. */
  45. int aes_set;
  46. #define AES_SET_MBS 1
  47. #define AES_SET_UTF8 2
  48. #define AES_SET_WCS 4
  49. };
  50. struct ae_acl {
  51. struct ae_acl *next;
  52. int type; /* E.g., access or default */
  53. int tag; /* E.g., user/group/other/mask */
  54. int permset; /* r/w/x bits */
  55. int id; /* uid/gid for user/group */
  56. struct aes name; /* uname/gname */
  57. };
  58. struct ae_xattr {
  59. struct ae_xattr *next;
  60. char *name;
  61. void *value;
  62. size_t size;
  63. };
  64. /*
  65. * Description of an archive entry.
  66. *
  67. * Basically, this is a "struct stat" with a few text fields added in.
  68. *
  69. * TODO: Add "comment", "charset", and possibly other entries
  70. * that are supported by "pax interchange" format. However, GNU, ustar,
  71. * cpio, and other variants don't support these features, so they're not an
  72. * excruciatingly high priority right now.
  73. *
  74. * TODO: "pax interchange" format allows essentially arbitrary
  75. * key/value attributes to be attached to any entry. Supporting
  76. * such extensions may make this library useful for special
  77. * applications (e.g., a package manager could attach special
  78. * package-management attributes to each entry). There are tricky
  79. * API issues involved, so this is not going to happen until
  80. * there's a real demand for it.
  81. *
  82. * TODO: Design a good API for handling sparse files.
  83. */
  84. struct archive_entry {
  85. /*
  86. * Note that ae_stat.st_mode & AE_IFMT can be 0!
  87. *
  88. * This occurs when the actual file type of the object is not
  89. * in the archive. For example, 'tar' archives store
  90. * hardlinks without marking the type of the underlying
  91. * object.
  92. */
  93. /*
  94. * Read archive_entry_copy_stat.c for an explanation of why I
  95. * don't just use "struct stat" instead of "struct aest" here
  96. * and why I have this odd pointer to a separately-allocated
  97. * struct stat.
  98. */
  99. void *stat;
  100. int stat_valid; /* Set to 0 whenever a field in aest changes. */
  101. struct aest {
  102. int64_t aest_atime;
  103. uint32_t aest_atime_nsec;
  104. int64_t aest_ctime;
  105. uint32_t aest_ctime_nsec;
  106. int64_t aest_mtime;
  107. uint32_t aest_mtime_nsec;
  108. int64_t aest_birthtime;
  109. uint32_t aest_birthtime_nsec;
  110. gid_t aest_gid;
  111. int64_t aest_ino;
  112. mode_t aest_mode;
  113. uint32_t aest_nlink;
  114. uint64_t aest_size;
  115. uid_t aest_uid;
  116. /*
  117. * Because converting between device codes and
  118. * major/minor values is platform-specific and
  119. * inherently a bit risky, we only do that conversion
  120. * lazily. That way, we will do a better job of
  121. * preserving information in those cases where no
  122. * conversion is actually required.
  123. */
  124. int aest_dev_is_broken_down;
  125. dev_t aest_dev;
  126. dev_t aest_devmajor;
  127. dev_t aest_devminor;
  128. int aest_rdev_is_broken_down;
  129. dev_t aest_rdev;
  130. dev_t aest_rdevmajor;
  131. dev_t aest_rdevminor;
  132. } ae_stat;
  133. int ae_set; /* bitmap of fields that are currently set */
  134. #define AE_SET_HARDLINK 1
  135. #define AE_SET_SYMLINK 2
  136. #define AE_SET_ATIME 4
  137. #define AE_SET_CTIME 8
  138. #define AE_SET_MTIME 16
  139. #define AE_SET_BIRTHTIME 32
  140. #define AE_SET_SIZE 64
  141. /*
  142. * Use aes here so that we get transparent mbs<->wcs conversions.
  143. */
  144. struct aes ae_fflags_text; /* Text fflags per fflagstostr(3) */
  145. unsigned long ae_fflags_set; /* Bitmap fflags */
  146. unsigned long ae_fflags_clear;
  147. struct aes ae_gname; /* Name of owning group */
  148. struct aes ae_hardlink; /* Name of target for hardlink */
  149. struct aes ae_pathname; /* Name of entry */
  150. struct aes ae_symlink; /* symlink contents */
  151. struct aes ae_uname; /* Name of owner */
  152. /* Not used within libarchive; useful for some clients. */
  153. struct aes ae_sourcepath; /* Path this entry is sourced from. */
  154. /* ACL support. */
  155. struct ae_acl *acl_head;
  156. struct ae_acl *acl_p;
  157. int acl_state; /* See acl_next for details. */
  158. wchar_t *acl_text_w;
  159. /* extattr support. */
  160. struct ae_xattr *xattr_head;
  161. struct ae_xattr *xattr_p;
  162. /* Miscellaneous. */
  163. char strmode[12];
  164. };
  165. #endif /* ARCHIVE_ENTRY_PRIVATE_H_INCLUDED */