tar_open(3)
β¨ NAME β¨
tar_open, tar_close β access a tar archive via a handle
okay so bestie, welcome to tar_open(3), a C Library Call, and yes we're doing this whole thing together π
π SYNOPSIS π
#include <libtar.h>
int tar_open(TAR **t, char *pathname, tartype_t *type, int oflags, int
mode, int options);
int tar_fdopen(TAR **t, int fd, char *pathname, tartype_t *type, int
oflags, int mode, int options);
int tar_fd(TAR *t");"
int tar_close(TAR *t");"
π¦ VERSION π¦
This man page documents version 1.2 of libtar. periodt π
π DESCRIPTION π
The tar_open() function opens a tar archive file corresponding to the filename named by the pathname argument. The oflags argument must be either O_RDONLY or O_WRONLY. no in-between, no vibes-based guessing, pick one π«Ά
The type argument specifies the access methods for the given file type. The tartype_t structure has members named openfunc, closefunc, readfunc() and writefunc(), which are pointers to the functions for opening, closing, reading, and writing the file, respectively. If type is NULL, the file type defaults to a normal file, and the standard open(), close(), read(), and write() functions are used. so chill of it honestly β¨
The options argument is a logical-or'ed combination of zero or more of the following β like, mix and match, it's giving build-your-own-adventure π
TAR_GNUβ Use GNU extensions. fancy πTAR_VERBOSEβ Send status messages tostdout. it's the yapper setting, it literally tells you everything π’TAR_NOOVERWRITEβ Do not overwrite pre-existing files. protect the girlies πTAR_IGNORE_EOTβ Skip all-zero blocks instead of treating them as EOT.TAR_IGNORE_MAGICβ Do not validate the magic field in file headers. β¨magicβ¨ but make it unverifiedTAR_CHECK_VERSIONβ Check the version field in file headers. (This field is normally ignored.)TAR_IGNORE_CRCβ Do not validate the CRC of file headers.
The tar_open() function allocates memory for a TAR handle, and a pointer to the allocated memory is saved in the location specified by t. The TAR handle may be passed to other libtar calls to modify the opened tar archive. The TAR handle maintains all of the information about the open tar archive, including the archive type, options, and oflags selected when tar_open() was called. it's the main character of this whole operation, fr fr π
The TAR handle generated by tar_open() contains a file header structure. When reading a tar archive, this structure contains the last file header read from the tar archive. When writing a tar archive, this structure is used as a staging area to construct the next file header to be written to the archive. In addition, the TAR handle contains a hash table which is used to keep track of the device and inode information for each file which gets written to the tar archive. This is used to detect hard links, so that files do not need to be duplicated in the archive. no cap, it's lowkey a genius little bookkeeping queen π§
The tar_fdopen() function is identical to the tar_open() function, except that fd is used as the previously-opened file descriptor for the tar file instead of calling type->openfunc() to open the file. same energy, different door πΈ
The tar_fd() function returns the file descriptor associated with the TAR handle t.
The tar_close() function closes the file descriptor associated with the TAR handle t and frees all dynamically-allocated memory. clean up after yourself bestie, we love a tidy icon π
π RETURN VALUE π
The tar_open(), tar_fdopen(), and tar_close() functions return 0 on success. On failure, they return -1 and set errno. not the -1 π
The tar_fd() function returns the file descriptor associated with the TAR handle t.
π ERRORS π
tar_open() will fail if:
EINVALβ Theoflagsargument was something other thanO_RDONLYorO_WRONLY. you had ONE job bestie π
In addition, tar_open() and tar_close() may fail if it cannot allocate memory using calloc(), or if the open or close functions for the specified tar archive type fail.
π SEE ALSO π
okay that's the whole page, you ate that π«Ά this tea was served to you courtesy of the University of Illinois, dated Jan 2001, and it's still out here doing the most for tar_open(3) β iconic behavior honestly βπ
π¦ where this page comes from
- arch rolling: libtar 1.2.20-8 Β· BSD
- fedora 43: libtar-devel 1.2.20-34.fc43 Β· MIT
- fedora 43: libtar-devel 1.2.20-34.fc43 Β· MIT
- fedora 44: libtar-devel 1.2.20-35.fc44 Β· MIT
- fedora 44: libtar-devel 1.2.20-35.fc44 Β· MIT
- nixos 26.05: libtar 1.2.20
- nixpkgs unstable: libtar 1.2.20
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms