Compare commits
2 Commits
main
...
read-poiso
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
952e796e28 | ||
|
|
9198193365 |
@@ -1,128 +0,0 @@
|
|||||||
|
|
||||||
# Contributor Covenant Code of Conduct
|
|
||||||
|
|
||||||
## Our Pledge
|
|
||||||
|
|
||||||
We as members, contributors, and leaders pledge to make participation in our
|
|
||||||
community a harassment-free experience for everyone, regardless of age, body
|
|
||||||
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
|
||||||
identity and expression, level of experience, education, socio-economic status,
|
|
||||||
nationality, personal appearance, race, caste, color, religion, or sexual
|
|
||||||
identity and orientation.
|
|
||||||
|
|
||||||
We pledge to act and interact in ways that contribute to an open, welcoming,
|
|
||||||
diverse, inclusive, and healthy community.
|
|
||||||
|
|
||||||
## Our Standards
|
|
||||||
|
|
||||||
Examples of behavior that contributes to a positive environment for our
|
|
||||||
community include:
|
|
||||||
|
|
||||||
- Demonstrating empathy and kindness toward other people
|
|
||||||
- Being respectful of differing opinions, viewpoints, and experiences
|
|
||||||
- Giving and gracefully accepting constructive feedback
|
|
||||||
- Accepting responsibility and apologizing to those affected by our mistakes,
|
|
||||||
and learning from the experience
|
|
||||||
- Focusing on what is best not just for us as individuals, but for the overall
|
|
||||||
community
|
|
||||||
|
|
||||||
Examples of unacceptable behavior include:
|
|
||||||
|
|
||||||
- The use of sexualized language or imagery, and sexual attention or advances of
|
|
||||||
any kind
|
|
||||||
- Trolling, insulting or derogatory comments, and personal or political attacks
|
|
||||||
- Public or private harassment
|
|
||||||
- Publishing others' private information, such as a physical or email address,
|
|
||||||
without their explicit permission
|
|
||||||
- Other conduct which could reasonably be considered inappropriate in a
|
|
||||||
professional setting
|
|
||||||
|
|
||||||
## Enforcement Responsibilities
|
|
||||||
|
|
||||||
Community leaders are responsible for clarifying and enforcing our standards of
|
|
||||||
acceptable behavior and will take appropriate and fair corrective action in
|
|
||||||
response to any behavior that they deem inappropriate, threatening, offensive,
|
|
||||||
or harmful.
|
|
||||||
|
|
||||||
Community leaders have the right and responsibility to remove, edit, or reject
|
|
||||||
comments, commits, code, wiki edits, issues, and other contributions that are
|
|
||||||
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
|
||||||
decisions when appropriate.
|
|
||||||
|
|
||||||
## Scope
|
|
||||||
|
|
||||||
This Code of Conduct applies within all community spaces, and also applies when
|
|
||||||
an individual is officially representing the community in public spaces.
|
|
||||||
Examples of representing our community include using an official email address,
|
|
||||||
posting via an official social media account, or acting as an appointed
|
|
||||||
representative at an online or offline event.
|
|
||||||
|
|
||||||
## Enforcement
|
|
||||||
|
|
||||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
||||||
reported to the community leaders responsible for enforcement at
|
|
||||||
<olivia.a.brooks77@gmail.com>.
|
|
||||||
All complaints will be reviewed and investigated promptly and fairly.
|
|
||||||
|
|
||||||
All community leaders are obligated to respect the privacy and security of the
|
|
||||||
reporter of any incident.
|
|
||||||
|
|
||||||
## Enforcement Guidelines
|
|
||||||
|
|
||||||
Community leaders will follow these Community Impact Guidelines in determining
|
|
||||||
the consequences for any action they deem in violation of this Code of Conduct:
|
|
||||||
|
|
||||||
### 1. Correction
|
|
||||||
|
|
||||||
**Community Impact**: Use of inappropriate language or other behavior deemed
|
|
||||||
unprofessional or unwelcome in the community.
|
|
||||||
|
|
||||||
**Consequence**: A private, written warning from community leaders, providing
|
|
||||||
clarity around the nature of the violation and an explanation of why the
|
|
||||||
behavior was inappropriate. A public apology may be requested.
|
|
||||||
|
|
||||||
### 2. Warning
|
|
||||||
|
|
||||||
**Community Impact**: A violation through a single incident or series of
|
|
||||||
actions.
|
|
||||||
|
|
||||||
**Consequence**: A warning with consequences for continued behavior. No
|
|
||||||
interaction with the people involved, including unsolicited interaction with
|
|
||||||
those enforcing the Code of Conduct, for a specified period of time. This
|
|
||||||
includes avoiding interactions in community spaces as well as external channels
|
|
||||||
like social media. Violating these terms may lead to a temporary or permanent
|
|
||||||
ban.
|
|
||||||
|
|
||||||
### 3. Temporary Ban
|
|
||||||
|
|
||||||
**Community Impact**: A serious violation of community standards, including
|
|
||||||
sustained inappropriate behavior.
|
|
||||||
|
|
||||||
**Consequence**: A temporary ban from any sort of interaction or public
|
|
||||||
communication with the community for a specified period of time. No public or
|
|
||||||
private interaction with the people involved, including unsolicited interaction
|
|
||||||
with those enforcing the Code of Conduct, is allowed during this period.
|
|
||||||
Violating these terms may lead to a permanent ban.
|
|
||||||
|
|
||||||
### 4. Permanent Ban
|
|
||||||
|
|
||||||
**Community Impact**: Demonstrating a pattern of violation of community
|
|
||||||
standards, including sustained inappropriate behavior, harassment of an
|
|
||||||
individual, or aggression toward or disparagement of classes of individuals.
|
|
||||||
|
|
||||||
**Consequence**: A permanent ban from any sort of public interaction within the
|
|
||||||
community.
|
|
||||||
|
|
||||||
## Attribution
|
|
||||||
|
|
||||||
This Code of Conduct is adapted from the
|
|
||||||
[Contributor Covenant](https://www.contributor-covenant.org/), version 2.1,
|
|
||||||
available at
|
|
||||||
<https://www.contributor-covenant.org/version/2/1/code_of_conduct/>.
|
|
||||||
|
|
||||||
Community Impact Guidelines were inspired by
|
|
||||||
[Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/inclusion).
|
|
||||||
|
|
||||||
For answers to common questions about this code of conduct, see the FAQ at
|
|
||||||
<https://www.contributor-covenant.org/faq/>. Translations are available at
|
|
||||||
<https://www.contributor-covenant.org/translations/>.
|
|
||||||
194
Cargo.lock
generated
194
Cargo.lock
generated
@@ -4,9 +4,9 @@ version = 4
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "addr2line"
|
name = "addr2line"
|
||||||
version = "0.25.1"
|
version = "0.24.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1b5d307320b3181d6d7954e663bd7c774a838b8220fe0593c86d9fb09f498b4b"
|
checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"gimli",
|
"gimli",
|
||||||
]
|
]
|
||||||
@@ -17,55 +17,11 @@ version = "2.0.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
|
checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "anstream"
|
|
||||||
version = "0.6.20"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "3ae563653d1938f79b1ab1b5e668c87c76a9930414574a6583a7b7e11a8e6192"
|
|
||||||
dependencies = [
|
|
||||||
"anstyle",
|
|
||||||
"anstyle-parse",
|
|
||||||
"anstyle-query",
|
|
||||||
"anstyle-wincon",
|
|
||||||
"colorchoice",
|
|
||||||
"is_terminal_polyfill",
|
|
||||||
"utf8parse",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anstyle"
|
name = "anstyle"
|
||||||
version = "1.0.13"
|
version = "1.0.10"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78"
|
checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "anstyle-parse"
|
|
||||||
version = "0.2.7"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2"
|
|
||||||
dependencies = [
|
|
||||||
"utf8parse",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "anstyle-query"
|
|
||||||
version = "1.1.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "6c8bdeb6047d8983be085bab0ba1472e6dc604e7041dbf6fcd5e71523014fae9"
|
|
||||||
dependencies = [
|
|
||||||
"windows-sys",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "anstyle-wincon"
|
|
||||||
version = "3.0.9"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "403f75924867bb1033c59fbf0797484329750cfbe3c4325cd33127941fabc882"
|
|
||||||
dependencies = [
|
|
||||||
"anstyle",
|
|
||||||
"once_cell_polyfill",
|
|
||||||
"windows-sys",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anyhow"
|
name = "anyhow"
|
||||||
@@ -78,9 +34,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "backtrace"
|
name = "backtrace"
|
||||||
version = "0.3.76"
|
version = "0.3.75"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bb531853791a215d7c62a30daf0dde835f381ab5de4589cfe7c649d2cbe92bd6"
|
checksum = "6806a6321ec58106fea15becdad98371e28d92ccbc7c8f1b3b6dd724fe8f1002"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"addr2line",
|
"addr2line",
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
@@ -88,16 +44,22 @@ dependencies = [
|
|||||||
"miniz_oxide",
|
"miniz_oxide",
|
||||||
"object",
|
"object",
|
||||||
"rustc-demangle",
|
"rustc-demangle",
|
||||||
"windows-link",
|
"windows-targets",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bitflags"
|
name = "base64"
|
||||||
version = "2.10.0"
|
version = "0.21.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3"
|
checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bitflags"
|
||||||
|
version = "2.8.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde_core",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -108,9 +70,9 @@ checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap"
|
name = "clap"
|
||||||
version = "4.5.53"
|
version = "4.5.31"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c9e340e012a1bf4935f5282ed1436d1489548e8f72308207ea5df0e23d2d03f8"
|
checksum = "027bb0d98429ae334a8698531da7077bdf906419543a35a55c2cb1b66437d767"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap_builder",
|
"clap_builder",
|
||||||
"clap_derive",
|
"clap_derive",
|
||||||
@@ -118,11 +80,10 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap_builder"
|
name = "clap_builder"
|
||||||
version = "4.5.53"
|
version = "4.5.31"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d76b5d13eaa18c901fd2f7fca939fefe3a0727a953561fefdf3b2922b8569d00"
|
checksum = "5589e0cba072e0f3d23791efac0fd8627b49c829c196a492e88168e6a669d863"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anstream",
|
|
||||||
"anstyle",
|
"anstyle",
|
||||||
"clap_lex",
|
"clap_lex",
|
||||||
"strsim",
|
"strsim",
|
||||||
@@ -130,9 +91,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap_derive"
|
name = "clap_derive"
|
||||||
version = "4.5.49"
|
version = "4.5.28"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2a0b5487afeab2deb2ff4e03a807ad1a03ac532ff5a2cee5d86884440c7f7671"
|
checksum = "bf4ced95c6f4a675af3da73304b9ac4ed991640c36374e4b46795c49e17cf1ed"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"heck",
|
"heck",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
@@ -142,21 +103,15 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap_lex"
|
name = "clap_lex"
|
||||||
version = "0.7.6"
|
version = "0.7.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d"
|
checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "colorchoice"
|
|
||||||
version = "1.0.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gimli"
|
name = "gimli"
|
||||||
version = "0.32.3"
|
version = "0.31.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e629b9b98ef3dd8afe6ca2bd0f89306cec16d43d907889945bc5d6687f2f13c7"
|
checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "heck"
|
name = "heck"
|
||||||
@@ -164,12 +119,6 @@ version = "0.5.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "is_terminal_polyfill"
|
|
||||||
version = "1.70.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "kramer"
|
name = "kramer"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
@@ -204,87 +153,63 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "object"
|
name = "object"
|
||||||
version = "0.37.3"
|
version = "0.36.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ff76201f031d8863c38aa7f905eca4f53abbfa15f609db4277d44cd8938f33fe"
|
checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"memchr",
|
"memchr",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "once_cell"
|
|
||||||
version = "1.21.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "once_cell_polyfill"
|
|
||||||
version = "1.70.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
version = "1.0.104"
|
version = "1.0.92"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9695f8df41bb4f3d222c95a67532365f569318332d03d5f3f67f37b20e6ebdf0"
|
checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quote"
|
name = "quote"
|
||||||
version = "1.0.42"
|
version = "1.0.37"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a338cc41d27e6cc6dce6cefc13a0729dfbb81c262b1f519331575dd80ef3067f"
|
checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ron"
|
name = "ron"
|
||||||
version = "0.12.0"
|
version = "0.8.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fd490c5b18261893f14449cbd28cb9c0b637aebf161cd77900bfdedaff21ec32"
|
checksum = "b91f7eff05f748767f183df4320a63d6936e9c6107d97c9e6bdd9784f4289c94"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"base64",
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"once_cell",
|
|
||||||
"serde",
|
"serde",
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
"typeid",
|
|
||||||
"unicode-ident",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustc-demangle"
|
name = "rustc-demangle"
|
||||||
version = "0.1.26"
|
version = "0.1.25"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "56f7d92ca342cea22a06f2121d944b4fd82af56988c270852495420f961d4ace"
|
checksum = "989e6739f80c4ad5b13e0fd7fe89531180375b18520cc8c82080e4dc4035b84f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.228"
|
version = "1.0.219"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
|
checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6"
|
||||||
dependencies = [
|
|
||||||
"serde_core",
|
|
||||||
"serde_derive",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "serde_core"
|
|
||||||
version = "1.0.228"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_derive"
|
name = "serde_derive"
|
||||||
version = "1.0.228"
|
version = "1.0.219"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
|
checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -299,47 +224,20 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "2.0.112"
|
version = "2.0.89"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "21f182278bf2d2bcb3c88b1b08a37df029d71ce3d3ae26168e3c653b213b99d4"
|
checksum = "44d46482f1c1c87acd84dea20c1bf5ebff4c757009ed6bf19cfd36fb10e92c4e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "typeid"
|
|
||||||
version = "1.0.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "bc7d623258602320d5c55d1bc22793b57daff0ec7efc270ea7d55ce1d5f5471c"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-ident"
|
name = "unicode-ident"
|
||||||
version = "1.0.22"
|
version = "1.0.14"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5"
|
checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "utf8parse"
|
|
||||||
version = "0.2.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows-link"
|
|
||||||
version = "0.2.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows-sys"
|
|
||||||
version = "0.59.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
|
|
||||||
dependencies = [
|
|
||||||
"windows-targets",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-targets"
|
name = "windows-targets"
|
||||||
|
|||||||
42
Cargo.toml
42
Cargo.toml
@@ -2,32 +2,40 @@
|
|||||||
name = "kramer"
|
name = "kramer"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
authors = ["Olivia Brooks"]
|
|
||||||
repository = "https://gitea.cutieguwu.ca/cutieguwu/kramer"
|
|
||||||
license = "MIT"
|
|
||||||
publish = false
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
ron = ">=0.8, <0.13"
|
libc = "0.2.178"
|
||||||
|
# NOTE:
|
||||||
|
# = X.X.X is the version used in testing.
|
||||||
|
# Use this version for greatest compatibility.
|
||||||
|
#
|
||||||
|
# For clap info, see [dependencies.clap]
|
||||||
|
# For serde info, see [dependencies.serde]
|
||||||
|
|
||||||
|
ron = "0.8.1, >=0.8, <0.9"
|
||||||
#rust-i18n = "3.1.3"
|
#rust-i18n = "3.1.3"
|
||||||
|
|
||||||
[dependencies.anyhow]
|
[dependencies.anyhow]
|
||||||
version = "1.0"
|
version = "1.0"
|
||||||
features = ["backtrace"]
|
features = [
|
||||||
|
"backtrace",
|
||||||
|
]
|
||||||
|
|
||||||
[dependencies.clap]
|
[dependencies.clap]
|
||||||
version = "4.5"
|
version = "4.5"
|
||||||
features = ["derive"]
|
default-features = false
|
||||||
|
features = [
|
||||||
|
# From default features collection
|
||||||
|
"error-context",
|
||||||
|
"help",
|
||||||
|
"std",
|
||||||
|
"suggestions",
|
||||||
|
"usage",
|
||||||
|
|
||||||
|
# Optional features
|
||||||
|
"derive",
|
||||||
|
]
|
||||||
|
|
||||||
[dependencies.serde]
|
[dependencies.serde]
|
||||||
version = "1.0"
|
version = "1.0.219"
|
||||||
features = ["derive"]
|
features = ["derive"]
|
||||||
|
|
||||||
# Yes. For one constant, this library is required.
|
|
||||||
# Technically, this did a bit more in early testing when I messed about
|
|
||||||
# with unsafe ffi disasters trying to solve problems.
|
|
||||||
#
|
|
||||||
# And yes, I spent time tracking down the first release with that constant.
|
|
||||||
# v0.2.25 is almost 9 years old as of writing this comment
|
|
||||||
[target.'cfg(all(unix, not(target_os = "macos")))'.dependencies]
|
|
||||||
libc = "~0.2.25"
|
|
||||||
|
|||||||
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2025 Olivia Brooks
|
Copyright (c) 2025 Olivia Bridie Alexandria Millicent Ivette Brooks
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
41
README.adoc
Normal file
41
README.adoc
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
= kramer
|
||||||
|
:toc:
|
||||||
|
|
||||||
|
// Hello people reading the README source :)
|
||||||
|
|
||||||
|
== Prelude
|
||||||
|
|
||||||
|
VERY EARLY ALPHA -- NOT YET FUNCTIONAL
|
||||||
|
|
||||||
|
I needed a program to efficiently repair the data on optical discs.
|
||||||
|
|
||||||
|
== Goals
|
||||||
|
|
||||||
|
* [*] CLI Args
|
||||||
|
** [*] Input device
|
||||||
|
** [*] Output file (ISO 9660)
|
||||||
|
** [*] Repair map file
|
||||||
|
** [*] sequence_length
|
||||||
|
** [*] brute_passes
|
||||||
|
** [*] Sector size override?
|
||||||
|
|
||||||
|
* Repair Algorithm
|
||||||
|
** Stage 1: Trial
|
||||||
|
*** [ ] 1 - From first sector, parse forward to error.
|
||||||
|
*** [ ] 2 - From last sector, parse backwards to error.
|
||||||
|
*** [ ] 3 - From center of data for trial, parse forward to error or end of remaining trial domain.
|
||||||
|
*** [ ] 4 - Stripe-skip remaining data, attempting to read largest trial domains first.
|
||||||
|
**** [ ] If data keeps reading good, no skip will occur until an error is reached.
|
||||||
|
** Stage 2: Isolation
|
||||||
|
*** [ ] From largest to smallest untrustworthy sequence, attempt to read each sequence at half sequence_length.
|
||||||
|
*** [ ] Same, but at quarter sequence_length.
|
||||||
|
*** [ ] Same, but at eighth sequence_length.
|
||||||
|
*** [ ] By sector, parse untrustworthy sequences from start to error, and end to error. Mark mid section for brute force.
|
||||||
|
** Stage 3: Brute Force
|
||||||
|
*** [ ] Desperately attempt to recover data from marked sections.
|
||||||
|
*** [ ] Attempt for brute_passes, retrying all failed sectors.
|
||||||
|
|
||||||
|
* [ ] Repair Map
|
||||||
|
** [ ] I'll figure out some kind of language for this...
|
||||||
|
|
||||||
|
== License
|
||||||
70
README.md
70
README.md
@@ -1,70 +0,0 @@
|
|||||||
# kramer
|
|
||||||
|
|
||||||
`kramer` is a data recovery utility for optical media.
|
|
||||||
|
|
||||||
There are plans to change the project name, but during initial development it
|
|
||||||
will continue to be referred to as kramer.
|
|
||||||
|
|
||||||
This is still in very early development, so expect old maps to no longer work.
|
|
||||||
|
|
||||||
## Plans
|
|
||||||
|
|
||||||
### Core
|
|
||||||
|
|
||||||
- [x] Mapping
|
|
||||||
- [x] Record the state of disc regions.
|
|
||||||
- [x] Recover from saved map.
|
|
||||||
- [x] Backup old map before truncating for new.
|
|
||||||
- [ ] Recovery
|
|
||||||
- [x] Initial / Patchworking
|
|
||||||
Technically there is an outstanding issue with sleepy firmware here,
|
|
||||||
but beside that this technically works.
|
|
||||||
- [ ] Isolate
|
|
||||||
- [ ] Scraping
|
|
||||||
- [ ] CLI
|
|
||||||
- [x] Arguments
|
|
||||||
- [ ] Recovery progress
|
|
||||||
- [ ] Recovery stats
|
|
||||||
- [ ] Documentation, eugh.
|
|
||||||
|
|
||||||
### Extra
|
|
||||||
|
|
||||||
- [ ] i18n
|
|
||||||
- [ ] English
|
|
||||||
- [ ] French
|
|
||||||
- [ ] TUI (akin to `ddrescueview`)
|
|
||||||
- [ ] Visual status map
|
|
||||||
- [ ] Recovery properties
|
|
||||||
- [ ] Recovery progress
|
|
||||||
- [ ] Recovery stats
|
|
||||||
|
|
||||||
## Recovery Strategy
|
|
||||||
|
|
||||||
### Initial Pass / Patchworking
|
|
||||||
|
|
||||||
Tries to read clusters of `max_buffer_size`, marking clusters with errors with
|
|
||||||
an increasing `level`.
|
|
||||||
|
|
||||||
This works by halving the length of the read buffer until one of two
|
|
||||||
conditions is met:
|
|
||||||
|
|
||||||
1. `max_buffer_size` has been divided by `max_buffer_subdivision`
|
|
||||||
(like a maximum recursion depth).
|
|
||||||
Effectively, it will keep running `max_buffer_size / isolation_depth;
|
|
||||||
isolation_depth++;` on each pass until `isolation_depth ==
|
|
||||||
max_buffer_subdivision`
|
|
||||||
2. `buffer_size <= min_buffer_size`
|
|
||||||
3. `buffer_size <= sector_size`
|
|
||||||
|
|
||||||
### Isolate
|
|
||||||
|
|
||||||
This is where we reach brute forcing territory. `ddrescue` refers to this as
|
|
||||||
trimming. `kramer` implements the same technique. However, thanks to the
|
|
||||||
patchworking pass, this sector-at-a-time reading can be minimized, hopefully
|
|
||||||
reducing wear and overall recovery time on drives with a very short spin-down
|
|
||||||
delay.
|
|
||||||
|
|
||||||
### Scraping (Stage::BruteForceAndDesperation)
|
|
||||||
|
|
||||||
This is the pure brute force, sector-at-a-time read. This has identical
|
|
||||||
behaviour to `ddrescue`'s scraping phase.
|
|
||||||
20
src/cli.rs
20
src/cli.rs
@@ -1,6 +1,8 @@
|
|||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::sync::LazyLock;
|
use std::sync::LazyLock;
|
||||||
|
|
||||||
|
use crate::FB_SECTOR_SIZE;
|
||||||
|
|
||||||
use clap::{ArgAction, Parser};
|
use clap::{ArgAction, Parser};
|
||||||
|
|
||||||
pub static CONFIG: LazyLock<Args> = LazyLock::new(|| Args::parse());
|
pub static CONFIG: LazyLock<Args> = LazyLock::new(|| Args::parse());
|
||||||
@@ -20,7 +22,7 @@ pub struct Args {
|
|||||||
pub map: Option<PathBuf>,
|
pub map: Option<PathBuf>,
|
||||||
|
|
||||||
/// Max number of consecutive sectors to test as a group
|
/// Max number of consecutive sectors to test as a group
|
||||||
#[arg(short, long, default_value_t = crate::FB_CLUSTER_LEN)]
|
#[arg(short, long, default_value_t = 128)]
|
||||||
pub cluster_length: usize,
|
pub cluster_length: usize,
|
||||||
|
|
||||||
/// Number of brute force read passes
|
/// Number of brute force read passes
|
||||||
@@ -28,21 +30,13 @@ pub struct Args {
|
|||||||
pub brute_passes: usize,
|
pub brute_passes: usize,
|
||||||
|
|
||||||
/// Sector size
|
/// Sector size
|
||||||
#[arg(short, long, default_value_t = crate::FB_SECTOR_SIZE)]
|
#[arg(short, long, default_value_t = FB_SECTOR_SIZE)]
|
||||||
pub sector_size: usize,
|
pub sector_size: usize,
|
||||||
|
|
||||||
// !!! ArgAction behaviour is backwards !!!
|
// Behaviour is backwards.
|
||||||
// ArgAction::SetFalse by default evaluates to true,
|
// ArgAction::SetFalse by default evaluates to true,
|
||||||
// ArgAction::SetTrue by default evaluates to false.
|
// ArgAction::SetTrue by default evaluates to false.
|
||||||
//
|
/// Whether to reopen the file on a read error or not.
|
||||||
/// Upon encountering a read error, reopen the source file before continuing.
|
#[arg(short, long, action=ArgAction::SetTrue)]
|
||||||
#[arg(short, long, action = ArgAction::SetTrue)]
|
|
||||||
pub reopen_on_error: bool,
|
pub reopen_on_error: bool,
|
||||||
|
|
||||||
/// Use O_DIRECT to bypass kernel buffer when reading.
|
|
||||||
//
|
|
||||||
// BSD seems to support O_DIRECT, but MacOS for certain does not.
|
|
||||||
#[cfg(all(unix, not(target_os = "macos")))]
|
|
||||||
#[arg(short, long = "direct", action = ArgAction::SetFalse)]
|
|
||||||
pub direct_io: bool,
|
|
||||||
}
|
}
|
||||||
|
|||||||
118
src/io.rs
118
src/io.rs
@@ -1,11 +1,11 @@
|
|||||||
|
use std::ffi::CString;
|
||||||
use std::fs::{File, OpenOptions};
|
use std::fs::{File, OpenOptions};
|
||||||
use std::io::{self, Seek, SeekFrom};
|
use std::io::{self, Seek, SeekFrom};
|
||||||
use std::ops::Index;
|
use std::os::fd::{AsRawFd, FromRawFd, IntoRawFd};
|
||||||
use std::path::Path;
|
|
||||||
|
|
||||||
use crate::cli::CONFIG;
|
use crate::cli::CONFIG;
|
||||||
|
|
||||||
use anyhow::{Context, anyhow};
|
use anyhow::Context;
|
||||||
|
|
||||||
/// Get length of data stream.
|
/// Get length of data stream.
|
||||||
/// Physical length of data stream in bytes
|
/// Physical length of data stream in bytes
|
||||||
@@ -21,28 +21,22 @@ pub fn get_stream_length<S: Seek>(stream: &mut S) -> io::Result<u64> {
|
|||||||
len
|
len
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(unix, not(target_os = "macos")))]
|
/*
|
||||||
|
* IO Error Poisoning:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Attempt 1:
|
||||||
|
*
|
||||||
|
* Wrap C calls w/ `ffi`. Most importantly, execute the `close()` through C.
|
||||||
|
*
|
||||||
|
* I cannot seem to execute `close()`... one hopes that reassigning will drop
|
||||||
|
* calling `close()` on the old fd, but I don't know.
|
||||||
|
*/
|
||||||
|
|
||||||
pub fn load_input() -> anyhow::Result<File> {
|
pub fn load_input() -> anyhow::Result<File> {
|
||||||
use std::os::unix::fs::OpenOptionsExt;
|
let path = CString::new(CONFIG.input.to_str().unwrap().to_owned())?;
|
||||||
|
let flags = libc::O_RDONLY | libc::O_DIRECT;
|
||||||
let mut options = OpenOptions::new();
|
Ok(unsafe { File::from_raw_fd(libc::open(path.as_ptr(), flags)) })
|
||||||
options.read(true);
|
|
||||||
|
|
||||||
if CONFIG.direct_io {
|
|
||||||
options.custom_flags(libc::O_DIRECT);
|
|
||||||
}
|
|
||||||
|
|
||||||
options
|
|
||||||
.open(&CONFIG.input)
|
|
||||||
.with_context(|| format!("Failed to open input file: {}", &CONFIG.input.display()))
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(any(not(unix), target_os = "macos"))]
|
|
||||||
pub fn load_input() -> anyhow::Result<File> {
|
|
||||||
OpenOptions::new()
|
|
||||||
.read(true)
|
|
||||||
.open(&CONFIG.input)
|
|
||||||
.with_context(|| format!("Failed to open input file: {}", &CONFIG.input.display()))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn load_output() -> anyhow::Result<File> {
|
pub fn load_output() -> anyhow::Result<File> {
|
||||||
@@ -66,21 +60,10 @@ pub fn load_map_read() -> std::io::Result<File> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn load_map_write() -> anyhow::Result<File> {
|
pub fn load_map_write() -> anyhow::Result<File> {
|
||||||
// Attempt to check if a map exists on the disk.
|
|
||||||
// If so, make a backup of it.
|
|
||||||
//
|
|
||||||
// This should be recoverable by just skipping over this error and logging a warning,
|
|
||||||
// but for now it will be an error condition.
|
|
||||||
if std::fs::exists(crate::path::MAP_PATH.clone())
|
|
||||||
.context("Could not check if map exists in fs to make a backup.")?
|
|
||||||
{
|
|
||||||
backup(crate::path::MAP_PATH.clone())?;
|
|
||||||
}
|
|
||||||
|
|
||||||
OpenOptions::new()
|
OpenOptions::new()
|
||||||
.write(true)
|
.write(true)
|
||||||
.create(true)
|
.create(true)
|
||||||
.truncate(true) // Wipe old map, in case we skip over backing up the old one.
|
.truncate(true) // Wipe old map. Should really make a backup first.
|
||||||
.open(crate::path::MAP_PATH.clone())
|
.open(crate::path::MAP_PATH.clone())
|
||||||
.with_context(|| {
|
.with_context(|| {
|
||||||
format!(
|
format!(
|
||||||
@@ -89,66 +72,3 @@ pub fn load_map_write() -> anyhow::Result<File> {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn backup<P: AsRef<Path>>(path: P) -> std::io::Result<()> {
|
|
||||||
std::fs::rename(
|
|
||||||
&path,
|
|
||||||
format!("{}.bak", path.as_ref().to_path_buf().display()),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
#[repr(C, align(512))]
|
|
||||||
pub struct DirectIOBuffer(pub [u8; crate::MAX_BUFFER_SIZE]);
|
|
||||||
|
|
||||||
impl DirectIOBuffer {
|
|
||||||
pub fn new() -> Self {
|
|
||||||
Self::default()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for DirectIOBuffer {
|
|
||||||
fn default() -> Self {
|
|
||||||
Self([crate::FB_NULL_VALUE; _])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<[u8; crate::MAX_BUFFER_SIZE]> for DirectIOBuffer {
|
|
||||||
fn from(value: [u8; crate::MAX_BUFFER_SIZE]) -> Self {
|
|
||||||
Self(value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl TryFrom<&[u8]> for DirectIOBuffer {
|
|
||||||
type Error = anyhow::Error;
|
|
||||||
|
|
||||||
fn try_from(value: &[u8]) -> Result<Self, Self::Error> {
|
|
||||||
if value.len() > crate::MAX_BUFFER_SIZE {
|
|
||||||
return Err(anyhow!("Provided slice is larger than MAX_BUFFER_SIZE."));
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(Self(value.try_into()?))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl AsRef<[u8]> for DirectIOBuffer {
|
|
||||||
fn as_ref(&self) -> &[u8] {
|
|
||||||
&self.0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl AsMut<[u8]> for DirectIOBuffer {
|
|
||||||
fn as_mut(&mut self) -> &mut [u8] {
|
|
||||||
&mut self.0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<Idx> Index<Idx> for DirectIOBuffer
|
|
||||||
where
|
|
||||||
Idx: std::slice::SliceIndex<[u8], Output = [u8]>,
|
|
||||||
{
|
|
||||||
type Output = Idx::Output;
|
|
||||||
fn index(&self, index: Idx) -> &Self::Output {
|
|
||||||
&self.0.as_slice()[index]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -9,11 +9,8 @@ use recovery::Recover;
|
|||||||
use anyhow;
|
use anyhow;
|
||||||
|
|
||||||
const FB_SECTOR_SIZE: usize = 2048;
|
const FB_SECTOR_SIZE: usize = 2048;
|
||||||
const FB_CLUSTER_LEN: usize = 128;
|
|
||||||
const FB_NULL_VALUE: u8 = 0;
|
const FB_NULL_VALUE: u8 = 0;
|
||||||
|
|
||||||
const MAX_BUFFER_SIZE: usize = FB_SECTOR_SIZE * FB_CLUSTER_LEN;
|
|
||||||
|
|
||||||
fn main() -> anyhow::Result<()> {
|
fn main() -> anyhow::Result<()> {
|
||||||
let mut recover_tool = Recover::new()?;
|
let mut recover_tool = Recover::new()?;
|
||||||
recover_tool.run()?;
|
recover_tool.run()?;
|
||||||
|
|||||||
@@ -3,8 +3,6 @@ use super::{Domain, Stage};
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// A map for data stored in memory for processing and saving to disk.
|
/// A map for data stored in memory for processing and saving to disk.
|
||||||
// derived Ord impl *should* use self.domain.start to sort? Not sure.
|
|
||||||
// Use `sort_by_key()` to be safe.
|
|
||||||
#[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
|
#[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
|
||||||
pub struct Cluster {
|
pub struct Cluster {
|
||||||
pub domain: Domain,
|
pub domain: Domain,
|
||||||
@@ -23,7 +21,6 @@ impl Default for Cluster {
|
|||||||
impl Cluster {
|
impl Cluster {
|
||||||
/// Breaks apart into a vec of clusters,
|
/// Breaks apart into a vec of clusters,
|
||||||
/// each of cluster_size, excepting last.
|
/// each of cluster_size, excepting last.
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn subdivide(&mut self, cluster_len: usize) -> Vec<Cluster> {
|
pub fn subdivide(&mut self, cluster_len: usize) -> Vec<Cluster> {
|
||||||
let domain_len = self.domain.len();
|
let domain_len = self.domain.len();
|
||||||
let mut start = self.domain.start;
|
let mut start = self.domain.start;
|
||||||
@@ -52,8 +49,6 @@ impl Cluster {
|
|||||||
clusters
|
clusters
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is used in unit tests at present. Ideally it probably shouldn't exist.
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn set_stage(&mut self, stage: Stage) -> &mut Self {
|
pub fn set_stage(&mut self, stage: Stage) -> &mut Self {
|
||||||
self.stage = stage;
|
self.stage = stage;
|
||||||
self
|
self
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ impl Default for Domain {
|
|||||||
|
|
||||||
impl Domain {
|
impl Domain {
|
||||||
/// Return length of domain in sectors.
|
/// Return length of domain in sectors.
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn len(self) -> usize {
|
pub fn len(self) -> usize {
|
||||||
self.end - self.start
|
self.end - self.start
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
|
||||||
use crate::mapping::cluster;
|
|
||||||
|
|
||||||
use super::{Cluster, Domain, DomainOverlap, Stage};
|
use super::{Cluster, Domain, DomainOverlap, Stage};
|
||||||
|
|
||||||
use anyhow;
|
use anyhow;
|
||||||
@@ -32,7 +30,7 @@ impl Default for MapFile {
|
|||||||
domain: Domain::default(),
|
domain: Domain::default(),
|
||||||
map: vec![Cluster {
|
map: vec![Cluster {
|
||||||
domain: Domain::default(),
|
domain: Domain::default(),
|
||||||
stage: Stage::Patchwork { depth: 0 },
|
stage: Stage::Untested,
|
||||||
}],
|
}],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -83,8 +81,18 @@ impl MapFile {
|
|||||||
let mut recover_stage = Stage::Damaged;
|
let mut recover_stage = Stage::Damaged;
|
||||||
|
|
||||||
for cluster in self.map.iter() {
|
for cluster in self.map.iter() {
|
||||||
if cluster.stage < recover_stage {
|
match cluster.stage {
|
||||||
recover_stage = cluster.stage;
|
Stage::Untested => return Stage::Untested,
|
||||||
|
Stage::ForIsolation { .. } => {
|
||||||
|
if recover_stage == Stage::Damaged || cluster.stage < recover_stage {
|
||||||
|
// Note that recover_stage after first condition is
|
||||||
|
// only ever Stage::ForIsolation(_), thus PartialEq,
|
||||||
|
// PartialOrd are useful for comparing the internal value.
|
||||||
|
recover_stage = cluster.stage
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Stage::Damaged => (),
|
||||||
|
Stage::Intact => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,29 +116,52 @@ impl MapFile {
|
|||||||
/// Defragments cluster groups.
|
/// Defragments cluster groups.
|
||||||
/// I.E. check forwards every cluster from current until stage changes,
|
/// I.E. check forwards every cluster from current until stage changes,
|
||||||
/// then group at once.
|
/// then group at once.
|
||||||
pub fn defrag(&mut self) {
|
pub fn defrag(&mut self) -> &mut Self {
|
||||||
self.map.sort_by_key(|c| c.domain.start);
|
|
||||||
|
|
||||||
let mut new_map: Vec<Cluster> = vec![];
|
let mut new_map: Vec<Cluster> = vec![];
|
||||||
let mut idx = 0;
|
|
||||||
let mut master;
|
|
||||||
while idx < self.map.len() - 1 {
|
|
||||||
master = self.map[idx];
|
|
||||||
|
|
||||||
for c in self.map[idx + 1..self.map.len()].into_iter() {
|
// Fetch first cluster.
|
||||||
if c.stage != master.stage {
|
let mut start_cluster = self.map.iter().find(|c| c.domain.start == 0).unwrap();
|
||||||
break;
|
|
||||||
|
// Even though this would be initialized by its first read,
|
||||||
|
// the compiler won't stop whining, and idk how to assert that to it.
|
||||||
|
let mut end_cluster = Cluster::default();
|
||||||
|
let mut new_cluster: Cluster;
|
||||||
|
|
||||||
|
let mut stage_common: bool;
|
||||||
|
let mut is_finished = false;
|
||||||
|
|
||||||
|
while !is_finished {
|
||||||
|
stage_common = true;
|
||||||
|
|
||||||
|
// Start a new cluster based on the cluster following
|
||||||
|
// the end of last new_cluster.
|
||||||
|
new_cluster = start_cluster.to_owned();
|
||||||
|
|
||||||
|
// While stage is common, and not finished,
|
||||||
|
// find each trailing cluster.
|
||||||
|
while stage_common && !is_finished {
|
||||||
|
end_cluster = start_cluster.to_owned();
|
||||||
|
|
||||||
|
if end_cluster.domain.end != self.domain.end {
|
||||||
|
start_cluster = self
|
||||||
|
.map
|
||||||
|
.iter()
|
||||||
|
.find(|c| end_cluster.domain.end == c.domain.start)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
stage_common = new_cluster.stage == start_cluster.stage
|
||||||
|
} else {
|
||||||
|
is_finished = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
idx += 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
master.domain.end = self.map[idx].domain.end;
|
// Set the new ending, encapsulating any clusters of common stage.
|
||||||
new_map.push(master);
|
new_cluster.domain.end = end_cluster.domain.end;
|
||||||
idx += 1;
|
new_map.push(new_cluster);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.map = new_map;
|
self.map = new_map;
|
||||||
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Extend the domain of the MapFile.
|
/// Extend the domain of the MapFile.
|
||||||
@@ -591,7 +622,7 @@ mod tests {
|
|||||||
let mut map = MapFile {
|
let mut map = MapFile {
|
||||||
map: vec![Cluster {
|
map: vec![Cluster {
|
||||||
domain: Domain { start: 0, end: 3 },
|
domain: Domain { start: 0, end: 3 },
|
||||||
stage: Stage::Patchwork { depth: 0 },
|
stage: Stage::Untested,
|
||||||
}],
|
}],
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
@@ -695,16 +726,17 @@ mod tests {
|
|||||||
|
|
||||||
// If this fails here, there's something SERIOUSLY wrong.
|
// If this fails here, there's something SERIOUSLY wrong.
|
||||||
assert!(
|
assert!(
|
||||||
mf_stage == Stage::Patchwork { depth: 0 },
|
mf_stage == Stage::Untested,
|
||||||
"Determined stage to be {:?}, when {:?} was expeccted.",
|
"Determined stage to be {:?}, when {:?} was expeccted.",
|
||||||
mf_stage,
|
mf_stage,
|
||||||
Stage::Patchwork { depth: 0 }
|
Stage::Untested
|
||||||
);
|
);
|
||||||
|
|
||||||
let stages = vec![
|
let stages = vec![
|
||||||
Stage::Damaged,
|
Stage::Damaged,
|
||||||
Stage::Patchwork { depth: 1 },
|
Stage::ForIsolation { level: 1 },
|
||||||
Stage::Patchwork { depth: 0 },
|
Stage::ForIsolation { level: 0 },
|
||||||
|
Stage::Untested,
|
||||||
];
|
];
|
||||||
|
|
||||||
mf.map = vec![];
|
mf.map = vec![];
|
||||||
@@ -730,17 +762,20 @@ mod tests {
|
|||||||
|
|
||||||
mf.map = vec![
|
mf.map = vec![
|
||||||
*Cluster::default().set_stage(Stage::Damaged),
|
*Cluster::default().set_stage(Stage::Damaged),
|
||||||
*Cluster::default().set_stage(Stage::Patchwork { depth: 1 }),
|
*Cluster::default().set_stage(Stage::ForIsolation { level: 0 }),
|
||||||
|
*Cluster::default().set_stage(Stage::ForIsolation { level: 1 }),
|
||||||
Cluster::default(),
|
Cluster::default(),
|
||||||
Cluster::default(),
|
Cluster::default(),
|
||||||
*Cluster::default().set_stage(Stage::Patchwork { depth: 1 }),
|
*Cluster::default().set_stage(Stage::ForIsolation { level: 1 }),
|
||||||
|
*Cluster::default().set_stage(Stage::ForIsolation { level: 0 }),
|
||||||
*Cluster::default().set_stage(Stage::Damaged),
|
*Cluster::default().set_stage(Stage::Damaged),
|
||||||
];
|
];
|
||||||
|
|
||||||
let stages = vec![
|
let stages = vec![
|
||||||
Stage::Damaged,
|
Stage::Damaged,
|
||||||
Stage::Patchwork { depth: 1 },
|
Stage::ForIsolation { level: 1 },
|
||||||
Stage::Patchwork { depth: 0 },
|
Stage::ForIsolation { level: 0 },
|
||||||
|
Stage::Untested,
|
||||||
];
|
];
|
||||||
|
|
||||||
for stage in stages {
|
for stage in stages {
|
||||||
@@ -768,84 +803,63 @@ mod tests {
|
|||||||
map: vec![
|
map: vec![
|
||||||
Cluster {
|
Cluster {
|
||||||
domain: Domain { start: 0, end: 1 },
|
domain: Domain { start: 0, end: 1 },
|
||||||
stage: Stage::Patchwork { depth: 0 },
|
stage: Stage::Untested,
|
||||||
},
|
},
|
||||||
Cluster {
|
Cluster {
|
||||||
domain: Domain { start: 1, end: 2 },
|
domain: Domain { start: 1, end: 2 },
|
||||||
stage: Stage::Patchwork { depth: 0 },
|
stage: Stage::Untested,
|
||||||
},
|
},
|
||||||
Cluster {
|
Cluster {
|
||||||
domain: Domain { start: 2, end: 3 },
|
domain: Domain { start: 2, end: 3 },
|
||||||
stage: Stage::Patchwork { depth: 0 },
|
stage: Stage::Untested,
|
||||||
},
|
},
|
||||||
Cluster {
|
Cluster {
|
||||||
domain: Domain { start: 3, end: 4 },
|
domain: Domain { start: 3, end: 4 },
|
||||||
stage: Stage::Isolate,
|
stage: Stage::ForIsolation { level: 0 },
|
||||||
},
|
},
|
||||||
Cluster {
|
Cluster {
|
||||||
domain: Domain { start: 4, end: 5 },
|
domain: Domain { start: 4, end: 5 },
|
||||||
stage: Stage::Isolate,
|
stage: Stage::ForIsolation { level: 0 },
|
||||||
},
|
},
|
||||||
Cluster {
|
Cluster {
|
||||||
domain: Domain { start: 5, end: 6 },
|
domain: Domain { start: 5, end: 6 },
|
||||||
stage: Stage::Patchwork { depth: 1 },
|
stage: Stage::ForIsolation { level: 1 },
|
||||||
},
|
},
|
||||||
Cluster {
|
Cluster {
|
||||||
domain: Domain { start: 6, end: 7 },
|
domain: Domain { start: 6, end: 7 },
|
||||||
stage: Stage::Patchwork { depth: 0 },
|
stage: Stage::ForIsolation { level: 0 },
|
||||||
},
|
},
|
||||||
Cluster {
|
Cluster {
|
||||||
domain: Domain { start: 7, end: 8 },
|
domain: Domain { start: 7, end: 8 },
|
||||||
stage: Stage::Damaged,
|
stage: Stage::Damaged,
|
||||||
},
|
},
|
||||||
Cluster {
|
|
||||||
domain: Domain { start: 8, end: 10 },
|
|
||||||
stage: Stage::Intact,
|
|
||||||
},
|
|
||||||
Cluster {
|
|
||||||
domain: Domain { start: 10, end: 11 },
|
|
||||||
stage: Stage::BruteForceAndDesperation,
|
|
||||||
},
|
|
||||||
Cluster {
|
|
||||||
domain: Domain { start: 11, end: 12 },
|
|
||||||
stage: Stage::BruteForceAndDesperation,
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
let expected = vec![
|
let expected = vec![
|
||||||
Cluster {
|
Cluster {
|
||||||
domain: Domain { start: 0, end: 3 },
|
domain: Domain { start: 0, end: 3 },
|
||||||
stage: Stage::Patchwork { depth: 0 },
|
stage: Stage::Untested,
|
||||||
},
|
},
|
||||||
Cluster {
|
Cluster {
|
||||||
domain: Domain { start: 3, end: 5 },
|
domain: Domain { start: 3, end: 5 },
|
||||||
stage: Stage::Isolate,
|
stage: Stage::ForIsolation { level: 0 },
|
||||||
},
|
},
|
||||||
Cluster {
|
Cluster {
|
||||||
domain: Domain { start: 5, end: 6 },
|
domain: Domain { start: 5, end: 6 },
|
||||||
stage: Stage::Patchwork { depth: 1 },
|
stage: Stage::ForIsolation { level: 1 },
|
||||||
},
|
},
|
||||||
Cluster {
|
Cluster {
|
||||||
domain: Domain { start: 6, end: 7 },
|
domain: Domain { start: 6, end: 7 },
|
||||||
stage: Stage::Patchwork { depth: 0 },
|
stage: Stage::ForIsolation { level: 0 },
|
||||||
},
|
},
|
||||||
Cluster {
|
Cluster {
|
||||||
domain: Domain { start: 7, end: 8 },
|
domain: Domain { start: 7, end: 8 },
|
||||||
stage: Stage::Damaged,
|
stage: Stage::Damaged,
|
||||||
},
|
},
|
||||||
Cluster {
|
|
||||||
domain: Domain { start: 8, end: 10 },
|
|
||||||
stage: Stage::Intact,
|
|
||||||
},
|
|
||||||
Cluster {
|
|
||||||
domain: Domain { start: 10, end: 12 },
|
|
||||||
stage: Stage::BruteForceAndDesperation,
|
|
||||||
},
|
|
||||||
];
|
];
|
||||||
|
|
||||||
mf.defrag();
|
mf.defrag();
|
||||||
mf.map.sort_by_key(|c| c.domain.start);
|
|
||||||
|
|
||||||
let received = mf.map;
|
let received = mf.map;
|
||||||
|
|
||||||
|
|||||||
@@ -2,17 +2,15 @@ use serde::{Deserialize, Serialize};
|
|||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
|
#[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
|
||||||
pub enum Stage {
|
pub enum Stage {
|
||||||
// Don't mess with the order.
|
Untested,
|
||||||
Patchwork { depth: usize },
|
ForIsolation { level: u8 },
|
||||||
Isolate,
|
|
||||||
BruteForceAndDesperation,
|
|
||||||
Damaged,
|
Damaged,
|
||||||
Intact,
|
Intact,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Stage {
|
impl Default for Stage {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Stage::Patchwork { depth: 0 }
|
Stage::Untested
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
120
src/recovery.rs
120
src/recovery.rs
@@ -2,13 +2,13 @@ use std::fs::File;
|
|||||||
use std::io::{BufWriter, Read, Seek, SeekFrom, Write};
|
use std::io::{BufWriter, Read, Seek, SeekFrom, Write};
|
||||||
use std::usize;
|
use std::usize;
|
||||||
|
|
||||||
use anyhow::Context;
|
use anyhow::{Context, anyhow};
|
||||||
|
|
||||||
use crate::cli::CONFIG;
|
use crate::cli::CONFIG;
|
||||||
use crate::io::DirectIOBuffer;
|
|
||||||
use crate::mapping::prelude::*;
|
use crate::mapping::prelude::*;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
#[allow(dead_code)]
|
||||||
pub struct Recover {
|
pub struct Recover {
|
||||||
input: File,
|
input: File,
|
||||||
output: BufWriter<File>,
|
output: BufWriter<File>,
|
||||||
@@ -43,15 +43,19 @@ impl Recover {
|
|||||||
|
|
||||||
/// Recover media.
|
/// Recover media.
|
||||||
pub fn run(&mut self) -> anyhow::Result<usize> {
|
pub fn run(&mut self) -> anyhow::Result<usize> {
|
||||||
|
// From start, read to end or error.
|
||||||
|
//
|
||||||
|
// If all data recovered, return early.
|
||||||
|
// Else, read from end to error.
|
||||||
|
|
||||||
let mut is_finished = false;
|
let mut is_finished = false;
|
||||||
|
|
||||||
while !is_finished {
|
while !is_finished {
|
||||||
self.map.defrag();
|
self.map.defrag();
|
||||||
|
|
||||||
match self.map.get_stage() {
|
match self.map.get_stage() {
|
||||||
Stage::Patchwork { depth } => self.copy_patchwork(depth)?,
|
Stage::Untested => self.copy_untested()?,
|
||||||
Stage::Isolate => todo!(),
|
Stage::ForIsolation { .. } => todo!(),
|
||||||
Stage::BruteForceAndDesperation => todo!(),
|
|
||||||
Stage::Damaged | Stage::Intact => {
|
Stage::Damaged | Stage::Intact => {
|
||||||
println!("Cannot recover further.");
|
println!("Cannot recover further.");
|
||||||
|
|
||||||
@@ -85,52 +89,39 @@ impl Recover {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Attempt to copy all untested blocks.
|
/// Attempt to copy all untested blocks.
|
||||||
fn copy_patchwork(&mut self, mut depth: usize) -> anyhow::Result<()> {
|
fn copy_untested(&mut self) -> anyhow::Result<()> {
|
||||||
let mut buf = DirectIOBuffer::new();
|
for untested in self.map.get_clusters(Stage::Untested) {
|
||||||
let mut buf_capacity = self.get_buf_capacity() as usize;
|
// Caching.
|
||||||
|
let mut read_position: usize;
|
||||||
|
let mut cluster: Cluster;
|
||||||
|
let mut buf: Vec<u8>;
|
||||||
|
let mut buf_capacity = self.get_buf_capacity() as usize;
|
||||||
|
|
||||||
while self.map.get_stage() == (Stage::Patchwork { depth }) {
|
dbg!(untested.domain);
|
||||||
// Order of these two expressions matters, stupid.
|
read_position = untested.domain.start;
|
||||||
buf_capacity /= depth;
|
|
||||||
depth += 1;
|
|
||||||
|
|
||||||
for cluster in self.map.get_clusters(Stage::Patchwork { depth }) {
|
while read_position < untested.domain.end {
|
||||||
self.read_domain(buf.as_mut(), cluster.domain, buf_capacity, Stage::Isolate)?;
|
dbg!(read_position);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
buf_capacity = buf_capacity.min(untested.domain.end - read_position);
|
||||||
}
|
buf = vec![crate::FB_NULL_VALUE; buf_capacity];
|
||||||
|
|
||||||
fn read_domain(
|
cluster = Cluster {
|
||||||
&mut self,
|
domain: Domain {
|
||||||
buf: &mut [u8],
|
start: read_position,
|
||||||
domain: Domain,
|
end: read_position + buf_capacity,
|
||||||
mut buf_capacity: usize,
|
},
|
||||||
next_stage: Stage,
|
stage: Stage::Intact,
|
||||||
) -> anyhow::Result<()> {
|
};
|
||||||
let mut cluster;
|
|
||||||
let mut read_position = domain.start;
|
|
||||||
|
|
||||||
while read_position < domain.end {
|
if let Err(err) = self.input.read_exact(&mut buf) {
|
||||||
buf_capacity = buf_capacity.min(domain.end - read_position);
|
// If buf were zeroed out before every read, one could theoretically recover
|
||||||
|
// part of that read given the assumption that all null values from the end to
|
||||||
|
// the first non-null value are unread, and some further padding from the last
|
||||||
|
// values are potentially invalid.
|
||||||
|
//
|
||||||
|
// That padding should have a cli arg to control it.
|
||||||
|
|
||||||
cluster = Cluster {
|
|
||||||
domain: Domain {
|
|
||||||
start: read_position,
|
|
||||||
end: read_position + buf_capacity,
|
|
||||||
},
|
|
||||||
stage: Stage::Intact,
|
|
||||||
};
|
|
||||||
|
|
||||||
match self.read_sectors(buf.as_mut()) {
|
|
||||||
Ok(bytes) => {
|
|
||||||
self.output
|
|
||||||
.write_all(&buf[0..bytes])
|
|
||||||
.context("Failed to write data to output file")?;
|
|
||||||
read_position += bytes;
|
|
||||||
}
|
|
||||||
Err(err) => {
|
|
||||||
println!("Hit error: {:?}", err);
|
println!("Hit error: {:?}", err);
|
||||||
if CONFIG.reopen_on_error {
|
if CONFIG.reopen_on_error {
|
||||||
self.reload_input()
|
self.reload_input()
|
||||||
@@ -144,21 +135,31 @@ impl Recover {
|
|||||||
.seek_relative(buf_capacity as i64)
|
.seek_relative(buf_capacity as i64)
|
||||||
.context("Failed to seek output by buf_capacity to skip previous error")?;
|
.context("Failed to seek output by buf_capacity to skip previous error")?;
|
||||||
|
|
||||||
cluster.stage = next_stage.clone();
|
// I don't remember what level was for.
|
||||||
|
cluster.stage = Stage::ForIsolation { level: 1 };
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
self.map.update(cluster);
|
if cluster.stage == Stage::Intact {
|
||||||
self.map.write_to(&mut crate::io::load_map_write()?)?;
|
self.output
|
||||||
|
.write_all(&buf[0..buf_capacity])
|
||||||
|
.context("Failed to write data to output file")?;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.map.update(cluster);
|
||||||
|
self.map.write_to(&mut crate::io::load_map_write()?)?;
|
||||||
|
read_position += buf_capacity;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.map.write_to(&mut crate::io::load_map_write()?)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set buffer capacity as cluster length in bytes.
|
/// Set buffer capacity as cluster length in bytes.
|
||||||
/// Varies depending on the recovery stage.
|
/// Varies depending on the recovery stage.
|
||||||
fn get_buf_capacity(&mut self) -> u64 {
|
fn get_buf_capacity(&mut self) -> u64 {
|
||||||
crate::MAX_BUFFER_SIZE.min(CONFIG.sector_size * CONFIG.cluster_length) as u64
|
CONFIG.sector_size as u64 * CONFIG.cluster_length as u64
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Reloads the input and restores the seek position.
|
/// Reloads the input and restores the seek position.
|
||||||
@@ -169,25 +170,6 @@ impl Recover {
|
|||||||
self.input.seek(SeekFrom::Start(seek_pos))?;
|
self.input.seek(SeekFrom::Start(seek_pos))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_sectors(&mut self, mut buf: &mut [u8]) -> std::io::Result<usize> {
|
|
||||||
let mut raw_buf = vec![crate::FB_NULL_VALUE; buf.len()];
|
|
||||||
let result = self.input.read(&mut raw_buf);
|
|
||||||
|
|
||||||
if result.is_err() {
|
|
||||||
return result;
|
|
||||||
} else if let Ok(mut bytes) = result
|
|
||||||
&& bytes >= CONFIG.sector_size
|
|
||||||
{
|
|
||||||
// Remember that this is integer division (floor division)
|
|
||||||
bytes = (bytes / CONFIG.sector_size) * CONFIG.sector_size;
|
|
||||||
buf.write_all(&raw_buf[..bytes]).unwrap();
|
|
||||||
|
|
||||||
return Ok(bytes);
|
|
||||||
} else {
|
|
||||||
return Ok(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|||||||
Reference in New Issue
Block a user