blob: 71fbfe8e58e0746275b6733c7c52db38b4038408 [file] [log] [blame]
// Copyright 2017 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "secure_erase_file/secure_erase_file.h"
#include <sysexits.h>
#include <base/command_line.h>
#include <base/logging.h>
#include <brillo/flag_helper.h>
#include <brillo/syslog_logging.h>
int main(int argc, const char* const argv[]) {
brillo::FlagHelper::Init(argc, argv, "Secure erase tool.");
brillo::InitLog(brillo::kLogToSyslog | brillo::kLogToStderr |
base::CommandLine::Init(argc, argv);
base::CommandLine::StringVector files =
if (files.size() < 1) {
LOG(WARNING) << "At least one file argument must be provided.";
return EX_USAGE;
// Use a status variable to erase all the files we possibly can, then drop
// caches. We still return an error if any files have failed so that external
// scripts can react accordingly.
bool ok = true;
for (const auto& file : files) {
ok &= secure_erase_file::SecureErase(base::FilePath(file));
ok &= secure_erase_file::DropCaches();
return ok ? 0 : EX_IOERR;