Changeset 63c1dd5 in mainline for uspace/app/vol/vol.c
- Timestamp:
- 2018-10-09T08:40:53Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 63a045c
- Parents:
- ee9c703
- git-author:
- Jiri Svoboda <jiri@…> (2018-10-08 18:38:16)
- git-committer:
- Jiri Svoboda <jiri@…> (2018-10-09 08:40:53)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/vol/vol.c
ree9c703 r63c1dd5 49 49 vcmd_help, 50 50 vcmd_list, 51 vcmd_cfglist, 51 52 } vol_cmd_t; 52 53 … … 239 240 } 240 241 242 /** List volume configuration entries. 243 * 244 * @return EOK on success or an error code 245 */ 246 static errno_t vol_cmd_cfglist(void) 247 { 248 vol_t *vol = NULL; 249 vol_info_t vinfo; 250 volume_id_t *volume_ids = NULL; 251 size_t nvols; 252 size_t i; 253 table_t *table = NULL; 254 errno_t rc; 255 256 rc = vol_create(&vol); 257 if (rc != EOK) { 258 printf("Error contacting volume service.\n"); 259 goto out; 260 } 261 262 rc = vol_get_volumes(vol, &volume_ids, &nvols); 263 if (rc != EOK) { 264 printf("Error getting list of volumes.\n"); 265 goto out; 266 } 267 268 rc = table_create(&table); 269 if (rc != EOK) { 270 printf("Out of memory.\n"); 271 goto out; 272 } 273 274 table_header_row(table); 275 table_printf(table, "Volume Name\t" "Path\n"); 276 277 for (i = 0; i < nvols; i++) { 278 rc = vol_info(vol, volume_ids[i], &vinfo); 279 if (rc != EOK) { 280 printf("Error getting volume information.\n"); 281 return EIO; 282 } 283 284 table_printf(table, "%s\t" "%s\n", vinfo.label, vinfo.path); 285 } 286 287 rc = table_print_out(table, stdout); 288 if (rc != EOK) 289 printf("Error printing table.\n"); 290 out: 291 table_destroy(table); 292 vol_destroy(vol); 293 free(volume_ids); 294 295 return rc; 296 } 297 241 298 static void print_syntax(void) 242 299 { 243 300 printf("Syntax:\n"); 244 printf(" %s List volumes\n", NAME); 301 printf(" %s List present volumes\n", NAME); 302 printf(" %s -c List volume configuration entries\n", NAME); 245 303 printf(" %s -h Print help\n", NAME); 246 304 printf(" %s eject <mp> Eject volume mounted in a directory\n", NAME); … … 264 322 if (str_cmp(cmd, "-h") == 0) { 265 323 vcmd = vcmd_help; 324 } else if (str_cmp(cmd, "-c") == 0) { 325 vcmd = vcmd_cfglist; 266 326 } else if (str_cmp(cmd, "eject") == 0) { 267 327 vcmd = vcmd_eject; … … 303 363 rc = vol_cmd_list(); 304 364 break; 365 case vcmd_cfglist: 366 rc = vol_cmd_cfglist(); 367 break; 305 368 } 306 369
Note:
See TracChangeset
for help on using the changeset viewer.