Changeset 0ecfc62 in mainline


Ignore:
Timestamp:
2015-10-09T18:11:08Z (9 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3a43785
Parents:
372df8f
Message:

Information structures need updating to new model.

Location:
uspace
Files:
13 edited

Legend:

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

    r372df8f r0ecfc62  
    525525        }
    526526
    527         switch (linfo.dcnt) {
    528         case dc_empty:
    529                 printf("Disk is empty.\n");
    530                 break;
    531         case dc_label:
     527        switch (linfo.ltype) {
     528        case lt_none:
     529                printf("Disk contains no label.\n");
     530                break;
     531        default:
    532532                rc = fdisk_ltype_format(linfo.ltype, &sltype);
    533533                if (rc != EOK) {
     
    540540                free(sltype);
    541541                sltype = NULL;
    542                 break;
    543         case dc_fs:
    544                 printf("Disk contains a file system.\n");
    545                 break;
    546         case dc_unknown:
    547                 printf("Disk contains unknown data.\n");
    548542                break;
    549543        }
     
    602596        }
    603597
    604         if (linfo.dcnt == dc_label) {
    605                 if ((linfo.flags & lf_ext_supp) != 0) {
    606                         if ((linfo.flags & lf_can_create_pri) != 0) {
    607                                 rc = nchoice_add(choice, "Create primary "
    608                                     "partition",
    609                                     (void *)devac_create_pri_part);
    610                                 if (rc != EOK) {
    611                                         assert(rc == ENOMEM);
     598        if ((linfo.flags & lf_ext_supp) != 0) {
     599                if ((linfo.flags & lf_can_create_pri) != 0) {
     600                        rc = nchoice_add(choice, "Create primary "
     601                            "partition",
     602                            (void *)devac_create_pri_part);
     603                        if (rc != EOK) {
     604                                assert(rc == ENOMEM);
     605                                printf("Out of memory.\n");
     606                                goto error;
     607                        }
     608                }
     609
     610                if ((linfo.flags & lf_can_create_ext) != 0) {
     611                        rc = nchoice_add(choice, "Create extended "
     612                            "partition",
     613                            (void *)devac_create_ext_part);
     614                        if (rc != EOK) {
     615                                assert(rc == ENOMEM);
     616                                printf("Out of memory.\n");
     617                                goto error;
     618                        }
     619                }
     620
     621                if ((linfo.flags & lf_can_create_log) != 0) {
     622                        rc = nchoice_add(choice, "Create logical "
     623                            "partition",
     624                            (void *)devac_create_log_part);
     625                        if (rc != EOK) {
     626                                assert(rc == ENOMEM);
     627                                printf("Out of memory.\n");
     628                                goto error;
     629                        }
     630                }
     631        } else { /* (linfo.flags & lf_ext_supp) == 0 */
     632                if ((linfo.flags & lf_can_create_pri) != 0) {
     633                        rc = nchoice_add(choice, "Create partition",
     634                            (void *)devac_create_pri_part);
     635                        if (rc != EOK) {
     636                                assert(rc == ENOMEM);
    612637                                        printf("Out of memory.\n");
    613638                                        goto error;
    614639                                }
    615                         }
    616 
    617                         if ((linfo.flags & lf_can_create_ext) != 0) {
    618                                 rc = nchoice_add(choice, "Create extended "
    619                                     "partition",
    620                                     (void *)devac_create_ext_part);
    621                                 if (rc != EOK) {
    622                                         assert(rc == ENOMEM);
    623                                         printf("Out of memory.\n");
    624                                         goto error;
    625                                 }
    626                         }
    627 
    628                         if ((linfo.flags & lf_can_create_log) != 0) {
    629                                 rc = nchoice_add(choice, "Create logical "
    630                                     "partition",
    631                                     (void *)devac_create_log_part);
    632                                 if (rc != EOK) {
    633                                         assert(rc == ENOMEM);
    634                                         printf("Out of memory.\n");
    635                                         goto error;
    636                                 }
    637                         }
    638                 } else { /* (linfo.flags & lf_ext_supp) == 0 */
    639                         if ((linfo.flags & lf_can_create_pri) != 0) {
    640                                 rc = nchoice_add(choice, "Create partition",
    641                                     (void *)devac_create_pri_part);
    642                                 if (rc != EOK) {
    643                                         assert(rc == ENOMEM);
    644                                         printf("Out of memory.\n");
    645                                         goto error;
    646                                 }
    647                         }
    648640                }
    649641        }
     
    659651        }
    660652
    661         if (linfo.dcnt == dc_empty) {
     653        if (linfo.ltype == lt_none) {
    662654                rc = nchoice_add(choice, "Create label",
    663655                    (void *)devac_create_label);
  • uspace/lib/c/generic/vol.c

    r372df8f r0ecfc62  
    192192{
    193193        async_exch_t *exch;
    194         sysarg_t dcnt, ltype, flags;
    195         int retval;
     194        sysarg_t retval;
     195        ipc_call_t answer;
    196196
    197197        exch = async_exchange_begin(vol->sess);
    198         retval = async_req_1_3(exch, VOL_PART_INFO, sid, &dcnt, &ltype,
    199             &flags);
     198        aid_t req = async_send_1(exch, VOL_PART_INFO, sid, &answer);
     199        int rc = async_data_read_start(exch, vinfo, sizeof(vol_part_info_t));
    200200        async_exchange_end(exch);
    201201
     202        if (rc != EOK) {
     203                async_forget(req);
     204                return EIO;
     205        }
     206
     207        async_wait_for(req, &retval);
    202208        if (retval != EOK)
    203209                return EIO;
    204210
    205         vinfo->dcnt = (label_disk_cnt_t)dcnt;
    206         vinfo->ltype = (label_type_t)ltype;
    207         vinfo->flags = (label_flags_t)flags;
    208211        return EOK;
    209212}
  • uspace/lib/c/include/types/label.h

    r372df8f r0ecfc62  
    3838#include <types/uuid.h>
    3939
    40 /** Disk contents */
     40/** Partition contents */
    4141typedef enum {
    42         /** Disk is considered empty */
    43         dc_empty = 0,
    44         /** Disk contains a recognized label */
    45         dc_label,
    46         /** Disk contains a recognized filesystem */
    47         dc_fs,
    48         /** Disk contains unrecognized data */
    49         dc_unknown
    50 } label_disk_cnt_t;
     42        /** Partition is considered empty */
     43        ptc_empty = 0,
     44        /** Partition contains a recognized filesystem */
     45        ptc_fs,
     46        /** Partition contains unrecognized data */
     47        ptc_unknown
     48} label_part_cnt_t;
    5149
    5250/** Disk label type */
  • uspace/lib/c/include/vol.h

    r372df8f r0ecfc62  
    4747} vol_t;
    4848
     49typedef enum {
     50        /** Partition is empty */
     51        vpc_empty,
     52        /** Partition contains a recognized filesystem */
     53        vpc_fs,
     54        /** Partition contains unrecognized data */
     55        vpc_unknown
     56} vol_part_cnt_t;
     57
     58/** File system type */
     59typedef enum {
     60        fs_exfat,
     61        fs_fat,
     62        fs_minix,
     63        fs_ext4
     64} vol_fstype_t;
     65
    4966/** Partition information */
    5067typedef struct {
    51         /** Partition contents */
    52         label_disk_cnt_t dcnt;
    53         /** Label type, if partition contents is label XXX */
    54         label_type_t ltype;
    55         /** Label flags */
    56         label_flags_t flags;
     68        /** Partition content type */
     69        vol_part_cnt_t pcnt;
     70        /** Filesystem type */
     71        vol_fstype_t fstype;
    5772} vol_part_info_t;
    5873
  • uspace/lib/fdisk/include/types/fdisk.h

    r372df8f r0ecfc62  
    102102        /** Fdisk instance */
    103103        struct fdisk *fdisk;
    104         /** Disk contents */
    105         label_disk_cnt_t dcnt;
    106104        /** Service ID */
    107105        service_id_t sid;
     
    123121
    124122typedef struct {
    125         /** Disk contents */
    126         label_disk_cnt_t dcnt;
    127123        /** Label type */
    128124        label_type_t ltype;
  • uspace/lib/fdisk/src/fdisk.c

    r372df8f r0ecfc62  
    388388        }
    389389
    390         dev->dcnt = dc_label;
    391 
    392390        printf("get label info\n");
    393391        rc = fdisk_update_dev_info(dev);
     
    486484        }
    487485
    488         info->dcnt = dc_label;
    489486        info->ltype = vinfo.ltype;
    490487        info->flags = vinfo.flags;
     
    526523                return EIO;
    527524
    528         dev->dcnt = dc_empty;
    529525        return EOK;
    530526}
  • uspace/lib/label/include/types/liblabel.h

    r372df8f r0ecfc62  
    6565
    6666struct label_info {
    67         /** Disk contents */
    68         label_disk_cnt_t dcnt;
    6967        /** Label type */
    7068        label_type_t ltype;
  • uspace/lib/label/src/dummy.c

    r372df8f r0ecfc62  
    157157{
    158158        memset(linfo, 0, sizeof(label_info_t));
    159         linfo->dcnt = dc_label;
    160159        linfo->ltype = lt_none;
    161160        linfo->flags = 0;
  • uspace/lib/label/src/gpt.c

    r372df8f r0ecfc62  
    547547{
    548548        memset(linfo, 0, sizeof(label_info_t));
    549         linfo->dcnt = dc_label;
    550549        linfo->ltype = lt_gpt;
    551550        linfo->flags = lf_ptype_uuid; /* Partition type is in UUID format */
  • uspace/lib/label/src/mbr.c

    r372df8f r0ecfc62  
    402402{
    403403        memset(linfo, 0, sizeof(label_info_t));
    404         linfo->dcnt = dc_label;
    405404        linfo->ltype = lt_mbr;
    406405
  • uspace/srv/volsrv/part.c

    r372df8f r0ecfc62  
    113113
    114114        link_initialize(&part->lparts);
    115         part->dcnt = dc_empty;
     115        part->pcnt = vpc_empty;
    116116
    117117        return part;
     
    149149        log_msg(LOG_DEFAULT, LVL_NOTE, "Probe partition %s", part->svc_name);
    150150
    151         part->dcnt = dc_unknown;
     151        part->pcnt = vpc_unknown;
    152152        list_append(&part->lparts, &vol_parts);
    153153
     
    227227int vol_part_empty_part(vol_part_t *part)
    228228{
    229         part->dcnt = dc_empty;
    230 
    231         return EOK;
    232 }
    233 
    234 int vol_part_get_info(vol_part_t *part, vol_part_info_t *dinfo)
    235 {
    236         dinfo->dcnt = part->dcnt;
     229        part->pcnt = vpc_empty;
     230
     231        return EOK;
     232}
     233
     234int vol_part_get_info(vol_part_t *part, vol_part_info_t *pinfo)
     235{
     236        pinfo->pcnt = part->pcnt;
     237        pinfo->fstype = part->fstype;
    237238        return EOK;
    238239}
  • uspace/srv/volsrv/types/part.h

    r372df8f r0ecfc62  
    4848        /** Service name */
    4949        char *svc_name;
    50         /** Disk contents */
    51         label_disk_cnt_t dcnt;
    52         /** Label type */
    53         label_type_t ltype;
     50        /** Partition contents */
     51        vol_part_cnt_t pcnt;
     52        /** Filesystem type */
     53        vol_fstype_t fstype;
    5454} vol_part_t;
    5555
  • uspace/srv/volsrv/volsrv.c

    r372df8f r0ecfc62  
    4040#include <ipc/vol.h>
    4141#include <loc.h>
     42#include <macros.h>
    4243#include <stdio.h>
    4344#include <stdlib.h>
     
    135136        }
    136137
    137         async_answer_3(iid, rc, pinfo.dcnt, pinfo.ltype, pinfo.flags);
     138        ipc_callid_t callid;
     139        size_t size;
     140        if (!async_data_read_receive(&callid, &size)) {
     141                async_answer_0(callid, EREFUSED);
     142                async_answer_0(iid, EREFUSED);
     143                return;
     144        }
     145
     146        if (size != sizeof(vol_part_info_t)) {
     147                async_answer_0(callid, EINVAL);
     148                async_answer_0(iid, EINVAL);
     149                return;
     150        }
     151
     152        rc = async_data_read_finalize(callid, &pinfo,
     153            min(size, sizeof(pinfo)));
     154        if (rc != EOK) {
     155                async_answer_0(callid, rc);
     156                async_answer_0(iid, rc);
     157                return;
     158        }
     159
     160        async_answer_0(iid, EOK);
    138161}
    139162
Note: See TracChangeset for help on using the changeset viewer.