use super::*;
use std::io::{Result, SeekFrom};
pub const XATTR_IDENTRY_SIZE: usize = 16;
pub const XATTR_HEADER_SIZE: usize = 16;
pub const NO_XATTR_INODE_FLAG: u32 = 0xffff_ffff;
pub const NO_XATTR_SUPERBLOCK_FLAG: u64 = 0xffff_ffff_ffff_ffff;
#[repr(C)]
#[derive(Debug, Default)]
pub struct OnDiskXAttrIdTable {
pub location: u64,
pub count: u32,
_padding: u32,
}
impl_converter!(OnDiskXAttrIdTable);
pub struct XAttrIndex {
pub location: u64,
pub count: u32,
pub size: u32,
}
pub struct XAttrTable {
pub location: u64,
pub list: Vec<XAttrIndex>,
pub data: Vec<u8>,
}
pub struct XAttrEntry {
pub xtype: u16,
pub size: u16,
pub key: u8,
}
pub fn read_xattrs_table(r: &mut SqsIoReader, sb: Superblock) -> Result<()> {
let mut header = OnDiskXAttrIdTable::default();
if sb.flags.no_xattrs() {
return Ok(());
}
warn!(
"[read_xattrs_table] xattr_id_table_start={}",
sb.xattr_id_table_start
);
r.seek(SeekFrom::Start(sb.xattr_id_table_start))
.map_err(|e| map_error!(e))?;
r.read_exact(&mut header.as_mut())
.map_err(|e| map_error!(e))?;
warn!("[read_xattrs_table] header={:?}", header);
Ok(())
}
#[cfg(test)]
mod tests {
use crate::tests::*;
use crate::*;
use std::io::Result;
#[test]
#[cfg_attr(not(feature = "gzip-sqs"), ignore)]
fn test_read_xattrs_table() -> Result<()> {
let (mut reader, sb) = prepare_tests().map_err(|e| map_error!(e))?;
read_xattrs_table(&mut reader, sb).map_err(|e| map_error!(e))?;
Ok(())
}
}