Path: blob/master/Utilities/cmlibarchive/libarchive/archive_entry.h
3153 views
/*-1* Copyright (c) 2003-2008 Tim Kientzle2* Copyright (c) 2016 Martin Matuska3* All rights reserved.4*5* Redistribution and use in source and binary forms, with or without6* modification, are permitted provided that the following conditions7* are met:8* 1. Redistributions of source code must retain the above copyright9* notice, this list of conditions and the following disclaimer.10* 2. Redistributions in binary form must reproduce the above copyright11* notice, this list of conditions and the following disclaimer in the12* documentation and/or other materials provided with the distribution.13*14* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR15* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES16* 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, BUT19* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,20* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY21* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT22* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF23* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.24*/2526#ifndef ARCHIVE_ENTRY_H_INCLUDED27#define ARCHIVE_ENTRY_H_INCLUDED2829/* Note: Compiler will complain if this does not match archive.h! */30#define ARCHIVE_VERSION_NUMBER 30070093132/*33* Note: archive_entry.h is for use outside of libarchive; the34* configuration headers (config.h, archive_platform.h, etc.) are35* purely internal. Do NOT use HAVE_XXX configuration macros to36* control the behavior of this header! If you must conditionalize,37* use predefined compiler and/or platform macros.38*/3940#include <sys/types.h>41#include <stddef.h> /* for wchar_t */42#include <stdint.h>43#include <time.h>4445#if defined(_WIN32) && !defined(__CYGWIN__)46#include <windows.h>47#endif4849/* Get a suitable 64-bit integer type. */50#if !defined(__LA_INT64_T_DEFINED)51# if ARCHIVE_VERSION_NUMBER < 400000052#define __LA_INT64_T la_int64_t53# endif54#define __LA_INT64_T_DEFINED55# if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__WATCOMC__)56typedef __int64 la_int64_t;57# else58#include <unistd.h>59# if defined(_SCO_DS) || defined(__osf__)60typedef long long la_int64_t;61# else62typedef int64_t la_int64_t;63# endif64# endif65#endif6667/* The la_ssize_t should match the type used in 'struct stat' */68#if !defined(__LA_SSIZE_T_DEFINED)69/* Older code relied on the __LA_SSIZE_T macro; after 4.0 we'll switch to the typedef exclusively. */70# if ARCHIVE_VERSION_NUMBER < 400000071#define __LA_SSIZE_T la_ssize_t72# endif73#define __LA_SSIZE_T_DEFINED74# if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__WATCOMC__)75# if defined(_SSIZE_T_DEFINED) || defined(_SSIZE_T_)76typedef ssize_t la_ssize_t;77# elif defined(_WIN64)78typedef __int64 la_ssize_t;79# else80typedef long la_ssize_t;81# endif82# else83# include <unistd.h> /* ssize_t */84typedef ssize_t la_ssize_t;85# endif86#endif8788/* Get a suitable definition for mode_t */89#if ARCHIVE_VERSION_NUMBER >= 399900090/* Switch to plain 'int' for libarchive 4.0. It's less broken than 'mode_t' */91# define __LA_MODE_T int92#elif defined(_WIN32) && !defined(__CYGWIN__) && !defined(__BORLANDC__) && !defined(__WATCOMC__)93# define __LA_MODE_T unsigned short94#else95# define __LA_MODE_T mode_t96#endif9798/* Large file support for Android */99#if defined(__LIBARCHIVE_BUILD) && defined(__ANDROID__)100#include "android_lf.h"101#endif102103/*104* On Windows, define LIBARCHIVE_STATIC if you're building or using a105* .lib. The default here assumes you're building a DLL. Only106* libarchive source should ever define __LIBARCHIVE_BUILD.107*/108#if ((defined __WIN32__) || (defined _WIN32) || defined(__CYGWIN__)) && (!defined LIBARCHIVE_STATIC)109# ifdef __LIBARCHIVE_BUILD110# ifdef __GNUC__111# define __LA_DECL __attribute__((dllexport)) extern112# else113# define __LA_DECL __declspec(dllexport)114# endif115# else116# ifdef __GNUC__117# define __LA_DECL118# else119# define __LA_DECL __declspec(dllimport)120# endif121# endif122#elif defined __LIBARCHIVE_ENABLE_VISIBILITY123# define __LA_DECL __attribute__((visibility("default")))124#else125/* Static libraries on all platforms and shared libraries on non-Windows. */126# define __LA_DECL127#endif128129/* CMake uses some deprecated APIs to build with old libarchive versions. */130#define __LA_DEPRECATED131132#ifdef __cplusplus133extern "C" {134#endif135136/*137* Description of an archive entry.138*139* You can think of this as "struct stat" with some text fields added in.140*141* TODO: Add "comment", "charset", and possibly other entries that are142* supported by "pax interchange" format. However, GNU, ustar, cpio,143* and other variants don't support these features, so they're not an144* excruciatingly high priority right now.145*146* TODO: "pax interchange" format allows essentially arbitrary147* key/value attributes to be attached to any entry. Supporting148* such extensions may make this library useful for special149* applications (e.g., a package manager could attach special150* package-management attributes to each entry).151*/152struct archive;153struct archive_entry;154155/*156* File-type constants. These are returned from archive_entry_filetype()157* and passed to archive_entry_set_filetype().158*159* These values match S_XXX defines on every platform I've checked,160* including Windows, AIX, Linux, Solaris, and BSD. They're161* (re)defined here because platforms generally don't define the ones162* they don't support. For example, Windows doesn't define S_IFLNK or163* S_IFBLK. Instead of having a mass of conditional logic and system164* checks to define any S_XXX values that aren't supported locally,165* I've just defined a new set of such constants so that166* libarchive-based applications can manipulate and identify archive167* entries properly even if the hosting platform can't store them on168* disk.169*170* These values are also used directly within some portable formats,171* such as cpio. If you find a platform that varies from these, the172* correct solution is to leave these alone and translate from these173* portable values to platform-native values when entries are read from174* or written to disk.175*/176/*177* In libarchive 4.0, we can drop the casts here.178* They're needed to work around Borland C's broken mode_t.179*/180#define AE_IFMT ((__LA_MODE_T)0170000)181#define AE_IFREG ((__LA_MODE_T)0100000)182#define AE_IFLNK ((__LA_MODE_T)0120000)183#define AE_IFSOCK ((__LA_MODE_T)0140000)184#define AE_IFCHR ((__LA_MODE_T)0020000)185#define AE_IFBLK ((__LA_MODE_T)0060000)186#define AE_IFDIR ((__LA_MODE_T)0040000)187#define AE_IFIFO ((__LA_MODE_T)0010000)188189/*190* Symlink types191*/192#define AE_SYMLINK_TYPE_UNDEFINED 0193#define AE_SYMLINK_TYPE_FILE 1194#define AE_SYMLINK_TYPE_DIRECTORY 2195196/*197* Basic object manipulation198*/199200__LA_DECL struct archive_entry *archive_entry_clear(struct archive_entry *);201/* The 'clone' function does a deep copy; all of the strings are copied too. */202__LA_DECL struct archive_entry *archive_entry_clone(struct archive_entry *);203__LA_DECL void archive_entry_free(struct archive_entry *);204__LA_DECL struct archive_entry *archive_entry_new(void);205206/*207* This form of archive_entry_new2() will pull character-set208* conversion information from the specified archive handle. The209* older archive_entry_new(void) form is equivalent to calling210* archive_entry_new2(NULL) and will result in the use of an internal211* default character-set conversion.212*/213__LA_DECL struct archive_entry *archive_entry_new2(struct archive *);214215/*216* Retrieve fields from an archive_entry.217*218* There are a number of implicit conversions among these fields. For219* example, if a regular string field is set and you read the _w wide220* character field, the entry will implicitly convert narrow-to-wide221* using the current locale. Similarly, dev values are automatically222* updated when you write devmajor or devminor and vice versa.223*224* In addition, fields can be "set" or "unset." Unset string fields225* return NULL, non-string fields have _is_set() functions to test226* whether they've been set. You can "unset" a string field by227* assigning NULL; non-string fields have _unset() functions to228* unset them.229*230* Note: There is one ambiguity in the above; string fields will231* also return NULL when implicit character set conversions fail.232* This is usually what you want.233*/234__LA_DECL time_t archive_entry_atime(struct archive_entry *);235__LA_DECL long archive_entry_atime_nsec(struct archive_entry *);236__LA_DECL int archive_entry_atime_is_set(struct archive_entry *);237__LA_DECL time_t archive_entry_birthtime(struct archive_entry *);238__LA_DECL long archive_entry_birthtime_nsec(struct archive_entry *);239__LA_DECL int archive_entry_birthtime_is_set(struct archive_entry *);240__LA_DECL time_t archive_entry_ctime(struct archive_entry *);241__LA_DECL long archive_entry_ctime_nsec(struct archive_entry *);242__LA_DECL int archive_entry_ctime_is_set(struct archive_entry *);243__LA_DECL dev_t archive_entry_dev(struct archive_entry *);244__LA_DECL int archive_entry_dev_is_set(struct archive_entry *);245__LA_DECL dev_t archive_entry_devmajor(struct archive_entry *);246__LA_DECL dev_t archive_entry_devminor(struct archive_entry *);247__LA_DECL __LA_MODE_T archive_entry_filetype(struct archive_entry *);248__LA_DECL int archive_entry_filetype_is_set(struct archive_entry *);249__LA_DECL void archive_entry_fflags(struct archive_entry *,250unsigned long * /* set */,251unsigned long * /* clear */);252__LA_DECL const char *archive_entry_fflags_text(struct archive_entry *);253__LA_DECL la_int64_t archive_entry_gid(struct archive_entry *);254__LA_DECL int archive_entry_gid_is_set(struct archive_entry *);255__LA_DECL const char *archive_entry_gname(struct archive_entry *);256__LA_DECL const char *archive_entry_gname_utf8(struct archive_entry *);257__LA_DECL const wchar_t *archive_entry_gname_w(struct archive_entry *);258__LA_DECL void archive_entry_set_link_to_hardlink(struct archive_entry *);259__LA_DECL const char *archive_entry_hardlink(struct archive_entry *);260__LA_DECL const char *archive_entry_hardlink_utf8(struct archive_entry *);261__LA_DECL const wchar_t *archive_entry_hardlink_w(struct archive_entry *);262__LA_DECL int archive_entry_hardlink_is_set(struct archive_entry *);263__LA_DECL la_int64_t archive_entry_ino(struct archive_entry *);264__LA_DECL la_int64_t archive_entry_ino64(struct archive_entry *);265__LA_DECL int archive_entry_ino_is_set(struct archive_entry *);266__LA_DECL __LA_MODE_T archive_entry_mode(struct archive_entry *);267__LA_DECL time_t archive_entry_mtime(struct archive_entry *);268__LA_DECL long archive_entry_mtime_nsec(struct archive_entry *);269__LA_DECL int archive_entry_mtime_is_set(struct archive_entry *);270__LA_DECL unsigned int archive_entry_nlink(struct archive_entry *);271__LA_DECL const char *archive_entry_pathname(struct archive_entry *);272__LA_DECL const char *archive_entry_pathname_utf8(struct archive_entry *);273__LA_DECL const wchar_t *archive_entry_pathname_w(struct archive_entry *);274__LA_DECL __LA_MODE_T archive_entry_perm(struct archive_entry *);275__LA_DECL int archive_entry_perm_is_set(struct archive_entry *);276__LA_DECL int archive_entry_rdev_is_set(struct archive_entry *);277__LA_DECL dev_t archive_entry_rdev(struct archive_entry *);278__LA_DECL dev_t archive_entry_rdevmajor(struct archive_entry *);279__LA_DECL dev_t archive_entry_rdevminor(struct archive_entry *);280__LA_DECL const char *archive_entry_sourcepath(struct archive_entry *);281__LA_DECL const wchar_t *archive_entry_sourcepath_w(struct archive_entry *);282__LA_DECL la_int64_t archive_entry_size(struct archive_entry *);283__LA_DECL int archive_entry_size_is_set(struct archive_entry *);284__LA_DECL const char *archive_entry_strmode(struct archive_entry *);285__LA_DECL void archive_entry_set_link_to_symlink(struct archive_entry *);286__LA_DECL const char *archive_entry_symlink(struct archive_entry *);287__LA_DECL const char *archive_entry_symlink_utf8(struct archive_entry *);288__LA_DECL int archive_entry_symlink_type(struct archive_entry *);289__LA_DECL const wchar_t *archive_entry_symlink_w(struct archive_entry *);290__LA_DECL la_int64_t archive_entry_uid(struct archive_entry *);291__LA_DECL int archive_entry_uid_is_set(struct archive_entry *);292__LA_DECL const char *archive_entry_uname(struct archive_entry *);293__LA_DECL const char *archive_entry_uname_utf8(struct archive_entry *);294__LA_DECL const wchar_t *archive_entry_uname_w(struct archive_entry *);295__LA_DECL int archive_entry_is_data_encrypted(struct archive_entry *);296__LA_DECL int archive_entry_is_metadata_encrypted(struct archive_entry *);297__LA_DECL int archive_entry_is_encrypted(struct archive_entry *);298299/*300* Set fields in an archive_entry.301*302* Note: Before libarchive 2.4, there were 'set' and 'copy' versions303* of the string setters. 'copy' copied the actual string, 'set' just304* stored the pointer. In libarchive 2.4 and later, strings are305* always copied.306*/307308__LA_DECL void archive_entry_set_atime(struct archive_entry *, time_t, long);309__LA_DECL void archive_entry_unset_atime(struct archive_entry *);310#if defined(_WIN32) && !defined(__CYGWIN__)311__LA_DECL void archive_entry_copy_bhfi(struct archive_entry *, struct _BY_HANDLE_FILE_INFORMATION *);312#endif313__LA_DECL void archive_entry_set_birthtime(struct archive_entry *, time_t, long);314__LA_DECL void archive_entry_unset_birthtime(struct archive_entry *);315__LA_DECL void archive_entry_set_ctime(struct archive_entry *, time_t, long);316__LA_DECL void archive_entry_unset_ctime(struct archive_entry *);317__LA_DECL void archive_entry_set_dev(struct archive_entry *, dev_t);318__LA_DECL void archive_entry_set_devmajor(struct archive_entry *, dev_t);319__LA_DECL void archive_entry_set_devminor(struct archive_entry *, dev_t);320__LA_DECL void archive_entry_set_filetype(struct archive_entry *, unsigned int);321__LA_DECL void archive_entry_set_fflags(struct archive_entry *,322unsigned long /* set */, unsigned long /* clear */);323/* Returns pointer to start of first invalid token, or NULL if none. */324/* Note that all recognized tokens are processed, regardless. */325__LA_DECL const char *archive_entry_copy_fflags_text(struct archive_entry *,326const char *);327__LA_DECL const char *archive_entry_copy_fflags_text_len(struct archive_entry *,328const char *, size_t);329__LA_DECL const wchar_t *archive_entry_copy_fflags_text_w(struct archive_entry *,330const wchar_t *);331__LA_DECL void archive_entry_set_gid(struct archive_entry *, la_int64_t);332__LA_DECL void archive_entry_set_gname(struct archive_entry *, const char *);333__LA_DECL void archive_entry_set_gname_utf8(struct archive_entry *, const char *);334__LA_DECL void archive_entry_copy_gname(struct archive_entry *, const char *);335__LA_DECL void archive_entry_copy_gname_w(struct archive_entry *, const wchar_t *);336__LA_DECL int archive_entry_update_gname_utf8(struct archive_entry *, const char *);337__LA_DECL void archive_entry_set_hardlink(struct archive_entry *, const char *);338__LA_DECL void archive_entry_set_hardlink_utf8(struct archive_entry *, const char *);339__LA_DECL void archive_entry_copy_hardlink(struct archive_entry *, const char *);340__LA_DECL void archive_entry_copy_hardlink_w(struct archive_entry *, const wchar_t *);341__LA_DECL int archive_entry_update_hardlink_utf8(struct archive_entry *, const char *);342__LA_DECL void archive_entry_set_ino(struct archive_entry *, la_int64_t);343__LA_DECL void archive_entry_set_ino64(struct archive_entry *, la_int64_t);344__LA_DECL void archive_entry_set_link(struct archive_entry *, const char *);345__LA_DECL void archive_entry_set_link_utf8(struct archive_entry *, const char *);346__LA_DECL void archive_entry_copy_link(struct archive_entry *, const char *);347__LA_DECL void archive_entry_copy_link_w(struct archive_entry *, const wchar_t *);348__LA_DECL int archive_entry_update_link_utf8(struct archive_entry *, const char *);349__LA_DECL void archive_entry_set_mode(struct archive_entry *, __LA_MODE_T);350__LA_DECL void archive_entry_set_mtime(struct archive_entry *, time_t, long);351__LA_DECL void archive_entry_unset_mtime(struct archive_entry *);352__LA_DECL void archive_entry_set_nlink(struct archive_entry *, unsigned int);353__LA_DECL void archive_entry_set_pathname(struct archive_entry *, const char *);354__LA_DECL void archive_entry_set_pathname_utf8(struct archive_entry *, const char *);355__LA_DECL void archive_entry_copy_pathname(struct archive_entry *, const char *);356__LA_DECL void archive_entry_copy_pathname_w(struct archive_entry *, const wchar_t *);357__LA_DECL int archive_entry_update_pathname_utf8(struct archive_entry *, const char *);358__LA_DECL void archive_entry_set_perm(struct archive_entry *, __LA_MODE_T);359__LA_DECL void archive_entry_set_rdev(struct archive_entry *, dev_t);360__LA_DECL void archive_entry_set_rdevmajor(struct archive_entry *, dev_t);361__LA_DECL void archive_entry_set_rdevminor(struct archive_entry *, dev_t);362__LA_DECL void archive_entry_set_size(struct archive_entry *, la_int64_t);363__LA_DECL void archive_entry_unset_size(struct archive_entry *);364__LA_DECL void archive_entry_copy_sourcepath(struct archive_entry *, const char *);365__LA_DECL void archive_entry_copy_sourcepath_w(struct archive_entry *, const wchar_t *);366__LA_DECL void archive_entry_set_symlink(struct archive_entry *, const char *);367__LA_DECL void archive_entry_set_symlink_type(struct archive_entry *, int);368__LA_DECL void archive_entry_set_symlink_utf8(struct archive_entry *, const char *);369__LA_DECL void archive_entry_copy_symlink(struct archive_entry *, const char *);370__LA_DECL void archive_entry_copy_symlink_w(struct archive_entry *, const wchar_t *);371__LA_DECL int archive_entry_update_symlink_utf8(struct archive_entry *, const char *);372__LA_DECL void archive_entry_set_uid(struct archive_entry *, la_int64_t);373__LA_DECL void archive_entry_set_uname(struct archive_entry *, const char *);374__LA_DECL void archive_entry_set_uname_utf8(struct archive_entry *, const char *);375__LA_DECL void archive_entry_copy_uname(struct archive_entry *, const char *);376__LA_DECL void archive_entry_copy_uname_w(struct archive_entry *, const wchar_t *);377__LA_DECL int archive_entry_update_uname_utf8(struct archive_entry *, const char *);378__LA_DECL void archive_entry_set_is_data_encrypted(struct archive_entry *, char is_encrypted);379__LA_DECL void archive_entry_set_is_metadata_encrypted(struct archive_entry *, char is_encrypted);380/*381* Routines to bulk copy fields to/from a platform-native "struct382* stat." Libarchive used to just store a struct stat inside of each383* archive_entry object, but this created issues when trying to384* manipulate archives on systems different than the ones they were385* created on.386*387* TODO: On Linux and other LFS systems, provide both stat32 and388* stat64 versions of these functions and all of the macro glue so389* that archive_entry_stat is magically defined to390* archive_entry_stat32 or archive_entry_stat64 as appropriate.391*/392__LA_DECL const struct stat *archive_entry_stat(struct archive_entry *);393__LA_DECL void archive_entry_copy_stat(struct archive_entry *, const struct stat *);394395/*396* Storage for Mac OS-specific AppleDouble metadata information.397* Apple-format tar files store a separate binary blob containing398* encoded metadata with ACL, extended attributes, etc.399* This provides a place to store that blob.400*/401402__LA_DECL const void * archive_entry_mac_metadata(struct archive_entry *, size_t *);403__LA_DECL void archive_entry_copy_mac_metadata(struct archive_entry *, const void *, size_t);404405/*406* Digest routine. This is used to query the raw hex digest for the407* given entry. The type of digest is provided as an argument.408*/409#define ARCHIVE_ENTRY_DIGEST_MD5 0x00000001410#define ARCHIVE_ENTRY_DIGEST_RMD160 0x00000002411#define ARCHIVE_ENTRY_DIGEST_SHA1 0x00000003412#define ARCHIVE_ENTRY_DIGEST_SHA256 0x00000004413#define ARCHIVE_ENTRY_DIGEST_SHA384 0x00000005414#define ARCHIVE_ENTRY_DIGEST_SHA512 0x00000006415416__LA_DECL const unsigned char * archive_entry_digest(struct archive_entry *, int /* type */);417418/*419* ACL routines. This used to simply store and return text-format ACL420* strings, but that proved insufficient for a number of reasons:421* = clients need control over uname/uid and gname/gid mappings422* = there are many different ACL text formats423* = would like to be able to read/convert archives containing ACLs424* on platforms that lack ACL libraries425*426* This last point, in particular, forces me to implement a reasonably427* complete set of ACL support routines.428*/429430/*431* Permission bits.432*/433#define ARCHIVE_ENTRY_ACL_EXECUTE 0x00000001434#define ARCHIVE_ENTRY_ACL_WRITE 0x00000002435#define ARCHIVE_ENTRY_ACL_READ 0x00000004436#define ARCHIVE_ENTRY_ACL_READ_DATA 0x00000008437#define ARCHIVE_ENTRY_ACL_LIST_DIRECTORY 0x00000008438#define ARCHIVE_ENTRY_ACL_WRITE_DATA 0x00000010439#define ARCHIVE_ENTRY_ACL_ADD_FILE 0x00000010440#define ARCHIVE_ENTRY_ACL_APPEND_DATA 0x00000020441#define ARCHIVE_ENTRY_ACL_ADD_SUBDIRECTORY 0x00000020442#define ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS 0x00000040443#define ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS 0x00000080444#define ARCHIVE_ENTRY_ACL_DELETE_CHILD 0x00000100445#define ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES 0x00000200446#define ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES 0x00000400447#define ARCHIVE_ENTRY_ACL_DELETE 0x00000800448#define ARCHIVE_ENTRY_ACL_READ_ACL 0x00001000449#define ARCHIVE_ENTRY_ACL_WRITE_ACL 0x00002000450#define ARCHIVE_ENTRY_ACL_WRITE_OWNER 0x00004000451#define ARCHIVE_ENTRY_ACL_SYNCHRONIZE 0x00008000452453#define ARCHIVE_ENTRY_ACL_PERMS_POSIX1E \454(ARCHIVE_ENTRY_ACL_EXECUTE \455| ARCHIVE_ENTRY_ACL_WRITE \456| ARCHIVE_ENTRY_ACL_READ)457458#define ARCHIVE_ENTRY_ACL_PERMS_NFS4 \459(ARCHIVE_ENTRY_ACL_EXECUTE \460| ARCHIVE_ENTRY_ACL_READ_DATA \461| ARCHIVE_ENTRY_ACL_LIST_DIRECTORY \462| ARCHIVE_ENTRY_ACL_WRITE_DATA \463| ARCHIVE_ENTRY_ACL_ADD_FILE \464| ARCHIVE_ENTRY_ACL_APPEND_DATA \465| ARCHIVE_ENTRY_ACL_ADD_SUBDIRECTORY \466| ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS \467| ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS \468| ARCHIVE_ENTRY_ACL_DELETE_CHILD \469| ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES \470| ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES \471| ARCHIVE_ENTRY_ACL_DELETE \472| ARCHIVE_ENTRY_ACL_READ_ACL \473| ARCHIVE_ENTRY_ACL_WRITE_ACL \474| ARCHIVE_ENTRY_ACL_WRITE_OWNER \475| ARCHIVE_ENTRY_ACL_SYNCHRONIZE)476477/*478* Inheritance values (NFS4 ACLs only); included in permset.479*/480#define ARCHIVE_ENTRY_ACL_ENTRY_INHERITED 0x01000000481#define ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT 0x02000000482#define ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT 0x04000000483#define ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT 0x08000000484#define ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY 0x10000000485#define ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS 0x20000000486#define ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS 0x40000000487488#define ARCHIVE_ENTRY_ACL_INHERITANCE_NFS4 \489(ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT \490| ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT \491| ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT \492| ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY \493| ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS \494| ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS \495| ARCHIVE_ENTRY_ACL_ENTRY_INHERITED)496497/* We need to be able to specify combinations of these. */498#define ARCHIVE_ENTRY_ACL_TYPE_ACCESS 0x00000100 /* POSIX.1e only */499#define ARCHIVE_ENTRY_ACL_TYPE_DEFAULT 0x00000200 /* POSIX.1e only */500#define ARCHIVE_ENTRY_ACL_TYPE_ALLOW 0x00000400 /* NFS4 only */501#define ARCHIVE_ENTRY_ACL_TYPE_DENY 0x00000800 /* NFS4 only */502#define ARCHIVE_ENTRY_ACL_TYPE_AUDIT 0x00001000 /* NFS4 only */503#define ARCHIVE_ENTRY_ACL_TYPE_ALARM 0x00002000 /* NFS4 only */504#define ARCHIVE_ENTRY_ACL_TYPE_POSIX1E (ARCHIVE_ENTRY_ACL_TYPE_ACCESS \505| ARCHIVE_ENTRY_ACL_TYPE_DEFAULT)506#define ARCHIVE_ENTRY_ACL_TYPE_NFS4 (ARCHIVE_ENTRY_ACL_TYPE_ALLOW \507| ARCHIVE_ENTRY_ACL_TYPE_DENY \508| ARCHIVE_ENTRY_ACL_TYPE_AUDIT \509| ARCHIVE_ENTRY_ACL_TYPE_ALARM)510511/* Tag values mimic POSIX.1e */512#define ARCHIVE_ENTRY_ACL_USER 10001 /* Specified user. */513#define ARCHIVE_ENTRY_ACL_USER_OBJ 10002 /* User who owns the file. */514#define ARCHIVE_ENTRY_ACL_GROUP 10003 /* Specified group. */515#define ARCHIVE_ENTRY_ACL_GROUP_OBJ 10004 /* Group who owns the file. */516#define ARCHIVE_ENTRY_ACL_MASK 10005 /* Modify group access (POSIX.1e only) */517#define ARCHIVE_ENTRY_ACL_OTHER 10006 /* Public (POSIX.1e only) */518#define ARCHIVE_ENTRY_ACL_EVERYONE 10107 /* Everyone (NFS4 only) */519520/*521* Set the ACL by clearing it and adding entries one at a time.522* Unlike the POSIX.1e ACL routines, you must specify the type523* (access/default) for each entry. Internally, the ACL data is just524* a soup of entries. API calls here allow you to retrieve just the525* entries of interest. This design (which goes against the spirit of526* POSIX.1e) is useful for handling archive formats that combine527* default and access information in a single ACL list.528*/529__LA_DECL void archive_entry_acl_clear(struct archive_entry *);530__LA_DECL int archive_entry_acl_add_entry(struct archive_entry *,531int /* type */, int /* permset */, int /* tag */,532int /* qual */, const char * /* name */);533__LA_DECL int archive_entry_acl_add_entry_w(struct archive_entry *,534int /* type */, int /* permset */, int /* tag */,535int /* qual */, const wchar_t * /* name */);536537/*538* To retrieve the ACL, first "reset", then repeatedly ask for the539* "next" entry. The want_type parameter allows you to request only540* certain types of entries.541*/542__LA_DECL int archive_entry_acl_reset(struct archive_entry *, int /* want_type */);543__LA_DECL int archive_entry_acl_next(struct archive_entry *, int /* want_type */,544int * /* type */, int * /* permset */, int * /* tag */,545int * /* qual */, const char ** /* name */);546547/*548* Construct a text-format ACL. The flags argument is a bitmask that549* can include any of the following:550*551* Flags only for archive entries with POSIX.1e ACL:552* ARCHIVE_ENTRY_ACL_TYPE_ACCESS - Include POSIX.1e "access" entries.553* ARCHIVE_ENTRY_ACL_TYPE_DEFAULT - Include POSIX.1e "default" entries.554* ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT - Include "default:" before each555* default ACL entry.556* ARCHIVE_ENTRY_ACL_STYLE_SOLARIS - Output only one colon after "other" and557* "mask" entries.558*559* Flags only for archive entries with NFSv4 ACL:560* ARCHIVE_ENTRY_ACL_STYLE_COMPACT - Do not output the minus character for561* unset permissions and flags in NFSv4 ACL permission and flag fields562*563* Flags for for archive entries with POSIX.1e ACL or NFSv4 ACL:564* ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID - Include extra numeric ID field in565* each ACL entry.566* ARCHIVE_ENTRY_ACL_STYLE_SEPARATOR_COMMA - Separate entries with comma567* instead of newline.568*/569#define ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID 0x00000001570#define ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT 0x00000002571#define ARCHIVE_ENTRY_ACL_STYLE_SOLARIS 0x00000004572#define ARCHIVE_ENTRY_ACL_STYLE_SEPARATOR_COMMA 0x00000008573#define ARCHIVE_ENTRY_ACL_STYLE_COMPACT 0x00000010574575__LA_DECL wchar_t *archive_entry_acl_to_text_w(struct archive_entry *,576la_ssize_t * /* len */, int /* flags */);577__LA_DECL char *archive_entry_acl_to_text(struct archive_entry *,578la_ssize_t * /* len */, int /* flags */);579__LA_DECL int archive_entry_acl_from_text_w(struct archive_entry *,580const wchar_t * /* wtext */, int /* type */);581__LA_DECL int archive_entry_acl_from_text(struct archive_entry *,582const char * /* text */, int /* type */);583584/* Deprecated constants */585#define OLD_ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID 1024586#define OLD_ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT 2048587588/* Deprecated functions */589__LA_DECL const wchar_t *archive_entry_acl_text_w(struct archive_entry *,590int /* flags */) __LA_DEPRECATED;591__LA_DECL const char *archive_entry_acl_text(struct archive_entry *,592int /* flags */) __LA_DEPRECATED;593594/* Return bitmask of ACL types in an archive entry */595__LA_DECL int archive_entry_acl_types(struct archive_entry *);596597/* Return a count of entries matching 'want_type' */598__LA_DECL int archive_entry_acl_count(struct archive_entry *, int /* want_type */);599600/* Return an opaque ACL object. */601/* There's not yet anything clients can actually do with this... */602struct archive_acl;603__LA_DECL struct archive_acl *archive_entry_acl(struct archive_entry *);604605/*606* extended attributes607*/608609__LA_DECL void archive_entry_xattr_clear(struct archive_entry *);610__LA_DECL void archive_entry_xattr_add_entry(struct archive_entry *,611const char * /* name */, const void * /* value */,612size_t /* size */);613614/*615* To retrieve the xattr list, first "reset", then repeatedly ask for the616* "next" entry.617*/618619__LA_DECL int archive_entry_xattr_count(struct archive_entry *);620__LA_DECL int archive_entry_xattr_reset(struct archive_entry *);621__LA_DECL int archive_entry_xattr_next(struct archive_entry *,622const char ** /* name */, const void ** /* value */, size_t *);623624/*625* sparse626*/627628__LA_DECL void archive_entry_sparse_clear(struct archive_entry *);629__LA_DECL void archive_entry_sparse_add_entry(struct archive_entry *,630la_int64_t /* offset */, la_int64_t /* length */);631632/*633* To retrieve the xattr list, first "reset", then repeatedly ask for the634* "next" entry.635*/636637__LA_DECL int archive_entry_sparse_count(struct archive_entry *);638__LA_DECL int archive_entry_sparse_reset(struct archive_entry *);639__LA_DECL int archive_entry_sparse_next(struct archive_entry *,640la_int64_t * /* offset */, la_int64_t * /* length */);641642/*643* Utility to match up hardlinks.644*645* The 'struct archive_entry_linkresolver' is a cache of archive entries646* for files with multiple links. Here's how to use it:647* 1. Create a lookup object with archive_entry_linkresolver_new()648* 2. Tell it the archive format you're using.649* 3. Hand each archive_entry to archive_entry_linkify().650* That function will return 0, 1, or 2 entries that should651* be written.652* 4. Call archive_entry_linkify(resolver, NULL) until653* no more entries are returned.654* 5. Call archive_entry_linkresolver_free(resolver) to free resources.655*656* The entries returned have their hardlink and size fields updated657* appropriately. If an entry is passed in that does not refer to658* a file with multiple links, it is returned unchanged. The intention659* is that you should be able to simply filter all entries through660* this machine.661*662* To make things more efficient, be sure that each entry has a valid663* nlinks value. The hardlink cache uses this to track when all links664* have been found. If the nlinks value is zero, it will keep every665* name in the cache indefinitely, which can use a lot of memory.666*667* Note that archive_entry_size() is reset to zero if the file668* body should not be written to the archive. Pay attention!669*/670struct archive_entry_linkresolver;671672/*673* There are three different strategies for marking hardlinks.674* The descriptions below name them after the best-known675* formats that rely on each strategy:676*677* "Old cpio" is the simplest, it always returns any entry unmodified.678* As far as I know, only cpio formats use this. Old cpio archives679* store every link with the full body; the onus is on the dearchiver680* to detect and properly link the files as they are restored.681* "tar" is also pretty simple; it caches a copy the first time it sees682* any link. Subsequent appearances are modified to be hardlink683* references to the first one without any body. Used by all tar684* formats, although the newest tar formats permit the "old cpio" strategy685* as well. This strategy is very simple for the dearchiver,686* and reasonably straightforward for the archiver.687* "new cpio" is trickier. It stores the body only with the last688* occurrence. The complication is that we might not689* see every link to a particular file in a single session, so690* there's no easy way to know when we've seen the last occurrence.691* The solution here is to queue one link until we see the next.692* At the end of the session, you can enumerate any remaining693* entries by calling archive_entry_linkify(NULL) and store those694* bodies. If you have a file with three links l1, l2, and l3,695* you'll get the following behavior if you see all three links:696* linkify(l1) => NULL (the resolver stores l1 internally)697* linkify(l2) => l1 (resolver stores l2, you write l1)698* linkify(l3) => l2, l3 (all links seen, you can write both).699* If you only see l1 and l2, you'll get this behavior:700* linkify(l1) => NULL701* linkify(l2) => l1702* linkify(NULL) => l2 (at end, you retrieve remaining links)703* As the name suggests, this strategy is used by newer cpio variants.704* It's noticeably more complex for the archiver, slightly more complex705* for the dearchiver than the tar strategy, but makes it straightforward706* to restore a file using any link by simply continuing to scan until707* you see a link that is stored with a body. In contrast, the tar708* strategy requires you to rescan the archive from the beginning to709* correctly extract an arbitrary link.710*/711712__LA_DECL struct archive_entry_linkresolver *archive_entry_linkresolver_new(void);713__LA_DECL void archive_entry_linkresolver_set_strategy(714struct archive_entry_linkresolver *, int /* format_code */);715__LA_DECL void archive_entry_linkresolver_free(struct archive_entry_linkresolver *);716__LA_DECL void archive_entry_linkify(struct archive_entry_linkresolver *,717struct archive_entry **, struct archive_entry **);718__LA_DECL struct archive_entry *archive_entry_partial_links(719struct archive_entry_linkresolver *res, unsigned int *links);720#ifdef __cplusplus721}722#endif723724/* This is meaningless outside of this header. */725#undef __LA_DECL726727#endif /* !ARCHIVE_ENTRY_H_INCLUDED */728729730