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