Changeset d3b2ffa in mainline for uspace/lib


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
Files:
2 added
7 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
  • uspace/lib/fdisk/include/fdisk.h

    r1e472ee rd3b2ffa  
    3737#define LIBFDISK_FDISK_H_
    3838
     39#include <errno.h>
    3940#include <loc.h>
    4041#include <types/fdisk.h>
     
    7273extern void fdisk_pspec_init(fdisk_part_spec_t *);
    7374
    74 extern errno_t fdisk_ltype_format(label_type_t, char **);
    75 extern errno_t fdisk_fstype_format(vol_fstype_t, char **);
    76 extern errno_t fdisk_pkind_format(label_pkind_t, char **);
    77 
    7875extern errno_t fdisk_get_vollabel_support(fdisk_dev_t *, vol_fstype_t,
    7976    vol_label_supp_t *);
  • uspace/lib/fdisk/src/fdisk.c

    r1e472ee rd3b2ffa  
    813813}
    814814
    815 errno_t fdisk_ltype_format(label_type_t ltype, char **rstr)
    816 {
    817         const char *sltype;
    818         char *s;
    819 
    820         sltype = NULL;
    821         switch (ltype) {
    822         case lt_none:
    823                 sltype = "None";
    824                 break;
    825         case lt_mbr:
    826                 sltype = "MBR";
    827                 break;
    828         case lt_gpt:
    829                 sltype = "GPT";
    830                 break;
    831         }
    832 
    833         s = str_dup(sltype);
    834         if (s == NULL)
    835                 return ENOMEM;
    836 
    837         *rstr = s;
    838         return EOK;
    839 }
    840 
    841 errno_t fdisk_fstype_format(vol_fstype_t fstype, char **rstr)
    842 {
    843         const char *sfstype;
    844         char *s;
    845 
    846         sfstype = NULL;
    847         switch (fstype) {
    848         case fs_exfat:
    849                 sfstype = "ExFAT";
    850                 break;
    851         case fs_fat:
    852                 sfstype = "FAT";
    853                 break;
    854         case fs_minix:
    855                 sfstype = "MINIX";
    856                 break;
    857         case fs_ext4:
    858                 sfstype = "Ext4";
    859                 break;
    860         case fs_cdfs:
    861                 sfstype = "ISO 9660";
    862                 break;
    863         }
    864 
    865         s = str_dup(sfstype);
    866         if (s == NULL)
    867                 return ENOMEM;
    868 
    869         *rstr = s;
    870         return EOK;
    871 }
    872 
    873 errno_t fdisk_pkind_format(label_pkind_t pkind, char **rstr)
    874 {
    875         const char *spkind;
    876         char *s;
    877 
    878         spkind = NULL;
    879         switch (pkind) {
    880         case lpk_primary:
    881                 spkind = "Primary";
    882                 break;
    883         case lpk_extended:
    884                 spkind = "Extended";
    885                 break;
    886         case lpk_logical:
    887                 spkind = "Logical";
    888                 break;
    889         }
    890 
    891         s = str_dup(spkind);
    892         if (s == NULL)
    893                 return ENOMEM;
    894 
    895         *rstr = s;
    896         return EOK;
    897 }
    898 
    899815/** Get free partition index. */
    900816static errno_t fdisk_part_get_free_idx(fdisk_dev_t *dev, int *rindex)
Note: See TracChangeset for help on using the changeset viewer.