Changes in uspace/app/bdsh/cmds/modules/mount/mount.c [41047bf:e6cb880] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/cmds/modules/mount/mount.c
r41047bf re6cb880 30 30 #include <stdlib.h> 31 31 #include <vfs/vfs.h> 32 #include <adt/list.h>33 32 #include <errno.h> 34 33 #include <getopt.h> 35 #include <inttypes.h>36 34 #include "config.h" 37 35 #include "util.h" … … 45 43 static struct option const long_options[] = { 46 44 { "help", no_argument, 0, 'h' }, 47 { "instance", required_argument, 0, 'i' },48 45 { 0, 0, 0, 0 } 49 46 }; … … 54 51 { 55 52 static char helpfmt[] = 56 "Usage: %s <fstype> <mp> [dev][<moptions>]\n";53 "Usage: %s <fstype> <mp> <dev> [<moptions>]\n"; 57 54 if (level == HELP_SHORT) { 58 55 printf("'%s' mounts a file system.\n", cmdname); … … 64 61 } 65 62 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 97 63 /* Main entry point for mount, accepts an array of arguments */ 98 64 int cmd_mount(char **argv) … … 100 66 unsigned int argc; 101 67 const char *mopts = ""; 102 const char *dev = "";103 68 int rc, c, opt_ind; 104 unsigned int instance = 0;105 bool instance_set = false;106 char **t_argv;107 69 108 70 argc = cli_count_args(argv); 109 71 110 72 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); 112 74 switch (c) { 113 75 case 'h': 114 76 help_cmd_mount(HELP_LONG); 115 77 return CMD_SUCCESS; 116 case 'i':117 instance = (unsigned int) strtol(optarg, NULL, 10);118 instance_set = true;119 break;120 78 } 121 79 } 122 80 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)) { 130 82 printf("%s: invalid number of arguments. Try `mount --help'\n", 131 83 cmdname); 132 84 return CMD_FAILURE; 133 85 } 134 if (argc == 1) {135 print_mtab_list();136 return CMD_SUCCESS;137 }138 if (argc > 3)139 dev = t_argv[3];140 86 if (argc == 5) 141 mopts = t_argv[4];87 mopts = argv[4]; 142 88 143 rc = mount( t_argv[1], t_argv[2], dev, mopts, 0, instance);89 rc = mount(argv[1], argv[2], argv[3], mopts, 0); 144 90 if (rc != EOK) { 145 91 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); 147 93 return CMD_FAILURE; 148 94 }
Note:
See TracChangeset
for help on using the changeset viewer.