summaryrefslogtreecommitdiffstats
path: root/Utilities/cmlibarchive/libarchive/archive_entry_private.h
blob: 6caf53176af59f12e17ab3edf4fc5c35f8f3f344 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/*-
 * Copyright (c) 2003-2007 Tim Kientzle
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * $FreeBSD: src/lib/libarchive/archive_entry_private.h,v 1.6 2008/09/30 03:53:03 kientzle Exp $
 */

#ifndef __LIBARCHIVE_BUILD
#error This header is only to be used internally to libarchive.
#endif

#ifndef ARCHIVE_ENTRY_PRIVATE_H_INCLUDED
#define ARCHIVE_ENTRY_PRIVATE_H_INCLUDED

#include "archive_string.h"

/*
 * Handle wide character (i.e., Unicode) and non-wide character
 * strings transparently.
 */

struct aes {
    struct archive_string aes_mbs;
    struct archive_string aes_utf8;
    const wchar_t *aes_wcs;
    /* Bitmap of which of the above are valid.  Because we're lazy
     * about malloc-ing and reusing the underlying storage, we
     * can't rely on NULL pointers to indicate whether a string
     * has been set. */
    int aes_set;
#define AES_SET_MBS 1
#define AES_SET_UTF8 2
#define AES_SET_WCS 4
};

struct ae_acl {
    struct ae_acl *next;
    int type;           /* E.g., access or default */
    int tag;            /* E.g., user/group/other/mask */
    int permset;        /* r/w/x bits */
    int id;         /* uid/gid for user/group */
    struct aes name;        /* uname/gname */
};

struct ae_xattr {
    struct ae_xattr *next;

    char    *name;
    void    *value;
    size_t  size;
};

/*
 * Description of an archive entry.
 *
 * Basically, this is a "struct stat" with a few text fields added in.
 *
 * TODO: Add "comment", "charset", and possibly other entries
 * that are supported by "pax interchange" format.  However, GNU, ustar,
 * cpio, and other variants don't support these features, so they're not an
 * excruciatingly high priority right now.
 *
 * TODO: "pax interchange" format allows essentially arbitrary
 * key/value attributes to be attached to any entry.  Supporting
 * such extensions may make this library useful for special
 * applications (e.g., a package manager could attach special
 * package-management attributes to each entry).  There are tricky
 * API issues involved, so this is not going to happen until
 * there's a real demand for it.
 *
 * TODO: Design a good API for handling sparse files.
 */
struct archive_entry {
    /*
     * Note that ae_stat.st_mode & AE_IFMT  can be  0!
     *
     * This occurs when the actual file type of the object is not
     * in the archive.  For example, 'tar' archives store
     * hardlinks without marking the type of the underlying
     * object.
     */

    /*
     * Read archive_entry_copy_stat.c for an explanation of why I
     * don't just use "struct stat" instead of "struct aest" here
     * and why I have this odd pointer to a separately-allocated
     * struct stat.
     */
    void *stat;
    int  stat_valid; /* Set to 0 whenever a field in aest changes. */

    struct aest {
        int64_t     aest_atime;
        uint32_t    aest_atime_nsec;
        int64_t     aest_ctime;
        uint32_t    aest_ctime_nsec;
        int64_t     aest_mtime;
        uint32_t    aest_mtime_nsec;
        int64_t     aest_birthtime;
        uint32_t    aest_birthtime_nsec;
        gid_t       aest_gid;
        int64_t     aest_ino;
        mode_t      aest_mode;
        uint32_t    aest_nlink;
        uint64_t    aest_size;
        uid_t       aest_uid;
        /*
         * Because converting between device codes and
         * major/minor values is platform-specific and
         * inherently a bit risky, we only do that conversion
         * lazily.  That way, we will do a better job of
         * preserving information in those cases where no
         * conversion is actually required.
         */
        int     aest_dev_is_broken_down;
        dev_t       aest_dev;
        dev_t       aest_devmajor;
        dev_t       aest_devminor;
        int     aest_rdev_is_broken_down;
        dev_t       aest_rdev;
        dev_t       aest_rdevmajor;
        dev_t       aest_rdevminor;
    } ae_stat;

    int ae_set; /* bitmap of fields that are currently set */
#define AE_SET_HARDLINK 1
#define AE_SET_SYMLINK  2
#define AE_SET_ATIME    4
#define AE_SET_CTIME    8
#define AE_SET_MTIME    16
#define AE_SET_BIRTHTIME 32
#define AE_SET_SIZE 64

    /*
     * Use aes here so that we get transparent mbs<->wcs conversions.
     */
    struct aes ae_fflags_text;  /* Text fflags per fflagstostr(3) */
    unsigned long ae_fflags_set;        /* Bitmap fflags */
    unsigned long ae_fflags_clear;
    struct aes ae_gname;        /* Name of owning group */
    struct aes ae_hardlink; /* Name of target for hardlink */
    struct aes ae_pathname; /* Name of entry */
    struct aes ae_symlink;      /* symlink contents */
    struct aes ae_uname;        /* Name of owner */

    /* Not used within libarchive; useful for some clients. */
    struct aes ae_sourcepath;   /* Path this entry is sourced from. */

    /* ACL support. */
    struct ae_acl   *acl_head;
    struct ae_acl   *acl_p;
    int      acl_state; /* See acl_next for details. */
    wchar_t     *acl_text_w;

    /* extattr support. */
    struct ae_xattr *xattr_head;
    struct ae_xattr *xattr_p;

    /* Miscellaneous. */
    char         strmode[12];
};


#endif /* ARCHIVE_ENTRY_PRIVATE_H_INCLUDED */