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