Skip to content

Conversation

erkinalp
Copy link

resolves #2 by providing an initial implementation of dd

devin-ai-integration bot and others added 6 commits June 30, 2025 20:16
- Add cmd_dd function with support for file copying and disk formatting
- Support standard dd syntax: if=input of=output [bs=blocksize] [count=blocks]
- Add cmd_dd_format function for FAT12 filesystem formatting
- Add cmd_dd_copy function for file-to-file copying operations
- Import BlockDevice trait to enable sector-level disk operations

Addresses issue krustowski#2 from krustowski/rou2exOS

Co-Authored-By: Erkin Alp Güney <erkinalp9035@gmail.com>
- Add skip= and seek= parameters for input/output offset positioning
- Add status= parameter for progress reporting (none, progress, noxfer)
- Add filesystem format selection: fs=fat12 or fs=raw
- Implement cmd_dd_format_raw for zero-fill raw formatting
- Enhanced block size validation (1-4096 bytes)
- Improved copy logic with proper offset handling and count limits
- Better error handling for invalid parameters and file operations
- Progress indicators for raw formatting operations

Co-Authored-By: Erkin Alp Güney <erkinalp9035@gmail.com>
- Make 'format' keyword optional in dd command syntax
- Support direct fs= parameter detection for filesystem operations
- Fix type conversion errors (usize to u64) for sector operations
- Fix buffer size mismatches for fs.read_file calls
- Add unsafe blocks for fs.write_file operations
- Update help text to reflect simplified command syntax

Examples:
- dd fs=raw if=data.txt (instead of dd format fs=raw if=data.txt)
- dd fs=fat12 bs=512
- dd fs=raw if=data.txt of=image.img

Co-Authored-By: Erkin Alp Güney <erkinalp9035@gmail.com>
- Remove [format] from usage syntax line
- Fix status=progress example to include output location
- Help text now reflects simplified dd command syntax

Addresses GitHub comment: help strings need to be updated to syntax without dd format

Co-Authored-By: Erkin Alp Güney <erkinalp9035@gmail.com>
@krustowski
Copy link
Owner

Hi @erkinalp,

Thank you very much for your contribution. Will look at it in more detail later. I have been cleaning branches a bit and merged the relevant one to master. Therefore there is a merge conflict at the moment, as I added a command (run) draft too. Could you please look at it too and try to resolve the conflict eventually?

@krustowski
Copy link
Owner

Thank you for the merge update of the branch. And I am sorry it's taking so long.

The fact is that I have been working on the external program execution and isolation, and this new command could be made into a solitaire program too. All programs run by kernel must implement and use the system ABI via syscalls.

There is also a new repository with more details about current implementation with examples in C++, Go, NASM and Rust. Therefore that repository is to be a home for all external applications/programs/modules in any language that is linkable into the ELF format. A simple implementation of the ELF loader is almost done, and experimentally it works for almost any ELF executable.

The problem is with a program exit, its graceful termination. In the current release (v0.8.1), there is a very simple flat binary loader, that is capable of returning back to shell. This is now being changed into the standard memory protection state, where kernel runs in so-called Ring 0, and other (user) programs in Ring 3. Memory has to be explicitly mapped with the user attribute to be accessible by user program (see iso/boot/boot.asm for more). Otherwise it triggers a Page Fault, General Protection Fault, or some kind of exception, that is to be handled by the kernel to resume or kill the process according to its state and environment.

Thank you for your patience and understanding.

@erkinalp
Copy link
Author

erkinalp commented Jul 3, 2025

I intend to keep the dd as an internal command to reuse some of the privileged calls in the internal command parser and keep in spirit with original JCL dd.

@krustowski
Copy link
Owner

Okay, dd will be integrated in shell, but note that the shell is being rewritten into an external program too atm, see: https://github.com/krustowski/rou2exOS-apps/tree/master/rust/r2sh

Shell will be running in higher privilege zone (Ring 2) than other userland (Ring 3) programs to be able to reach some special system calls.

@erkinalp
Copy link
Author

erkinalp commented Jul 6, 2025

Shell will be running in higher privilege zone (Ring 2) than other userland (Ring 3) programs to be able to reach some special system calls.

Some architectures such as ARM and RISC-V only have two rings, a three-ring architecture might necessiate using a type 2 hypervisor to emulate the extra rings in two-ring systems.

@krustowski
Copy link
Owner

Yeah, I have been reading some chunks about the ring topology in other architectures too. Great point! In two-ring systems the shell would be running in Ring 0, I suppose.

As far as ARM is concerned, I would like to port the kernel to this architecture as well, but some changes need to be applied to the kernel structure to be able to switch archs more easily. I am thinking about something like the arch core module that would contain some API to operate on different architectures.

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.

Command suggestion: dd

2 participants