Skip to main content

ota_lib/
storage.rs

1// Copyright 2020 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5use anyhow::{Context, Error};
6use fdr_lib::execute_reset;
7use fidl_fuchsia_io as fio;
8
9// Wipe and re-provision FVM. This will wipe both data and blobfs. This should only
10// be used in OTA flows, since wiping blobfs will result in an unusable primary system.
11// TODO(https://fxbug.dev/395155386): Remove workflows that invoke this function, since we do not
12// use recovery OTA functionality in production.
13pub async fn wipe_storage() -> Result<fio::DirectoryProxy, Error> {
14    Err(zx::Status::NOT_SUPPORTED)
15        .context("WipeStorage is not supported, see https://fxbug.dev/395155386.")
16}
17
18// Instead of formatting the data partition directly, reset it via the factory reset service.
19// The data partition is reformatted on first boot under normal circumstances and will do so
20// after a reboot following being reset.
21// This immediately reboots the device and needs to run separately from wipe_storage for now.
22pub async fn wipe_data() -> Result<(), Error> {
23    execute_reset().await.context("Failed to factory reset data")
24}