bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 1 | /* |
| 2 | ** Copyright 1998-2003 University of Illinois Board of Trustees |
| 3 | ** Copyright 1998-2003 Mark D. Roth |
| 4 | ** All rights reserved. |
| 5 | ** |
| 6 | ** libtar.h - header file for libtar library |
| 7 | ** |
| 8 | ** Mark D. Roth <roth@uiuc.edu> |
| 9 | ** Campus Information Technologies and Educational Services |
| 10 | ** University of Illinois at Urbana-Champaign |
| 11 | */ |
| 12 | |
| 13 | #ifndef LIBTAR_H |
| 14 | #define LIBTAR_H |
| 15 | |
| 16 | #include <sys/types.h> |
| 17 | #include <sys/stat.h> |
Ethan Yonker | 7118774 | 2017-01-13 13:30:10 -0600 | [diff] [blame] | 18 | #include <linux/capability.h> |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 19 | #include "tar.h" |
| 20 | |
| 21 | #include "libtar_listhash.h" |
| 22 | |
Ethan Yonker | 79f88bd | 2016-12-09 14:52:12 -0600 | [diff] [blame] | 23 | #ifdef HAVE_EXT4_CRYPT |
Ethan Yonker | fefe591 | 2017-09-30 22:22:13 -0500 | [diff] [blame] | 24 | # include "ext4crypt_tar.h" |
Ethan Yonker | 79f88bd | 2016-12-09 14:52:12 -0600 | [diff] [blame] | 25 | #endif |
| 26 | |
bigbiff | 7ba7500 | 2020-04-11 20:47:09 -0400 | [diff] [blame] | 27 | #ifdef USE_FSCRYPT |
| 28 | #include "fscrypt_policy.h" |
| 29 | #endif |
| 30 | |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 31 | #ifdef __cplusplus |
| 32 | extern "C" |
| 33 | { |
| 34 | #endif |
| 35 | |
| 36 | |
| 37 | /* useful constants */ |
James Christopher Adduono | 6f57f7c | 2016-03-01 16:01:53 -0500 | [diff] [blame] | 38 | /* see FIXME note in block.c regarding T_BLOCKSIZE */ |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 39 | #define T_BLOCKSIZE 512 |
| 40 | #define T_NAMELEN 100 |
| 41 | #define T_PREFIXLEN 155 |
| 42 | #define T_MAXPATHLEN (T_NAMELEN + T_PREFIXLEN) |
| 43 | |
| 44 | /* GNU extensions for typeflag */ |
| 45 | #define GNU_LONGNAME_TYPE 'L' |
| 46 | #define GNU_LONGLINK_TYPE 'K' |
| 47 | |
Vojtech Bocek | 25fd68d | 2013-08-27 03:10:10 +0200 | [diff] [blame] | 48 | /* extended metadata for next file - used to store selinux_context */ |
| 49 | #define TH_EXT_TYPE 'x' |
Ethan Yonker | 7118774 | 2017-01-13 13:30:10 -0600 | [diff] [blame] | 50 | #define TH_POL_TYPE_DO_NOT_USE 'p' |
Vojtech Bocek | 25fd68d | 2013-08-27 03:10:10 +0200 | [diff] [blame] | 51 | |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 52 | /* our version of the tar header structure */ |
| 53 | struct tar_header |
| 54 | { |
| 55 | char name[100]; |
| 56 | char mode[8]; |
| 57 | char uid[8]; |
| 58 | char gid[8]; |
| 59 | char size[12]; |
| 60 | char mtime[12]; |
| 61 | char chksum[8]; |
| 62 | char typeflag; |
| 63 | char linkname[100]; |
| 64 | char magic[6]; |
| 65 | char version[2]; |
| 66 | char uname[32]; |
| 67 | char gname[32]; |
| 68 | char devmajor[8]; |
| 69 | char devminor[8]; |
| 70 | char prefix[155]; |
| 71 | char padding[12]; |
| 72 | char *gnu_longname; |
| 73 | char *gnu_longlink; |
Vojtech Bocek | 25fd68d | 2013-08-27 03:10:10 +0200 | [diff] [blame] | 74 | char *selinux_context; |
Ethan Yonker | 79f88bd | 2016-12-09 14:52:12 -0600 | [diff] [blame] | 75 | #ifdef HAVE_EXT4_CRYPT |
Ethan Yonker | fefe591 | 2017-09-30 22:22:13 -0500 | [diff] [blame] | 76 | struct ext4_encryption_policy *eep; |
Ethan Yonker | 79f88bd | 2016-12-09 14:52:12 -0600 | [diff] [blame] | 77 | #endif |
bigbiff | 7ba7500 | 2020-04-11 20:47:09 -0400 | [diff] [blame] | 78 | #ifdef USE_FSCRYPT |
| 79 | struct fscrypt_encryption_policy *fep; |
| 80 | #endif |
Ethan Yonker | 7118774 | 2017-01-13 13:30:10 -0600 | [diff] [blame] | 81 | int has_cap_data; |
| 82 | struct vfs_cap_data cap_data; |
Ethan Yonker | 8d039f7 | 2017-02-03 14:26:15 -0600 | [diff] [blame] | 83 | int has_user_default; |
| 84 | int has_user_cache; |
| 85 | int has_user_code_cache; |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 86 | }; |
| 87 | |
| 88 | |
| 89 | /***** handle.c ************************************************************/ |
| 90 | |
| 91 | typedef int (*openfunc_t)(const char *, int, ...); |
| 92 | typedef int (*closefunc_t)(int); |
| 93 | typedef ssize_t (*readfunc_t)(int, void *, size_t); |
| 94 | typedef ssize_t (*writefunc_t)(int, const void *, size_t); |
| 95 | |
| 96 | typedef struct |
| 97 | { |
| 98 | openfunc_t openfunc; |
| 99 | closefunc_t closefunc; |
| 100 | readfunc_t readfunc; |
| 101 | writefunc_t writefunc; |
| 102 | } |
| 103 | tartype_t; |
| 104 | |
| 105 | typedef struct |
| 106 | { |
| 107 | tartype_t *type; |
James Christopher Adduono | 6f57f7c | 2016-03-01 16:01:53 -0500 | [diff] [blame] | 108 | const char *pathname; |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 109 | long fd; |
| 110 | int oflags; |
| 111 | int options; |
| 112 | struct tar_header th_buf; |
| 113 | libtar_hash_t *h; |
James Christopher Adduono | 6f57f7c | 2016-03-01 16:01:53 -0500 | [diff] [blame] | 114 | |
| 115 | /* introduced in libtar 1.2.21 */ |
| 116 | char *th_pathname; |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 117 | } |
| 118 | TAR; |
| 119 | |
| 120 | /* constant values for the TAR options field */ |
| 121 | #define TAR_GNU 1 /* use GNU extensions */ |
| 122 | #define TAR_VERBOSE 2 /* output file info to stdout */ |
| 123 | #define TAR_NOOVERWRITE 4 /* don't overwrite existing files */ |
| 124 | #define TAR_IGNORE_EOT 8 /* ignore double zero blocks as EOF */ |
| 125 | #define TAR_CHECK_MAGIC 16 /* check magic in file header */ |
| 126 | #define TAR_CHECK_VERSION 32 /* check version in file header */ |
| 127 | #define TAR_IGNORE_CRC 64 /* ignore CRC in file header */ |
Vojtech Bocek | 25fd68d | 2013-08-27 03:10:10 +0200 | [diff] [blame] | 128 | #define TAR_STORE_SELINUX 128 /* store selinux context */ |
James Christopher Adduono | 6f57f7c | 2016-03-01 16:01:53 -0500 | [diff] [blame] | 129 | #define TAR_USE_NUMERIC_ID 256 /* favor numeric owner over names */ |
bigbiff | 7ba7500 | 2020-04-11 20:47:09 -0400 | [diff] [blame] | 130 | #ifdef HAVE_EXT4_CRYPT |
Ethan Yonker | 79f88bd | 2016-12-09 14:52:12 -0600 | [diff] [blame] | 131 | #define TAR_STORE_EXT4_POL 512 /* store ext4 crypto policy */ |
bigbiff | 7ba7500 | 2020-04-11 20:47:09 -0400 | [diff] [blame] | 132 | #endif |
| 133 | #ifdef USE_FSCRYPT |
| 134 | #define TAR_STORE_FSCRYPT_POL 512 /* store fscrypt crypto policy */ |
| 135 | #endif |
Ethan Yonker | 7118774 | 2017-01-13 13:30:10 -0600 | [diff] [blame] | 136 | #define TAR_STORE_POSIX_CAP 1024 /* store posix file capabilities */ |
Ethan Yonker | 8d039f7 | 2017-02-03 14:26:15 -0600 | [diff] [blame] | 137 | #define TAR_STORE_ANDROID_USER_XATTR 2048 /* store android user.* xattr */ |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 138 | |
| 139 | /* this is obsolete - it's here for backwards-compatibility only */ |
| 140 | #define TAR_IGNORE_MAGIC 0 |
| 141 | |
| 142 | extern const char libtar_version[]; |
| 143 | |
| 144 | |
| 145 | /* open a new tarfile handle */ |
James Christopher Adduono | 6f57f7c | 2016-03-01 16:01:53 -0500 | [diff] [blame] | 146 | int tar_open(TAR **t, const char *pathname, tartype_t *type, |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 147 | int oflags, int mode, int options); |
| 148 | |
| 149 | /* make a tarfile handle out of a previously-opened descriptor */ |
James Christopher Adduono | 6f57f7c | 2016-03-01 16:01:53 -0500 | [diff] [blame] | 150 | int tar_fdopen(TAR **t, int fd, const char *pathname, tartype_t *type, |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 151 | int oflags, int mode, int options); |
| 152 | |
| 153 | /* returns the descriptor associated with t */ |
| 154 | int tar_fd(TAR *t); |
| 155 | |
| 156 | /* close tarfile handle */ |
| 157 | int tar_close(TAR *t); |
| 158 | |
| 159 | |
| 160 | /***** append.c ************************************************************/ |
| 161 | |
| 162 | /* forward declaration to appease the compiler */ |
| 163 | struct tar_dev; |
| 164 | |
| 165 | /* cleanup function */ |
| 166 | void tar_dev_free(struct tar_dev *tdp); |
| 167 | |
| 168 | /* Appends a file to the tar archive. |
| 169 | * Arguments: |
| 170 | * t = TAR handle to append to |
| 171 | * realname = path of file to append |
| 172 | * savename = name to save the file under in the archive |
| 173 | */ |
James Christopher Adduono | 6f57f7c | 2016-03-01 16:01:53 -0500 | [diff] [blame] | 174 | int tar_append_file(TAR *t, const char *realname, const char *savename); |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 175 | |
| 176 | /* write EOF indicator */ |
| 177 | int tar_append_eof(TAR *t); |
| 178 | |
| 179 | /* add file contents to a tarchive */ |
James Christopher Adduono | 6f57f7c | 2016-03-01 16:01:53 -0500 | [diff] [blame] | 180 | int tar_append_regfile(TAR *t, const char *realname); |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 181 | |
James Christopher Adduono | 6f57f7c | 2016-03-01 16:01:53 -0500 | [diff] [blame] | 182 | /* Appends in-memory file contents to a tarchive. |
| 183 | * Arguments: |
| 184 | * t = TAR handle to append to |
| 185 | * savename = name to save the file under in the archive |
| 186 | * mode = mode |
| 187 | * uid, gid = owner |
| 188 | * buf, len = in-memory buffer |
| 189 | */ |
| 190 | int tar_append_file_contents(TAR *t, const char *savename, mode_t mode, |
| 191 | uid_t uid, gid_t gid, void *buf, size_t len); |
| 192 | |
| 193 | /* add buffer to a tarchive */ |
| 194 | int tar_append_buffer(TAR *t, void *buf, size_t len); |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 195 | |
| 196 | /***** block.c *************************************************************/ |
| 197 | |
| 198 | /* macros for reading/writing tarchive blocks */ |
| 199 | #define tar_block_read(t, buf) \ |
| 200 | (*((t)->type->readfunc))((t)->fd, (char *)(buf), T_BLOCKSIZE) |
| 201 | #define tar_block_write(t, buf) \ |
| 202 | (*((t)->type->writefunc))((t)->fd, (char *)(buf), T_BLOCKSIZE) |
| 203 | |
| 204 | /* read/write a header block */ |
| 205 | int th_read(TAR *t); |
| 206 | int th_write(TAR *t); |
| 207 | |
| 208 | |
| 209 | /***** decode.c ************************************************************/ |
| 210 | |
| 211 | /* determine file type */ |
| 212 | #define TH_ISREG(t) ((t)->th_buf.typeflag == REGTYPE \ |
| 213 | || (t)->th_buf.typeflag == AREGTYPE \ |
| 214 | || (t)->th_buf.typeflag == CONTTYPE \ |
James Christopher Adduono | 6f57f7c | 2016-03-01 16:01:53 -0500 | [diff] [blame] | 215 | || (S_ISREG((mode_t)oct_to_int((t)->th_buf.mode, sizeof((t)->th_buf.mode))) \ |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 216 | && (t)->th_buf.typeflag != LNKTYPE)) |
| 217 | #define TH_ISLNK(t) ((t)->th_buf.typeflag == LNKTYPE) |
| 218 | #define TH_ISSYM(t) ((t)->th_buf.typeflag == SYMTYPE \ |
James Christopher Adduono | 6f57f7c | 2016-03-01 16:01:53 -0500 | [diff] [blame] | 219 | || S_ISLNK((mode_t)oct_to_int((t)->th_buf.mode, sizeof((t)->th_buf.mode)))) |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 220 | #define TH_ISCHR(t) ((t)->th_buf.typeflag == CHRTYPE \ |
James Christopher Adduono | 6f57f7c | 2016-03-01 16:01:53 -0500 | [diff] [blame] | 221 | || S_ISCHR((mode_t)oct_to_int((t)->th_buf.mode, sizeof((t)->th_buf.mode)))) |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 222 | #define TH_ISBLK(t) ((t)->th_buf.typeflag == BLKTYPE \ |
James Christopher Adduono | 6f57f7c | 2016-03-01 16:01:53 -0500 | [diff] [blame] | 223 | || S_ISBLK((mode_t)oct_to_int((t)->th_buf.mode, sizeof((t)->th_buf.mode)))) |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 224 | #define TH_ISDIR(t) ((t)->th_buf.typeflag == DIRTYPE \ |
James Christopher Adduono | 6f57f7c | 2016-03-01 16:01:53 -0500 | [diff] [blame] | 225 | || S_ISDIR((mode_t)oct_to_int((t)->th_buf.mode, sizeof((t)->th_buf.mode))) \ |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 226 | || ((t)->th_buf.typeflag == AREGTYPE \ |
James Christopher Adduono | 6f57f7c | 2016-03-01 16:01:53 -0500 | [diff] [blame] | 227 | && strnlen((t)->th_buf.name, T_NAMELEN) \ |
| 228 | && ((t)->th_buf.name[strnlen((t)->th_buf.name, T_NAMELEN) - 1] == '/'))) |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 229 | #define TH_ISFIFO(t) ((t)->th_buf.typeflag == FIFOTYPE \ |
James Christopher Adduono | 6f57f7c | 2016-03-01 16:01:53 -0500 | [diff] [blame] | 230 | || S_ISFIFO((mode_t)oct_to_int((t)->th_buf.mode, sizeof((t)->th_buf.mode)))) |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 231 | #define TH_ISLONGNAME(t) ((t)->th_buf.typeflag == GNU_LONGNAME_TYPE) |
| 232 | #define TH_ISLONGLINK(t) ((t)->th_buf.typeflag == GNU_LONGLINK_TYPE) |
Vojtech Bocek | 25fd68d | 2013-08-27 03:10:10 +0200 | [diff] [blame] | 233 | #define TH_ISEXTHEADER(t) ((t)->th_buf.typeflag == TH_EXT_TYPE) |
Ethan Yonker | 7118774 | 2017-01-13 13:30:10 -0600 | [diff] [blame] | 234 | #define TH_ISPOLHEADER(t) ((t)->th_buf.typeflag == TH_POL_TYPE_DO_NOT_USE) |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 235 | |
| 236 | /* decode tar header info */ |
James Christopher Adduono | 6f57f7c | 2016-03-01 16:01:53 -0500 | [diff] [blame] | 237 | #define th_get_crc(t) oct_to_int((t)->th_buf.chksum, sizeof((t)->th_buf.chksum)) |
| 238 | #define th_get_size(t) oct_to_int_ex((t)->th_buf.size, sizeof((t)->th_buf.size)) |
| 239 | #define th_get_mtime(t) oct_to_int_ex((t)->th_buf.mtime, sizeof((t)->th_buf.mtime)) |
| 240 | #define th_get_devmajor(t) oct_to_int((t)->th_buf.devmajor, sizeof((t)->th_buf.devmajor)) |
| 241 | #define th_get_devminor(t) oct_to_int((t)->th_buf.devminor, sizeof((t)->th_buf.devminor)) |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 242 | #define th_get_linkname(t) ((t)->th_buf.gnu_longlink \ |
| 243 | ? (t)->th_buf.gnu_longlink \ |
| 244 | : (t)->th_buf.linkname) |
| 245 | char *th_get_pathname(TAR *t); |
| 246 | mode_t th_get_mode(TAR *t); |
| 247 | uid_t th_get_uid(TAR *t); |
| 248 | gid_t th_get_gid(TAR *t); |
| 249 | |
| 250 | |
| 251 | /***** encode.c ************************************************************/ |
| 252 | |
| 253 | /* encode file info in th_header */ |
| 254 | void th_set_type(TAR *t, mode_t mode); |
James Christopher Adduono | 6f57f7c | 2016-03-01 16:01:53 -0500 | [diff] [blame] | 255 | void th_set_path(TAR *t, const char *pathname); |
| 256 | void th_set_link(TAR *t, const char *linkname); |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 257 | void th_set_device(TAR *t, dev_t device); |
| 258 | void th_set_user(TAR *t, uid_t uid); |
| 259 | void th_set_group(TAR *t, gid_t gid); |
| 260 | void th_set_mode(TAR *t, mode_t fmode); |
| 261 | #define th_set_mtime(t, fmtime) \ |
James Christopher Adduono | 6f57f7c | 2016-03-01 16:01:53 -0500 | [diff] [blame] | 262 | int_to_oct_ex((fmtime), (t)->th_buf.mtime, sizeof((t)->th_buf.mtime)) |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 263 | #define th_set_size(t, fsize) \ |
James Christopher Adduono | 6f57f7c | 2016-03-01 16:01:53 -0500 | [diff] [blame] | 264 | int_to_oct_ex((fsize), (t)->th_buf.size, sizeof((t)->th_buf.size)) |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 265 | |
| 266 | /* encode everything at once (except the pathname and linkname) */ |
| 267 | void th_set_from_stat(TAR *t, struct stat *s); |
| 268 | |
| 269 | /* encode magic, version, and crc - must be done after everything else is set */ |
| 270 | void th_finish(TAR *t); |
| 271 | |
| 272 | |
| 273 | /***** extract.c ***********************************************************/ |
| 274 | |
| 275 | /* sequentially extract next file from t */ |
James Christopher Adduono | 6f57f7c | 2016-03-01 16:01:53 -0500 | [diff] [blame] | 276 | int tar_extract_file(TAR *t, const char *realname, const char *prefix, const int *progress_fd); |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 277 | |
| 278 | /* extract different file types */ |
James Christopher Adduono | 6f57f7c | 2016-03-01 16:01:53 -0500 | [diff] [blame] | 279 | int tar_extract_dir(TAR *t, const char *realname); |
| 280 | int tar_extract_hardlink(TAR *t, const char *realname, const char *prefix); |
| 281 | int tar_extract_symlink(TAR *t, const char *realname); |
| 282 | int tar_extract_chardev(TAR *t, const char *realname); |
| 283 | int tar_extract_blockdev(TAR *t, const char *realname); |
| 284 | int tar_extract_fifo(TAR *t, const char *realname); |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 285 | |
| 286 | /* for regfiles, we need to extract the content blocks as well */ |
James Christopher Adduono | 6f57f7c | 2016-03-01 16:01:53 -0500 | [diff] [blame] | 287 | int tar_extract_regfile(TAR *t, const char *realname, const int *progress_fd); |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 288 | int tar_skip_regfile(TAR *t); |
| 289 | |
James Christopher Adduono | 6f57f7c | 2016-03-01 16:01:53 -0500 | [diff] [blame] | 290 | /* extract regfile to buffer */ |
| 291 | int tar_extract_file_contents(TAR *t, void *buf, size_t *lenp); |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 292 | |
| 293 | /***** output.c ************************************************************/ |
| 294 | |
| 295 | /* print the tar header */ |
| 296 | void th_print(TAR *t); |
| 297 | |
| 298 | /* print "ls -l"-like output for the file described by th */ |
| 299 | void th_print_long_ls(TAR *t); |
| 300 | |
| 301 | |
| 302 | /***** util.c *************************************************************/ |
| 303 | |
| 304 | /* hashing function for pathnames */ |
| 305 | int path_hashfunc(char *key, int numbuckets); |
| 306 | |
| 307 | /* matching function for dev_t's */ |
| 308 | int dev_match(dev_t *dev1, dev_t *dev2); |
| 309 | |
| 310 | /* matching function for ino_t's */ |
| 311 | int ino_match(ino_t *ino1, ino_t *ino2); |
| 312 | |
| 313 | /* hashing function for dev_t's */ |
| 314 | int dev_hash(dev_t *dev); |
| 315 | |
| 316 | /* hashing function for ino_t's */ |
| 317 | int ino_hash(ino_t *inode); |
| 318 | |
| 319 | /* create any necessary dirs */ |
| 320 | int mkdirhier(char *path); |
| 321 | |
| 322 | /* calculate header checksum */ |
| 323 | int th_crc_calc(TAR *t); |
| 324 | |
| 325 | /* calculate a signed header checksum */ |
| 326 | int th_signed_crc_calc(TAR *t); |
| 327 | |
| 328 | /* compare checksums in a forgiving way */ |
| 329 | #define th_crc_ok(t) (th_get_crc(t) == th_crc_calc(t) || th_get_crc(t) == th_signed_crc_calc(t)) |
| 330 | |
| 331 | /* string-octal to integer conversion */ |
James Christopher Adduono | 6f57f7c | 2016-03-01 16:01:53 -0500 | [diff] [blame] | 332 | int64_t oct_to_int(char *oct, size_t len); |
| 333 | |
| 334 | /* string-octal or binary to integer conversion */ |
| 335 | int64_t oct_to_int_ex(char *oct, size_t len); |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 336 | |
| 337 | /* integer to NULL-terminated string-octal conversion */ |
James Christopher Adduono | 6f57f7c | 2016-03-01 16:01:53 -0500 | [diff] [blame] | 338 | void int_to_oct(int64_t num, char *oct, size_t octlen); |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 339 | |
James Christopher Adduono | 6f57f7c | 2016-03-01 16:01:53 -0500 | [diff] [blame] | 340 | /* integer to string-octal conversion, or binary as necessary */ |
| 341 | void int_to_oct_ex(int64_t num, char *oct, size_t octlen); |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 342 | |
Ethan Yonker | 7118774 | 2017-01-13 13:30:10 -0600 | [diff] [blame] | 343 | /* prints posix file capabilities */ |
| 344 | void print_caps(struct vfs_cap_data *cap_data); |
| 345 | |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 346 | |
| 347 | /***** wrapper.c **********************************************************/ |
| 348 | |
| 349 | /* extract groups of files */ |
| 350 | int tar_extract_glob(TAR *t, char *globname, char *prefix); |
Ethan Yonker | 1b7a31b | 2014-07-03 15:09:22 -0500 | [diff] [blame] | 351 | int tar_extract_all(TAR *t, char *prefix, const int *progress_fd); |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 352 | |
| 353 | /* add a whole tree of files */ |
James Christopher Adduono | 6f57f7c | 2016-03-01 16:01:53 -0500 | [diff] [blame] | 354 | int tar_append_tree(TAR *t, char *realdir, char *savedir); |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 355 | |
n0d3 | 3b51163 | 2013-03-06 21:14:15 +0200 | [diff] [blame] | 356 | /* find an entry */ |
| 357 | int tar_find(TAR *t, char *searchstr); |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 358 | |
| 359 | #ifdef __cplusplus |
| 360 | } |
| 361 | #endif |
| 362 | |
| 363 | #endif /* ! LIBTAR_H */ |
| 364 | |