Skip to content

Implement dd nearing completion#2474

Merged
sylvestre merged 84 commits intouutils:masterfrom
backwaterred:master
Aug 4, 2021
Merged

Implement dd nearing completion#2474
sylvestre merged 84 commits intouutils:masterfrom
backwaterred:master

Conversation

@backwaterred
Copy link
Contributor

@backwaterred backwaterred commented Jul 2, 2021

Back in the day, I opened #1861 indicating that I would work on dd. I thought it would be a month or so to complete it, but I was off by a small-ish margin ;-). Even though a few features are still missing, and some cleanup work remains, I am opening this pull request to bring dev work to the wider community, and basically stop hoarding the project.

Below is a list of todo items I am aware of.

  • Windows testing
  • MacOS testing
  • RedoxOS testing [edit]

Future work (to be created as separate issues)

  • Additional testing. CLI testing for bad input. Trigger unit tests when tests performed from project root.
  • Print stats in response to the INFO signal. I believe this is only available on BSD-style (i.e. MacOS included) systems. I'm not currently running one, and there doesn't appear to be a standard way to do this in Rust.
  • A robust system-independent iflag=FLAG and oflag=FLAG implementation. Currently flags [cio, nocache, nolinks, text, binary] are not implemented at all, and [direct, directory, dsync, sync, nonblock, noatime, noctty, nofollow] are only expected to work on Linux. Testing is also a little light on this one.
  • A good Ctrl-c handler. This should try to shut things down nicely at first, then get more aggressive after a second Ctrl-c.
  • Deduplication of dd_fileout(...) and dd_stdout(...) (ideally there should just be one function). Fixing this will require adjusting the way that fsync() fdatasync() and write_all() are handled. The solution probably involves dynamic dispatch.
  • Tune Clap to make better use of the lib's features. Ideas: default values, improved help text. Clarity on difference between traditional and modern arg passing (Clap should give us --if foo.file for free, and if=foo.file should continue to work), mention multiplier strings.
  • Additional documentation for all the things.
  • Address the newline question: Block & Unblock currently only accept LF as a newline character. Should this behaviour be made system dependent?

I'd like to continue working on this project, and am happy for any suggestions.

ty and others added 30 commits March 16, 2021 14:32
- Prototype code.
- Adds project boilerplate for integration with coreutils framework.
- Move code closer to real impl
- Remove Makefile from repo
- implements basic copy & progress functionality
- rough work for conversion tables
- adds sanity tests (mt, zeros, ones, deadbeef & rand)
- Adds support for calling dd fn from cl
- Adds basic cl tests from project root
- Adds support for multiplier strings (c, w, b, kB, KB, KiB, ... EB, E,
  EiB.
- Moves all arg parsing & tests to parseargs.rs
- Moves conversion tables to conversion_tables.rs
- Adds ebcdic_lcase and _ucase tables
- Refactors options: This **Breaks Write for Output**
- All conv flags now parsed (full functionality is TODO)
- Changes functionality of eg. conv=ebcdic,ucase to match gnudd
- conv=sparse option requires knowledge of File/Stdout to change
  behaviour.
- Unclear how best to impl this.
- Possible option: develop 4 versions of dd<X,Y> for each valid pair of { File, Stdin,
  Stdout }.
- Adds duplicate dd fn :-( for differentiating between File backed and
  non-File outputs.
- Implements cflag=sparse,fsync,fdatasync which were previously blocked.
- Adds plumbing for IFlags & OFlags incl parsing.
- Partial impl for seek=N and skip=N which were previously blocked.
- Completes impl of skip=N, and seek=N
- Parses cbs=N
- Pushes file/stdout specific logic to trait objects.
- Extracts read/write helper
- Extracts conv/block/unblock helper
- Impl block
- WIP: Many failing tests!
- Unit tests split into individual folders
- Parseargs test module renamed unit_tests to match new structure
- Move test macros to specific modules.
- Adds unit tests
- Implements unblock
- All tests passing
- Splits read fn into conv=sync and standard (consecutive)
  versions.
- Fixes bug in previous read/fill where short reads would copy to wrong
  position in output buffer.
- Fixes bug in unit tests. Empty source would pass (since no bytes
  failed to match).
- Adds tests where ibs causes extention
- Impl conv=sync. All tests passing.
- Spoiler Alert: Turns out it was just the lcm.
- Adds print fn's
- Modifies internal fn's as needed to track read/write state
- Modifies status update thread to respect status level
- Adds signal handler for SIGUSR1 (print xfer stats)
- Adds tests for count=READS and count=BYTES.
- Implements count logic for read count and bytes count limits.
- Adds words to cspell exceptions
- Converts test macros to use Default trait.
- Converts parser to use Default trait.
- Adds Windows-friendly test files for block/unblock when nl is present
  in test/spec file.
- Adds words to cspell exceptions
- Converts test macros to use Default trait.
- Converts parser to use Default trait.
- Adds Windows-friendly test files for block/unblock when nl is present
  in test/spec file.
Copy link
Contributor

@miDeb miDeb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some more comments 🙂

backwaterred and others added 6 commits July 23, 2021 14:53
- Adds more jargon to the spellchecker jargon file.
- Adds more ignores to the per-project ignores.
- Fixes clippy warnigns about uneeded clones on non-linux.
- Block/Unblock now account for system dependend newlines.
@backwaterred
Copy link
Contributor Author

May I get the pending build actions approved?

- cSpell valiantly vanquished
- fmt issues addressed
@backwaterred
Copy link
Contributor Author

backwaterred commented Aug 4, 2021

I've addressed the block/unblock tests that fail on Windows... by ignoring them. I was working on a solution, but it was just big enough to feel like it should be a separate issue, so I've reverted my changes.

Some questions came up as I was implementing this feature. If there are certain answers to them feel free to link or give them here. If there are no certain answers and a bit of discussion is required, then it would probably be best to have this discussion in the issue itself. Either way, I'll link this comment in the issue when it's created , and link this comment for reference. Questions are below:

  • What set of newline markers should this feature (block & unblock) support?
    • Does the project already has a stance on newlines?
  • Should support be determined by the platform uutils was compiled on (ie. recognize only CR+LF on Windows, only LF on Linux, LF and maybe? CR on MacOS) or take Python's stance of universal newlines (recognize all newlines on all platforms).

@sylvestre
Copy link
Contributor

Code coverage and clippy are failing on Windows.
Could you please just disable these macros for this platform and we will land it? :)
this PR is becoming quite big :)

@backwaterred
Copy link
Contributor Author

backwaterred commented Aug 4, 2021

Agreed :-) Those issues should be addressed in the most recent push.

@sylvestre
Copy link
Contributor

Excellent! many thanks :)

@sylvestre sylvestre merged commit 54f4c8f into uutils:master Aug 4, 2021
This was referenced Dec 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants