1tar_open(3)                     C Library Calls                    tar_open(3)
2
3
4

NAME

6       tar_open, tar_close - access a tar archive via a handle
7

SYNOPSIS

9       #include <libtar.h>
10
11       int  tar_open(TAR **t, char *pathname, tartype_t *type, int oflags, int
12       mode, int options);
13
14       int tar_fdopen(TAR **t, int fd, char *pathname,  tartype_t  *type,  int
15       oflags, int mode, int options);
16
17       int tar_fd(TAR *t");"
18
19       int tar_close(TAR *t");"
20

VERSION

22       This man page documents version 1.2 of libtar.
23

DESCRIPTION

25       The  tar_open()  function opens a tar archive file corresponding to the
26       filename named by the pathname argument.  The oflags argument  must  be
27       either O_RDONLY or O_WRONLY.
28
29       The type argument specifies the access methods for the given file type.
30       The tartype_t structure has members named  openfunc,  closefunc,  read‐
31       func()  and  writefunc(), which are pointers to the functions for open‐
32       ing, closing, reading, and writing the file, respectively.  If type  is
33       NULL, the file type defaults to a normal file, and the standard open(),
34       close(), read(), and write() functions are used.
35
36       The options argument is a logical-or'ed combination of zero or more  of
37       the following:
38
39       TAR_GNU
40              Use GNU extensions.
41
42       TAR_VERBOSE
43              Send status messages to stdout.
44
45       TAR_NOOVERWRITE
46              Do not overwrite pre-existing files.
47
48       TAR_IGNORE_EOT
49              Skip all-zero blocks instead of treating them as EOT.
50
51       TAR_IGNORE_MAGIC
52              Do not validate the magic field in file headers.
53
54       TAR_CHECK_VERSION
55              Check  the  version  field in file headers.  (This field is nor‐
56              mally ignored.)
57
58       TAR_IGNORE_CRC
59              Do not validate the CRC of file headers.
60
61       The tar_open() function allocates  memory  for  a  TAR  handle,  and  a
62       pointer  to  the allocated memory is saved in the location specified by
63       t.  The TAR handle may be passed to other libtar calls  to  modify  the
64       opened  tar  archive.   The TAR handle maintains all of the information
65       about the open tar archive, including the archive  type,  options,  and
66       oflags selected when tar_open() was called.
67
68       The  TAR  handle  generated by tar_open() contains a file header struc‐
69       ture.  When reading a tar archive, this  structure  contains  the  last
70       file  header  read  from  the tar archive.  When writing a tar archive,
71       this structure is used as a staging area to  construct  the  next  file
72       header  to be written to the archive.  In addition, the TAR handle con‐
73       tains a hash table which is used to keep track of the device and  inode
74       information  for each file which gets written to the tar archive.  This
75       is used to detect hard links, so that files do not need  to  be  dupli‐
76       cated in the archive.
77
78       The  tar_fdopen()  function  is  identical  to the tar_open() function,
79       except that fd is used as the previously-opened file descriptor for the
80       tar file instead of calling type->openfunc() to open the file.
81
82       The  tar_fd()  function returns the file descriptor associated with the
83       TAR handle t.
84
85       The tar_close() function closes the file descriptor associated with the
86       TAR handle t and frees all dynamically-allocated memory.
87

RETURN VALUE

89       The  tar_open(),  tar_fdopen(),  and  tar_close() functions return 0 on
90       success.  On failure, they return -1 and set errno.
91
92       The tar_fd() function returns the file descriptor associated  with  the
93       TAR handle t.
94

ERRORS

96       tar_open() will fail if:
97
98       EINVAL The  oflags  argument  was  something  other  than  O_RDONLY  or
99              O_WRONLY.
100
101       In addition, tar_open() and tar_close() may fail if it cannot  allocate
102       memory using calloc(), or if the open or close functions for the speci‐
103       fied tar archive type fail.
104

SEE ALSO

106       open(2), close(2), calloc(3)
107
108
109
110University of Illinois             Jan 2001                        tar_open(3)
Impressum