// Copyright 2018 The Fuchsia 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 #include #include #include #include #include #include #include #include "fs-host/common.h" #define MIN_ARGS 3 // Options struct. struct { const char* name; Option option; const char* argument; const char* default_value; const char* help; } OPTS[] = { {"depfile", Option::kDepfile, "", nullptr, "Produce a depfile"}, {"readonly", Option::kReadonly, "", nullptr, "Mount filesystem read-only"}, {"offset", Option::kOffset, "[bytes]", "0", "Byte offset at which minfs partition starts"}, {"length", Option::kLength, "[bytes]", "Remaining Length", "Length in bytes of minfs partition"}, {"help", Option::kHelp, "", nullptr, "Display this message"}, }; // Commands struct. struct { const char* name; Command command; uint32_t flags; ArgType arg_type; const char* help; } CMDS[] = { {"create", Command::kMkfs, O_RDWR | O_CREAT, ArgType::kOptional, "Initialize filesystem."}, {"mkfs", Command::kMkfs, O_RDWR | O_CREAT, ArgType::kOptional, "Initialize filesystem."}, {"check", Command::kFsck, O_RDONLY, ArgType::kNone, "Check filesystem integrity."}, {"fsck", Command::kFsck, O_RDONLY, ArgType::kNone, "Check filesystem integrity."}, {"add", Command::kAdd, O_RDWR, ArgType::kMany, "Add files to an fs image (additional arguments required)."}, {"cp", Command::kCp, O_RDWR, ArgType::kTwo, "Copy to/from fs."}, {"mkdir", Command::kMkdir, O_RDWR, ArgType::kOne, "Create directory."}, {"ls", Command::kLs, O_RDONLY, ArgType::kOne, "List contents of directory."}, {"manifest", Command::kManifest, O_RDWR, ArgType::kOne, "Add files to fs as specified in manifest (deprecated)."}, }; // Arguments struct. struct { const char* name; Argument argument; } ARGS[] = { {"--manifest", Argument::kManifest}, {"--blob", Argument::kBlob}, }; zx_status_t FsCreator::ProcessAndRun(int argc, char** argv) { zx_status_t status; if ((status = ProcessArgs(argc, argv)) != ZX_OK) { return status; } return RunCommand(); } zx_status_t FsCreator::Usage() { fprintf(stderr, "usage: %s [