Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bdsh/cmds/modules/mount/mount.c

    re6cb880 r286286c  
    4343static struct option const long_options[] = {
    4444        { "help", no_argument, 0, 'h' },
     45        { "instance", required_argument, 0, 'i' },
    4546        { 0, 0, 0, 0 }
    4647};
     
    5152{
    5253        static char helpfmt[] =
    53             "Usage:  %s <fstype> <mp> <dev> [<moptions>]\n";
     54            "Usage:  %s <fstype> <mp> [dev] [<moptions>]\n";
    5455        if (level == HELP_SHORT) {
    5556                printf("'%s' mounts a file system.\n", cmdname);
     
    6667        unsigned int argc;
    6768        const char *mopts = "";
     69        const char *dev = "";
    6870        int rc, c, opt_ind;
     71        unsigned int instance = 0;
     72        bool instance_set = false;
     73        char **t_argv;
    6974
    7075        argc = cli_count_args(argv);
    7176
    7277        for (c = 0, optind = 0, opt_ind = 0; c != -1;) {
    73                 c = getopt_long(argc, argv, "h", long_options, &opt_ind);
     78                c = getopt_long(argc, argv, "i:h", long_options, &opt_ind);
    7479                switch (c) {
    7580                case 'h':
    7681                        help_cmd_mount(HELP_LONG);
    7782                        return CMD_SUCCESS;
     83                case 'i':
     84                        instance = (unsigned int) strtol(optarg, NULL, 10);
     85                        instance_set = true;
     86                        break;
    7887                }
    7988        }
    8089
    81         if ((argc < 4) || (argc > 5)) {
     90        if (instance_set) {
     91                argc -= 2;
     92                t_argv = &argv[2];
     93        } else
     94                t_argv = &argv[0];
     95
     96        if ((argc < 3) || (argc > 5)) {
    8297                printf("%s: invalid number of arguments. Try `mount --help'\n",
    8398                    cmdname);
    8499                return CMD_FAILURE;
    85100        }
     101        if (argc > 3)
     102                dev = t_argv[3];
    86103        if (argc == 5)
    87                 mopts = argv[4];
     104                mopts = t_argv[4];
    88105
    89         rc = mount(argv[1], argv[2], argv[3], mopts, 0);
     106        rc = mount(t_argv[1], t_argv[2], dev, mopts, 0, instance);
    90107        if (rc != EOK) {
    91108                printf("Unable to mount %s filesystem to %s on %s (rc=%d)\n",
    92                     argv[1], argv[2], argv[3], rc);
     109                    t_argv[1], t_argv[2], t_argv[3], rc);
    93110                return CMD_FAILURE;
    94111        }
Note: See TracChangeset for help on using the changeset viewer.