Skip to content

Commit 1a8bed4

Browse files
mayastor-borsAbhinandan-Purkait
andcommitted
chore(bors): merge pull request #1105
1105: fix: reject cross fs restore if fs type is different r=Abhinandan-Purkait a=Abhinandan-Purkait - While preparing device we ignore the existing fs on the device and went on with format, silently corrupting the existing fs on the device in case of an invalid cross fs restore. Co-authored-by: Abhinandan Purkait <purkaitabhinandan@gmail.com>
2 parents b6a4e47 + c292e7c commit 1a8bed4

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

.github/workflows/image-pr.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,11 @@ jobs:
1515
with:
1616
submodules: 'recursive'
1717
- uses: cachix/install-nix-action@v31.3.0
18+
- name: Pre-populate nix-shell
19+
run: |
20+
export NIX_PATH=nixpkgs=$(jq '.nixpkgs.url' nix/sources.json -r)
21+
echo "NIX_PATH=$NIX_PATH" >> $GITHUB_ENV
22+
nix-shell --run "echo" shell.nix
23+
1824
- name: Test building the release images
19-
run: ./scripts/release.sh --skip-publish --build-bins
25+
run: nix-shell --run "./scripts/release.sh --skip-publish --build-bins"

control-plane/csi-driver/src/bin/node/format.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,13 @@ pub(crate) async fn prepare_device(
1818

1919
let fs_ops = fstype.fs_ops()?;
2020

21-
if let Ok(fs) = fs {
22-
debug!("Found existing filesystem ({}) on device {}", fs, device);
21+
if let Ok(ref found_fs) = fs {
22+
debug!("Found existing filesystem ({found_fs}) on device {device}");
23+
if found_fs != fstype.as_ref() {
24+
return Err(format!(
25+
"device {device} has filesystem {found_fs} but {fstype} was requested; cross-filesystem restores are not supported"
26+
));
27+
}
2328
if let Some(fs_id) = fs_id {
2429
debug!("Attempting to set uuid for filesystem {fs_id}, device: {device}");
2530
fs_ops

0 commit comments

Comments
 (0)