Skip to content

Commit

Permalink
Support reading AIX big archive format (#462)
Browse files Browse the repository at this point in the history
  • Loading branch information
ecnelises authored Sep 18, 2022
1 parent 0ee154b commit 13c1392
Show file tree
Hide file tree
Showing 2 changed files with 245 additions and 32 deletions.
46 changes: 46 additions & 0 deletions src/archive.rs
Original file line number Diff line number Diff line change
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],
}


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

0 comments on commit 13c1392

Please sign in to comment.