VirtualBox

source: vbox/trunk/include/iprt/formats/tar.h@ 103224

Last change on this file since 103224 was 98325, checked in by vboxsync, 23 months ago

Runtime,Main: Remove the now unused and deprecated RTTar* API in favor of the VFS implementation, move the header declaring the tar headers to iprt/formats so the appliance code can access some required defines [build fix, needed to split up the tar format header]

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 11.9 KB
Line 
1/* $Id: tar.h 98325 2023-01-26 16:16:07Z vboxsync $ */
2/** @file
3 * IPRT - TAR Virtual Filesystem.
4 */
5
6/*
7 * Copyright (C) 2010-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * The contents of this file may alternatively be used under the terms
26 * of the Common Development and Distribution License Version 1.0
27 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
28 * in the VirtualBox distribution, in which case the provisions of the
29 * CDDL are applicable instead of those of the GPL.
30 *
31 * You may elect to license modified versions of this file under the
32 * terms and conditions of either the GPL or the CDDL or both.
33 *
34 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
35 */
36
37#ifndef IPRT_INCLUDED_formats_tar_h
38#define IPRT_INCLUDED_formats_tar_h
39#ifndef RT_WITHOUT_PRAGMA_ONCE
40# pragma once
41#endif
42
43#include <iprt/assert.h>
44
45/** @name RTZIPTARHDRPOSIX::typeflag
46 * @{ */
47#define RTZIPTAR_TF_OLDNORMAL '\0' /**< Normal disk file, Unix compatible */
48#define RTZIPTAR_TF_NORMAL '0' /**< Normal disk file */
49#define RTZIPTAR_TF_LINK '1' /**< Link to previously dumped file */
50#define RTZIPTAR_TF_SYMLINK '2' /**< Symbolic link */
51#define RTZIPTAR_TF_CHR '3' /**< Character special file */
52#define RTZIPTAR_TF_BLK '4' /**< Block special file */
53#define RTZIPTAR_TF_DIR '5' /**< Directory */
54#define RTZIPTAR_TF_FIFO '6' /**< FIFO special file */
55#define RTZIPTAR_TF_CONTIG '7' /**< Contiguous file */
56
57#define RTZIPTAR_TF_X_HDR 'x' /**< Extended header. */
58#define RTZIPTAR_TF_X_GLOBAL 'g' /**< Global extended header. */
59
60#define RTZIPTAR_TF_SOLARIS_XHDR 'X'
61
62#define RTZIPTAR_TF_GNU_DUMPDIR 'D'
63#define RTZIPTAR_TF_GNU_LONGLINK 'K' /**< GNU long link header. */
64#define RTZIPTAR_TF_GNU_LONGNAME 'L' /**< GNU long name header. */
65#define RTZIPTAR_TF_GNU_MULTIVOL 'M'
66#define RTZIPTAR_TF_GNU_SPARSE 'S'
67#define RTZIPTAR_TF_GNU_VOLDHR 'V'
68/** @} */
69
70/** Maximum length of a tar filename, excluding the terminating '\0'. More
71 * does not fit into a tar record. */
72#define RTZIPTAR_NAME_MAX 99
73
74
75/**
76 * The ancient tar header.
77 *
78 * The posix and gnu headers are compatible with the members up to and including
79 * link name, from there on they differ.
80 */
81typedef struct RTZIPTARHDRANCIENT
82{
83 char name[100];
84 char mode[8];
85 char uid[8];
86 char gid[8];
87 char size[12];
88 char mtime[12];
89 char chksum[8];
90 char typeflag;
91 char linkname[100]; /**< Was called linkflag. */
92 char unused[8+64+16+155+12];
93} RTZIPTARHDRANCIENT;
94AssertCompileSize(RTZIPTARHDRANCIENT, 512);
95AssertCompileMemberOffset(RTZIPTARHDRANCIENT, name, 0);
96AssertCompileMemberOffset(RTZIPTARHDRANCIENT, mode, 100);
97AssertCompileMemberOffset(RTZIPTARHDRANCIENT, uid, 108);
98AssertCompileMemberOffset(RTZIPTARHDRANCIENT, gid, 116);
99AssertCompileMemberOffset(RTZIPTARHDRANCIENT, size, 124);
100AssertCompileMemberOffset(RTZIPTARHDRANCIENT, mtime, 136);
101AssertCompileMemberOffset(RTZIPTARHDRANCIENT, chksum, 148);
102AssertCompileMemberOffset(RTZIPTARHDRANCIENT, typeflag, 156);
103AssertCompileMemberOffset(RTZIPTARHDRANCIENT, linkname, 157);
104AssertCompileMemberOffset(RTZIPTARHDRANCIENT, unused, 257);
105
106
107/** The uniform standard tape archive format magic value. */
108#define RTZIPTAR_USTAR_MAGIC "ustar"
109/** The ustar version string.
110 * @remarks The terminator character is not part of the field. */
111#define RTZIPTAR_USTAR_VERSION "00"
112
113/** The GNU magic + version value. */
114#define RTZIPTAR_GNU_MAGIC "ustar "
115
116
117/**
118 * The posix header (according to SuS).
119 */
120typedef struct RTZIPTARHDRPOSIX
121{
122 char name[100];
123 char mode[8];
124 char uid[8];
125 char gid[8];
126 char size[12];
127 char mtime[12];
128 char chksum[8];
129 char typeflag;
130 char linkname[100];
131 char magic[6];
132 char version[2];
133 char uname[32];
134 char gname[32];
135 char devmajor[8];
136 char devminor[8];
137 char prefix[155];
138 char unused[12];
139} RTZIPTARHDRPOSIX;
140AssertCompileSize(RTZIPTARHDRPOSIX, 512);
141AssertCompileMemberOffset(RTZIPTARHDRPOSIX, name, 0);
142AssertCompileMemberOffset(RTZIPTARHDRPOSIX, mode, 100);
143AssertCompileMemberOffset(RTZIPTARHDRPOSIX, uid, 108);
144AssertCompileMemberOffset(RTZIPTARHDRPOSIX, gid, 116);
145AssertCompileMemberOffset(RTZIPTARHDRPOSIX, size, 124);
146AssertCompileMemberOffset(RTZIPTARHDRPOSIX, mtime, 136);
147AssertCompileMemberOffset(RTZIPTARHDRPOSIX, chksum, 148);
148AssertCompileMemberOffset(RTZIPTARHDRPOSIX, typeflag, 156);
149AssertCompileMemberOffset(RTZIPTARHDRPOSIX, linkname, 157);
150AssertCompileMemberOffset(RTZIPTARHDRPOSIX, magic, 257);
151AssertCompileMemberOffset(RTZIPTARHDRPOSIX, version, 263);
152AssertCompileMemberOffset(RTZIPTARHDRPOSIX, uname, 265);
153AssertCompileMemberOffset(RTZIPTARHDRPOSIX, gname, 297);
154AssertCompileMemberOffset(RTZIPTARHDRPOSIX, devmajor, 329);
155AssertCompileMemberOffset(RTZIPTARHDRPOSIX, devminor, 337);
156AssertCompileMemberOffset(RTZIPTARHDRPOSIX, prefix, 345);
157
158/**
159 * GNU sparse data segment descriptor.
160 */
161typedef struct RTZIPTARGNUSPARSE
162{
163 char offset[12]; /**< Absolute offset relative to the start of the file. */
164 char numbytes[12];
165} RTZIPTARGNUSPARSE;
166AssertCompileSize(RTZIPTARGNUSPARSE, 24);
167AssertCompileMemberOffset(RTZIPTARGNUSPARSE, offset, 0);
168AssertCompileMemberOffset(RTZIPTARGNUSPARSE, numbytes, 12);
169/** Pointer to a GNU sparse data segment descriptor. */
170typedef RTZIPTARGNUSPARSE *PRTZIPTARGNUSPARSE;
171/** Pointer to a const GNU sparse data segment descriptor. */
172typedef RTZIPTARGNUSPARSE *PCRTZIPTARGNUSPARSE;
173
174/**
175 * The GNU header.
176 */
177typedef struct RTZIPTARHDRGNU
178{
179 char name[100];
180 char mode[8];
181 char uid[8];
182 char gid[8];
183 char size[12];
184 char mtime[12];
185 char chksum[8];
186 char typeflag;
187 char linkname[100];
188 char magic[8];
189 char uname[32];
190 char gname[32];
191 char devmajor[8];
192 char devminor[8];
193 char atime[12];
194 char ctime[12];
195 char offset[12]; /**< for multi-volume? */
196 char longnames[4]; /**< Seems to be unused. */
197 char unused[1];
198 RTZIPTARGNUSPARSE sparse[4];
199 char isextended; /**< More headers about sparse stuff if binary value 1. */
200 char realsize[12];
201 char unused2[17];
202} RTZIPTARHDRGNU;
203AssertCompileSize(RTZIPTARHDRGNU, 512);
204AssertCompileMemberOffset(RTZIPTARHDRGNU, name, 0);
205AssertCompileMemberOffset(RTZIPTARHDRGNU, mode, 100);
206AssertCompileMemberOffset(RTZIPTARHDRGNU, uid, 108);
207AssertCompileMemberOffset(RTZIPTARHDRGNU, gid, 116);
208AssertCompileMemberOffset(RTZIPTARHDRGNU, size, 124);
209AssertCompileMemberOffset(RTZIPTARHDRGNU, mtime, 136);
210AssertCompileMemberOffset(RTZIPTARHDRGNU, chksum, 148);
211AssertCompileMemberOffset(RTZIPTARHDRGNU, typeflag, 156);
212AssertCompileMemberOffset(RTZIPTARHDRGNU, linkname, 157);
213AssertCompileMemberOffset(RTZIPTARHDRGNU, magic, 257);
214AssertCompileMemberOffset(RTZIPTARHDRGNU, uname, 265);
215AssertCompileMemberOffset(RTZIPTARHDRGNU, gname, 297);
216AssertCompileMemberOffset(RTZIPTARHDRGNU, devmajor, 329);
217AssertCompileMemberOffset(RTZIPTARHDRGNU, devminor, 337);
218AssertCompileMemberOffset(RTZIPTARHDRGNU, atime, 345);
219AssertCompileMemberOffset(RTZIPTARHDRGNU, ctime, 357);
220AssertCompileMemberOffset(RTZIPTARHDRGNU, offset, 369);
221AssertCompileMemberOffset(RTZIPTARHDRGNU, longnames, 381);
222AssertCompileMemberOffset(RTZIPTARHDRGNU, unused, 385);
223AssertCompileMemberOffset(RTZIPTARHDRGNU, sparse, 386);
224AssertCompileMemberOffset(RTZIPTARHDRGNU, isextended,482);
225AssertCompileMemberOffset(RTZIPTARHDRGNU, realsize, 483);
226AssertCompileMemberOffset(RTZIPTARHDRGNU, unused2, 495);
227
228
229/**
230 * GNU sparse header.
231 */
232typedef struct RTZIPTARHDRGNUSPARSE
233{
234 RTZIPTARGNUSPARSE sp[21];
235 char isextended;
236 char unused[7];
237} RTZIPTARHDRGNUSPARSE;
238AssertCompileSize(RTZIPTARHDRGNUSPARSE, 512);
239AssertCompileMemberOffset(RTZIPTARHDRGNUSPARSE, sp, 0);
240AssertCompileMemberOffset(RTZIPTARHDRGNUSPARSE, isextended, 504);
241AssertCompileMemberOffset(RTZIPTARHDRGNUSPARSE, unused, 505);
242
243
244/**
245 * The bits common to posix and GNU.
246 */
247typedef struct RTZIPTARHDRCOMMON
248{
249 char name[100];
250 char mode[8];
251 char uid[8];
252 char gid[8];
253 char size[12];
254 char mtime[12];
255 char chksum[8];
256 char typeflag;
257 char linkname[100];
258 char magic[6];
259 char version[2];
260 char uname[32];
261 char gname[32];
262 char devmajor[8];
263 char devminor[8];
264 char not_common[155+12];
265} RTZIPTARHDRCOMMON;
266AssertCompileMembersSameSizeAndOffset(RTZIPTARHDRCOMMON, name, RTZIPTARHDRPOSIX, name);
267AssertCompileMembersSameSizeAndOffset(RTZIPTARHDRCOMMON, mode, RTZIPTARHDRPOSIX, mode);
268AssertCompileMembersSameSizeAndOffset(RTZIPTARHDRCOMMON, uid, RTZIPTARHDRPOSIX, uid);
269AssertCompileMembersSameSizeAndOffset(RTZIPTARHDRCOMMON, gid, RTZIPTARHDRPOSIX, gid);
270AssertCompileMembersSameSizeAndOffset(RTZIPTARHDRCOMMON, size, RTZIPTARHDRPOSIX, size);
271AssertCompileMembersSameSizeAndOffset(RTZIPTARHDRCOMMON, mtime, RTZIPTARHDRPOSIX, mtime);
272AssertCompileMembersSameSizeAndOffset(RTZIPTARHDRCOMMON, chksum, RTZIPTARHDRPOSIX, chksum);
273AssertCompileMembersSameSizeAndOffset(RTZIPTARHDRCOMMON, typeflag, RTZIPTARHDRPOSIX, typeflag);
274AssertCompileMembersSameSizeAndOffset(RTZIPTARHDRCOMMON, linkname, RTZIPTARHDRPOSIX, linkname);
275AssertCompileMembersSameSizeAndOffset(RTZIPTARHDRCOMMON, magic, RTZIPTARHDRPOSIX, magic);
276AssertCompileMembersSameSizeAndOffset(RTZIPTARHDRCOMMON, version, RTZIPTARHDRPOSIX, version);
277AssertCompileMembersSameSizeAndOffset(RTZIPTARHDRCOMMON, uname, RTZIPTARHDRPOSIX, uname);
278AssertCompileMembersSameSizeAndOffset(RTZIPTARHDRCOMMON, gname, RTZIPTARHDRPOSIX, gname);
279AssertCompileMembersSameSizeAndOffset(RTZIPTARHDRCOMMON, devmajor, RTZIPTARHDRPOSIX, devmajor);
280AssertCompileMembersSameSizeAndOffset(RTZIPTARHDRCOMMON, devminor, RTZIPTARHDRPOSIX, devminor);
281
282AssertCompileMembersSameSizeAndOffset(RTZIPTARHDRCOMMON, name, RTZIPTARHDRGNU, name);
283AssertCompileMembersSameSizeAndOffset(RTZIPTARHDRCOMMON, mode, RTZIPTARHDRGNU, mode);
284AssertCompileMembersSameSizeAndOffset(RTZIPTARHDRCOMMON, uid, RTZIPTARHDRGNU, uid);
285AssertCompileMembersSameSizeAndOffset(RTZIPTARHDRCOMMON, gid, RTZIPTARHDRGNU, gid);
286AssertCompileMembersSameSizeAndOffset(RTZIPTARHDRCOMMON, size, RTZIPTARHDRGNU, size);
287AssertCompileMembersSameSizeAndOffset(RTZIPTARHDRCOMMON, mtime, RTZIPTARHDRGNU, mtime);
288AssertCompileMembersSameSizeAndOffset(RTZIPTARHDRCOMMON, chksum, RTZIPTARHDRGNU, chksum);
289AssertCompileMembersSameSizeAndOffset(RTZIPTARHDRCOMMON, typeflag, RTZIPTARHDRGNU, typeflag);
290AssertCompileMembersSameSizeAndOffset(RTZIPTARHDRCOMMON, linkname, RTZIPTARHDRGNU, linkname);
291AssertCompileMembersAtSameOffset( RTZIPTARHDRCOMMON, magic, RTZIPTARHDRGNU, magic);
292AssertCompileMembersSameSizeAndOffset(RTZIPTARHDRCOMMON, uname, RTZIPTARHDRGNU, uname);
293AssertCompileMembersSameSizeAndOffset(RTZIPTARHDRCOMMON, gname, RTZIPTARHDRGNU, gname);
294AssertCompileMembersSameSizeAndOffset(RTZIPTARHDRCOMMON, devmajor, RTZIPTARHDRGNU, devmajor);
295AssertCompileMembersSameSizeAndOffset(RTZIPTARHDRCOMMON, devminor, RTZIPTARHDRGNU, devminor);
296
297#endif /* !IPRT_INCLUDED_formats_tar_h */
298
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette