Lines Matching defs:pax

54 struct pax {
82 struct archive_entry *, struct pax *, int);
99 static void sparse_list_clear(struct pax *);
100 static int sparse_list_add(struct pax *, int64_t, int64_t);
104 * Set output format to 'restricted pax' format.
106 * This is the same as normal 'pax', but tries to suppress
107 * the pax header whenever possible. This is the default for
121 a->archive.archive_format_name = "restricted POSIX pax interchange";
126 * Set output format to 'pax' format.
132 struct pax *pax;
140 pax = (struct pax *)calloc(1, sizeof(*pax));
141 if (pax == NULL) {
143 "Can't allocate pax data");
146 pax->flags = WRITE_LIBARCHIVE_XATTR | WRITE_SCHILY_XATTR;
148 a->format_data = pax;
149 a->format_name = "pax";
157 a->archive.archive_format_name = "POSIX pax interchange";
165 struct pax *pax = (struct pax *)a->format_data;
175 "pax: hdrcharset option needs a character-set name");
182 pax->opt_binary = 1;
192 pax->sconv_utf8 = archive_string_conversion_to_charset(
194 if (pax->sconv_utf8 == NULL)
200 "pax: invalid charset name");
281 * Add a key/value attribute to the pax header. This function handles
291 * Add a key/value attribute to the pax header. This function handles
341 archive_write_pax_header_xattr(struct pax *pax, const char *encoded_name,
347 if (pax->flags & WRITE_LIBARCHIVE_XATTR) {
354 add_pax_attr(&(pax->pax_header), s.s, encoded_value);
359 if (pax->flags & WRITE_SCHILY_XATTR) {
363 add_pax_attr_binary(&(pax->pax_header), s.s, value, value_len);
370 struct pax *pax, struct archive_entry *entry)
385 r = archive_strcpy_l(&(pax->l_url_encoded_name),
386 url_encoded_name, pax->sconv_utf8);
389 encoded_name = pax->l_url_encoded_name.s;
397 archive_write_pax_header_xattr(pax, encoded_name,
494 /* Add ACL to pax header */
497 struct archive_entry *entry, struct pax *pax, int flags)
514 p = archive_entry_acl_to_text_l(entry, NULL, flags, pax->sconv_utf8);
528 add_pax_attr(&(pax->pax_header),
554 struct pax *pax;
573 pax = (struct pax *)a->format_data;
585 if (pax->opt_binary)
589 if (pax->sconv_utf8 == NULL) {
592 pax->sconv_utf8 = archive_string_conversion_to_charset(
594 if (pax->sconv_utf8 == NULL)
598 sconv = pax->sconv_utf8;
644 "Can't allocate pax data");
673 "Can't allocate pax data");
805 "Can't allocate pax data");
808 archive_string_empty(&(pax->pax_header)); /* Blank our work area. */
809 archive_string_empty(&(pax->sparse_map));
811 sparse_list_clear(pax);
902 if (sconv == NULL && !pax->opt_binary) {
925 add_pax_attr(&(pax->pax_header), "hdrcharset", "BINARY");
930 * 'path' to pax extended attrs. (Note that an unconvertible
935 add_pax_attr(&(pax->pax_header), "path", path);
966 add_pax_attr(&(pax->pax_header), "path", path);
977 * 'linkpath' to pax extended attrs. */
979 add_pax_attr(&(pax->pax_header), "linkpath", linkpath);
996 /* If file size is too large, add 'size' to pax extended attrs. */
998 add_pax_attr_int(&(pax->pax_header), "size",
1003 /* If numeric GID is too large, add 'gid' to pax extended attrs. */
1005 add_pax_attr_int(&(pax->pax_header), "gid",
1011 * 'gname' to pax extended attrs. */
1014 add_pax_attr(&(pax->pax_header), "gname", gname);
1019 /* If numeric UID is too large, add 'uid' to pax extended attrs. */
1021 add_pax_attr_int(&(pax->pax_header), "uid",
1026 /* Add 'uname' to pax extended attrs if necessary. */
1029 add_pax_attr(&(pax->pax_header), "uname", uname);
1055 add_pax_attr_int(&(pax->pax_header), "SCHILY.devmajor",
1062 * value even if they don't understand the pax
1076 add_pax_attr_int(&(pax->pax_header), "SCHILY.devminor",
1091 * high-resolution timestamp in "restricted pax" mode.
1123 * restricted pax format, but that confused people who
1125 * them in full pax format.
1130 add_pax_attr_time(&(pax->pax_header), "ctime",
1136 add_pax_attr_time(&(pax->pax_header), "atime",
1144 add_pax_attr_time(&(pax->pax_header),
1151 * The following items are handled differently in "pax
1152 * restricted" format. In particular, in "pax restricted"
1162 add_pax_attr_time(&(pax->pax_header), "mtime",
1169 add_pax_attr(&(pax->pax_header), "SCHILY.fflags", p);
1173 ret = add_pax_acl(a, entry_original, pax,
1181 ret = add_pax_acl(a, entry_original, pax,
1189 ret = add_pax_acl(a, entry_original, pax,
1201 add_pax_attr_int(&(pax->pax_header),
1203 add_pax_attr_int(&(pax->pax_header),
1209 add_pax_attr(&(pax->pax_header),
1211 add_pax_attr_int(&(pax->pax_header),
1226 archive_string_sprintf(&(pax->sparse_map), "%d\n",
1230 archive_string_sprintf(&(pax->sparse_map),
1235 if (sparse_list_add(pax, soffset, slength)
1248 if (archive_write_pax_header_xattrs(a, pax, entry_original)
1258 add_pax_attr(&(pax->pax_header),
1262 add_pax_attr(&(pax->pax_header),
1280 * XXX Full pax interchange format does permit a hardlink
1284 * don't check here, then every pax archive will end up with
1299 if (archive_strlen(&(pax->sparse_map))) {
1300 size_t mapsize = archive_strlen(&(pax->sparse_map));
1301 pax->sparse_map_padding = 0x1ff & (-(ssize_t)mapsize);
1303 mapsize + pax->sparse_map_padding + sparse_total);
1313 * for readers that don't support pax attribute extensions.
1337 if (archive_strlen(&(pax->pax_header)) > 0) {
1348 archive_strlen(&(pax->pax_header)));
1404 sparse_list_clear(pax);
1405 pax->entry_bytes_remaining = 0;
1406 pax->entry_padding = 0;
1410 pax->entry_bytes_remaining = archive_strlen(&(pax->pax_header));
1411 pax->entry_padding =
1412 0x1ff & (-(int64_t)pax->entry_bytes_remaining);
1414 r = __archive_write_output(a, pax->pax_header.s,
1415 archive_strlen(&(pax->pax_header)));
1421 r = __archive_write_nulls(a, (size_t)pax->entry_padding);
1426 pax->entry_bytes_remaining = pax->entry_padding = 0;
1440 if (pax->sparse_list == NULL && real_size > 0) {
1443 sparse_list_add(pax, 0, real_size);
1446 pax->entry_padding = 0x1ff & (-(int64_t)sparse_total);
1588 * The ustar header for the pax extended attributes must have a
1598 * practice, if the pax extended attributes get extracted as regular
1653 * TODO: Push this string into the 'pax' structure to avoid
1724 struct pax *pax;
1726 pax = (struct pax *)a->format_data;
1727 if (pax == NULL)
1730 archive_string_free(&pax->pax_header);
1731 archive_string_free(&pax->sparse_map);
1732 archive_string_free(&pax->l_url_encoded_name);
1733 sparse_list_clear(pax);
1734 free(pax);
1742 struct pax *pax;
1746 pax = (struct pax *)a->format_data;
1747 remaining = pax->entry_bytes_remaining;
1749 while (pax->sparse_list) {
1751 if (!pax->sparse_list->is_hole)
1752 remaining += pax->sparse_list->remaining;
1753 sb = pax->sparse_list->next;
1754 free(pax->sparse_list);
1755 pax->sparse_list = sb;
1758 ret = __archive_write_nulls(a, (size_t)(remaining + pax->entry_padding));
1759 pax->entry_bytes_remaining = pax->entry_padding = 0;
1766 struct pax *pax;
1771 pax = (struct pax *)a->format_data;
1777 if (archive_strlen(&(pax->sparse_map))) {
1778 ret = __archive_write_output(a, pax->sparse_map.s,
1779 archive_strlen(&(pax->sparse_map)));
1782 ret = __archive_write_nulls(a, pax->sparse_map_padding);
1785 archive_string_empty(&(pax->sparse_map));
1792 while (pax->sparse_list != NULL &&
1793 pax->sparse_list->remaining == 0) {
1794 struct sparse_block *sb = pax->sparse_list->next;
1795 free(pax->sparse_list);
1796 pax->sparse_list = sb;
1799 if (pax->sparse_list == NULL)
1804 if (ws > pax->sparse_list->remaining)
1805 ws = (size_t)pax->sparse_list->remaining;
1807 if (pax->sparse_list->is_hole) {
1810 pax->sparse_list->remaining -= ws;
1816 pax->sparse_list->remaining -= ws;
1932 sparse_list_clear(struct pax *pax)
1934 while (pax->sparse_list != NULL) {
1935 struct sparse_block *sb = pax->sparse_list;
1936 pax->sparse_list = sb->next;
1939 pax->sparse_tail = NULL;
1943 _sparse_list_add_block(struct pax *pax, int64_t offset, int64_t length,
1955 if (pax->sparse_list == NULL || pax->sparse_tail == NULL)
1956 pax->sparse_list = pax->sparse_tail = sb;
1958 pax->sparse_tail->next = sb;
1959 pax->sparse_tail = sb;
1965 sparse_list_add(struct pax *pax, int64_t offset, int64_t length)
1970 if (pax->sparse_tail == NULL)
1973 last_offset = pax->sparse_tail->offset +
1974 pax->sparse_tail->remaining;
1978 r = _sparse_list_add_block(pax, last_offset,
1984 return (_sparse_list_add_block(pax, offset, length, 0));