Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support reading AIX big archive format #462

Merged
merged 5 commits into from Sep 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
46 changes: 46 additions & 0 deletions src/archive.rs
Expand Up @@ -8,6 +8,9 @@ use crate::pod::Pod;
/// File identification bytes stored at the beginning of the file.
pub const MAGIC: [u8; 8] = *b"!<arch>\n";

/// File identification bytes at the beginning of AIX big archive.
pub const AIX_BIG_MAGIC: [u8; 8] = *b"<bigaf>\n";

/// File identification bytes stored at the beginning of a thin archive.
///
/// A thin archive only contains a symbol table and file names.
Expand Down Expand Up @@ -36,4 +39,47 @@ pub struct Header {
pub terminator: [u8; 2],
}

/// The header at the start of an AIX big archive member, without name.
#[derive(Debug, Clone, Copy)]
#[repr(C)]
pub struct AixHeader {
/// File member size in decimal.
pub size: [u8; 20],
/// Next member offset in decimal.
pub nxtmem: [u8; 20],
/// Previous member offset in decimal.
pub prvmem: [u8; 20],
/// File member date in decimal.
pub date: [u8; 12],
/// File member user id in decimal.
pub uid: [u8; 12],
/// File member group id in decimal.
pub gid: [u8; 12],
/// File member mode in octal.
pub mode: [u8; 12],
/// File member name length in decimal.
pub namlen: [u8; 4],
}

/// The AIX big archive's fixed length header at file beginning.
#[derive(Debug, Clone, Copy)]
#[repr(C)]
pub struct AIXFileHeader {
/// Offset of member table
pub memoff: [u8; 20],
/// Offset of global symbol table
pub gstoff: [u8; 20],
/// ffset of global symbol table for 64-bit objects
pub gst64off: [u8; 20],
/// Offset of first member
pub fstmoff: [u8; 20],
/// Offset of last member
pub lstmoff: [u8; 20],
/// Offset of first member on free list
pub freeoff: [u8; 20],
}
ecnelises marked this conversation as resolved.
Show resolved Hide resolved


unsafe_impl_pod!(Header);
unsafe_impl_pod!(AixHeader);
unsafe_impl_pod!(AIXFileHeader);