Ignore:
File:
1 edited

Legend:

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

    r41047bf re6cb880  
    3030#include <stdlib.h>
    3131#include <vfs/vfs.h>
    32 #include <adt/list.h>
    3332#include <errno.h>
    3433#include <getopt.h>
    35 #include <inttypes.h>
    3634#include "config.h"
    3735#include "util.h"
     
    4543static struct option const long_options[] = {
    4644        { "help", no_argument, 0, 'h' },
    47         { "instance", required_argument, 0, 'i' },
    4845        { 0, 0, 0, 0 }
    4946};
     
    5451{
    5552        static char helpfmt[] =
    56             "Usage:  %s <fstype> <mp> [dev] [<moptions>]\n";
     53            "Usage:  %s <fstype> <mp> <dev> [<moptions>]\n";
    5754        if (level == HELP_SHORT) {
    5855                printf("'%s' mounts a file system.\n", cmdname);
     
    6461}
    6562
    66 static void print_mtab_list(void)
    67 {
    68         LIST_INITIALIZE(mtab_list);
    69         get_mtab_list(&mtab_list);
    70 
    71         mtab_ent_t *old_ent = NULL;
    72 
    73         list_foreach(mtab_list, cur) {
    74                 mtab_ent_t *mtab_ent = list_get_instance(cur, mtab_ent_t,
    75                     link);
    76 
    77                 if (old_ent)
    78                         free(old_ent);
    79 
    80                 old_ent = mtab_ent;
    81 
    82                 printf("%s", mtab_ent->fs_name);
    83                 if (mtab_ent->instance)
    84                         printf("/%d", mtab_ent->instance);
    85                 printf(" on %s ", mtab_ent->mp);
    86 
    87                 if (str_size(mtab_ent->opts) > 0)
    88                         printf("opts=%s ", mtab_ent->opts);
    89 
    90                 printf("(service=%" PRIun ")\n", mtab_ent->service_id);
    91         }
    92 
    93         if (old_ent)
    94                 free(old_ent);
    95 }
    96 
    9763/* Main entry point for mount, accepts an array of arguments */
    9864int cmd_mount(char **argv)
     
    10066        unsigned int argc;
    10167        const char *mopts = "";
    102         const char *dev = "";
    10368        int rc, c, opt_ind;
    104         unsigned int instance = 0;
    105         bool instance_set = false;
    106         char **t_argv;
    10769
    10870        argc = cli_count_args(argv);
    10971
    11072        for (c = 0, optind = 0, opt_ind = 0; c != -1;) {
    111                 c = getopt_long(argc, argv, "i:h", long_options, &opt_ind);
     73                c = getopt_long(argc, argv, "h", long_options, &opt_ind);
    11274                switch (c) {
    11375                case 'h':
    11476                        help_cmd_mount(HELP_LONG);
    11577                        return CMD_SUCCESS;
    116                 case 'i':
    117                         instance = (unsigned int) strtol(optarg, NULL, 10);
    118                         instance_set = true;
    119                         break;
    12078                }
    12179        }
    12280
    123         if (instance_set) {
    124                 argc -= 2;
    125                 t_argv = &argv[2];
    126         } else
    127                 t_argv = &argv[0];
    128 
    129         if ((argc == 2) || (argc > 5)) {
     81        if ((argc < 4) || (argc > 5)) {
    13082                printf("%s: invalid number of arguments. Try `mount --help'\n",
    13183                    cmdname);
    13284                return CMD_FAILURE;
    13385        }
    134         if (argc == 1) {
    135                 print_mtab_list();
    136                 return CMD_SUCCESS;
    137         }
    138         if (argc > 3)
    139                 dev = t_argv[3];
    14086        if (argc == 5)
    141                 mopts = t_argv[4];
     87                mopts = argv[4];
    14288
    143         rc = mount(t_argv[1], t_argv[2], dev, mopts, 0, instance);
     89        rc = mount(argv[1], argv[2], argv[3], mopts, 0);
    14490        if (rc != EOK) {
    14591                printf("Unable to mount %s filesystem to %s on %s (rc=%d)\n",
    146                     t_argv[1], t_argv[2], t_argv[3], rc);
     92                    argv[1], argv[2], argv[3], rc);
    14793                return CMD_FAILURE;
    14894        }
Note: See TracChangeset for help on using the changeset viewer.