Skip to content

Commit

Permalink
Add support for unpacking coredumps
Browse files Browse the repository at this point in the history
Signed-off-by: Michal Srb <michal@redhat.com>
  • Loading branch information
msrb committed Feb 4, 2024
1 parent 665bc5e commit 0f85350
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/include/dump_dir.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ void dd_save_text(struct dump_dir *dd, const char *name, const char *data);
void dd_save_binary(struct dump_dir *dd, const char *name, const char *data, unsigned size);
int dd_copy_file(struct dump_dir *dd, const char *name, const char *source_path);
int dd_copy_file_unpack(struct dump_dir *dd, const char *name, const char *source_path);
int dd_unpack_coredump(struct dump_dir *dd, const char *coredump_archive_filename);

/* Create an item of the given name with contents of the given file (see man openat)
*
Expand Down
20 changes: 20 additions & 0 deletions src/lib/dump_dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -2419,6 +2419,26 @@ int dd_copy_file_unpack(struct dump_dir *dd, const char *name, const char *sourc

}

int dd_unpack_coredump(struct dump_dir *dd, const char *coredump_archive_filename)
{
if (dd_exist(dd, FILENAME_COREDUMP))
return 0;

if (!coredump_archive_filename || !dd_exist(dd, coredump_archive_filename))
{
error_msg("Coredump archive file missing in the problem directory '%s'", dd->dd_dirname);
return -1;
}

const gchar *parts[] = {dd->dd_dirname, coredump_archive_filename, NULL};
g_autofree const char *coredump_archive_path = g_build_filenamev((gchar **) parts);

if (dd_copy_file_unpack(dd, FILENAME_COREDUMP, coredump_archive_path))
return -1;

return 0;
}

/* flags - for future needs */
int dd_create_archive(struct dump_dir *dd, const char *archive_name,
const_string_vector_const_ptr_t exclude_elements, int flags)
Expand Down
1 change: 1 addition & 0 deletions src/lib/libreport.sym
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ global:
dd_save_binary;
dd_copy_file;
dd_copy_file_unpack;
dd_unpack_coredump;
dd_copy_file_at;
dd_copy_fd;
dd_item_stat;
Expand Down

0 comments on commit 0f85350

Please sign in to comment.