Changeset f3504c1 in mainline for uspace/app/mkexfat/mkexfat.c


Ignore:
Timestamp:
2017-07-11T19:05:33Z (7 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
94c05b89
Parents:
b2906c0
Message:

ExFAT volume label support.

File:
1 edited

Legend:

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

    rb2906c0 rf3504c1  
    101101        size_t   sector_size;
    102102        size_t   cluster_size;
     103        const char *label;
    103104} exfat_cfg_t;
    104 
    105105
    106106static unsigned log2(unsigned n);
     
    126126        {"cluster-size", required_argument, 0, 'c'},
    127127        {"fs-size", required_argument, 0, 's'},
     128        {"label", required_argument, 0, 'L' },
    128129};
    129130
     
    132133        printf("Usage: mkexfat [options] <device>\n"
    133134            "-c, --cluster-size ## Specify the cluster size (Kb)\n"
    134             "-s, --fs-size ##      Specify the filesystem size (sectors)\n");
     135            "-s, --fs-size ##      Specify the filesystem size (sectors)\n"
     136            "    --label ##        Volume label\n");
    135137}
    136138
     
    597599        exfat_dentry_t *d;
    598600        aoff64_t rootdir_sec;
     601        uint16_t wlabel[EXFAT_VOLLABEL_LEN + 1];
    599602        int rc;
    600603        uint8_t *data;
     
    608611
    609612        /* Initialize the volume label dentry */
    610         d->type = EXFAT_TYPE_VOLLABEL;
    611         str_to_utf16(d->vollabel.label, 8, "HELENOS ");
    612         d->vollabel.size = 8;
    613 
    614         d++;
     613
     614        if (cfg->label != NULL) {
     615                memset(wlabel, 0, (EXFAT_VOLLABEL_LEN + 1) * sizeof(uint16_t));
     616                rc = str_to_utf16(wlabel, EXFAT_VOLLABEL_LEN + 1, cfg->label);
     617                if (rc != EOK) {
     618                        rc = EINVAL;
     619                        goto exit;
     620                }
     621
     622                d->type = EXFAT_TYPE_VOLLABEL;
     623                memcpy(d->vollabel.label, wlabel, EXFAT_VOLLABEL_LEN * 2);
     624                d->vollabel.size = utf16_wsize(wlabel);
     625                assert(d->vollabel.size <= EXFAT_VOLLABEL_LEN);
     626
     627                d++;
     628        } else {
     629                d->type = EXFAT_TYPE_VOLLABEL & ~EXFAT_TYPE_USED;
     630        }
    615631
    616632        /* Initialize the allocation bitmap dentry */
     
    751767
    752768        cfg.cluster_size = 0;
     769        cfg.label = NULL;
    753770
    754771        for (c = 0, optind = 0, opt_ind = 0; c != -1;) {
    755                 c = getopt_long(argc, argv, "hs:c:",
     772                c = getopt_long(argc, argv, "hs:c:L:",
    756773                    long_options, &opt_ind);
    757774                switch (c) {
     
    781798                        }
    782799                        break;
     800                case 'L':
     801                        cfg.label = optarg;
     802                        break;
    783803                }
    784804        }
Note: See TracChangeset for help on using the changeset viewer.