Changeset 63c1dd5 in mainline for uspace/app/vol/vol.c


Ignore:
Timestamp:
2018-10-09T08:40:53Z (6 years ago)
Author:
Jiri Svoboda <jiri@…>
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)
Message:

Persistence of Tetris highscore table. Detect live mode and create directory structure in init task. Reading volume configuration, vol -c.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/vol/vol.c

    ree9c703 r63c1dd5  
    4949        vcmd_help,
    5050        vcmd_list,
     51        vcmd_cfglist,
    5152} vol_cmd_t;
    5253
     
    239240}
    240241
     242/** List volume configuration entries.
     243 *
     244 * @return EOK on success or an error code
     245 */
     246static 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");
     290out:
     291        table_destroy(table);
     292        vol_destroy(vol);
     293        free(volume_ids);
     294
     295        return rc;
     296}
     297
    241298static void print_syntax(void)
    242299{
    243300        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);
    245303        printf("  %s -h             Print help\n", NAME);
    246304        printf("  %s eject <mp>     Eject volume mounted in a directory\n", NAME);
     
    264322                if (str_cmp(cmd, "-h") == 0) {
    265323                        vcmd = vcmd_help;
     324                } else if (str_cmp(cmd, "-c") == 0) {
     325                        vcmd = vcmd_cfglist;
    266326                } else if (str_cmp(cmd, "eject") == 0) {
    267327                        vcmd = vcmd_eject;
     
    303363                rc = vol_cmd_list();
    304364                break;
     365        case vcmd_cfglist:
     366                rc = vol_cmd_cfglist();
     367                break;
    305368        }
    306369
Note: See TracChangeset for help on using the changeset viewer.