1 /*
2  * Copyright (C) 2016 The Android Open Source Project
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *  * Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  *  * Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in
12  *    the documentation and/or other materials provided with the
13  *    distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  */
28 
29 #pragma once
30 
31 /**
32  * @file tar.h
33  * @brief Constants for reading/writing `.tar` files.
34  */
35 
36 #include <sys/cdefs.h>
37 
38 /** `.tar` file magic. (Includes the NUL.) */
39 #define TMAGIC "ustar"
40 /** `.tar` file magic length in bytes. */
41 #define TMAGLEN 6
42 /** `.tar` file version. (Does not include the NUL.) */
43 #define TVERSION "00"
44 /** `.tar` file version length in bytes. */
45 #define TVERSLEN 2
46 
47 /** Regular file type flag. */
48 #define REGTYPE '0'
49 /** Alternate regular file type flag. */
50 #define AREGTYPE '\0'
51 /** Link type flag. */
52 #define LNKTYPE '1'
53 /** Symbolic link type flag. */
54 #define SYMTYPE '2'
55 /** Character special file type flag. */
56 #define CHRTYPE '3'
57 /** Block special file type flag. */
58 #define BLKTYPE '4'
59 /** Directory type flag. */
60 #define DIRTYPE '5'
61 /** FIFO special file type flag. */
62 #define FIFOTYPE '6'
63 /** Reserved type flag. */
64 #define CONTTYPE '7'
65 
66 /** Set-UID mode field bit. */
67 #define TSUID 04000
68 /** Set-GID mode field bit. */
69 #define TSGID 02000
70 /** Directory restricted deletion mode field bit. */
71 #define TSVTX 01000
72 /** Readable by user mode field bit. */
73 #define TUREAD 00400
74 /** Writable by user mode field bit. */
75 #define TUWRITE 00200
76 /** Executable by user mode field bit. */
77 #define TUEXEC 00100
78 /** Readable by group mode field bit. */
79 #define TGREAD 00040
80 /** Writable by group mode field bit. */
81 #define TGWRITE 00020
82 /** Executable by group mode field bit. */
83 #define TGEXEC 00010
84 /** Readable by other mode field bit. */
85 #define TOREAD 00004
86 /** Writable by other mode field bit. */
87 #define TOWRITE 00002
88 /** Executable by other mode field bit. */
89 #define TOEXEC 00001
90