initfs: Hard code creation time
This improves reproducibility of the initfs.
This commit is contained in:
@@ -6,7 +6,7 @@ use core::str;
|
||||
use alloc::string::String;
|
||||
|
||||
use hashbrown::HashMap;
|
||||
use redox_initfs::{InitFs, Inode, InodeDir, InodeKind, InodeStruct, types::Timespec};
|
||||
use redox_initfs::{InitFs, Inode, InodeDir, InodeKind, InodeStruct};
|
||||
|
||||
use redox_rt::proc::FdGuard;
|
||||
use redox_scheme::{
|
||||
@@ -315,8 +315,6 @@ impl SchemeSync for InitFsScheme {
|
||||
fn fstat(&mut self, id: usize, stat: &mut Stat, _ctx: &CallerCtx) -> Result<()> {
|
||||
let handle = self.handles.get(&id).ok_or(Error::new(EBADF))?.as_node()?;
|
||||
|
||||
let Timespec { sec, nsec } = self.fs.image_creation_time();
|
||||
|
||||
let inode = Self::get_inode(&self.fs, handle.inode)?;
|
||||
|
||||
stat.st_ino = inode.id();
|
||||
@@ -331,10 +329,10 @@ impl SchemeSync for InitFsScheme {
|
||||
stat.st_gid = 0;
|
||||
stat.st_size = u64::try_from(inode_len(inode)?).unwrap_or(u64::MAX);
|
||||
|
||||
stat.st_ctime = sec.get();
|
||||
stat.st_ctime_nsec = nsec.get();
|
||||
stat.st_mtime = sec.get();
|
||||
stat.st_mtime_nsec = nsec.get();
|
||||
stat.st_ctime = 0;
|
||||
stat.st_ctime_nsec = 0;
|
||||
stat.st_mtime = 0;
|
||||
stat.st_mtime_nsec = 0;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -216,9 +216,6 @@ impl<'initfs> InitFs<'initfs> {
|
||||
|
||||
Ok(this)
|
||||
}
|
||||
pub fn image_creation_time(&self) -> Timespec {
|
||||
self.get_header_assume_valid().creation_time
|
||||
}
|
||||
fn get_header_assume_valid(&self) -> &Header {
|
||||
plain::from_bytes::<Header>(&self.base[..core::mem::size_of::<Header>()])
|
||||
.expect("expected header type to require no alignment, and size to be sufficient")
|
||||
|
||||
+2
-10
@@ -53,24 +53,16 @@ pub struct Offset(pub U32);
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct Length(pub U32);
|
||||
|
||||
#[repr(C, packed)]
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct Timespec {
|
||||
pub sec: U64,
|
||||
pub nsec: U32,
|
||||
}
|
||||
|
||||
#[repr(C, packed)]
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct Header {
|
||||
pub magic: Magic,
|
||||
pub inode_table_offset: Offset,
|
||||
pub creation_time: Timespec,
|
||||
pub inode_count: U16,
|
||||
pub bootstrap_entry: U64,
|
||||
pub initfs_size: U64,
|
||||
pub page_size: U16,
|
||||
pub root_inode: U16,
|
||||
pub inode_count: U16,
|
||||
pub bootstrap_entry: U64,
|
||||
}
|
||||
|
||||
const _: () = {
|
||||
|
||||
@@ -521,12 +521,6 @@ pub fn archive(
|
||||
|
||||
let inode_table_offset = write_inode_table(&mut state)?;
|
||||
|
||||
let current_system_time = std::time::SystemTime::now();
|
||||
|
||||
let time_since_epoch = current_system_time
|
||||
.duration_since(std::time::SystemTime::UNIX_EPOCH)
|
||||
.context("could not calculate timestamp")?;
|
||||
|
||||
{
|
||||
let mut header_bytes = [0_u8; std::mem::size_of::<initfs::Header>()];
|
||||
let header = plain::from_mut_bytes(&mut header_bytes)
|
||||
@@ -534,10 +528,6 @@ pub fn archive(
|
||||
|
||||
*header = initfs::Header {
|
||||
magic: initfs::Magic(initfs::MAGIC),
|
||||
creation_time: initfs::Timespec {
|
||||
sec: time_since_epoch.as_secs().into(),
|
||||
nsec: time_since_epoch.subsec_nanos().into(),
|
||||
},
|
||||
inode_count: state.inode_table.count().into(),
|
||||
inode_table_offset,
|
||||
bootstrap_entry: bootstrap_entry.into(),
|
||||
|
||||
Reference in New Issue
Block a user