Changeset db9c889 in mainline for uspace/lib/c/generic/vol.c


Ignore:
Timestamp:
2018-06-29T13:22:39Z (7 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
72c72d4
Parents:
5f36841
git-author:
Jiri Svoboda <jiri@…> (2018-06-28 17:22:13)
git-committer:
Jiri Svoboda <jiri@…> (2018-06-29 13:22:39)
Message:

Add volume administration utility.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/vol.c

    r5f36841 rdb9c889  
    304304}
    305305
     306/** Format file system type as string.
     307 *
     308 * @param fstype File system type
     309 * @param rstr Place to store pointer to newly allocated string
     310 * @return EOK on success, ENOMEM if out of memory
     311 */
     312errno_t vol_fstype_format(vol_fstype_t fstype, char **rstr)
     313{
     314        const char *sfstype;
     315        char *s;
     316
     317        sfstype = NULL;
     318        switch (fstype) {
     319        case fs_exfat:
     320                sfstype = "ExFAT";
     321                break;
     322        case fs_fat:
     323                sfstype = "FAT";
     324                break;
     325        case fs_minix:
     326                sfstype = "MINIX";
     327                break;
     328        case fs_ext4:
     329                sfstype = "Ext4";
     330                break;
     331        case fs_cdfs:
     332                sfstype = "ISO 9660";
     333                break;
     334        }
     335
     336        s = str_dup(sfstype);
     337        if (s == NULL)
     338                return ENOMEM;
     339
     340        *rstr = s;
     341        return EOK;
     342}
     343
     344/** Format partition content / file system type as string.
     345 *
     346 * @param pcnt Partition content
     347 * @param fstype File system type
     348 * @param rstr Place to store pointer to newly allocated string
     349 * @return EOK on success, ENOMEM if out of memory
     350 */
     351errno_t vol_pcnt_fs_format(vol_part_cnt_t pcnt, vol_fstype_t fstype,
     352    char **rstr)
     353{
     354        int rc;
     355        char *s = NULL;
     356
     357        switch (pcnt) {
     358        case vpc_empty:
     359                s = str_dup("Empty");
     360                if (s == NULL)
     361                        return ENOMEM;
     362                break;
     363        case vpc_fs:
     364                rc = vol_fstype_format(fstype, &s);
     365                if (rc != EOK)
     366                        return ENOMEM;
     367                break;
     368        case vpc_unknown:
     369                s = str_dup("Unknown");
     370                if (s == NULL)
     371                        return ENOMEM;
     372                break;
     373        }
     374
     375        assert(s != NULL);
     376        *rstr = s;
     377        return EOK;
     378}
     379
    306380/** @}
    307381 */
Note: See TracChangeset for help on using the changeset viewer.