1228753Smm/*- 2228753Smm * Copyright (c) 2003-2007 Tim Kientzle 3228753Smm * All rights reserved. 4228753Smm * 5228753Smm * Redistribution and use in source and binary forms, with or without 6228753Smm * modification, are permitted provided that the following conditions 7228753Smm * are met: 8228753Smm * 1. Redistributions of source code must retain the above copyright 9228753Smm * notice, this list of conditions and the following disclaimer. 10228753Smm * 2. Redistributions in binary form must reproduce the above copyright 11228753Smm * notice, this list of conditions and the following disclaimer in the 12228753Smm * documentation and/or other materials provided with the distribution. 13228753Smm * 14228753Smm * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR 15228753Smm * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16228753Smm * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17228753Smm * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, 18228753Smm * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19228753Smm * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20228753Smm * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21228753Smm * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22228753Smm * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23228753Smm * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24228753Smm * 25228763Smm * $FreeBSD: stable/10/contrib/libarchive/libarchive/archive_entry_private.h 368708 2020-12-16 22:25:40Z mm $ 26228753Smm */ 27228753Smm 28358090Smm#ifndef ARCHIVE_ENTRY_PRIVATE_H_INCLUDED 29358090Smm#define ARCHIVE_ENTRY_PRIVATE_H_INCLUDED 30358090Smm 31228753Smm#ifndef __LIBARCHIVE_BUILD 32228753Smm#error This header is only to be used internally to libarchive. 33228753Smm#endif 34228753Smm 35232153Smm#include "archive_acl_private.h" 36228753Smm#include "archive_string.h" 37228753Smm 38228753Smmstruct ae_xattr { 39228753Smm struct ae_xattr *next; 40228753Smm 41228753Smm char *name; 42228753Smm void *value; 43228753Smm size_t size; 44228753Smm}; 45228753Smm 46232153Smmstruct ae_sparse { 47232153Smm struct ae_sparse *next; 48232153Smm 49232153Smm int64_t offset; 50232153Smm int64_t length; 51232153Smm}; 52232153Smm 53368708Smmstruct ae_digest { 54368708Smm unsigned char md5[16]; 55368708Smm unsigned char rmd160[20]; 56368708Smm unsigned char sha1[20]; 57368708Smm unsigned char sha256[32]; 58368708Smm unsigned char sha384[48]; 59368708Smm unsigned char sha512[64]; 60368708Smm}; 61368708Smm 62228753Smm/* 63228753Smm * Description of an archive entry. 64228753Smm * 65228753Smm * Basically, this is a "struct stat" with a few text fields added in. 66228753Smm * 67228753Smm * TODO: Add "comment", "charset", and possibly other entries 68228753Smm * that are supported by "pax interchange" format. However, GNU, ustar, 69228753Smm * cpio, and other variants don't support these features, so they're not an 70228753Smm * excruciatingly high priority right now. 71228753Smm * 72228753Smm * TODO: "pax interchange" format allows essentially arbitrary 73228753Smm * key/value attributes to be attached to any entry. Supporting 74228753Smm * such extensions may make this library useful for special 75228753Smm * applications (e.g., a package manager could attach special 76228753Smm * package-management attributes to each entry). There are tricky 77228753Smm * API issues involved, so this is not going to happen until 78228753Smm * there's a real demand for it. 79228753Smm * 80228753Smm * TODO: Design a good API for handling sparse files. 81228753Smm */ 82228753Smmstruct archive_entry { 83232153Smm struct archive *archive; 84232153Smm 85228753Smm /* 86228753Smm * Note that ae_stat.st_mode & AE_IFMT can be 0! 87228753Smm * 88228753Smm * This occurs when the actual file type of the object is not 89228753Smm * in the archive. For example, 'tar' archives store 90228753Smm * hardlinks without marking the type of the underlying 91228753Smm * object. 92228753Smm */ 93228753Smm 94228753Smm /* 95232153Smm * We have a "struct aest" for holding file metadata rather than just 96232153Smm * a "struct stat" because on some platforms the "struct stat" has 97232153Smm * fields which are too narrow to hold the range of possible values; 98232153Smm * we don't want to lose information if we read an archive and write 99232153Smm * out another (e.g., in "tar -cf new.tar @old.tar"). 100232153Smm * 101232153Smm * The "stat" pointer points to some form of platform-specific struct 102232153Smm * stat; it is declared as a void * rather than a struct stat * as 103232153Smm * some platforms have multiple varieties of stat structures. 104228753Smm */ 105228753Smm void *stat; 106228753Smm int stat_valid; /* Set to 0 whenever a field in aest changes. */ 107228753Smm 108228753Smm struct aest { 109228753Smm int64_t aest_atime; 110228753Smm uint32_t aest_atime_nsec; 111228753Smm int64_t aest_ctime; 112228753Smm uint32_t aest_ctime_nsec; 113228753Smm int64_t aest_mtime; 114228753Smm uint32_t aest_mtime_nsec; 115228753Smm int64_t aest_birthtime; 116228753Smm uint32_t aest_birthtime_nsec; 117232153Smm int64_t aest_gid; 118228753Smm int64_t aest_ino; 119228753Smm uint32_t aest_nlink; 120228753Smm uint64_t aest_size; 121232153Smm int64_t aest_uid; 122228753Smm /* 123228753Smm * Because converting between device codes and 124228753Smm * major/minor values is platform-specific and 125228753Smm * inherently a bit risky, we only do that conversion 126228753Smm * lazily. That way, we will do a better job of 127228753Smm * preserving information in those cases where no 128228753Smm * conversion is actually required. 129228753Smm */ 130228753Smm int aest_dev_is_broken_down; 131228753Smm dev_t aest_dev; 132228753Smm dev_t aest_devmajor; 133228753Smm dev_t aest_devminor; 134228753Smm int aest_rdev_is_broken_down; 135228753Smm dev_t aest_rdev; 136228753Smm dev_t aest_rdevmajor; 137228753Smm dev_t aest_rdevminor; 138228753Smm } ae_stat; 139228753Smm 140228753Smm int ae_set; /* bitmap of fields that are currently set */ 141228753Smm#define AE_SET_HARDLINK 1 142228753Smm#define AE_SET_SYMLINK 2 143228753Smm#define AE_SET_ATIME 4 144228753Smm#define AE_SET_CTIME 8 145228753Smm#define AE_SET_MTIME 16 146228753Smm#define AE_SET_BIRTHTIME 32 147228753Smm#define AE_SET_SIZE 64 148232153Smm#define AE_SET_INO 128 149232153Smm#define AE_SET_DEV 256 150228753Smm 151228753Smm /* 152228753Smm * Use aes here so that we get transparent mbs<->wcs conversions. 153228753Smm */ 154232153Smm struct archive_mstring ae_fflags_text; /* Text fflags per fflagstostr(3) */ 155228753Smm unsigned long ae_fflags_set; /* Bitmap fflags */ 156228753Smm unsigned long ae_fflags_clear; 157232153Smm struct archive_mstring ae_gname; /* Name of owning group */ 158232153Smm struct archive_mstring ae_hardlink; /* Name of target for hardlink */ 159232153Smm struct archive_mstring ae_pathname; /* Name of entry */ 160232153Smm struct archive_mstring ae_symlink; /* symlink contents */ 161232153Smm struct archive_mstring ae_uname; /* Name of owner */ 162228753Smm 163228753Smm /* Not used within libarchive; useful for some clients. */ 164232153Smm struct archive_mstring ae_sourcepath; /* Path this entry is sourced from. */ 165228753Smm 166302001Smm#define AE_ENCRYPTION_NONE 0 167302001Smm#define AE_ENCRYPTION_DATA 1 168302001Smm#define AE_ENCRYPTION_METADATA 2 169302001Smm char encryption; 170302001Smm 171232153Smm void *mac_metadata; 172232153Smm size_t mac_metadata_size; 173232153Smm 174368708Smm /* Digest support. */ 175368708Smm struct ae_digest digest; 176368708Smm 177228753Smm /* ACL support. */ 178232153Smm struct archive_acl acl; 179228753Smm 180228753Smm /* extattr support. */ 181228753Smm struct ae_xattr *xattr_head; 182228753Smm struct ae_xattr *xattr_p; 183228753Smm 184232153Smm /* sparse support. */ 185232153Smm struct ae_sparse *sparse_head; 186232153Smm struct ae_sparse *sparse_tail; 187232153Smm struct ae_sparse *sparse_p; 188232153Smm 189228753Smm /* Miscellaneous. */ 190228753Smm char strmode[12]; 191348608Smm 192348608Smm /* Symlink type support */ 193348608Smm int ae_symlink_type; 194228753Smm}; 195228753Smm 196368708Smmint 197368708Smmarchive_entry_set_digest(struct archive_entry *entry, int type, 198368708Smm const unsigned char *digest); 199368708Smm 200228753Smm#endif /* ARCHIVE_ENTRY_PRIVATE_H_INCLUDED */ 201