archive_entry_private.h 6.0 KB

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