Merge pull request #3237 from datauwu/tar-avoid-redundant-mode
tar: avoid redundant mode parsing
This commit is contained in:
2 files changed
+5
-14
No files matched your search
@@ -1347,6 +1347,7 @@ header_common(struct archive_read *a, struct tar *tar,
|
||||
const struct archive_entry_header_ustar *header;
|
||||
const char *existing_linkpath;
|
||||
const wchar_t *existing_wcs_linkpath;
|
||||
mode_t header_mode;
|
||||
int err = ARCHIVE_OK;
|
||||
|
||||
header = (const struct archive_entry_header_ustar *)h;
|
||||
@@ -1354,12 +1355,10 @@ header_common(struct archive_read *a, struct tar *tar,
|
||||
/* Parse out the numeric fields (all are octal) */
|
||||
|
||||
/* Split mode handling: Set filetype always, perm only if not already set */
|
||||
archive_entry_set_filetype(entry,
|
||||
(mode_t)tar_atol(header->mode, sizeof(header->mode)));
|
||||
if (!archive_entry_perm_is_set(entry)) {
|
||||
archive_entry_set_perm(entry,
|
||||
(mode_t)tar_atol(header->mode, sizeof(header->mode)));
|
||||
}
|
||||
header_mode = (mode_t)tar_atol(header->mode, sizeof(header->mode));
|
||||
archive_entry_set_filetype(entry, header_mode);
|
||||
if (!archive_entry_perm_is_set(entry))
|
||||
archive_entry_set_perm(entry, header_mode);
|
||||
|
||||
/* Set uid, gid, mtime if not already set */
|
||||
if (!archive_entry_uid_is_set(entry)) {
|
||||
|
||||
@@ -1337,14 +1337,6 @@ archive_write_pax_header(struct archive_write *a,
|
||||
if (archive_entry_filetype(entry_main) != AE_IFREG)
|
||||
archive_entry_set_size(entry_main, 0);
|
||||
|
||||
/*
|
||||
* Pax-restricted does not store data for hardlinks, in order
|
||||
* to improve compatibility with ustar.
|
||||
*/
|
||||
if (a->archive.archive_format != ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE &&
|
||||
hardlink != NULL)
|
||||
archive_entry_set_size(entry_main, 0);
|
||||
|
||||
/*
|
||||
* XXX Full pax interchange format does permit a hardlink
|
||||
* entry to have data associated with it. I'm not supporting
|
||||
|
||||
Reference in new issue
Block a user