Skip to content

Commit

Permalink
Merge pull request #28 from poliorcetics/dep-update
Browse files Browse the repository at this point in the history
deps: Update bitflags and memoffset
  • Loading branch information
ColinFinck committed Jun 13, 2023
2 parents ea4b054 + 38ac006 commit a490444
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ categories = ["filesystem", "no-std", "os::windows-apis", "parser-implementation
arrayvec = { version = "0.7.2", default-features = false }
binread = { version = "2.2.0", features = ["const_generics"], default-features = false }
byteorder = { version = "1.4.3", default-features = false }
bitflags = "1.3.2"
bitflags = "2.3.1"
derive_more = "0.99.17"
displaydoc = { version = "0.2.3", default-features = false }
enumn = "0.1.3"
memoffset = "0.8.0"
memoffset = "0.9.0"
nt-string = { version = "0.1.1", features = ["alloc"], default-features = false }
strum_macros = "0.24.0"
time = { version = "0.3.9", features = ["large-dates", "macros"], default-features = false, optional = true }
Expand Down
2 changes: 1 addition & 1 deletion examples/ntfs-shell/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ fn fileinfo_std(attribute: NtfsAttribute) -> Result<()> {

let std_info = attribute.resident_structured_value::<NtfsStandardInformation>()?;

println!("{:34}{:?}", "Attributes:", std_info.file_attributes());
println!("{:34}{}", "Attributes:", std_info.file_attributes());

let atime = OffsetDateTime::from(std_info.access_time())
.format(TIME_FORMAT)
Expand Down
9 changes: 8 additions & 1 deletion src/attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// SPDX-License-Identifier: MIT OR Apache-2.0

use core::iter::FusedIterator;
use core::mem;
use core::ops::Range;
use core::{fmt, mem};

use binread::io::{Read, Seek};
use bitflags::bitflags;
Expand Down Expand Up @@ -49,6 +49,7 @@ struct NtfsAttributeHeader {

bitflags! {
/// Flags returned by [`NtfsAttribute::flags`].
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct NtfsAttributeFlags: u16 {
/// The attribute value is compressed.
const COMPRESSED = 0x0001;
Expand All @@ -59,6 +60,12 @@ bitflags! {
}
}

impl fmt::Display for NtfsAttributeFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Display::fmt(&self.0, f)
}
}

/// On-disk structure of the extra header of an NTFS Attribute that has a resident value.
#[repr(C, packed)]
struct NtfsResidentAttributeHeader {
Expand Down
8 changes: 8 additions & 0 deletions src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: MIT OR Apache-2.0

use core::cmp::Ordering;
use core::fmt;
use core::num::NonZeroU64;

use alloc::vec;
Expand Down Expand Up @@ -96,6 +97,7 @@ struct FileRecordHeader {

bitflags! {
/// Flags returned by [`NtfsFile::flags`].
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct NtfsFileFlags: u16 {
/// Record is in use.
const IN_USE = 0x0001;
Expand All @@ -104,6 +106,12 @@ bitflags! {
}
}

impl fmt::Display for NtfsFileFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Display::fmt(&self.0, f)
}
}

/// A single NTFS File Record.
///
/// These records are denoted via a `FILE` signature on the filesystem.
Expand Down
9 changes: 8 additions & 1 deletion src/index_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

use core::iter::FusedIterator;
use core::marker::PhantomData;
use core::mem;
use core::ops::Range;
use core::{fmt, mem};

use alloc::vec::Vec;
use binread::io::{Read, Seek};
Expand Down Expand Up @@ -43,6 +43,7 @@ struct IndexEntryHeader {

bitflags! {
/// Flags returned by [`NtfsIndexEntry::flags`].
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct NtfsIndexEntryFlags: u8 {
/// This Index Entry points to a sub-node.
const HAS_SUBNODE = 0x01;
Expand All @@ -51,6 +52,12 @@ bitflags! {
}
}

impl fmt::Display for NtfsIndexEntryFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Display::fmt(&self.0, f)
}
}

#[derive(Clone, Debug)]
pub(crate) struct IndexEntryRange<E>
where
Expand Down
9 changes: 9 additions & 0 deletions src/structured_values/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ mod standard_information;
mod volume_information;
mod volume_name;

use core::fmt;

pub use attribute_list::*;
pub use file_name::*;
pub use index_allocation::*;
Expand All @@ -36,6 +38,7 @@ bitflags! {
/// Returned by [`NtfsStandardInformation::file_attributes`] and [`NtfsFileName::file_attributes`].
///
/// [`NtfsAttribute`]: crate::attribute::NtfsAttribute
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct NtfsFileAttributeFlags: u32 {
/// File is marked read-only.
const READ_ONLY = 0x0001;
Expand Down Expand Up @@ -71,6 +74,12 @@ bitflags! {
}
}

impl fmt::Display for NtfsFileAttributeFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Display::fmt(&self.0, f)
}
}

/// Trait implemented by every NTFS attribute structured value.
pub trait NtfsStructuredValue<'n, 'f>: Sized {
const TY: NtfsAttributeType;
Expand Down
9 changes: 9 additions & 0 deletions src/structured_values/volume_information.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright 2021-2022 Colin Finck <colin@reactos.org>
// SPDX-License-Identifier: MIT OR Apache-2.0

use core::fmt;

use binread::io::{Cursor, Read, Seek};
use binread::{BinRead, BinReaderExt};
use bitflags::bitflags;
Expand All @@ -26,6 +28,7 @@ struct VolumeInformationData {

bitflags! {
/// Flags returned by [`NtfsVolumeInformation::flags`].
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct NtfsVolumeFlags: u16 {
/// The volume needs to be checked by `chkdsk`.
const IS_DIRTY = 0x0001;
Expand All @@ -39,6 +42,12 @@ bitflags! {
}
}

impl fmt::Display for NtfsVolumeFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Display::fmt(&self.0, f)
}
}

/// Structure of a $VOLUME_INFORMATION attribute.
///
/// This attribute is only used by the top-level $Volume file and contains general information about the filesystem.
Expand Down

0 comments on commit a490444

Please sign in to comment.