archive_entry_private.h revision 302001
1219019Sgabor/*- 2219019Sgabor * Copyright (c) 2003-2007 Tim Kientzle 3219019Sgabor * All rights reserved. 4219019Sgabor * 5219019Sgabor * Redistribution and use in source and binary forms, with or without 6219019Sgabor * modification, are permitted provided that the following conditions 7219019Sgabor * are met: 8219019Sgabor * 1. Redistributions of source code must retain the above copyright 9219019Sgabor * notice, this list of conditions and the following disclaimer. 10219019Sgabor * 2. Redistributions in binary form must reproduce the above copyright 11219019Sgabor * notice, this list of conditions and the following disclaimer in the 12219019Sgabor * documentation and/or other materials provided with the distribution. 13219019Sgabor * 14219019Sgabor * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR 15219019Sgabor * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16219019Sgabor * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17219019Sgabor * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, 18219019Sgabor * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19219019Sgabor * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20219019Sgabor * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21219019Sgabor * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22219019Sgabor * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23219019Sgabor * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24219019Sgabor * 25219019Sgabor * $FreeBSD: stable/10/contrib/libarchive/libarchive/archive_entry_private.h 302001 2016-06-17 22:40:10Z mm $ 26219019Sgabor */ 27219019Sgabor 28219019Sgabor#ifndef __LIBARCHIVE_BUILD 29219019Sgabor#error This header is only to be used internally to libarchive. 30219019Sgabor#endif 31219019Sgabor 32219019Sgabor#ifndef ARCHIVE_ENTRY_PRIVATE_H_INCLUDED 33219019Sgabor#define ARCHIVE_ENTRY_PRIVATE_H_INCLUDED 34219019Sgabor 35219019Sgabor#include "archive_acl_private.h" 36219019Sgabor#include "archive_string.h" 37219019Sgabor 38219019Sgaborstruct ae_xattr { 39219019Sgabor struct ae_xattr *next; 40219019Sgabor 41219019Sgabor char *name; 42219019Sgabor void *value; 43219019Sgabor size_t size; 44219019Sgabor}; 45219019Sgabor 46252582Speterstruct ae_sparse { 47252582Speter struct ae_sparse *next; 48250984Sed 49219019Sgabor int64_t offset; 50240365Sdim int64_t length; 51219019Sgabor}; 52219019Sgabor 53219019Sgabor/* 54219019Sgabor * Description of an archive entry. 55219019Sgabor * 56219019Sgabor * Basically, this is a "struct stat" with a few text fields added in. 57219019Sgabor * 58250984Sed * TODO: Add "comment", "charset", and possibly other entries 59219019Sgabor * that are supported by "pax interchange" format. However, GNU, ustar, 60219019Sgabor * cpio, and other variants don't support these features, so they're not an 61219019Sgabor * excruciatingly high priority right now. 62250984Sed * 63219019Sgabor * TODO: "pax interchange" format allows essentially arbitrary 64219019Sgabor * key/value attributes to be attached to any entry. Supporting 65238197Seadler * such extensions may make this library useful for special 66219019Sgabor * applications (e.g., a package manager could attach special 67219019Sgabor * package-management attributes to each entry). There are tricky 68219019Sgabor * API issues involved, so this is not going to happen until 69219019Sgabor * there's a real demand for it. 70219019Sgabor * 71219019Sgabor * TODO: Design a good API for handling sparse files. 72219019Sgabor */ 73219019Sgaborstruct archive_entry { 74219019Sgabor struct archive *archive; 75219019Sgabor 76219019Sgabor /* 77219019Sgabor * Note that ae_stat.st_mode & AE_IFMT can be 0! 78219019Sgabor * 79219019Sgabor * This occurs when the actual file type of the object is not 80219019Sgabor * in the archive. For example, 'tar' archives store 81219019Sgabor * hardlinks without marking the type of the underlying 82219019Sgabor * object. 83219019Sgabor */ 84219019Sgabor 85219019Sgabor /* 86219019Sgabor * We have a "struct aest" for holding file metadata rather than just 87219019Sgabor * a "struct stat" because on some platforms the "struct stat" has 88219019Sgabor * fields which are too narrow to hold the range of possible values; 89219019Sgabor * we don't want to lose information if we read an archive and write 90219019Sgabor * out another (e.g., in "tar -cf new.tar @old.tar"). 91219019Sgabor * 92219019Sgabor * The "stat" pointer points to some form of platform-specific struct 93219019Sgabor * stat; it is declared as a void * rather than a struct stat * as 94219019Sgabor * some platforms have multiple varieties of stat structures. 95219019Sgabor */ 96219019Sgabor void *stat; 97219019Sgabor int stat_valid; /* Set to 0 whenever a field in aest changes. */ 98219019Sgabor 99219019Sgabor struct aest { 100219019Sgabor int64_t aest_atime; 101219019Sgabor uint32_t aest_atime_nsec; 102219019Sgabor int64_t aest_ctime; 103 uint32_t aest_ctime_nsec; 104 int64_t aest_mtime; 105 uint32_t aest_mtime_nsec; 106 int64_t aest_birthtime; 107 uint32_t aest_birthtime_nsec; 108 int64_t aest_gid; 109 int64_t aest_ino; 110 uint32_t aest_nlink; 111 uint64_t aest_size; 112 int64_t aest_uid; 113 /* 114 * Because converting between device codes and 115 * major/minor values is platform-specific and 116 * inherently a bit risky, we only do that conversion 117 * lazily. That way, we will do a better job of 118 * preserving information in those cases where no 119 * conversion is actually required. 120 */ 121 int aest_dev_is_broken_down; 122 dev_t aest_dev; 123 dev_t aest_devmajor; 124 dev_t aest_devminor; 125 int aest_rdev_is_broken_down; 126 dev_t aest_rdev; 127 dev_t aest_rdevmajor; 128 dev_t aest_rdevminor; 129 } ae_stat; 130 131 int ae_set; /* bitmap of fields that are currently set */ 132#define AE_SET_HARDLINK 1 133#define AE_SET_SYMLINK 2 134#define AE_SET_ATIME 4 135#define AE_SET_CTIME 8 136#define AE_SET_MTIME 16 137#define AE_SET_BIRTHTIME 32 138#define AE_SET_SIZE 64 139#define AE_SET_INO 128 140#define AE_SET_DEV 256 141 142 /* 143 * Use aes here so that we get transparent mbs<->wcs conversions. 144 */ 145 struct archive_mstring ae_fflags_text; /* Text fflags per fflagstostr(3) */ 146 unsigned long ae_fflags_set; /* Bitmap fflags */ 147 unsigned long ae_fflags_clear; 148 struct archive_mstring ae_gname; /* Name of owning group */ 149 struct archive_mstring ae_hardlink; /* Name of target for hardlink */ 150 struct archive_mstring ae_pathname; /* Name of entry */ 151 struct archive_mstring ae_symlink; /* symlink contents */ 152 struct archive_mstring ae_uname; /* Name of owner */ 153 154 /* Not used within libarchive; useful for some clients. */ 155 struct archive_mstring ae_sourcepath; /* Path this entry is sourced from. */ 156 157#define AE_ENCRYPTION_NONE 0 158#define AE_ENCRYPTION_DATA 1 159#define AE_ENCRYPTION_METADATA 2 160 char encryption; 161 162 void *mac_metadata; 163 size_t mac_metadata_size; 164 165 /* ACL support. */ 166 struct archive_acl acl; 167 168 /* extattr support. */ 169 struct ae_xattr *xattr_head; 170 struct ae_xattr *xattr_p; 171 172 /* sparse support. */ 173 struct ae_sparse *sparse_head; 174 struct ae_sparse *sparse_tail; 175 struct ae_sparse *sparse_p; 176 177 /* Miscellaneous. */ 178 char strmode[12]; 179}; 180 181#endif /* ARCHIVE_ENTRY_PRIVATE_H_INCLUDED */ 182