Path: blob/master/Utilities/cmlibarchive/libarchive/archive_entry_private.h
3153 views
/*-1* Copyright (c) 2003-2007 Tim Kientzle2* All rights reserved.3*4* Redistribution and use in source and binary forms, with or without5* modification, are permitted provided that the following conditions6* are met:7* 1. Redistributions of source code must retain the above copyright8* notice, this list of conditions and the following disclaimer.9* 2. Redistributions in binary form must reproduce the above copyright10* notice, this list of conditions and the following disclaimer in the11* documentation and/or other materials provided with the distribution.12*13* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR14* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES15* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.16* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,17* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT18* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,19* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY20* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT21* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF22* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.23*/2425#ifndef ARCHIVE_ENTRY_PRIVATE_H_INCLUDED26#define ARCHIVE_ENTRY_PRIVATE_H_INCLUDED2728#ifndef __LIBARCHIVE_BUILD29#error This header is only to be used internally to libarchive.30#endif3132#include "archive_acl_private.h"33#include "archive_string.h"3435struct ae_xattr {36struct ae_xattr *next;3738char *name;39void *value;40size_t size;41};4243struct ae_sparse {44struct ae_sparse *next;4546int64_t offset;47int64_t length;48};4950struct ae_digest {51unsigned char md5[16];52unsigned char rmd160[20];53unsigned char sha1[20];54unsigned char sha256[32];55unsigned char sha384[48];56unsigned char sha512[64];57};5859/*60* Description of an archive entry.61*62* Basically, this is a "struct stat" with a few text fields added in.63*64* TODO: Add "comment", "charset", and possibly other entries65* that are supported by "pax interchange" format. However, GNU, ustar,66* cpio, and other variants don't support these features, so they're not an67* excruciatingly high priority right now.68*69* TODO: "pax interchange" format allows essentially arbitrary70* key/value attributes to be attached to any entry. Supporting71* such extensions may make this library useful for special72* applications (e.g., a package manager could attach special73* package-management attributes to each entry). There are tricky74* API issues involved, so this is not going to happen until75* there's a real demand for it.76*77* TODO: Design a good API for handling sparse files.78*/79struct archive_entry {80struct archive *archive;8182/*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 not86* in the archive. For example, 'tar' archives store87* hardlinks without marking the type of the underlying88* object.89*/9091/*92* We have a "struct aest" for holding file metadata rather than just93* a "struct stat" because on some platforms the "struct stat" has94* fields which are too narrow to hold the range of possible values;95* we don't want to lose information if we read an archive and write96* out another (e.g., in "tar -cf new.tar @old.tar").97*98* The "stat" pointer points to some form of platform-specific struct99* stat; it is declared as a void * rather than a struct stat * as100* some platforms have multiple varieties of stat structures.101*/102void *stat;103int stat_valid; /* Set to 0 whenever a field in aest changes. */104105struct aest {106int64_t aest_atime;107uint32_t aest_atime_nsec;108int64_t aest_ctime;109uint32_t aest_ctime_nsec;110int64_t aest_mtime;111uint32_t aest_mtime_nsec;112int64_t aest_birthtime;113uint32_t aest_birthtime_nsec;114int64_t aest_gid;115int64_t aest_ino;116uint32_t aest_nlink;117uint64_t aest_size;118int64_t aest_uid;119/*120* Because converting between device codes and121* major/minor values is platform-specific and122* inherently a bit risky, we only do that conversion123* lazily. That way, we will do a better job of124* preserving information in those cases where no125* conversion is actually required.126*/127int aest_dev_is_broken_down;128dev_t aest_dev;129dev_t aest_devmajor;130dev_t aest_devminor;131int aest_rdev_is_broken_down;132dev_t aest_rdev;133dev_t aest_rdevmajor;134dev_t aest_rdevminor;135} ae_stat;136137int ae_set; /* bitmap of fields that are currently set */138#define AE_SET_HARDLINK 1139#define AE_SET_SYMLINK 2140#define AE_SET_ATIME 4141#define AE_SET_CTIME 8142#define AE_SET_MTIME 16143#define AE_SET_BIRTHTIME 32144#define AE_SET_SIZE 64145#define AE_SET_INO 128146#define AE_SET_DEV 256147#define AE_SET_PERM 512148#define AE_SET_FILETYPE 1024149#define AE_SET_UID 2048150#define AE_SET_GID 4096151#define AE_SET_RDEV 8192152153/*154* Use aes here so that we get transparent mbs<->wcs conversions.155*/156struct archive_mstring ae_fflags_text; /* Text fflags per fflagstostr(3) */157unsigned long ae_fflags_set; /* Bitmap fflags */158unsigned long ae_fflags_clear;159struct archive_mstring ae_gname; /* Name of owning group */160struct archive_mstring ae_linkname; /* Name of target for hardlink or symlink */161struct archive_mstring ae_pathname; /* Name of entry */162struct archive_mstring ae_uname; /* Name of owner */163164/* Not used within libarchive; useful for some clients. */165struct archive_mstring ae_sourcepath; /* Path this entry is sourced from. */166167#define AE_ENCRYPTION_NONE 0168#define AE_ENCRYPTION_DATA 1169#define AE_ENCRYPTION_METADATA 2170char encryption;171172void *mac_metadata;173size_t mac_metadata_size;174175/* Digest support. */176struct ae_digest digest;177178/* ACL support. */179struct archive_acl acl;180181/* extattr support. */182struct ae_xattr *xattr_head;183struct ae_xattr *xattr_p;184185/* sparse support. */186struct ae_sparse *sparse_head;187struct ae_sparse *sparse_tail;188struct ae_sparse *sparse_p;189190/* Miscellaneous. */191char strmode[12];192193/* Symlink type support */194int ae_symlink_type;195};196197int198archive_entry_set_digest(struct archive_entry *entry, int type,199const unsigned char *digest);200201#endif /* ARCHIVE_ENTRY_PRIVATE_H_INCLUDED */202203204