Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

tar_open(3) [centos man page]

tar_open(3)							  C Library Calls						       tar_open(3)

NAME
tar_open, tar_close - access a tar archive via a handle 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. 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. 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. The options argument is a logical-or'ed combination of zero or more of the following: TAR_GNU Use GNU extensions. TAR_VERBOSE Send status messages to stdout. TAR_NOOVERWRITE Do not overwrite pre-existing files. 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. TAR_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. 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 infor- mation 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. 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. 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. RETURN VALUE
The tar_open(), tar_fdopen(), and tar_close() functions return 0 on success. On failure, they return -1 and set errno. The tar_fd() function returns the file descriptor associated with the TAR handle t. ERRORS
tar_open() will fail if: EINVAL The oflags argument was something other than O_RDONLY or O_WRONLY. 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
open(2), close(2), calloc(3) University of Illinois Jan 2001 tar_open(3)

Check Out this Related Man Page

tar_append_file(3)						  C Library Calls						tar_append_file(3)

NAME
tar_append_file, tar_append_eof, tar_append_regfile - append data to tar archives SYNOPSIS
#include <libtar.h> int tar_append_file(TAR *t, char *realname, char *savename); int tar_append_regfile(TAR *t, char *realname); int tar_append_eof(TAR *t); VERSION
This man page documents version 1.2 of libtar. DESCRIPTION
The tar_append_file() function creates a tar file header block describing the file named by the realname argument, but with the encoded filename of savename. It then sets the current header associated with the TAR handle t to the newly created header block, and writes this block to the tar archive associated with t. If the file named by realname is a regular file (and is not encoded as a hard link), tar_append_file() will call tar_append_regfile() to append the contents of the file. The tar_append_regfile() function appends the contents of a regular file to the tar archive associated with t. Since this function is called by tar_append_file(), it should only be necessary for applications that construct and write the tar file header on their own. The tar_append_eof() function writes an EOF marker (two blocks of all zeros) to the tar file associated with t. RETURN VALUES
On successful completion, these functions will return 0. On failure, they will return -1 and set errno to an appropriate value. ERRORS
The tar_append_*() functions will fail if: EINVAL Less than T_BLOCKSIZE bytes were written to the tar archive. EINVAL Less than T_BLOCKSIZE bytes were read from the realname file. They may also fail if any of the following functions fail: lstat(), malloc(), open(), read(), th_write(), or the write function for the file type associated with the TAR handle t. SEE ALSO
read(2), open(2), lstat(2), th_write(3) University of Illinois Jan 2001 tar_append_file(3)
Man Page

Featured Tech Videos