src/storage/blobfs/test/unit/format-test.cc
// Validates that a formatted filesystem mounted as writable with a journal cannot be mounted on a
// read-only device. This "auto-conversion" is disabled because journal replay is necessary
// to guarantee filesystem correctness, which involves writeback.
Validates that a formatted filesystem mounted as writable with a journal cannot be mounted on a
read-only device. This "auto-conversion" is disabled because journal replay is necessary
to guarantee filesystem correctness, which involves writeback.
Validates that a formatted filesystem mounted as writable with a journal cannot be mounted on a read - only device . This " auto - conversion " is disabled because journal replay is necessary to guarantee filesystem correctness which involves writeback .
TEST(FormatFilesystemTest, FormatDeviceWithJournalCannotAutoConvertReadonly) {
  const uint64_t kBlockCount = 1 << 20;
  const uint32_t kBlockSize = kBlobfsBlockSize;
  auto device = std::make_unique<FakeBlockDevice>(kBlockCount, kBlockSize);
  ASSERT_EQ(FormatFilesystem(device.get()), ZX_OK);
  device->SetInfoFlags(fuchsia_hardware_block_FLAG_READONLY);
  MountOptions options = {};
  options.writability = Writability::Writable;
  options.metrics = false;
  options.journal = true;
  std::unique_ptr<Blobfs> blobfs = nullptr;
  ASSERT_EQ(ZX_ERR_ACCESS_DENIED,
            Blobfs::Create(nullptr, std::move(device), &options, zx::resource(), &blobfs));
}
TEST ( FormatFilesystemTest , FormatDeviceWithJournalCannotAutoConvertReadonly ) { const uint64_t kBlockCount = 1 << 20 ; const uint32_t kBlockSize = kBlobfsBlockSize ; auto device = std :: make_unique < FakeBlockDevice > ( kBlockCount , kBlockSize ) ; ASSERT_EQ ( FormatFilesystem ( device . get ( ) ) , ZX_OK ) ; device -> SetInfoFlags ( fuchsia_hardware_block_FLAG_READONLY ) ; MountOptions options = { } ; options . writability = Writability :: Writable ; options . metrics = false ; options . journal = true ; std :: unique_ptr < Blobfs > blobfs = nullptr ; ASSERT_EQ ( ZX_ERR_ACCESS_DENIED , Blobfs :: Create ( nullptr , std :: move ( device ) , & options , zx :: resource ( ) , & blobfs ) ) ; }
Validates that a formatted filesystem mounted as writable with a journal cannot be mounted on a
read-only device.
Validates that a formatted filesystem mounted as writable with a journal cannot be mounted on a read - only device .