Changeset b7a4d06 in mainline for uspace/app/fdisk/fdisk.c


Ignore:
Timestamp:
2015-07-18T12:55:12Z (10 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c43db5f
Parents:
70815a24
Message:

Most of extended (but not logical) partition support.

File:
1 edited

Legend:

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

    r70815a24 rb7a4d06  
    5151        /** Delete label */
    5252        devac_delete_label,
    53         /** Create partition */
    54         devac_create_part,
     53        /** Create (primary) partition */
     54        devac_create_pri_part,
     55        /** Create extended partition */
     56        devac_create_ext_part,
     57        /** Create logical partition */
     58        devac_create_log_part,
    5559        /** Delete partition */
    5660        devac_delete_part,
     
    312316}
    313317
    314 static int fdsk_create_part(fdisk_dev_t *dev)
     318static int fdsk_create_part(fdisk_dev_t *dev, label_pkind_t pkind)
    315319{
    316320        int rc;
    317321        fdisk_part_spec_t pspec;
    318322        fdisk_cap_t cap;
    319         fdisk_fstype_t fstype;
     323        fdisk_fstype_t fstype = fdfs_none;
    320324        tinput_t *tinput = NULL;
    321325        char *scap;
     
    345349        tinput = NULL;
    346350
    347         rc = fdsk_select_fstype(&fstype);
    348         if (rc != EOK)
    349                 goto error;
     351        if (pkind != lpk_extended) {
     352                rc = fdsk_select_fstype(&fstype);
     353                if (rc != EOK)
     354                        goto error;
     355        }
    350356
    351357        fdisk_pspec_init(&pspec);
    352358        pspec.capacity = cap;
     359        pspec.pkind = pkind;
    353360        pspec.fstype = fstype;
    354361
     
    471478        char *sfstype = NULL;
    472479        char *svcname = NULL;
     480        char *spkind;
    473481        int rc;
    474482        int npart;
     
    563571                }
    564572
    565                 printf("Partition %d: %s, %s\n", npart, scap, sfstype);
     573                printf("Partition %d: %s", npart, scap);
     574                if ((linfo.flags & lf_ext_supp) != 0) {
     575                        rc = fdisk_pkind_format(pinfo.pkind, &spkind);
     576                        if (rc != EOK) {
     577                                printf("\nOut of memory.\n");
     578                                goto error;
     579                        }
     580
     581                        printf(", %s", spkind);
     582                        free(spkind);
     583                }
     584
     585                if (pinfo.pkind != lpk_extended)
     586                        printf(", %s", sfstype);
     587                printf("\n");
     588
    566589                free(scap);
    567590                scap = NULL;
     
    580603
    581604        if (linfo.dcnt == dc_label) {
    582                 rc = nchoice_add(choice, "Create partition",
    583                     (void *)devac_create_part);
    584                 if (rc != EOK) {
    585                         assert(rc == ENOMEM);
    586                         printf("Out of memory.\n");
    587                         goto error;
     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);
     612                                        printf("Out of memory.\n");
     613                                        goto error;
     614                                }
     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                        }
    588648                }
    589649        }
     
    637697                (void) fdsk_delete_label(dev);
    638698                break;
    639         case devac_create_part:
    640                 (void) fdsk_create_part(dev);
     699        case devac_create_pri_part:
     700                (void) fdsk_create_part(dev, lpk_primary);
     701                break;
     702        case devac_create_ext_part:
     703                (void) fdsk_create_part(dev, lpk_extended);
     704                break;
     705        case devac_create_log_part:
     706                (void) fdsk_create_part(dev, lpk_logical);
    641707                break;
    642708        case devac_delete_part:
Note: See TracChangeset for help on using the changeset viewer.