Changeset View
Changeset View
Standalone View
Standalone View
elfcopy/archive.c
Show First 20 Lines • Show All 434 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
static void | static void | ||||
ac_write_objs(struct elfcopy *ecp, int ofd) | ac_write_objs(struct elfcopy *ecp, int ofd) | ||||
{ | { | ||||
struct archive *a; | struct archive *a; | ||||
struct archive_entry *entry; | struct archive_entry *entry; | ||||
struct ar_obj *obj; | struct ar_obj *obj; | ||||
time_t timestamp; | |||||
int nr; | int nr; | ||||
if ((a = archive_write_new()) == NULL) | if ((a = archive_write_new()) == NULL) | ||||
errx(EXIT_FAILURE, "archive_write_new failed"); | errx(EXIT_FAILURE, "archive_write_new failed"); | ||||
archive_write_set_format_ar_svr4(a); | archive_write_set_format_ar_svr4(a); | ||||
AC(archive_write_open_fd(a, ofd)); | AC(archive_write_open_fd(a, ofd)); | ||||
/* Write the archive symbol table, even if it's empty. */ | /* Write the archive symbol table, even if it's empty. */ | ||||
entry = archive_entry_new(); | entry = archive_entry_new(); | ||||
archive_entry_copy_pathname(entry, "/"); | archive_entry_copy_pathname(entry, "/"); | ||||
archive_entry_set_mtime(entry, time(NULL), 0); | if (elftc_timestamp(×tamp) != 0) | ||||
err(EXIT_FAILURE, "elftc_timestamp"); | |||||
archive_entry_set_mtime(entry, timestamp, 0); | |||||
archive_entry_set_size(entry, (ecp->s_cnt + 1) * sizeof(uint32_t) + | archive_entry_set_size(entry, (ecp->s_cnt + 1) * sizeof(uint32_t) + | ||||
ecp->s_sn_sz); | ecp->s_sn_sz); | ||||
AC(archive_write_header(a, entry)); | AC(archive_write_header(a, entry)); | ||||
nr = htobe32(ecp->s_cnt); | nr = htobe32(ecp->s_cnt); | ||||
ac_write_data(a, &nr, sizeof(uint32_t)); | ac_write_data(a, &nr, sizeof(uint32_t)); | ||||
ac_write_data(a, ecp->s_so, sizeof(uint32_t) * ecp->s_cnt); | ac_write_data(a, ecp->s_so, sizeof(uint32_t) * ecp->s_cnt); | ||||
ac_write_data(a, ecp->s_sn, ecp->s_sn_sz); | ac_write_data(a, ecp->s_sn, ecp->s_sn_sz); | ||||
archive_entry_free(entry); | archive_entry_free(entry); | ||||
▲ Show 20 Lines • Show All 62 Lines • Show Last 20 Lines |