/* * This file is part of the Aaru Data Preservation Suite. * Copyright (c) 2019-2026 Natalia Portillo. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include "aaruformat.h" #include "usage.h" #include "version.h" // Optional if you want a central place for version macros void print_banner() { printf("AaruFormat Tool version %d.%d\n", AARUFORMAT_TOOL_MAJOR_VERSION, AARUFORMAT_TOOL_MINOR_VERSION); printf("Copyright (C) 2019-2026 Natalia Portillo\n"); printf("libaaruformat version %d.%d\n\n", LIBAARUFORMAT_MAJOR_VERSION, LIBAARUFORMAT_MINOR_VERSION); } void usage() { printf("\nUsage:\n"); printf(" aaruformattool [arguments]\n\n"); printf("Available verbs:\n"); printf(" cli-compare Compares two AaruFormat images sector by sector (CLI mode).\n"); printf(" compare Compares two AaruFormat images.\n"); printf(" convert Converts an AaruFormat image to another AaruFormat image.\n"); printf(" convert-ps3 Converts a PS3 disc image to AaruFormat with decrypted storage.\n"); printf(" convert-wiiu Converts a Wii U disc image to AaruFormat with decrypted storage.\n"); printf(" convert-ngcw Converts a GameCube/Wii disc image to AaruFormat.\n"); printf(" identify Identifies if the indicated file is a supported AaruFormat image.\n"); printf(" info Prints information about a given AaruFormat image.\n"); printf(" inject-media-tag Injects a media tag into an AaruFormat image.\n"); printf(" read Reads a sector and prints it out on screen.\n"); printf(" read_long Reads a sector with all its prefixes and suffixes.\n"); printf(" repair-cd-arena Repairs CD sector prefix/suffix arenas damaged by the resume bug.\n"); printf(" upgrade-ddt-to-alpha21 Upgrades a DDT image to alpha21 format.\n"); printf(" verify Verifies the integrity of blocks in an image.\n"); printf(" verify_sectors Verifies the integrity of all sectors in an image.\n\n"); printf("For help with any verb, run:\n"); printf(" aaruformattool --help\n"); } void usage_identify() { printf("\nUsage:\n"); printf(" aaruformattool identify \n\n"); printf("Identifies if the file is a supported AaruFormat image.\n"); printf("Arguments:\n"); printf(" Path to the image file.\n"); } void usage_info() { printf("\nUsage:\n"); printf(" aaruformattool info \n\n"); printf("Prints metadata about the image.\n"); printf("Arguments:\n"); printf(" Path to AaruFormat image.\n"); } void usage_read() { printf("\nUsage:\n"); printf(" aaruformattool read \n\n"); printf("Reads a sector and prints it out.\n"); printf("Arguments:\n"); printf(" Sector number to read.\n"); printf(" Path to image file.\n"); } void usage_read_long() { printf("\nUsage:\n"); printf(" aaruformattool read_long \n\n"); printf("Reads sector with all metadata and prints it out.\n"); printf("Arguments:\n"); printf(" Sector number to read.\n"); printf(" Path to image file.\n"); } void usage_verify() { printf("\nUsage:\n"); printf(" aaruformattool verify [--recover] \n\n"); printf("Checks block-level integrity.\n"); printf("Arguments:\n"); printf(" Path to image file.\n"); printf("Options:\n"); printf(" --recover Attempt erasure coding recovery of corrupt blocks.\n"); printf(" Reads all sectors, transparently recovering any corrupt\n"); printf(" blocks via RS parity. Reports recoverable vs unrecoverable.\n"); } void usage_verify_sectors() { printf("\nUsage:\n"); printf(" aaruformattool verify_sectors \n\n"); printf("Checks sector-level integrity.\n"); printf("Arguments:\n"); printf(" Path to image file.\n"); } void usage_compare() { printf("\nUsage:\n"); printf(" aaruformattool compare \n\n"); printf("Compares two AaruFormat images.\n"); printf("Arguments:\n"); printf(" Path to first image file.\n"); printf(" Path to second image file.\n"); } void usage_cli_compare() { printf("\nUsage:\n"); printf(" aaruformattool cli-compare [-l] \n\n"); printf("Compares two AaruFormat images sector by sector and lists all different sectors.\n"); printf("Arguments:\n"); printf(" Path to first image file.\n"); printf(" Path to second image file.\n"); printf("Options:\n"); printf(" -l Use long sector read (includes tags and metadata).\n"); } void usage_convert() { printf("\nUsage:\n"); printf(" aaruformattool convert [-l] [--erasure-coding=K,M] \n\n"); printf("Converts an AaruFormat image by reading all sectors from input and writing them to output.\n"); printf("Arguments:\n"); printf(" Path to input image file.\n"); printf(" Path to output image file.\n"); printf("Options:\n"); printf(" -l Use long sector read/write (includes tags and metadata).\n"); printf(" --erasure-coding=K,M\n"); printf(" Enable Reed-Solomon erasure coding with K data blocks and\n"); printf(" M parity blocks per stripe. Examples:\n"); printf(" --erasure-coding=16,1 Low overhead (~6%%), single fault tolerance\n"); printf(" --erasure-coding=8,2 Medium overhead (~12%%), double fault tolerance\n"); printf(" --erasure-coding=4,4 High overhead (~25%%), quad fault tolerance\n"); } void usage_upgrade_ddt_to_alpha21() { printf("\nUsage:\n"); printf(" aaruformattool upgrade-ddt-to-alpha21 \n\n"); printf("Upgrades a DDT image to alpha21 format.\n"); printf("Arguments:\n"); printf(" Path to the DDT image file to upgrade.\n"); } void usage_repair_cd_arena() { printf("\nUsage:\n"); printf(" aaruformattool repair-cd-arena [--dry-run] \n\n"); printf("Repairs CD sector prefix/suffix arenas in a v2 image whose resumed dump sessions left the\n"); printf("final deduplication table referencing slots past the shrunken data block (garbage reads on\n"); printf("errored sectors). Recovers the slots from the orphaned dump generations still in the file.\n"); printf("Arguments:\n"); printf(" --dry-run Only report how many slots are recoverable; write nothing.\n"); printf(" Path to the AaruFormat image to repair (modified in place).\n"); } void usage_inject_media_tag() { printf("\nUsage:\n"); printf(" aaruformattool inject-media-tag \n\n"); printf("Injects a media tag into an AaruFormat image.\n"); printf("Arguments:\n"); printf(" The type of media tag to inject.\n"); printf(" Path to the file containing the media tag data.\n"); printf(" Path to the AaruFormat image file.\n"); } void usage_convert_ps3() { printf("\nUsage:\n"); printf(" aaruformattool convert-ps3 [options]\n\n"); printf("Converts a PS3 disc ISO or AaruFormat image to an AaruFormat image with\n"); printf("decrypted sector storage and PS3 encryption metadata.\n\n"); printf("Arguments:\n"); printf(" Path to input ISO or AaruFormat image.\n"); printf(" Path to output AaruFormat image.\n\n"); printf("Options:\n"); printf(" --disc-key= 32-char hex disc key (16 bytes).\n"); printf(" --data1-key= 32-char hex data1 key (disc key will be derived).\n"); printf(" --ird= Path to IRD file (extracts keys, PIC, metadata).\n\n"); printf("Key resolution order:\n"); printf(" 1. --disc-key argument\n"); printf(" 2. --data1-key argument (derives disc key)\n"); printf(" 3. --ird file (extracts data1 key, derives disc key)\n"); printf(" 4. Sidecar files: .disc_key, .data1, .ird\n"); printf(" 5. Source AaruFormat image media tags\n"); } void usage_convert_wiiu() { printf("\nUsage:\n"); printf(" aaruformattool convert-wiiu [options]\n\n"); printf("Converts a Wii U disc WUD, WUX, or AaruFormat image to an AaruFormat image\n"); printf("with decrypted sector storage and Wii U encryption metadata.\n\n"); printf("Arguments:\n"); printf(" Path to input WUD, WUX, or AaruFormat image.\n"); printf(" Path to output AaruFormat image.\n\n"); printf("Options:\n"); printf(" --disc-key= 32-char hex disc key (16 bytes).\n\n"); printf("Key resolution order:\n"); printf(" 1. --disc-key argument\n"); printf(" 2. Sidecar files: .disckey, .key\n"); printf(" 3. Source AaruFormat image media tags\n"); } void usage_convert_ngcw() { printf("\nUsage:\n"); printf(" aaruformattool convert-ngcw \n\n"); printf("Converts a Nintendo GameCube or Wii disc ISO or AaruFormat image to an\n"); printf("AaruFormat image with decrypted sectors (Wii) and junk regions removed.\n\n"); printf("Arguments:\n"); printf(" Path to input ISO or AaruFormat image.\n"); printf(" Path to output AaruFormat image.\n\n"); printf("The disc type (GameCube or Wii) is auto-detected from the disc header.\n"); printf("Wii common keys are hardcoded; no key arguments are needed.\n"); printf("A .bca sidecar file will be imported if found alongside the input.\n"); }