1228753Smm/*- 2228753Smm * Copyright (c) 2003-2008 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 * 25229592Smm * $FreeBSD$ 26228753Smm */ 27228753Smm 28228753Smm#ifndef ARCHIVE_ENTRY_H_INCLUDED 29228753Smm#define ARCHIVE_ENTRY_H_INCLUDED 30228753Smm 31228753Smm/* 32228753Smm * Note: archive_entry.h is for use outside of libarchive; the 33228753Smm * configuration headers (config.h, archive_platform.h, etc.) are 34228753Smm * purely internal. Do NOT use HAVE_XXX configuration macros to 35228753Smm * control the behavior of this header! If you must conditionalize, 36228753Smm * use predefined compiler and/or platform macros. 37228753Smm */ 38228753Smm 39228753Smm#include <sys/types.h> 40228753Smm#include <stddef.h> /* for wchar_t */ 41228753Smm#include <time.h> 42228753Smm 43228753Smm#if defined(_WIN32) && !defined(__CYGWIN__) 44228753Smm#include <windows.h> 45228753Smm#endif 46228753Smm 47228753Smm/* Get appropriate definitions of standard POSIX-style types. */ 48228753Smm/* These should match the types used in 'struct stat' */ 49228753Smm#if defined(_WIN32) && !defined(__CYGWIN__) 50228753Smm#define __LA_INT64_T __int64 51228753Smm# if defined(__BORLANDC__) 52228753Smm# define __LA_UID_T uid_t 53228753Smm# define __LA_GID_T gid_t 54228753Smm# define __LA_DEV_T dev_t 55228753Smm# define __LA_MODE_T mode_t 56228753Smm# else 57228753Smm# define __LA_UID_T short 58228753Smm# define __LA_GID_T short 59228753Smm# define __LA_DEV_T unsigned int 60228753Smm# define __LA_MODE_T unsigned short 61228753Smm# endif 62228753Smm#else 63228753Smm#include <unistd.h> 64228753Smm#define __LA_INT64_T int64_t 65228753Smm#define __LA_UID_T uid_t 66228753Smm#define __LA_GID_T gid_t 67228753Smm#define __LA_DEV_T dev_t 68228753Smm#define __LA_MODE_T mode_t 69228753Smm#endif 70228753Smm 71228753Smm/* 72228753Smm * XXX Is this defined for all Windows compilers? If so, in what 73228753Smm * header? It would be nice to remove the __LA_INO_T indirection and 74228753Smm * just use plain ino_t everywhere. Likewise for the other types just 75228753Smm * above. 76228753Smm */ 77228753Smm#define __LA_INO_T ino_t 78228753Smm 79228753Smm 80228753Smm/* 81228753Smm * On Windows, define LIBARCHIVE_STATIC if you're building or using a 82228753Smm * .lib. The default here assumes you're building a DLL. Only 83228753Smm * libarchive source should ever define __LIBARCHIVE_BUILD. 84228753Smm */ 85228753Smm#if ((defined __WIN32__) || (defined _WIN32) || defined(__CYGWIN__)) && (!defined LIBARCHIVE_STATIC) 86228753Smm# ifdef __LIBARCHIVE_BUILD 87228753Smm# ifdef __GNUC__ 88228753Smm# define __LA_DECL __attribute__((dllexport)) extern 89228753Smm# else 90228753Smm# define __LA_DECL __declspec(dllexport) 91228753Smm# endif 92228753Smm# else 93228753Smm# ifdef __GNUC__ 94228753Smm# define __LA_DECL __attribute__((dllimport)) extern 95228753Smm# else 96228753Smm# define __LA_DECL __declspec(dllimport) 97228753Smm# endif 98228753Smm# endif 99228753Smm#else 100228753Smm/* Static libraries on all platforms and shared libraries on non-Windows. */ 101228753Smm# define __LA_DECL 102228753Smm#endif 103228753Smm 104228753Smm#ifdef __cplusplus 105228753Smmextern "C" { 106228753Smm#endif 107228753Smm 108228753Smm/* 109228753Smm * Description of an archive entry. 110228753Smm * 111228753Smm * You can think of this as "struct stat" with some text fields added in. 112228753Smm * 113228753Smm * TODO: Add "comment", "charset", and possibly other entries that are 114228753Smm * supported by "pax interchange" format. However, GNU, ustar, cpio, 115228753Smm * and other variants don't support these features, so they're not an 116228753Smm * excruciatingly high priority right now. 117228753Smm * 118228753Smm * TODO: "pax interchange" format allows essentially arbitrary 119228753Smm * key/value attributes to be attached to any entry. Supporting 120228753Smm * such extensions may make this library useful for special 121228753Smm * applications (e.g., a package manager could attach special 122228753Smm * package-management attributes to each entry). 123228753Smm */ 124228753Smmstruct archive_entry; 125228753Smm 126228753Smm/* 127228753Smm * File-type constants. These are returned from archive_entry_filetype() 128228753Smm * and passed to archive_entry_set_filetype(). 129228753Smm * 130228753Smm * These values match S_XXX defines on every platform I've checked, 131228753Smm * including Windows, AIX, Linux, Solaris, and BSD. They're 132228753Smm * (re)defined here because platforms generally don't define the ones 133228753Smm * they don't support. For example, Windows doesn't define S_IFLNK or 134228753Smm * S_IFBLK. Instead of having a mass of conditional logic and system 135228753Smm * checks to define any S_XXX values that aren't supported locally, 136228753Smm * I've just defined a new set of such constants so that 137228753Smm * libarchive-based applications can manipulate and identify archive 138228753Smm * entries properly even if the hosting platform can't store them on 139228753Smm * disk. 140228753Smm * 141228753Smm * These values are also used directly within some portable formats, 142228753Smm * such as cpio. If you find a platform that varies from these, the 143228753Smm * correct solution is to leave these alone and translate from these 144228753Smm * portable values to platform-native values when entries are read from 145228753Smm * or written to disk. 146228753Smm */ 147228753Smm#define AE_IFMT 0170000 148228753Smm#define AE_IFREG 0100000 149228753Smm#define AE_IFLNK 0120000 150228753Smm#define AE_IFSOCK 0140000 151228753Smm#define AE_IFCHR 0020000 152228753Smm#define AE_IFBLK 0060000 153228753Smm#define AE_IFDIR 0040000 154228753Smm#define AE_IFIFO 0010000 155228753Smm 156228753Smm/* 157228753Smm * Basic object manipulation 158228753Smm */ 159228753Smm 160228753Smm__LA_DECL struct archive_entry *archive_entry_clear(struct archive_entry *); 161228753Smm/* The 'clone' function does a deep copy; all of the strings are copied too. */ 162228753Smm__LA_DECL struct archive_entry *archive_entry_clone(struct archive_entry *); 163228753Smm__LA_DECL void archive_entry_free(struct archive_entry *); 164228753Smm__LA_DECL struct archive_entry *archive_entry_new(void); 165228753Smm 166228753Smm/* 167228753Smm * Retrieve fields from an archive_entry. 168228753Smm * 169228753Smm * There are a number of implicit conversions among these fields. For 170228753Smm * example, if a regular string field is set and you read the _w wide 171228753Smm * character field, the entry will implicitly convert narrow-to-wide 172228753Smm * using the current locale. Similarly, dev values are automatically 173228753Smm * updated when you write devmajor or devminor and vice versa. 174228753Smm * 175228753Smm * In addition, fields can be "set" or "unset." Unset string fields 176228753Smm * return NULL, non-string fields have _is_set() functions to test 177228753Smm * whether they've been set. You can "unset" a string field by 178228753Smm * assigning NULL; non-string fields have _unset() functions to 179228753Smm * unset them. 180228753Smm * 181228753Smm * Note: There is one ambiguity in the above; string fields will 182228753Smm * also return NULL when implicit character set conversions fail. 183228753Smm * This is usually what you want. 184228753Smm */ 185228753Smm__LA_DECL time_t archive_entry_atime(struct archive_entry *); 186228753Smm__LA_DECL long archive_entry_atime_nsec(struct archive_entry *); 187228753Smm__LA_DECL int archive_entry_atime_is_set(struct archive_entry *); 188228753Smm__LA_DECL time_t archive_entry_birthtime(struct archive_entry *); 189228753Smm__LA_DECL long archive_entry_birthtime_nsec(struct archive_entry *); 190228753Smm__LA_DECL int archive_entry_birthtime_is_set(struct archive_entry *); 191228753Smm__LA_DECL time_t archive_entry_ctime(struct archive_entry *); 192228753Smm__LA_DECL long archive_entry_ctime_nsec(struct archive_entry *); 193228753Smm__LA_DECL int archive_entry_ctime_is_set(struct archive_entry *); 194228753Smm__LA_DECL dev_t archive_entry_dev(struct archive_entry *); 195228753Smm__LA_DECL dev_t archive_entry_devmajor(struct archive_entry *); 196228753Smm__LA_DECL dev_t archive_entry_devminor(struct archive_entry *); 197228753Smm__LA_DECL __LA_MODE_T archive_entry_filetype(struct archive_entry *); 198228753Smm__LA_DECL void archive_entry_fflags(struct archive_entry *, 199228753Smm unsigned long * /* set */, 200228753Smm unsigned long * /* clear */); 201228753Smm__LA_DECL const char *archive_entry_fflags_text(struct archive_entry *); 202228753Smm__LA_DECL __LA_GID_T archive_entry_gid(struct archive_entry *); 203228753Smm__LA_DECL const char *archive_entry_gname(struct archive_entry *); 204228753Smm__LA_DECL const wchar_t *archive_entry_gname_w(struct archive_entry *); 205228753Smm__LA_DECL const char *archive_entry_hardlink(struct archive_entry *); 206228753Smm__LA_DECL const wchar_t *archive_entry_hardlink_w(struct archive_entry *); 207228753Smm__LA_DECL __LA_INO_T archive_entry_ino(struct archive_entry *); 208228753Smm__LA_DECL __LA_INT64_T archive_entry_ino64(struct archive_entry *); 209228753Smm__LA_DECL __LA_MODE_T archive_entry_mode(struct archive_entry *); 210228753Smm__LA_DECL time_t archive_entry_mtime(struct archive_entry *); 211228753Smm__LA_DECL long archive_entry_mtime_nsec(struct archive_entry *); 212228753Smm__LA_DECL int archive_entry_mtime_is_set(struct archive_entry *); 213228753Smm__LA_DECL unsigned int archive_entry_nlink(struct archive_entry *); 214228753Smm__LA_DECL const char *archive_entry_pathname(struct archive_entry *); 215228753Smm__LA_DECL const wchar_t *archive_entry_pathname_w(struct archive_entry *); 216228753Smm__LA_DECL dev_t archive_entry_rdev(struct archive_entry *); 217228753Smm__LA_DECL dev_t archive_entry_rdevmajor(struct archive_entry *); 218228753Smm__LA_DECL dev_t archive_entry_rdevminor(struct archive_entry *); 219228753Smm__LA_DECL const char *archive_entry_sourcepath(struct archive_entry *); 220228753Smm__LA_DECL __LA_INT64_T archive_entry_size(struct archive_entry *); 221228753Smm__LA_DECL int archive_entry_size_is_set(struct archive_entry *); 222228753Smm__LA_DECL const char *archive_entry_strmode(struct archive_entry *); 223228753Smm__LA_DECL const char *archive_entry_symlink(struct archive_entry *); 224228753Smm__LA_DECL const wchar_t *archive_entry_symlink_w(struct archive_entry *); 225228753Smm__LA_DECL __LA_UID_T archive_entry_uid(struct archive_entry *); 226228753Smm__LA_DECL const char *archive_entry_uname(struct archive_entry *); 227228753Smm__LA_DECL const wchar_t *archive_entry_uname_w(struct archive_entry *); 228228753Smm 229228753Smm/* 230228753Smm * Set fields in an archive_entry. 231228753Smm * 232228753Smm * Note that string 'set' functions do not copy the string, only the pointer. 233228753Smm * In contrast, 'copy' functions do copy the object pointed to. 234228753Smm * 235228753Smm * Note: As of libarchive 2.4, 'set' functions do copy the string and 236228753Smm * are therefore exact synonyms for the 'copy' versions. The 'copy' 237228753Smm * names will be retired in libarchive 3.0. 238228753Smm */ 239228753Smm 240228753Smm__LA_DECL void archive_entry_set_atime(struct archive_entry *, time_t, long); 241228753Smm__LA_DECL void archive_entry_unset_atime(struct archive_entry *); 242228753Smm#if defined(_WIN32) && !defined(__CYGWIN__) 243228753Smm__LA_DECL void archive_entry_copy_bhfi(struct archive_entry *, 244228753Smm BY_HANDLE_FILE_INFORMATION *); 245228753Smm#endif 246228753Smm__LA_DECL void archive_entry_set_birthtime(struct archive_entry *, time_t, long); 247228753Smm__LA_DECL void archive_entry_unset_birthtime(struct archive_entry *); 248228753Smm__LA_DECL void archive_entry_set_ctime(struct archive_entry *, time_t, long); 249228753Smm__LA_DECL void archive_entry_unset_ctime(struct archive_entry *); 250228753Smm__LA_DECL void archive_entry_set_dev(struct archive_entry *, dev_t); 251228753Smm__LA_DECL void archive_entry_set_devmajor(struct archive_entry *, dev_t); 252228753Smm__LA_DECL void archive_entry_set_devminor(struct archive_entry *, dev_t); 253228753Smm__LA_DECL void archive_entry_set_filetype(struct archive_entry *, unsigned int); 254228753Smm__LA_DECL void archive_entry_set_fflags(struct archive_entry *, 255228753Smm unsigned long /* set */, unsigned long /* clear */); 256228753Smm/* Returns pointer to start of first invalid token, or NULL if none. */ 257228753Smm/* Note that all recognized tokens are processed, regardless. */ 258228753Smm__LA_DECL const char *archive_entry_copy_fflags_text(struct archive_entry *, 259228753Smm const char *); 260228753Smm__LA_DECL const wchar_t *archive_entry_copy_fflags_text_w(struct archive_entry *, 261228753Smm const wchar_t *); 262228753Smm__LA_DECL void archive_entry_set_gid(struct archive_entry *, __LA_GID_T); 263228753Smm__LA_DECL void archive_entry_set_gname(struct archive_entry *, const char *); 264228753Smm__LA_DECL void archive_entry_copy_gname(struct archive_entry *, const char *); 265228753Smm__LA_DECL void archive_entry_copy_gname_w(struct archive_entry *, const wchar_t *); 266228753Smm__LA_DECL int archive_entry_update_gname_utf8(struct archive_entry *, const char *); 267228753Smm__LA_DECL void archive_entry_set_hardlink(struct archive_entry *, const char *); 268228753Smm__LA_DECL void archive_entry_copy_hardlink(struct archive_entry *, const char *); 269228753Smm__LA_DECL void archive_entry_copy_hardlink_w(struct archive_entry *, const wchar_t *); 270228753Smm__LA_DECL int archive_entry_update_hardlink_utf8(struct archive_entry *, const char *); 271228753Smm#if ARCHIVE_VERSION_NUMBER >= 3000000 272228753Smm/* Starting with libarchive 3.0, this will be synonym for ino64. */ 273228753Smm__LA_DECL void archive_entry_set_ino(struct archive_entry *, __LA_INT64_T); 274228753Smm#else 275228753Smm__LA_DECL void archive_entry_set_ino(struct archive_entry *, unsigned long); 276228753Smm#endif 277228753Smm__LA_DECL void archive_entry_set_ino64(struct archive_entry *, __LA_INT64_T); 278228753Smm__LA_DECL void archive_entry_set_link(struct archive_entry *, const char *); 279228753Smm__LA_DECL void archive_entry_copy_link(struct archive_entry *, const char *); 280228753Smm__LA_DECL void archive_entry_copy_link_w(struct archive_entry *, const wchar_t *); 281228753Smm__LA_DECL int archive_entry_update_link_utf8(struct archive_entry *, const char *); 282228753Smm__LA_DECL void archive_entry_set_mode(struct archive_entry *, __LA_MODE_T); 283228753Smm__LA_DECL void archive_entry_set_mtime(struct archive_entry *, time_t, long); 284228753Smm__LA_DECL void archive_entry_unset_mtime(struct archive_entry *); 285228753Smm__LA_DECL void archive_entry_set_nlink(struct archive_entry *, unsigned int); 286228753Smm__LA_DECL void archive_entry_set_pathname(struct archive_entry *, const char *); 287228753Smm__LA_DECL void archive_entry_copy_pathname(struct archive_entry *, const char *); 288228753Smm__LA_DECL void archive_entry_copy_pathname_w(struct archive_entry *, const wchar_t *); 289228753Smm__LA_DECL int archive_entry_update_pathname_utf8(struct archive_entry *, const char *); 290228753Smm__LA_DECL void archive_entry_set_perm(struct archive_entry *, __LA_MODE_T); 291228753Smm__LA_DECL void archive_entry_set_rdev(struct archive_entry *, dev_t); 292228753Smm__LA_DECL void archive_entry_set_rdevmajor(struct archive_entry *, dev_t); 293228753Smm__LA_DECL void archive_entry_set_rdevminor(struct archive_entry *, dev_t); 294228753Smm__LA_DECL void archive_entry_set_size(struct archive_entry *, __LA_INT64_T); 295228753Smm__LA_DECL void archive_entry_unset_size(struct archive_entry *); 296228753Smm__LA_DECL void archive_entry_copy_sourcepath(struct archive_entry *, const char *); 297228753Smm__LA_DECL void archive_entry_set_symlink(struct archive_entry *, const char *); 298228753Smm__LA_DECL void archive_entry_copy_symlink(struct archive_entry *, const char *); 299228753Smm__LA_DECL void archive_entry_copy_symlink_w(struct archive_entry *, const wchar_t *); 300228753Smm__LA_DECL int archive_entry_update_symlink_utf8(struct archive_entry *, const char *); 301228753Smm__LA_DECL void archive_entry_set_uid(struct archive_entry *, __LA_UID_T); 302228753Smm__LA_DECL void archive_entry_set_uname(struct archive_entry *, const char *); 303228753Smm__LA_DECL void archive_entry_copy_uname(struct archive_entry *, const char *); 304228753Smm__LA_DECL void archive_entry_copy_uname_w(struct archive_entry *, const wchar_t *); 305228753Smm__LA_DECL int archive_entry_update_uname_utf8(struct archive_entry *, const char *); 306228753Smm/* 307228753Smm * Routines to bulk copy fields to/from a platform-native "struct 308228753Smm * stat." Libarchive used to just store a struct stat inside of each 309228753Smm * archive_entry object, but this created issues when trying to 310228753Smm * manipulate archives on systems different than the ones they were 311228753Smm * created on. 312228753Smm * 313228753Smm * TODO: On Linux, provide both stat32 and stat64 versions of these functions. 314228753Smm */ 315228753Smm__LA_DECL const struct stat *archive_entry_stat(struct archive_entry *); 316228753Smm__LA_DECL void archive_entry_copy_stat(struct archive_entry *, const struct stat *); 317228753Smm 318228753Smm 319228753Smm/* 320228753Smm * ACL routines. This used to simply store and return text-format ACL 321228753Smm * strings, but that proved insufficient for a number of reasons: 322228753Smm * = clients need control over uname/uid and gname/gid mappings 323228753Smm * = there are many different ACL text formats 324228753Smm * = would like to be able to read/convert archives containing ACLs 325228753Smm * on platforms that lack ACL libraries 326228753Smm * 327228753Smm * This last point, in particular, forces me to implement a reasonably 328228753Smm * complete set of ACL support routines. 329228753Smm * 330228753Smm * TODO: Extend this to support NFSv4/NTFS permissions. That should 331228753Smm * allow full ACL support on Mac OS, in particular, which uses 332228753Smm * POSIX.1e-style interfaces to manipulate NFSv4/NTFS permissions. 333228753Smm */ 334228753Smm 335228753Smm/* 336228753Smm * Permission bits mimic POSIX.1e. Note that I've not followed POSIX.1e's 337228753Smm * "permset"/"perm" abstract type nonsense. A permset is just a simple 338228753Smm * bitmap, following long-standing Unix tradition. 339228753Smm */ 340228753Smm#define ARCHIVE_ENTRY_ACL_EXECUTE 1 341228753Smm#define ARCHIVE_ENTRY_ACL_WRITE 2 342228753Smm#define ARCHIVE_ENTRY_ACL_READ 4 343228753Smm 344228753Smm/* We need to be able to specify either or both of these. */ 345228753Smm#define ARCHIVE_ENTRY_ACL_TYPE_ACCESS 256 346228753Smm#define ARCHIVE_ENTRY_ACL_TYPE_DEFAULT 512 347228753Smm 348228753Smm/* Tag values mimic POSIX.1e */ 349228753Smm#define ARCHIVE_ENTRY_ACL_USER 10001 /* Specified user. */ 350228753Smm#define ARCHIVE_ENTRY_ACL_USER_OBJ 10002 /* User who owns the file. */ 351228753Smm#define ARCHIVE_ENTRY_ACL_GROUP 10003 /* Specified group. */ 352228753Smm#define ARCHIVE_ENTRY_ACL_GROUP_OBJ 10004 /* Group who owns the file. */ 353228753Smm#define ARCHIVE_ENTRY_ACL_MASK 10005 /* Modify group access. */ 354228753Smm#define ARCHIVE_ENTRY_ACL_OTHER 10006 /* Public. */ 355228753Smm 356228753Smm/* 357228753Smm * Set the ACL by clearing it and adding entries one at a time. 358228753Smm * Unlike the POSIX.1e ACL routines, you must specify the type 359228753Smm * (access/default) for each entry. Internally, the ACL data is just 360228753Smm * a soup of entries. API calls here allow you to retrieve just the 361228753Smm * entries of interest. This design (which goes against the spirit of 362228753Smm * POSIX.1e) is useful for handling archive formats that combine 363228753Smm * default and access information in a single ACL list. 364228753Smm */ 365228753Smm__LA_DECL void archive_entry_acl_clear(struct archive_entry *); 366228753Smm__LA_DECL void archive_entry_acl_add_entry(struct archive_entry *, 367228753Smm int /* type */, int /* permset */, int /* tag */, 368228753Smm int /* qual */, const char * /* name */); 369228753Smm__LA_DECL void archive_entry_acl_add_entry_w(struct archive_entry *, 370228753Smm int /* type */, int /* permset */, int /* tag */, 371228753Smm int /* qual */, const wchar_t * /* name */); 372228753Smm 373228753Smm/* 374228753Smm * To retrieve the ACL, first "reset", then repeatedly ask for the 375228753Smm * "next" entry. The want_type parameter allows you to request only 376228753Smm * access entries or only default entries. 377228753Smm */ 378228753Smm__LA_DECL int archive_entry_acl_reset(struct archive_entry *, int /* want_type */); 379228753Smm__LA_DECL int archive_entry_acl_next(struct archive_entry *, int /* want_type */, 380228753Smm int * /* type */, int * /* permset */, int * /* tag */, 381228753Smm int * /* qual */, const char ** /* name */); 382228753Smm__LA_DECL int archive_entry_acl_next_w(struct archive_entry *, int /* want_type */, 383228753Smm int * /* type */, int * /* permset */, int * /* tag */, 384228753Smm int * /* qual */, const wchar_t ** /* name */); 385228753Smm 386228753Smm/* 387228753Smm * Construct a text-format ACL. The flags argument is a bitmask that 388228753Smm * can include any of the following: 389228753Smm * 390228753Smm * ARCHIVE_ENTRY_ACL_TYPE_ACCESS - Include access entries. 391228753Smm * ARCHIVE_ENTRY_ACL_TYPE_DEFAULT - Include default entries. 392228753Smm * ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID - Include extra numeric ID field in 393228753Smm * each ACL entry. (As used by 'star'.) 394228753Smm * ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT - Include "default:" before each 395228753Smm * default ACL entry. 396228753Smm */ 397228753Smm#define ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID 1024 398228753Smm#define ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT 2048 399228753Smm__LA_DECL const wchar_t *archive_entry_acl_text_w(struct archive_entry *, 400228753Smm int /* flags */); 401228753Smm 402228753Smm/* Return a count of entries matching 'want_type' */ 403228753Smm__LA_DECL int archive_entry_acl_count(struct archive_entry *, int /* want_type */); 404228753Smm 405228753Smm/* 406228753Smm * Private ACL parser. This is private because it handles some 407228753Smm * very weird formats that clients should not be messing with. 408228753Smm * Clients should only deal with their platform-native formats. 409228753Smm * Because of the need to support many formats cleanly, new arguments 410228753Smm * are likely to get added on a regular basis. Clients who try to use 411228753Smm * this interface are likely to be surprised when it changes. 412228753Smm * 413228753Smm * You were warned! 414228753Smm * 415228753Smm * TODO: Move this declaration out of the public header and into 416228753Smm * a private header. Warnings above are silly. 417228753Smm */ 418228753Smm__LA_DECL int __archive_entry_acl_parse_w(struct archive_entry *, 419228753Smm const wchar_t *, int /* type */); 420228753Smm 421228753Smm/* 422228753Smm * extended attributes 423228753Smm */ 424228753Smm 425228753Smm__LA_DECL void archive_entry_xattr_clear(struct archive_entry *); 426228753Smm__LA_DECL void archive_entry_xattr_add_entry(struct archive_entry *, 427228753Smm const char * /* name */, const void * /* value */, 428228753Smm size_t /* size */); 429228753Smm 430228753Smm/* 431228753Smm * To retrieve the xattr list, first "reset", then repeatedly ask for the 432228753Smm * "next" entry. 433228753Smm */ 434228753Smm 435228753Smm__LA_DECL int archive_entry_xattr_count(struct archive_entry *); 436228753Smm__LA_DECL int archive_entry_xattr_reset(struct archive_entry *); 437228753Smm__LA_DECL int archive_entry_xattr_next(struct archive_entry *, 438228753Smm const char ** /* name */, const void ** /* value */, size_t *); 439228753Smm 440228753Smm/* 441228753Smm * Utility to match up hardlinks. 442228753Smm * 443228753Smm * The 'struct archive_entry_linkresolver' is a cache of archive entries 444228753Smm * for files with multiple links. Here's how to use it: 445228753Smm * 1. Create a lookup object with archive_entry_linkresolver_new() 446228753Smm * 2. Tell it the archive format you're using. 447228753Smm * 3. Hand each archive_entry to archive_entry_linkify(). 448228753Smm * That function will return 0, 1, or 2 entries that should 449228753Smm * be written. 450228753Smm * 4. Call archive_entry_linkify(resolver, NULL) until 451228753Smm * no more entries are returned. 452228753Smm * 5. Call archive_entry_link_resolver_free(resolver) to free resources. 453228753Smm * 454228753Smm * The entries returned have their hardlink and size fields updated 455228753Smm * appropriately. If an entry is passed in that does not refer to 456228753Smm * a file with multiple links, it is returned unchanged. The intention 457228753Smm * is that you should be able to simply filter all entries through 458228753Smm * this machine. 459228753Smm * 460228753Smm * To make things more efficient, be sure that each entry has a valid 461228753Smm * nlinks value. The hardlink cache uses this to track when all links 462228753Smm * have been found. If the nlinks value is zero, it will keep every 463228753Smm * name in the cache indefinitely, which can use a lot of memory. 464228753Smm * 465228753Smm * Note that archive_entry_size() is reset to zero if the file 466228753Smm * body should not be written to the archive. Pay attention! 467228753Smm */ 468228753Smmstruct archive_entry_linkresolver; 469228753Smm 470228753Smm/* 471228753Smm * There are three different strategies for marking hardlinks. 472228753Smm * The descriptions below name them after the best-known 473228753Smm * formats that rely on each strategy: 474228753Smm * 475228753Smm * "Old cpio" is the simplest, it always returns any entry unmodified. 476228753Smm * As far as I know, only cpio formats use this. Old cpio archives 477228753Smm * store every link with the full body; the onus is on the dearchiver 478228753Smm * to detect and properly link the files as they are restored. 479228753Smm * "tar" is also pretty simple; it caches a copy the first time it sees 480228753Smm * any link. Subsequent appearances are modified to be hardlink 481228753Smm * references to the first one without any body. Used by all tar 482228753Smm * formats, although the newest tar formats permit the "old cpio" strategy 483228753Smm * as well. This strategy is very simple for the dearchiver, 484228753Smm * and reasonably straightforward for the archiver. 485228753Smm * "new cpio" is trickier. It stores the body only with the last 486228753Smm * occurrence. The complication is that we might not 487228753Smm * see every link to a particular file in a single session, so 488228753Smm * there's no easy way to know when we've seen the last occurrence. 489228753Smm * The solution here is to queue one link until we see the next. 490228753Smm * At the end of the session, you can enumerate any remaining 491228753Smm * entries by calling archive_entry_linkify(NULL) and store those 492228753Smm * bodies. If you have a file with three links l1, l2, and l3, 493228753Smm * you'll get the following behavior if you see all three links: 494228753Smm * linkify(l1) => NULL (the resolver stores l1 internally) 495228753Smm * linkify(l2) => l1 (resolver stores l2, you write l1) 496228753Smm * linkify(l3) => l2, l3 (all links seen, you can write both). 497228753Smm * If you only see l1 and l2, you'll get this behavior: 498228753Smm * linkify(l1) => NULL 499228753Smm * linkify(l2) => l1 500228753Smm * linkify(NULL) => l2 (at end, you retrieve remaining links) 501228753Smm * As the name suggests, this strategy is used by newer cpio variants. 502228753Smm * It's noticably more complex for the archiver, slightly more complex 503228753Smm * for the dearchiver than the tar strategy, but makes it straightforward 504228753Smm * to restore a file using any link by simply continuing to scan until 505228753Smm * you see a link that is stored with a body. In contrast, the tar 506228753Smm * strategy requires you to rescan the archive from the beginning to 507228753Smm * correctly extract an arbitrary link. 508228753Smm */ 509228753Smm 510228753Smm__LA_DECL struct archive_entry_linkresolver *archive_entry_linkresolver_new(void); 511228753Smm__LA_DECL void archive_entry_linkresolver_set_strategy( 512228753Smm struct archive_entry_linkresolver *, int /* format_code */); 513228753Smm__LA_DECL void archive_entry_linkresolver_free(struct archive_entry_linkresolver *); 514228753Smm__LA_DECL void archive_entry_linkify(struct archive_entry_linkresolver *, 515228753Smm struct archive_entry **, struct archive_entry **); 516228753Smm 517228753Smm#ifdef __cplusplus 518228753Smm} 519228753Smm#endif 520228753Smm 521228753Smm/* This is meaningless outside of this header. */ 522228753Smm#undef __LA_DECL 523228753Smm 524228753Smm#endif /* !ARCHIVE_ENTRY_H_INCLUDED */ 525