Changeset c08fb04 in mainline


Ignore:
Timestamp:
2011-11-05T12:37:05Z (12 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
72fda53
Parents:
4965357f
Message:

Print the mtab list when executing the mount command without any argument.

File:
1 edited

Legend:

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

    r4965357f rc08fb04  
    3030#include <stdlib.h>
    3131#include <vfs/vfs.h>
     32#include <adt/list.h>
    3233#include <errno.h>
    3334#include <getopt.h>
     
    6061        }
    6162        return;
     63}
     64
     65static void print_mtab_list(void)
     66{
     67        LIST_INITIALIZE(mtab_list);
     68        get_mtab_list(&mtab_list);
     69
     70        mtab_list_ent_t *old_ent = NULL;
     71
     72        list_foreach(mtab_list, cur) {
     73                mtab_list_ent_t *ent = list_get_instance(cur, mtab_list_ent_t,
     74                    link);
     75
     76                mtab_ent_t *mtab_ent = &ent->mtab_ent;
     77
     78                if (old_ent)
     79                        free(old_ent);
     80
     81                old_ent = ent;
     82
     83                printf("%s on %s ", mtab_ent->fs_name, mtab_ent->mp);
     84
     85                if (str_size(mtab_ent->opts) > 0)
     86                        printf("opts=%s ", mtab_ent->opts);
     87
     88                printf("(instance=%d, flags=%d, fs_handle=%d)\n",
     89                    mtab_ent->instance, mtab_ent->flags, mtab_ent->fs_handle);
     90        }
     91
     92        if (old_ent)
     93                free(old_ent);
    6294}
    6395
     
    94126                t_argv = &argv[0];
    95127
    96         if ((argc < 3) || (argc > 5)) {
     128        if ((argc == 2) || (argc > 5)) {
    97129                printf("%s: invalid number of arguments. Try `mount --help'\n",
    98130                    cmdname);
    99131                return CMD_FAILURE;
     132        }
     133        if (argc == 1) {
     134                print_mtab_list();
     135                return CMD_SUCCESS;
    100136        }
    101137        if (argc > 3)
Note: See TracChangeset for help on using the changeset viewer.