Changeset d3b2ffa in mainline for uspace/lib/c


Ignore:
Timestamp:
2018-06-29T15:40:10Z (7 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5e904dd
Parents:
1e472ee (diff), 1a9174e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge volume management improvements (still WIP).

Location:
uspace/lib/c
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/Makefile

    r1e472ee rd3b2ffa  
    112112        generic/io/log.c \
    113113        generic/io/logctl.c \
     114        generic/io/label.c \
    114115        generic/io/kio.c \
    115116        generic/io/klog.c \
  • uspace/lib/c/generic/vol.c

    r1e472ee rd3b2ffa  
    235235}
    236236
     237/** Unmount partition (and possibly eject the media). */
     238errno_t vol_part_eject(vol_t *vol, service_id_t sid)
     239{
     240        async_exch_t *exch;
     241        errno_t retval;
     242
     243        exch = async_exchange_begin(vol->sess);
     244        retval = async_req_1_0(exch, VOL_PART_EJECT, sid);
     245        async_exchange_end(exch);
     246
     247        if (retval != EOK)
     248                return retval;
     249
     250        return EOK;
     251}
     252
    237253/** Erase partition (to the extent where we will consider it not containing
    238254 * a file system.
     
    304320}
    305321
     322/** Format file system type as string.
     323 *
     324 * @param fstype File system type
     325 * @param rstr Place to store pointer to newly allocated string
     326 * @return EOK on success, ENOMEM if out of memory
     327 */
     328errno_t vol_fstype_format(vol_fstype_t fstype, char **rstr)
     329{
     330        const char *sfstype;
     331        char *s;
     332
     333        sfstype = NULL;
     334        switch (fstype) {
     335        case fs_exfat:
     336                sfstype = "ExFAT";
     337                break;
     338        case fs_fat:
     339                sfstype = "FAT";
     340                break;
     341        case fs_minix:
     342                sfstype = "MINIX";
     343                break;
     344        case fs_ext4:
     345                sfstype = "Ext4";
     346                break;
     347        case fs_cdfs:
     348                sfstype = "ISO 9660";
     349                break;
     350        }
     351
     352        s = str_dup(sfstype);
     353        if (s == NULL)
     354                return ENOMEM;
     355
     356        *rstr = s;
     357        return EOK;
     358}
     359
     360/** Format partition content / file system type as string.
     361 *
     362 * @param pcnt Partition content
     363 * @param fstype File system type
     364 * @param rstr Place to store pointer to newly allocated string
     365 * @return EOK on success, ENOMEM if out of memory
     366 */
     367errno_t vol_pcnt_fs_format(vol_part_cnt_t pcnt, vol_fstype_t fstype,
     368    char **rstr)
     369{
     370        int rc;
     371        char *s = NULL;
     372
     373        switch (pcnt) {
     374        case vpc_empty:
     375                s = str_dup("Empty");
     376                if (s == NULL)
     377                        return ENOMEM;
     378                break;
     379        case vpc_fs:
     380                rc = vol_fstype_format(fstype, &s);
     381                if (rc != EOK)
     382                        return ENOMEM;
     383                break;
     384        case vpc_unknown:
     385                s = str_dup("Unknown");
     386                if (s == NULL)
     387                        return ENOMEM;
     388                break;
     389        }
     390
     391        assert(s != NULL);
     392        *rstr = s;
     393        return EOK;
     394}
     395
    306396/** @}
    307397 */
  • uspace/lib/c/include/ipc/vol.h

    r1e472ee rd3b2ffa  
    4242        VOL_PART_ADD,
    4343        VOL_PART_INFO,
     44        VOL_PART_EJECT,
    4445        VOL_PART_EMPTY,
    4546        VOL_PART_LSUPP,
    46         VOL_PART_MKFS,
     47        VOL_PART_MKFS
    4748} vol_request_t;
    4849
  • uspace/lib/c/include/types/vol.h

    r1e472ee rd3b2ffa  
    3737
    3838#include <async.h>
     39#include <ipc/vfs.h>
    3940#include <ipc/vol.h>
    4041#include <stdbool.h>
     
    7576        /** Volume label */
    7677        char label[VOL_LABEL_MAXLEN + 1];
     78        /** Current mount point */
     79        char cur_mp[MAX_PATH_LEN + 1]; /* XXX too big */
     80        /** Current mount point is automatic */
     81        bool cur_mp_auto;
    7782} vol_part_info_t;
    7883
  • uspace/lib/c/include/vol.h

    r1e472ee rd3b2ffa  
    3737
    3838#include <async.h>
     39#include <errno.h>
    3940#include <loc.h>
    4041#include <stdint.h>
     
    4748extern errno_t vol_part_add(vol_t *, service_id_t);
    4849extern errno_t vol_part_info(vol_t *, service_id_t, vol_part_info_t *);
     50extern errno_t vol_part_eject(vol_t *, service_id_t);
    4951extern errno_t vol_part_empty(vol_t *, service_id_t);
    5052extern errno_t vol_part_get_lsupp(vol_t *, vol_fstype_t, vol_label_supp_t *);
    5153extern errno_t vol_part_mkfs(vol_t *, service_id_t, vol_fstype_t, const char *);
     54
     55extern errno_t vol_fstype_format(vol_fstype_t, char **);
     56extern errno_t vol_pcnt_fs_format(vol_part_cnt_t, vol_fstype_t, char **);
    5257
    5358#endif
Note: See TracChangeset for help on using the changeset viewer.