Skip to content

fsverity: Wrap enable_verity in test code to retry on ETXTBSY #150

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

Closed
wants to merge 1 commit into from

Conversation

jeckersb
Copy link
Collaborator

Signed-off-by: John Eckersberg [email protected]

@jeckersb
Copy link
Collaborator Author

Hm failures have nothing to do with this...

@jeckersb
Copy link
Collaborator Author

Somewhat confused why it's getting console-0.15.12 when we have 0.15.11 in Cargo.lock

@@ -172,6 +172,24 @@ mod tests {
fd
}

/// Wrap the real method inside of the tests and do a little
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm still not a big fan of fixing this only in the tests.

}
}

unreachable!("We always return on the last iteration above");
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can avoid this unreachable! with an explicit loop, something like this

fn enable_verity<H: FsVerityHashValue>(fd: impl AsFd) -> Result<(), EnableVerityError> {
    let mut attempt = 1;
    loop {
        match super::enable_verity::<H>(&fd) {
            Err(EnableVerityError::FileOpenedForWrite) if attempt < 3 => {
                std::thread::sleep(std::time::Duration::from_millis(1));
                attempt += 1;
            }
            other => return other,
        }
    }
}

But anyways I think it wouldn't really be too much more code to do the copy-based fallback right? And make it generic outside of the tests

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I just now saw your comments in #106, before that I though we had agreed to leave enable_verity alone which is why I did this.

@jeckersb jeckersb closed this Jun 26, 2025
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.

2 participants