Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to write block to disk: Os { code: 22, kind: InvalidInput, message: "Invalid argument" }) on MacOS #124

Closed
ifd3f opened this issue May 20, 2024 · 1 comment · Fixed by #126
Labels
bug Something isn't working os: darwin Issues specific to the MacOS build.

Comments

@ifd3f
Copy link
Owner

ifd3f commented May 20, 2024

This issue has been split off from #105 .

To Reproduce

Steps to reproduce the behavior:

  1. Plug in a USB
  2. ./caligula-x86_64-darwin burn caligula-x86_64-darwin
  3. Go through the prompts
  4. Select the plugged USB
  5. The osascript prompt pops up. Entering in the password, however, does not appear to grant sudo, and the password is asked in the terminal again.
  6. Running yields the error

See the following error logs: 1714950829848.child.log 1714950829848.main.log

2024-05-05T23:14:00.846797Z DEBUG caligula::writer_process::child: Opening file caligula-x86_64-darwin
2024-05-05T23:14:00.846821Z DEBUG caligula::writer_process::child: Got input file size size=3998608
2024-05-05T23:14:00.846829Z DEBUG caligula::writer_process::child: Opening /dev/rdisk2 for writing
2024-05-05T23:14:00.916385Z ERROR caligula::writer_process::child: PanicInfo { payload: Any { .. }, message: Some(Failed to write block to disk: Os { code: 22, kind: InvalidInput, message: "Invalid argument" }), location: Location { file: "src/writer_process/child.rs", line: 185, col: 14 }, can_unwind: true, force_no_backtrace: false }

Since it's at this specific line, that implies we opened it correctly, but the first block isn't even being written.

    #[inline]
    fn on_block(&mut self, block: &[u8], _scratch: &mut [u8]) -> Result<(), ErrorType> {
        trace!(block_len = block.len(), "Writing block");

        let written = self
            .file
            .write(block)
            .expect("Failed to write block to disk"); // line 185
        if written != block.len() {
            return Err(ErrorType::EndOfOutput);
        }
        Ok(())
    }

Originally posted by @ifd3f in #105 (comment)

@ifd3f ifd3f changed the title It seems that this is because the device is mounted. Unmounting it first gives a different error [1714950829848.child.log](https://github.com/ifd3f/caligula/files/15214888/1714950829848.child.log) [1714950829848.main.log](https://github.com/ifd3f/caligula/files/15214889/1714950829848.main.log) Failed to write block to disk: Os { code: 22, kind: InvalidInput, message: "Invalid argument" }) on MacOS May 20, 2024
@ifd3f ifd3f added bug Something isn't working os: darwin Issues specific to the MacOS build. labels May 20, 2024
@ifd3f
Copy link
Owner Author

ifd3f commented May 20, 2024

Actually, this works on inputs with sizes aligned to block size. So it's most definitely a block alignment problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working os: darwin Issues specific to the MacOS build.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant