VirtualBox

Ignore:
Timestamp:
Dec 8, 2018 2:52:36 PM (6 years ago)
Author:
vboxsync
Message:

Make usage output fit into 80 columns. Further edit usage verbage / formatting. Fix broken --vm option. Properly reject unrecognized arguments on command line.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ImageMounter/vboximg-mount/vboximg-mount.cpp

    r76043 r76069  
    181181     uint32_t      fRW;                     /** Flag to allow changes to FUSE-mounted Virtual Disk image */
    182182     uint32_t      fBriefUsage;             /** Flag to display only FS-specific program usage options */
    183      uint32_t      fVerbose;                /** Make some noise */
     183     uint32_t      fVerbose;                /** Add more info to lists and operations */
    184184} g_vboximgOpts;
    185185
     
    206206    OPTION("-h",              fBriefUsage,       1),
    207207    FUSE_OPT_KEY("--help",    USAGE_FLAG),
     208    FUSE_OPT_KEY("-vm",       FUSE_OPT_KEY_NONOPT),
    208209    FUSE_OPT_END
    209210};
     
    214215    RTPrintf("usage: vboximg-mount [options] <mountpoint>\n\n"
    215216        "vboximg-mount options:\n\n"
    216         "    [ { -l | --list } ]                        If a disk image is specified [-i, --image], list partition table\n"
    217         "                                               for the specified disk image.\n"
     217        "  [ { -i | --image= } <specifier> ]  VirtualBox disk image (UUID, name or path)\n"
    218218        "\n"
    219         "                                               If no image is specified on the command line, list registered VMs\n"
    220         "                                               and their disk media.  If a verbose flag is specified,\n"
    221         "                                               VM and media list will be long format, including snapshot images\n"
    222         "                                               and component locations (e.g. paths).\n"
     219        "  [ { -l | --list } ]                If image specified, list its partitions, \n"
     220        "                                     otherwise, list registered VMs and\n"
     221        "                                     associated disks. In verbose mode,\n"
     222        "                                     VM/media list will be long format, i.e.\n"
     223        "                                     including snapshot images and file paths.\n"
    223224        "\n"
    224         "    [ { -i | --image= } <UUID | name | path> ] Virtual Box disk image to use\n"
     225        "  [ --vm=UUID ]                      Restrict media list to specified vm.\n"
    225226        "\n"
    226         "    [ { -p | --partition= } <partition #> ]    Mount specified partition number via FUSE\n"
     227        "  [ { -p | --partition= } <part #> ] Expose only specified partition via FUSE.\n"
    227228        "\n"
    228         "    [ { -o | --offset= } <byte #> ]            Disk I/O will be based on offset from disk start\n"
    229         "                                               (Can't use with -p or --partition options)\n"
     229        "  [ { -o | --offset= } <byte #> ]    Bias disk I/O by offset from disk start.\n"
     230        "                                     (incompatible with -p, --partition)\n"
    230231        "\n"
    231         "    [ -s | --size=<bytes> ]                    Sets size of mounted disk from disk start or from\n"
    232         "                                               offset, if specified. (Can't use with\n"
    233         "                                               -p or --partition options)\n"
     232        "  [ { -s | --size=<bytes> } ]        Specify size of mounted disk.\n"
     233        "                                     (incompatible with -p, --partition)\n"
    234234        "\n"
    235         "    [ --diff=<diff #> ]                        Apply diffs (snapshot differencing disk images)\n"
    236         "                                               to specified base disk image up to and including\n"
    237         "                                               specified diff number.\n"
    238         "                                               (0 = Apply no diffs, default = Apply all diffs)\n"
     235        "  [ { --diff=<diff #> } ]            Limits default operation (of applying all\n"
     236        "                                     snapshots of virtual disk) to specified\n"
     237        "                                     disk differencing image #. Diffs will\n"
     238        "                                     be merged-in up to and including diff #.\n"
     239        "                                     (default: All diffs, 0 = No diffs)\n"
    239240        "\n"
    240         "    [ --rw ]                                   Make image writeable (default = readonly)\n"
    241         "    [ --root ]                                 Same as -o allow_root\n"
     241        "  [ --rw ]                           Make image writeable (default = readonly)\n"
     242        "  [ --root ]                         Same as -o allow_root.\n"
    242243        "\n"
    243         "    [ --vm < Path | UUID >]                    VM UUID (limit media list to specific VM)\n"
     244        "  [ { -v | --verbose }]              Log extra information.\n"
    244245        "\n"
    245         "    [ --verbose]                               Log extra information\n"
    246         "    -o opt[,opt...]                            FUSE mount options\n"
    247         "    -h                                         Display short usage info showing only the above\n"
    248         "    -?                                         Display short usage info showing only the above\n"
    249         "    --help                                     Display long usage info (including FUSE opts)\n\n"
     246        "  [ -o opt[,opt...]]                 FUSE mount options.\n"
     247        "\n"
     248        "  [ { -h | -? } ]                    Display short usage info (no FUSE options).\n"
     249        "  [ --help ]                         Display long usage info (incl. FUSE opts).\n\n"
    250250    );
    251251    RTPrintf("\n");
    252     RTPrintf("When successful, the --image option creates a one-directory-deep filesystem \n");
    253     RTPrintf("rooted at the specified mountpoint.  The contents of the directory will be \n");
    254     RTPrintf("a symbolic link with the base name of the image file pointing to the path of\n");
    255     RTPrintf("the virtual disk image, and a regular file named 'vhdd', which represents\n");
    256     RTPrintf("the byte stream of the disk image as interpreted by VirtualBox.\n");
    257     RTPrintf("It is the vhdd file that the user or a utility will subsequently mount on\n");
    258     RTPrintf("the host OS to gain access to the virtual disk contents.\n\n");
    259     RTPrintf("If any of the partition, size or offset related options are used, the\n");
    260     RTPrintf("constraining start offset (in bytes) and size (in bytes) will be\n");
    261     RTPrintf("appended in brackets to the symbolic link basename to indicate\n");
    262     RTPrintf("which part of the image is exposed by the FUSE filesystem implementation.\n\n");
     252    RTPrintf("When successful, the --image option instantiates a one-directory-deep FUSE\n");
     253    RTPrintf("filesystem rooted at the specified mountpoint.  Its contents are a\n");
     254    RTPrintf("symbolic link named as basename of the image path, pointing to full path of\n");
     255    RTPrintf("the virtual disk image. Also a regular file named 'vhdd', which is a device\n");
     256    RTPrintf("node through which a raw byte stream of the disk image (as synthesized by\n");
     257    RTPrintf("the VirtualBox runtime engine) can be accessed. It is the vhdd file that the\n");
     258    RTPrintf("user or a utility can subsequently mount on the host OS.\n");
    263259}
    264260
     
    268264    (void) data;
    269265    (void) arg;
    270     switch(optKey)
    271     {
    272         case USAGE_FLAG:
    273             briefUsage();
    274             fuse_opt_add_arg(outargs, "-ho");
    275             fuse_main(outargs->argc, outargs->argv, &g_vboximgOps, NULL);
    276             break;
    277     }
    278     return 1;
     266    (void) optKey;
     267    (void) outargs;
     268    /*
     269     * Apparently this handler is only called for arguments FUSE can't parse,
     270     * and arguments that don't result in variable assignment such as "USAGE"
     271     * In this impl. that's always deemed a parsing error.
     272     */
     273    return -1;
    279274}
    280275
     
    860855                CHECK_ERROR(pMachine, COMGETTER(SettingsFilePath)(pMachineLocation.asOutParam()));
    861856
     857
    862858                if (   g_vboximgOpts.pszVm == NULL
    863859                    || RTStrNCmp(CSTR(pMachineUuid), g_vboximgOpts.pszVm, MAX_UUID_LEN) == 0
     
    875871                    listMedia(pMachine, RTStrDup(CSTR(pMachineName)), RTStrDup(CSTR(pMachineUuid)));
    876872                }
    877                 else
    878                 {
    879                     listMedia(pMachine, RTStrDup(CSTR(pMachineName)), RTStrDup(CSTR(pMachineUuid)));
    880                 }
    881873            }
    882874        }
     
    12591251
    12601252    rc = fuse_opt_parse(&args, &g_vboximgOpts, vboximgOptDefs, vboximgOptHandler);
     1253    if (rc < 0 || argc < 2 || RTStrCmp(argv[1], "-?" ) == 0 || g_vboximgOpts.fBriefUsage)
     1254    {
     1255        briefUsage();
     1256        return 0;
     1257    }
    12611258
    12621259    if (g_vboximgOpts.fAllowRoot)
    12631260        fuse_opt_add_arg(&args, "-oallow_root");
    1264 
    1265     if (rc == -1)
    1266         return RTMsgErrorExitFailure("Couldn't parse fuse options, rc=%Rrc\n", rc);
    1267 
    1268     if (argc < 2 || RTStrCmp(argv[1], "-?" ) == 0 || g_vboximgOpts.fBriefUsage)
    1269     {
    1270         briefUsage();
    1271         return 0;
    1272     }
    12731261
    12741262    /*
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette