Merge branch 'endian-num' into 'master'
Migrate from `redox_simple_endian` to `endian-num` See merge request redox-os/redoxfs!72
This commit is contained in:
Generated
+7
-7
@@ -131,6 +131,12 @@ dependencies = [
|
||||
"subtle",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "endian-num"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1ad847bb2094f110bbdd6fa564894ca4556fd978958e93985420d680d3cb6d14"
|
||||
|
||||
[[package]]
|
||||
name = "env_logger"
|
||||
version = "0.9.3"
|
||||
@@ -294,12 +300,6 @@ version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "436d45c2b6a5b159d43da708e62b25be3a4a3d5550d654b72216ade4c4bfd717"
|
||||
|
||||
[[package]]
|
||||
name = "redox_simple_endian"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "175b27da3d5db1502bd20ae0917ba132d256a2b169f1686681304ebb86504eab"
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.4.1"
|
||||
@@ -331,6 +331,7 @@ dependencies = [
|
||||
"aes",
|
||||
"argon2",
|
||||
"base64ct",
|
||||
"endian-num",
|
||||
"env_logger",
|
||||
"fuser",
|
||||
"getrandom",
|
||||
@@ -339,7 +340,6 @@ dependencies = [
|
||||
"log",
|
||||
"range-tree",
|
||||
"redox-path",
|
||||
"redox_simple_endian",
|
||||
"redox_syscall 0.5.1",
|
||||
"seahash",
|
||||
"termion",
|
||||
|
||||
+1
-9
@@ -35,6 +35,7 @@ aes = { version = "=0.7.5", default-features = false }
|
||||
argon2 = { version = "0.3.4", default-features = false, features = ["alloc"] }
|
||||
base64ct = { version = "1", default-features = false }
|
||||
env_logger = { version = "0.9", optional = true }
|
||||
endian-num = "0.1"
|
||||
getrandom = { version = "0.2.5", optional = true }
|
||||
libc = "0.2"
|
||||
log = { version = "0.4.14", default-features = false, optional = true}
|
||||
@@ -46,15 +47,6 @@ uuid = { version = "1.4", default-features = false }
|
||||
redox-path = "0.3.0"
|
||||
libredox = { version = "0.1.3", optional = true }
|
||||
|
||||
# https://github.com/rexlunae/simple-endian-rs/pull/5
|
||||
[dependencies.redox_simple_endian]
|
||||
version = "0.3.0"
|
||||
default-features = false
|
||||
features = [
|
||||
"bitwise", "comparisons", "format", "math_ops", "neg_ops", "shift_ops",
|
||||
"both_endian", "float_impls", "integer_impls", "byte_impls"
|
||||
]
|
||||
|
||||
[features]
|
||||
default = ["std", "log"]
|
||||
force-soft = [
|
||||
|
||||
+5
-5
@@ -1,6 +1,6 @@
|
||||
use alloc::vec::Vec;
|
||||
use core::{fmt, mem, ops, slice};
|
||||
use simple_endian::*;
|
||||
use endian_num::Le;
|
||||
|
||||
use crate::{BlockAddr, BlockLevel, BlockPtr, BlockTrait, BLOCK_SIZE};
|
||||
|
||||
@@ -125,8 +125,8 @@ impl Allocator {
|
||||
|
||||
#[repr(packed)]
|
||||
pub struct AllocEntry {
|
||||
index: u64le,
|
||||
count: i64le,
|
||||
index: Le<u64>,
|
||||
count: Le<i64>,
|
||||
}
|
||||
|
||||
impl AllocEntry {
|
||||
@@ -146,11 +146,11 @@ impl AllocEntry {
|
||||
}
|
||||
|
||||
pub fn index(&self) -> u64 {
|
||||
{ self.index }.to_native()
|
||||
self.index.to_ne()
|
||||
}
|
||||
|
||||
pub fn count(&self) -> i64 {
|
||||
{ self.count }.to_native()
|
||||
self.count.to_ne()
|
||||
}
|
||||
|
||||
pub fn is_null(&self) -> bool {
|
||||
|
||||
+5
-5
@@ -1,5 +1,5 @@
|
||||
use core::{fmt, marker::PhantomData, mem, ops, slice};
|
||||
use simple_endian::*;
|
||||
use endian_num::Le;
|
||||
|
||||
use crate::BLOCK_SIZE;
|
||||
|
||||
@@ -178,8 +178,8 @@ impl<T> ops::DerefMut for BlockList<T> {
|
||||
|
||||
#[repr(packed)]
|
||||
pub struct BlockPtr<T> {
|
||||
addr: u64le,
|
||||
hash: u64le,
|
||||
addr: Le<u64>,
|
||||
hash: Le<u64>,
|
||||
phantom: PhantomData<T>,
|
||||
}
|
||||
|
||||
@@ -193,11 +193,11 @@ impl<T> BlockPtr<T> {
|
||||
}
|
||||
|
||||
pub fn addr(&self) -> BlockAddr {
|
||||
BlockAddr({ self.addr }.to_native())
|
||||
BlockAddr(self.addr.to_ne())
|
||||
}
|
||||
|
||||
pub fn hash(&self) -> u64 {
|
||||
{ self.hash }.to_native()
|
||||
self.hash.to_ne()
|
||||
}
|
||||
|
||||
pub fn is_null(&self) -> bool {
|
||||
|
||||
+11
-11
@@ -1,6 +1,6 @@
|
||||
use core::ops::{Deref, DerefMut};
|
||||
use core::{fmt, mem, slice};
|
||||
use simple_endian::*;
|
||||
use endian_num::Le;
|
||||
|
||||
use aes::{Aes128, BlockDecrypt, BlockEncrypt};
|
||||
use uuid::Uuid;
|
||||
@@ -16,13 +16,13 @@ pub struct Header {
|
||||
/// Signature, should be SIGNATURE
|
||||
pub signature: [u8; 8],
|
||||
/// Version, should be VERSION
|
||||
pub version: u64le,
|
||||
pub version: Le<u64>,
|
||||
/// Disk ID, a 128-bit unique identifier
|
||||
pub uuid: [u8; 16],
|
||||
/// Disk size, in number of BLOCK_SIZE sectors
|
||||
pub size: u64le,
|
||||
pub size: Le<u64>,
|
||||
/// Generation of header
|
||||
pub generation: u64le,
|
||||
pub generation: Le<u64>,
|
||||
/// Block of first tree node
|
||||
pub tree: BlockPtr<Tree>,
|
||||
/// Block of last alloc node
|
||||
@@ -34,7 +34,7 @@ pub struct Header {
|
||||
/// encrypted hash of header data without hash, set to hash and padded if disk is not encrypted
|
||||
pub encrypted_hash: [u8; 16],
|
||||
/// hash of header data without hash
|
||||
pub hash: u64le,
|
||||
pub hash: Le<u64>,
|
||||
}
|
||||
|
||||
impl Header {
|
||||
@@ -58,12 +58,12 @@ impl Header {
|
||||
return false;
|
||||
}
|
||||
|
||||
if { self.version }.to_native() != VERSION {
|
||||
if self.version.to_ne() != VERSION {
|
||||
// Version does not match
|
||||
return false;
|
||||
}
|
||||
|
||||
if { self.hash }.to_native() != self.create_hash() {
|
||||
if self.hash.to_ne() != self.create_hash() {
|
||||
// Hash does not match
|
||||
return false;
|
||||
}
|
||||
@@ -77,11 +77,11 @@ impl Header {
|
||||
}
|
||||
|
||||
pub fn size(&self) -> u64 {
|
||||
{ self.size }.to_native()
|
||||
self.size.to_ne()
|
||||
}
|
||||
|
||||
pub fn generation(&self) -> u64 {
|
||||
{ self.generation }.to_native()
|
||||
self.generation.to_ne()
|
||||
}
|
||||
|
||||
fn create_hash(&self) -> u64 {
|
||||
@@ -94,7 +94,7 @@ impl Header {
|
||||
|
||||
fn create_encrypted_hash(&self, aes_opt: Option<&Aes128>) -> [u8; 16] {
|
||||
let mut encrypted_hash = [0; 16];
|
||||
for (i, b) in { self.hash }.to_native().to_le_bytes().iter().enumerate() {
|
||||
for (i, b) in self.hash.to_le_bytes().iter().enumerate() {
|
||||
encrypted_hash[i] = *b;
|
||||
}
|
||||
if let Some(aes) = aes_opt {
|
||||
@@ -212,7 +212,7 @@ fn header_hash_test() {
|
||||
let mut header = Header::default();
|
||||
assert_eq!(header.create_hash(), 0xe81ffcb86026ff96);
|
||||
header.update_hash(None);
|
||||
assert_eq!({ header.hash }.to_native(), 0xe81ffcb86026ff96);
|
||||
assert_eq!(header.hash.to_ne(), 0xe81ffcb86026ff96);
|
||||
assert_eq!(
|
||||
header.encrypted_hash,
|
||||
[0x96, 0xff, 0x26, 0x60, 0xb8, 0xfc, 0x1f, 0xe8, 0, 0, 0, 0, 0, 0, 0, 0]
|
||||
|
||||
+22
-22
@@ -1,5 +1,5 @@
|
||||
use core::{fmt, mem, ops, slice};
|
||||
use simple_endian::*;
|
||||
use endian_num::Le;
|
||||
|
||||
use crate::{BlockLevel, BlockList, BlockPtr, BlockTrait, RecordRaw, BLOCK_SIZE, RECORD_LEVEL};
|
||||
|
||||
@@ -82,18 +82,18 @@ type BlockListL4 = BlockList<BlockListL3>;
|
||||
/// A file/folder node
|
||||
#[repr(packed)]
|
||||
pub struct Node {
|
||||
pub mode: u16le,
|
||||
pub uid: u32le,
|
||||
pub gid: u32le,
|
||||
pub links: u32le,
|
||||
pub size: u64le,
|
||||
pub ctime: u64le,
|
||||
pub ctime_nsec: u32le,
|
||||
pub mtime: u64le,
|
||||
pub mtime_nsec: u32le,
|
||||
pub atime: u64le,
|
||||
pub atime_nsec: u32le,
|
||||
pub record_level: u32le,
|
||||
pub mode: Le<u16>,
|
||||
pub uid: Le<u32>,
|
||||
pub gid: Le<u32>,
|
||||
pub links: Le<u32>,
|
||||
pub size: Le<u64>,
|
||||
pub ctime: Le<u64>,
|
||||
pub ctime_nsec: Le<u32>,
|
||||
pub mtime: Le<u64>,
|
||||
pub mtime_nsec: Le<u32>,
|
||||
pub atime: Le<u64>,
|
||||
pub atime_nsec: Le<u32>,
|
||||
pub record_level: Le<u32>,
|
||||
pub padding: [u8; BLOCK_SIZE as usize - 4094],
|
||||
// 128 * RECORD_SIZE (16 MiB, 128 KiB each)
|
||||
pub level0: [BlockPtr<RecordRaw>; 128],
|
||||
@@ -178,39 +178,39 @@ impl Node {
|
||||
}
|
||||
|
||||
pub fn mode(&self) -> u16 {
|
||||
{ self.mode }.to_native()
|
||||
self.mode.to_ne()
|
||||
}
|
||||
|
||||
pub fn uid(&self) -> u32 {
|
||||
{ self.uid }.to_native()
|
||||
self.uid.to_ne()
|
||||
}
|
||||
|
||||
pub fn gid(&self) -> u32 {
|
||||
{ self.gid }.to_native()
|
||||
self.gid.to_ne()
|
||||
}
|
||||
|
||||
pub fn links(&self) -> u32 {
|
||||
{ self.links }.to_native()
|
||||
self.links.to_ne()
|
||||
}
|
||||
|
||||
pub fn size(&self) -> u64 {
|
||||
{ self.size }.to_native()
|
||||
self.size.to_ne()
|
||||
}
|
||||
|
||||
pub fn ctime(&self) -> (u64, u32) {
|
||||
({ self.ctime }.to_native(), { self.ctime_nsec }.to_native())
|
||||
(self.ctime.to_ne(), self.ctime_nsec.to_ne())
|
||||
}
|
||||
|
||||
pub fn mtime(&self) -> (u64, u32) {
|
||||
({ self.mtime }.to_native(), { self.mtime_nsec }.to_native())
|
||||
(self.mtime.to_ne(), self.mtime_nsec.to_ne())
|
||||
}
|
||||
|
||||
pub fn atime(&self) -> (u64, u32) {
|
||||
({ self.atime }.to_native(), { self.atime_nsec }.to_native())
|
||||
(self.atime.to_ne(), self.atime_nsec.to_ne())
|
||||
}
|
||||
|
||||
pub fn record_level(&self) -> BlockLevel {
|
||||
BlockLevel({ self.record_level }.to_native() as usize)
|
||||
BlockLevel(self.record_level.to_ne() as usize)
|
||||
}
|
||||
|
||||
pub fn set_mode(&mut self, mode: u16) {
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
use core::{marker::PhantomData, mem, ops, slice};
|
||||
use simple_endian::*;
|
||||
use endian_num::Le;
|
||||
|
||||
use crate::{BlockLevel, BlockPtr, BlockRaw, BlockTrait};
|
||||
|
||||
@@ -87,7 +87,7 @@ impl<T> ops::DerefMut for TreeList<T> {
|
||||
|
||||
#[repr(packed)]
|
||||
pub struct TreePtr<T> {
|
||||
id: u32le,
|
||||
id: Le<u32>,
|
||||
phantom: PhantomData<T>,
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ impl<T> TreePtr<T> {
|
||||
}
|
||||
|
||||
pub fn id(&self) -> u32 {
|
||||
{ self.id }.to_native()
|
||||
self.id.to_ne()
|
||||
}
|
||||
|
||||
pub fn is_null(&self) -> bool {
|
||||
|
||||
Reference in New Issue
Block a user