Changeset 8565a42 in mainline for uspace/srv/fs/udf


Ignore:
Timestamp:
2018-03-02T20:34:50Z (8 years ago)
Author:
GitHub <noreply@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a1a81f69, d5e5fd1
Parents:
3061bc1 (diff), 34e1206 (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.
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:34:50)
git-committer:
GitHub <noreply@…> (2018-03-02 20:34:50)
Message:

Remove all trailing whitespace, everywhere.

See individual commit messages for details.

Location:
uspace/srv/fs/udf
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/udf/udf.c

    r3061bc1 r8565a42  
    6363        log_init(NAME);
    6464        log_msg(LOG_DEFAULT, LVL_NOTE, "HelenOS UDF 1.02 file system server");
    65        
     65
    6666        if (argc == 3) {
    6767                if (!str_cmp(argv[1], "--instance"))
     
    7272                }
    7373        }
    74        
     74
    7575        async_sess_t *vfs_sess =
    7676            service_connect_blocking(SERVICE_VFS, INTERFACE_VFS_DRIVER, 0);
     
    7979                return 2;
    8080        }
    81        
     81
    8282        errno_t rc = fs_register(vfs_sess, &udf_vfs_info, &udf_ops,
    8383            &udf_libfs_ops);
    8484        if (rc != EOK)
    8585                goto err;
    86        
     86
    8787        rc = udf_idx_init();
    8888        if (rc != EOK)
    8989                goto err;
    90        
     90
    9191        log_msg(LOG_DEFAULT, LVL_NOTE, "Accepting connections");
    9292        task_retval(0);
    9393        async_manager();
    94        
     94
    9595        /* Not reached */
    9696        return 0;
    97        
     97
    9898err:
    9999        log_msg(LOG_DEFAULT, LVL_FATAL, "Failed to register file system: %s", str_error(rc));
  • uspace/srv/fs/udf/udf.h

    r3061bc1 r8565a42  
    8585        size_t open_nodes_count;
    8686        udf_charspec_t charset;
    87        
     87
    8888        uint32_t sector_size;
    8989        udf_lvolume_t *volumes;
     
    105105        fs_node_t *fs_node;
    106106        fibril_mutex_t lock;
    107        
     107
    108108        fs_index_t index;  /* FID logical block */
    109109        ht_link_t link;
    110110        size_t ref_cnt;
    111111        size_t link_cnt;
    112        
     112
    113113        uint8_t type;  /* 1 - file, 0 - directory */
    114114        uint64_t data_size;
  • uspace/srv/fs/udf/udf_cksum.c

    r3061bc1 r8565a42  
    7979{
    8080        uint16_t crc = 0;
    81        
     81
    8282        while (len-- > 0) {
    8383                /*
     
    8888                crc = crc_table[(crc >> 8 ^ (*buf++ & 0xff)) & 0xff] ^ (crc << 8);
    8989        }
    90        
     90
    9191        return crc;
    9292}
     
    9898{
    9999        uint8_t result = 0;
    100        
     100
    101101        for (size_t i = 0; i < UDF_TAG_SIZE; i++) {
    102102                if (i == 4)
    103103                        continue;
    104                
     104
    105105                result = (result + tag[i]) % 256;
    106106        }
    107        
     107
    108108        return result;
    109109}
  • uspace/srv/fs/udf/udf_file.c

    r3061bc1 r8565a42  
    6565        if (rc != EOK)
    6666                return rc;
    67        
     67
    6868        udf_ext_ad_t *exd = (udf_ext_ad_t *) block->data;
    6969        uint32_t start = node->instance->partitions[
    7070            FLE16(exd->extent_location.partition_num)].start +
    7171            FLE32(exd->extent_location.lblock_num);
    72        
     72
    7373        log_msg(LOG_DEFAULT, LVL_DEBUG,
    7474            "Extended allocator: start=%d, block_num=%d, len=%d", start,
    7575            FLE32(exd->extent_location.lblock_num), FLE32(exd->info_length));
    76        
     76
    7777        uint32_t len = FLE32(exd->info_length);
    7878        block_put(block);
    79        
     79
    8080        return udf_read_allocation_sequence(node, NULL, icb_flag, start, len);
    8181}
     
    9797{
    9898        node->alloc_size = 0;
    99        
     99
    100100        switch (icb_flag) {
    101101        case UDF_SHORT_AD:
    102102                log_msg(LOG_DEFAULT, LVL_DEBUG,
    103103                    "ICB: sequence of allocation descriptors - icbflag = short_ad_t");
    104                
     104
    105105                /*
    106106                 * Identify number of current partition. Virtual partition
     
    110110                size_t pd_num = (size_t) -1;
    111111                size_t min_start = 0;
    112                
     112
    113113                for (size_t i = 0; i < node->instance->partition_cnt; i++) {
    114114                        if ((node->index >= node->instance->partitions[i].start) &&
     
    121121                        }
    122122                }
    123                
     123
    124124                if (pd_num == (size_t) -1)
    125125                        return ENOENT;
    126                
     126
    127127                /*
    128128                 * According to doc, in this we should stop our loop if pass
     
    133133                 * which we check inside of loop.
    134134                 */
    135                
     135
    136136                while (true) {
    137137                        udf_short_ad_t *short_d =
    138138                            (udf_short_ad_t *) (af + start_alloc +
    139139                            node->alloc_size * sizeof(udf_short_ad_t));
    140                        
     140
    141141                        if (FLE32(short_d->length) == 0)
    142142                                break;
    143                        
     143
    144144                        /*
    145145                         * ECMA 167 4/12 - next sequence of allocation descriptors
     
    152152                                break;
    153153                        }
    154                        
     154
    155155                        node->allocators = realloc(node->allocators,
    156156                            (node->alloc_size + 1) * sizeof(udf_allocator_t));
     
    161161                        node->alloc_size++;
    162162                }
    163                
     163
    164164                node->allocators = realloc(node->allocators,
    165165                    node->alloc_size * sizeof(udf_allocator_t));
    166166                break;
    167                
     167
    168168        case UDF_LONG_AD:
    169169                log_msg(LOG_DEFAULT, LVL_DEBUG,
    170170                    "ICB: sequence of allocation descriptors - icbflag = long_ad_t");
    171                
     171
    172172                while (true) {
    173173                        udf_long_ad_t *long_d =
    174174                            (udf_long_ad_t *) (af + start_alloc +
    175175                            node->alloc_size * sizeof(udf_long_ad_t));
    176                        
     176
    177177                        if (FLE32(long_d->length) == 0)
    178178                                break;
    179                        
     179
    180180                        uint32_t pos_long_ad = udf_long_ad_to_pos(node->instance, long_d);
    181                        
     181
    182182                        /*
    183183                         * ECMA 167 4/12 - next sequence of allocation descriptors
     
    188188                                break;
    189189                        }
    190                        
     190
    191191                        node->allocators = realloc(node->allocators,
    192192                            (node->alloc_size + 1) * sizeof(udf_allocator_t));
     
    194194                            EXT_LENGTH(FLE32(long_d->length));
    195195                        node->allocators[node->alloc_size].position = pos_long_ad;
    196                        
     196
    197197                        node->alloc_size++;
    198198                }
    199                
     199
    200200                node->allocators = realloc(node->allocators,
    201201                    node->alloc_size * sizeof(udf_allocator_t));
    202202                break;
    203                
     203
    204204        case UDF_EXTENDED_AD:
    205205                log_msg(LOG_DEFAULT, LVL_DEBUG,
    206206                    "ICB: sequence of allocation descriptors - icbflag = extended_ad_t");
    207207                break;
    208                
     208
    209209        case UDF_DATA_AD:
    210210                log_msg(LOG_DEFAULT, LVL_DEBUG,
    211211                    "ICB: sequence of allocation descriptors - icbflag = 3, node contains data itself");
    212                
     212
    213213                node->data = malloc(node->data_size);
    214214                if (!node->data)
    215215                        return ENOMEM;
    216                
     216
    217217                memcpy(node->data, (af + start_alloc), node->data_size);
    218218                node->alloc_size = 0;
    219219                break;
    220220        }
    221        
     221
    222222        return EOK;
    223223}
     
    237237        while (true) {
    238238                fs_index_t pos = node->index;
    239                
     239
    240240                block_t *block = NULL;
    241241                errno_t rc = block_get(&block, node->instance->service_id, pos,
     
    243243                if (rc != EOK)
    244244                        return rc;
    245                
     245
    246246                udf_descriptor_tag_t *data = (udf_descriptor_tag_t *) block->data;
    247247                if (data->checksum != udf_tag_checksum((uint8_t *) data)) {
     
    249249                        return EINVAL;
    250250                }
    251                
     251
    252252                /* One sector size descriptors */
    253253                switch (FLE16(data->id)) {
    254254                case UDF_FILE_ENTRY:
    255255                        log_msg(LOG_DEFAULT, LVL_DEBUG, "ICB: File entry descriptor found");
    256                        
     256
    257257                        udf_file_entry_descriptor_t *file =
    258258                            (udf_file_entry_descriptor_t *) block->data;
     
    260260                        node->data_size = FLE64(file->info_lenght);
    261261                        node->type = (file->icbtag.file_type == UDF_ICBTYPE_DIR) ? NODE_DIR : NODE_FILE;
    262                        
     262
    263263                        rc = udf_read_allocation_sequence(node, (uint8_t *) file, icb_flag,
    264264                            FLE32(file->ea_lenght) + UDF_FE_OFFSET, FLE32(file->ad_lenght));
    265265                        block_put(block);
    266266                        return rc;
    267                        
     267
    268268                case UDF_EFILE_ENTRY:
    269269                        log_msg(LOG_DEFAULT, LVL_DEBUG, "ICB: Extended file entry descriptor found");
    270                        
     270
    271271                        udf_extended_file_entry_descriptor_t *efile =
    272272                            (udf_extended_file_entry_descriptor_t *) block->data;
     
    274274                        node->data_size = FLE64(efile->info_lenght);
    275275                        node->type = (efile->icbtag.file_type == UDF_ICBTYPE_DIR) ? NODE_DIR : NODE_FILE;
    276                        
     276
    277277                        rc = udf_read_allocation_sequence(node, (uint8_t *) efile, icb_flag,
    278278                            FLE32(efile->ea_lenght) + UDF_EFE_OFFSET, FLE32(efile->ad_lenght));
    279279                        block_put(block);
    280280                        return rc;
    281                        
     281
    282282                case UDF_ICB_TERMINAL:
    283283                        log_msg(LOG_DEFAULT, LVL_DEBUG, "ICB: Terminal entry descriptor found");
     
    285285                        return EOK;
    286286                }
    287                
     287
    288288                pos++;
    289                
     289
    290290                rc = block_put(block);
    291291                if (rc != EOK)
    292292                        return rc;
    293293        }
    294        
     294
    295295        return EOK;
    296296}
     
    323323        size_t fid_sum = 0;
    324324        size_t n = 0;
    325        
     325
    326326        while (node->data_size - fid_sum >= MIN_FID_LEN) {
    327327                udf_descriptor_tag_t *desc =
     
    333333                                return ENOENT;
    334334                }
    335                
     335
    336336                *fid = (udf_file_identifier_descriptor_t *)
    337337                    (node->data + fid_sum);
    338                
     338
    339339                /* According to ECMA 167 4/14.4.9 */
    340340                size_t padding = 4 * (((*fid)->lenght_file_id +
     
    343343                size_t size_fid = (*fid)->lenght_file_id +
    344344                    FLE16((*fid)->lenght_iu) + padding + 38;
    345                
     345
    346346                fid_sum += size_fid;
    347                
     347
    348348                /* aAcording to ECMA 167 4/8.6 */
    349349                if (((*fid)->lenght_file_id != 0) &&
    350350                    (((*fid)->file_characteristics & 4) == 0)) {
    351351                        n++;
    352                        
     352
    353353                        if (n == pos + 1)
    354354                                return EOK;
    355355                }
    356356        }
    357        
     357
    358358        return ENOENT;
    359359}
     
    374374        if (node->data == NULL)
    375375                return udf_get_fid_in_allocator(fid, block, node, pos);
    376        
     376
    377377        return udf_get_fid_in_data(fid, node, pos);
    378378}
     
    392392{
    393393        void *buf = malloc(node->instance->sector_size);
    394        
     394
    395395        // FIXME: Check for NULL return value
    396        
     396
    397397        size_t j = 0;
    398398        size_t n = 0;
    399399        size_t len = 0;
    400        
     400
    401401        while (j < node->alloc_size) {
    402402                size_t i = 0;
     
    408408                                return rc;
    409409                        }
    410                        
     410
    411411                        /*
    412412                         * Last item in allocator is a part of sector. We take
     
    422422                                break;
    423423                        }
    424                        
     424
    425425                        rc = udf_get_fid_in_sector(fid, block, node, pos, &n, &buf, &len);
    426426                        if (rc == EOK) {
     
    428428                                return EOK;
    429429                        }
    430                        
     430
    431431                        if (rc == EINVAL) {
    432432                                // FIXME: Memory leak
    433433                                return ENOENT;
    434434                        }
    435                        
     435
    436436                        if (rc == ENOENT) {
    437437                                if (block) {
    438438                                        rc = block_put(*block);
    439439                                        *block = NULL;
    440                                        
     440
    441441                                        if (rc != EOK)
    442442                                                return rc;
    443443                                }
    444444                        }
    445                        
     445
    446446                        i++;
    447447                }
    448                
     448
    449449                j++;
    450450        }
    451        
     451
    452452        if (buf)
    453453                free(buf);
    454        
     454
    455455        return ENOENT;
    456456}
     
    474474{
    475475        void *fidbuf = malloc(node->instance->sector_size);
    476        
     476
    477477        // FIXME: Check for NULL return value
    478        
     478
    479479        bool buf_flag;
    480        
     480
    481481        if (*len > 0) {
    482482                memcpy(fidbuf, *buf, *len);
     
    484484        } else
    485485                buf_flag = false;
    486        
     486
    487487        size_t fid_sum = 0;
    488488        while (node->instance->sector_size - fid_sum > 0) {
    489489                if (node->instance->sector_size - fid_sum >= MIN_FID_LEN) {
    490490                        void *fid_data;
    491                        
     491
    492492                        if (buf_flag) {
    493493                                memcpy((fidbuf + *len), (*block)->data,
     
    496496                        } else
    497497                                fid_data = (*block)->data + fid_sum;
    498                        
     498
    499499                        udf_descriptor_tag_t *desc =
    500500                            (udf_descriptor_tag_t *) fid_data;
    501                        
     501
    502502                        if (desc->checksum != udf_tag_checksum((uint8_t *) desc)) {
    503503                                if (fidbuf)
    504504                                        free(fidbuf);
    505                                
     505
    506506                                if (*buf) {
    507507                                        free(*buf);
     
    509509                                        *len = 0;
    510510                                }
    511                                
     511
    512512                                return EINVAL;
    513513                        }
    514                        
     514
    515515                        *fid = (udf_file_identifier_descriptor_t *) fid_data;
    516                        
     516
    517517                        /* According to ECMA 167 4/14.4.9 */
    518518                        size_t padding = 4 * (((*fid)->lenght_file_id +
     
    525525                        else
    526526                                fid_sum += size_fid;
    527                        
     527
    528528                        /* According to ECMA 167 4/8.6 */
    529529                        if (((*fid)->lenght_file_id != 0) &&
     
    533533                                        if (fidbuf)
    534534                                                free(fidbuf);
    535                                        
     535
    536536                                        return EOK;
    537537                                }
    538538                        }
    539                        
     539
    540540                        if (fidbuf) {
    541541                                buf_flag = false;
     
    543543                                fidbuf = NULL;
    544544                        }
    545                        
     545
    546546                        if (*buf) {
    547547                                free(*buf);
     
    552552                        if (*buf)
    553553                                free(*buf);
    554                        
     554
    555555                        *len = node->instance->sector_size - fid_sum;
    556556                        *buf = malloc(*len);
    557557                        buf_flag = false;
    558558                        memcpy(*buf, ((*block)->data + fid_sum), *len);
    559                        
     559
    560560                        return ENOENT;
    561561                }
    562562        }
    563        
     563
    564564        return ENOENT;
    565565}
     
    581581        size_t i = 0;
    582582        size_t l = 0;
    583        
     583
    584584        while (i < node->alloc_size) {
    585585                if (pos >= l + node->allocators[i].length) {
     
    589589                        break;
    590590        }
    591        
     591
    592592        size_t sector_cnt = ALL_UP(l, node->instance->sector_size);
    593593        size_t sector_num = pos / node->instance->sector_size;
    594        
     594
    595595        block_t *block = NULL;
    596596        errno_t rc = block_get(&block, node->instance->service_id,
     
    601601                return rc;
    602602        }
    603        
     603
    604604        size_t sector_pos = pos % node->instance->sector_size;
    605        
     605
    606606        if (sector_pos + len < node->instance->sector_size)
    607607                *read_len = len;
    608608        else
    609609                *read_len = node->instance->sector_size - sector_pos;
    610        
     610
    611611        if (ALL_UP(node->allocators[i].length, node->instance->sector_size) ==
    612612            sector_num - sector_cnt + 1) {
     
    618618                        *read_len = len;
    619619        }
    620        
     620
    621621        async_data_read_finalize(callid, block->data + sector_pos, *read_len);
    622622        return block_put(block);
  • uspace/srv/fs/udf/udf_idx.c

    r3061bc1 r8565a42  
    9595        if (!hash_table_create(&udf_idx, 0, 0, &udf_idx_ops))
    9696                return ENOMEM;
    97        
     97
    9898        return EOK;
    9999}
     
    127127                .index = index
    128128        };
    129        
     129
    130130        ht_link_t *already_open = hash_table_find(&udf_idx, &key);
    131131        if (already_open) {
     
    133133                    udf_node_t, link);
    134134                node->ref_cnt++;
    135                
     135
    136136                *udfn = node;
    137                
     137
    138138                fibril_mutex_unlock(&udf_idx_lock);
    139139                return EOK;
    140140        }
    141        
     141
    142142        fibril_mutex_unlock(&udf_idx_lock);
    143143        return ENOENT;
     
    156156{
    157157        fibril_mutex_lock(&udf_idx_lock);
    158        
     158
    159159        udf_node_t *udf_node = malloc(sizeof(udf_node_t));
    160160        if (udf_node == NULL) {
     
    162162                return ENOMEM;
    163163        }
    164        
     164
    165165        fs_node_t *fs_node = malloc(sizeof(fs_node_t));
    166166        if (fs_node == NULL) {
     
    169169                return ENOMEM;
    170170        }
    171        
     171
    172172        fs_node_initialize(fs_node);
    173        
     173
    174174        udf_node->index = index;
    175175        udf_node->instance = instance;
     
    179179        udf_node->data = NULL;
    180180        udf_node->allocators = NULL;
    181        
     181
    182182        fibril_mutex_initialize(&udf_node->lock);
    183183        fs_node->data = udf_node;
    184        
     184
    185185        hash_table_insert(&udf_idx, &udf_node->link);
    186186        instance->open_nodes_count++;
    187        
     187
    188188        *udfn = udf_node;
    189        
     189
    190190        fibril_mutex_unlock(&udf_idx_lock);
    191191        return EOK;
     
    202202{
    203203        assert(node->ref_cnt == 0);
    204        
     204
    205205        fibril_mutex_lock(&udf_idx_lock);
    206        
     206
    207207        hash_table_remove_item(&udf_idx, &node->link);
    208        
     208
    209209        assert(node->instance->open_nodes_count > 0);
    210210        node->instance->open_nodes_count--;
    211        
     211
    212212        free(node->fs_node);
    213213        free(node);
    214        
     214
    215215        fibril_mutex_unlock(&udf_idx_lock);
    216216        return EOK;
  • uspace/srv/fs/udf/udf_ops.c

    r3061bc1 r8565a42  
    7575        if (rc != EOK)
    7676                return rc;
    77        
     77
    7878        udf_node_t *node;
    7979        rc = udf_idx_get(&node, instance, index);
     
    8282                if (rc != EOK)
    8383                        return rc;
    84                
     84
    8585                rc = udf_node_get_core(node);
    8686                if (rc != EOK) {
     
    8989                }
    9090        }
    91        
     91
    9292        *rfn = FS_NODE(node);
    9393        return EOK;
     
    100100        if (rc != EOK)
    101101                return rc;
    102        
     102
    103103        return udf_node_get(rfn, service_id,
    104104            instance->volumes[DEFAULT_VOL].root_dir);
     
    110110        if (udfn)
    111111                return udfn->instance->service_id;
    112        
     112
    113113        return 0;
    114114}
     
    119119        if (name == NULL)
    120120                return ENOMEM;
    121        
     121
    122122        block_t *block = NULL;
    123123        udf_file_identifier_descriptor_t *fid = NULL;
    124124        size_t pos = 0;
    125        
     125
    126126        while (udf_get_fid(&fid, &block, UDF_NODE(pfn), pos) == EOK) {
    127127                udf_long_ad_t long_ad = fid->icb;
    128                
     128
    129129                udf_to_unix_name(name, MAX_FILE_NAME_LEN,
    130130                    (char *) fid->implementation_use + FLE16(fid->lenght_iu),
    131131                    fid->lenght_file_id, &UDF_NODE(pfn)->instance->charset);
    132                
     132
    133133                if (str_casecmp(name, component) == 0) {
    134134                        errno_t rc = udf_node_get(rfn, udf_service_get(pfn),
    135135                            udf_long_ad_to_pos(UDF_NODE(pfn)->instance, &long_ad));
    136                        
     136
    137137                        if (block != NULL)
    138138                                block_put(block);
    139                        
     139
    140140                        free(name);
    141141                        return rc;
    142142                }
    143                
     143
    144144                if (block != NULL) {
    145145                        errno_t rc = block_put(block);
     
    147147                                return rc;
    148148                }
    149                
     149
    150150                pos++;
    151151        }
    152        
     152
    153153        free(name);
    154154        return ENOENT;
     
    165165        if (!node)
    166166                return EINVAL;
    167        
     167
    168168        fibril_mutex_lock(&node->lock);
    169169        node->ref_cnt--;
    170170        fibril_mutex_unlock(&node->lock);
    171        
     171
    172172        /* Delete node from hash table and memory */
    173173        if (!node->ref_cnt)
    174174                udf_idx_del(node);
    175        
     175
    176176        return EOK;
    177177}
     
    208208        if (node)
    209209                return node->index;
    210        
     210
    211211        return 0;
    212212}
     
    217217        if (node)
    218218                return node->data_size;
    219        
     219
    220220        return 0;
    221221}
     
    226226        if (node)
    227227                return node->link_cnt;
    228        
     228
    229229        return 0;
    230230}
     
    235235        if (node)
    236236                return node->type == NODE_DIR;
    237        
     237
    238238        return false;
    239239}
     
    244244        if (node)
    245245                return node->type == NODE_FILE;
    246        
     246
    247247        return false;
    248248}
     
    257257        if (NULL == instance)
    258258                return ENOENT;
    259        
     259
    260260        *size = instance->volumes[DEFAULT_VOL].logical_block_size;
    261        
     261
    262262        return EOK;
    263263}
     
    266266{
    267267        *count = 0;
    268        
     268
    269269        return EOK;
    270270}
     
    273273{
    274274        *count = 0;
    275        
     275
    276276        return EOK;
    277277}
     
    308308{
    309309        enum cache_mode cmode;
    310        
     310
    311311        /* Check for option enabling write through. */
    312312        if (str_cmp(opts, "wtcache") == 0)
     
    314314        else
    315315                cmode = CACHE_MODE_WB;
    316        
     316
    317317        udf_instance_t *instance = malloc(sizeof(udf_instance_t));
    318318        if (!instance)
    319319                return ENOMEM;
    320        
     320
    321321        instance->sector_size = 0;
    322        
     322
    323323        /* Check for block size. Will be enhanced later */
    324324        if (str_cmp(opts, "bs=512") == 0)
     
    328328        else if (str_cmp(opts, "bs=2048") == 0)
    329329                instance->sector_size = 2048;
    330        
     330
    331331        /* initialize block cache */
    332332        errno_t rc = block_init(service_id, MAX_SIZE);
    333333        if (rc != EOK)
    334334                return rc;
    335        
     335
    336336        rc = fs_instance_create(service_id, instance);
    337337        if (rc != EOK) {
     
    340340                return rc;
    341341        }
    342        
     342
    343343        instance->service_id = service_id;
    344344        instance->open_nodes_count = 0;
    345        
     345
    346346        /* Check Volume Recognition Sequence */
    347347        rc = udf_volume_recongnition(service_id);
     
    353353                return rc;
    354354        }
    355        
     355
    356356        /* Search for Anchor Volume Descriptor */
    357357        udf_anchor_volume_descriptor_t avd;
     
    364364                return rc;
    365365        }
    366        
     366
    367367        log_msg(LOG_DEFAULT, LVL_DEBUG,
    368368            "Volume: Anchor volume descriptor found. Sector size=%" PRIu32,
     
    376376            PRIu32 " (sector)]", avd.reserve_extent.length,
    377377            avd.reserve_extent.location);
    378        
     378
    379379        /* Initialize the block cache */
    380380        rc = block_cache_init(service_id, instance->sector_size, 0, cmode);
     
    385385                return rc;
    386386        }
    387        
     387
    388388        /* Read Volume Descriptor Sequence */
    389389        rc = udf_read_volume_descriptor_sequence(service_id, avd.main_extent);
     
    396396                return rc;
    397397        }
    398        
     398
    399399        fs_node_t *rfn;
    400400        rc = udf_node_get(&rfn, service_id, instance->volumes[DEFAULT_VOL].root_dir);
     
    407407                return rc;
    408408        }
    409        
     409
    410410        udf_node_t *node = UDF_NODE(rfn);
    411411        *index = instance->volumes[DEFAULT_VOL].root_dir;
    412412        *size = node->data_size;
    413        
     413
    414414        return EOK;
    415415}
     
    421421        if (rc != EOK)
    422422                return rc;
    423        
     423
    424424        udf_node_t *nodep = UDF_NODE(fn);
    425425        udf_instance_t *instance = nodep->instance;
    426        
     426
    427427        /*
    428428         * We expect exactly two references on the root node.
     
    434434                return EBUSY;
    435435        }
    436        
     436
    437437        /*
    438438         * Put the root node twice.
     
    440440        udf_node_put(fn);
    441441        udf_node_put(fn);
    442        
     442
    443443        fs_instance_destroy(service_id);
    444444        free(instance);
    445445        block_cache_fini(service_id);
    446446        block_fini(service_id);
    447        
     447
    448448        return EOK;
    449449}
     
    456456        if (rc != EOK)
    457457                return rc;
    458        
     458
    459459        fs_node_t *rfn;
    460460        rc = udf_node_get(&rfn, service_id, index);
    461461        if (rc != EOK)
    462462                return rc;
    463        
     463
    464464        udf_node_t *node = UDF_NODE(rfn);
    465        
     465
    466466        ipc_callid_t callid;
    467467        size_t len = 0;
     
    471471                return EINVAL;
    472472        }
    473        
     473
    474474        if (node->type == NODE_FILE) {
    475475                if (pos >= node->data_size) {
     
    479479                        return EOK;
    480480                }
    481                
     481
    482482                size_t read_len = 0;
    483483                if (node->data == NULL)
     
    489489                        rc = EOK;
    490490                }
    491                
     491
    492492                *rbytes = read_len;
    493493                (void) udf_node_put(rfn);
     
    498498                if (udf_get_fid(&fid, &block, node, pos) == EOK) {
    499499                        char *name = malloc(MAX_FILE_NAME_LEN + 1);
    500                        
     500
    501501                        // FIXME: Check for NULL return value
    502                        
     502
    503503                        udf_to_unix_name(name, MAX_FILE_NAME_LEN,
    504504                            (char *) fid->implementation_use + FLE16(fid->lenght_iu),
    505505                            fid->lenght_file_id, &node->instance->charset);
    506                        
     506
    507507                        async_data_read_finalize(callid, name, str_size(name) + 1);
    508508                        *rbytes = 1;
    509509                        free(name);
    510510                        udf_node_put(rfn);
    511                        
     511
    512512                        if (block != NULL)
    513513                                return block_put(block);
    514                        
     514
    515515                        return EOK;
    516516                } else {
  • uspace/srv/fs/udf/udf_osta.c

    r3061bc1 r8565a42  
    5959        if ((ch == 0x0000) || (ch == 0x002F))
    6060                return false;
    61        
     61
    6262        return true;
    6363}
     
    8585        /* Use udf_compressed to store current byte being read. */
    8686        uint8_t comp_id = udf_compressed[0];
    87        
     87
    8888        /* First check for valid compID. */
    8989        if ((comp_id != 8) && (comp_id != 16))
    9090                return 0;
    91        
     91
    9292        size_t unicode_idx = 0;
    9393        size_t byte_idx = 1;
    94        
     94
    9595        /* Loop through all the bytes. */
    9696        while ((byte_idx < number_of_bytes) && (unicode_idx < unicode_max_len)) {
     
    103103                } else
    104104                        unicode[unicode_idx] = 0;
    105                
     105
    106106                if (byte_idx < number_of_bytes) {
    107107                        /* Then the next byte to the low bits. */
    108108                        unicode[unicode_idx] |= udf_compressed[byte_idx++];
    109109                }
    110                
     110
    111111                unicode_idx++;
    112112        }
    113        
     113
    114114        return unicode_idx;
    115115}
     
    136136        size_t new_idx = 0;
    137137        size_t new_ext_idx = 0;
    138        
     138
    139139        for (size_t idx = 0; idx < udf_len; idx++) {
    140140                uint16_t current = udf_name[idx];
    141                
     141
    142142                if ((!legal_check(current)) || (!ascii_check(current))) {
    143143                        needs_crc = true;
    144                        
     144
    145145                        /*
    146146                         * Replace Illegal and non-displayable chars with
     
    148148                         */
    149149                        current = ILLEGAL_CHAR_MARK;
    150                        
     150
    151151                        /*
    152152                         * Skip any other illegal or non-displayable
     
    158158                                idx++;
    159159                }
    160                
     160
    161161                /* Record position of extension, if one is found. */
    162162                if ((current == PERIOD) && ((udf_len - idx - 1) <= EXT_SIZE)) {
     
    170170                        }
    171171                }
    172                
     172
    173173                if (new_idx < MAXLEN)
    174174                        new_name[new_idx++] = current;
     
    176176                        needs_crc = true;
    177177        }
    178        
     178
    179179        if (needs_crc) {
    180180                uint16_t ext[EXT_SIZE];
    181181                size_t local_ext_idx = 0;
    182                
     182
    183183                if (has_ext) {
    184184                        size_t max_filename_len;
    185                        
     185
    186186                        /* Translate extension, and store it in ext. */
    187187                        for (size_t idx = 0; (idx < EXT_SIZE) &&
    188188                            (ext_idx + idx + 1 < udf_len); idx++) {
    189189                                uint16_t current = udf_name[ext_idx + idx + 1];
    190                                
     190
    191191                                if ((!legal_check(current)) || (!ascii_check(current))) {
    192192                                        needs_crc = true;
    193                                        
     193
    194194                                        /*
    195195                                         * Replace Illegal and non-displayable
     
    197197                                         */
    198198                                        current = ILLEGAL_CHAR_MARK;
    199                                        
     199
    200200                                        /*
    201201                                         * Skip any other illegal or
     
    207207                                                idx++;
    208208                                }
    209                                
     209
    210210                                ext[local_ext_idx++] = current;
    211211                        }
    212                        
     212
    213213                        /*
    214214                         * Truncate filename to leave room for extension and
     
    224224                        new_idx = MAXLEN - 5;
    225225                }
    226                
     226
    227227                /* Add mark for CRC. */
    228228                new_name[new_idx++] = CRC_MARK;
    229                
     229
    230230                /* Calculate CRC from original filename. */
    231231                uint16_t value_crc = udf_unicode_cksum(udf_name, udf_len);
    232                
     232
    233233                /* Convert 16-bits of CRC to hex characters. */
    234234                const char hex_char[] = "0123456789ABCDEF";
    235                
     235
    236236                new_name[new_idx++] = hex_char[(value_crc & 0xf000) >> 12];
    237237                new_name[new_idx++] = hex_char[(value_crc & 0x0f00) >> 8];
    238238                new_name[new_idx++] = hex_char[(value_crc & 0x00f0) >> 4];
    239239                new_name[new_idx++] = hex_char[(value_crc & 0x000f)];
    240                
     240
    241241                /* Place a translated extension at end, if found. */
    242242                if (has_ext) {
    243243                        new_name[new_idx++] = PERIOD;
    244                        
     244
    245245                        for (size_t idx = 0; idx < local_ext_idx; idx++)
    246246                                new_name[new_idx++] = ext[idx];
    247247                }
    248248        }
    249        
     249
    250250        return new_idx;
    251251}
     
    265265        const char *osta_id = "OSTA Compressed Unicode";
    266266        size_t ucode_chars, nice_uchars;
    267        
     267
    268268        uint16_t *raw_name = malloc(MAX_BUF * sizeof(uint16_t));
    269269        uint16_t *unix_name = malloc(MAX_BUF * sizeof(uint16_t));
    270        
     270
    271271        // FIXME: Check for malloc returning NULL
    272        
     272
    273273        bool is_osta_typ0 = (chsp->type == 0) &&
    274274            (str_cmp((char *) chsp->info, osta_id) == 0);
    275        
     275
    276276        if (is_osta_typ0) {
    277277                *raw_name = 0;
    278278                *unix_name = 0;
    279                
     279
    280280                ucode_chars =
    281281                    udf_uncompress_unicode(len, (uint8_t *) id, raw_name, MAX_BUF);
     
    283283                nice_uchars =
    284284                    udf_translate_name(unix_name, raw_name, ucode_chars);
    285                
     285
    286286                /* Output UTF-8 */
    287287                unix_name[nice_uchars] = 0;
     
    292292                    str_size((char *) (id + 1)));
    293293        }
    294        
     294
    295295        free(raw_name);
    296296        free(unix_name);
  • uspace/srv/fs/udf/udf_volume.c

    r3061bc1 r8565a42  
    6767            FLE16(long_ad->location.partition_num),
    6868            FLE32(long_ad->location.lblock_num));
    69        
     69
    7070        return instance->partitions[
    7171            FLE16(long_ad->location.partition_num)].start +
     
    108108        if (!vd)
    109109                return ENOMEM;
    110        
     110
    111111        errno_t rc = udf_volume_recongnition_structure_test(service_id, addr, vd);
    112112        if (rc != EOK) {
     
    114114                return rc;
    115115        }
    116        
     116
    117117        for (size_t i = 0; i < VRS_DEPTH; i++) {
    118118                addr += sizeof(udf_vrs_descriptor_t);
    119                
     119
    120120                rc = udf_volume_recongnition_structure_test(service_id, addr, vd);
    121121                if (rc != EOK) {
     
    123123                        return rc;
    124124                }
    125                
     125
    126126                /*
    127127                 * UDF standard identifier. According to ECMA 167 2/9.1.2
     
    133133                        continue;
    134134                }
    135                
     135
    136136                if (str_lcmp(VRS_END, (char *) vd->identifier, VRS_ID_LEN) == 0) {
    137137                        log_msg(LOG_DEFAULT, LVL_DEBUG, "VRS: end found");
     
    139139                }
    140140        }
    141        
     141
    142142        free(vd);
    143        
     143
    144144        if (nsr_found)
    145145                return EOK;
     
    178178        if (rc != EOK)
    179179                return rc;
    180        
     180
    181181        if (avd->tag.checksum != udf_tag_checksum((uint8_t *) &avd->tag))
    182182                return EINVAL;
    183        
     183
    184184        // TODO: Should be tested in big-endian mode
    185185        udf_prepare_tag(&avd->tag);
    186        
     186
    187187        if (avd->tag.id != UDF_TAG_AVDP)
    188188                return EINVAL;
    189        
     189
    190190        GET_LE32(avd->main_extent.length);
    191191        GET_LE32(avd->main_extent.location);
    192192        GET_LE32(avd->reserve_extent.length);
    193193        GET_LE32(avd->reserve_extent.location);
    194        
     194
    195195        return EOK;
    196196}
     
    211211{
    212212        uint32_t default_sector_size[] = {512, 1024, 2048, 4096, 8192, 0};
    213        
     213
    214214        udf_instance_t *instance;
    215215        errno_t rc = fs_instance_get(service_id, (void **) &instance);
    216216        if (rc != EOK)
    217217                return rc;
    218        
     218
    219219        if (instance->sector_size) {
    220220                return udf_get_anchor_volume_descriptor_by_ssize(service_id, avd,
     
    229229                                return EOK;
    230230                        }
    231                        
     231
    232232                        i++;
    233233                }
    234234        }
    235        
     235
    236236        return EINVAL;
    237237}
     
    273273                }
    274274        }
    275        
     275
    276276        return false;
    277277}
     
    310310                }
    311311        }
    312        
     312
    313313        return false;
    314314}
     
    343343                }
    344344        }
    345        
     345
    346346        return false;
    347347}
     
    368368        if (rc != EOK)
    369369                return rc;
    370        
     370
    371371        udf_descriptor_tag_t *desc = (udf_descriptor_tag_t *) (block->data);
    372372        if (desc->checksum != udf_tag_checksum((uint8_t *) desc)) {
     
    374374                return EINVAL;
    375375        }
    376        
     376
    377377        /*
    378378         * We think that we have only one allocator. It is means that virtual
     
    383383        case UDF_FILE_ENTRY:
    384384                log_msg(LOG_DEFAULT, LVL_DEBUG, "ICB: File entry descriptor found");
    385                
     385
    386386                udf_file_entry_descriptor_t *fed =
    387387                    (udf_file_entry_descriptor_t *) block->data;
     
    392392                instance->partitions[id].lenght = FLE32(short_d->length);
    393393                break;
    394                
     394
    395395        case UDF_EFILE_ENTRY:
    396396                log_msg(LOG_DEFAULT, LVL_DEBUG, "ICB: Extended file entry descriptor found");
    397                
     397
    398398                udf_extended_file_entry_descriptor_t *efed =
    399399                    (udf_extended_file_entry_descriptor_t *) block->data;
     
    404404                break;
    405405        }
    406        
     406
    407407        return block_put(block);
    408408}
     
    426426                        return i;
    427427        }
    428        
     428
    429429        return (size_t) -1;
    430430}
     
    448448        if (instance->volumes == NULL)
    449449                return ENOMEM;
    450        
     450
    451451        instance->partitions = calloc(pd_cnt, sizeof(udf_partition_t));
    452452        if (instance->partitions == NULL) {
     
    454454                return ENOMEM;
    455455        }
    456        
     456
    457457        instance->partition_cnt = pd_cnt;
    458        
     458
    459459        /*
    460460         * Fill information about logical volumes. We will save
    461461         * information about all partitions placed inside each volumes.
    462462         */
    463        
     463
    464464        size_t vir_pd_cnt = 0;
    465465        for (size_t i = 0; i < lvd_cnt; i++) {
     
    471471                        return ENOMEM;
    472472                }
    473                
     473
    474474                instance->volumes[i].partition_cnt = 0;
    475475                instance->volumes[i].logical_block_size =
    476476                    FLE32(lvd[i].logical_block_size);
    477                
     477
    478478                /*
    479479                 * In theory we could have more than 1 logical volume. But now
     
    481481                 * partitions from array pd belong to only first lvd
    482482                 */
    483                
     483
    484484                uint8_t *idx = lvd[i].partition_map;
    485485                for (size_t j = 0; j < FLE32(lvd[i].number_of_partitions_maps);
     
    487487                        udf_type1_partition_map_t *pm1 =
    488488                            (udf_type1_partition_map_t *) idx;
    489                        
     489
    490490                        if (pm1->partition_map_type == 1) {
    491491                                size_t pd_num = udf_find_partition(pd, pd_cnt,
     
    495495                                        return ENOENT;
    496496                                }
    497                                
     497
    498498                                /*
    499499                                 * Fill information about physical partitions. We will save all
     
    509509                                instance->partitions[j].start =
    510510                                    FLE32(pd[pd_num].starting_location);
    511                                
     511
    512512                                instance->volumes[i].partitions[
    513513                                    instance->volumes[i].partition_cnt] =
    514514                                    &instance->partitions[j];
    515                                
     515
    516516                                log_msg(LOG_DEFAULT, LVL_DEBUG, "Volume[%" PRIun "]: partition [type %u] "
    517517                                    "found and filled", i, pm1->partition_map_type);
    518                                
     518
    519519                                instance->volumes[i].partition_cnt++;
    520520                                idx += pm1->partition_map_lenght;
    521521                                continue;
    522522                        }
    523                        
     523
    524524                        udf_type2_partition_map_t *pm2 =
    525525                            (udf_type2_partition_map_t *) idx;
    526                        
     526
    527527                        if (pm2->partition_map_type == 2) {
    528528                                // TODO: check partition_ident for metadata_partition_map
    529                                
     529
    530530                                udf_metadata_partition_map_t *metadata =
    531531                                    (udf_metadata_partition_map_t *) idx;
    532                                
     532
    533533                                log_msg(LOG_DEFAULT, LVL_DEBUG, "Metadata file location=%u",
    534534                                    FLE32(metadata->metadata_fileloc));
    535                                
     535
    536536                                vir_pd_cnt++;
    537537                                instance->partitions = realloc(instance->partitions,
     
    541541                                        return ENOMEM;
    542542                                }
    543                                
     543
    544544                                instance->partition_cnt++;
    545                                
     545
    546546                                size_t pd_num = udf_find_partition(pd, pd_cnt,
    547547                                    FLE16(metadata->partition_number));
     
    550550                                        return ENOENT;
    551551                                }
    552                                
     552
    553553                                instance->partitions[j].number =
    554554                                    FLE16(metadata->partition_number);
     
    560560                                        return rc;
    561561                                }
    562                                
     562
    563563                                /* Virtual partition placed inside physical */
    564564                                instance->partitions[j].start +=
    565565                                    FLE32(pd[pd_num].starting_location);
    566                                
     566
    567567                                instance->volumes[i].partitions[
    568568                                    instance->volumes[i].partition_cnt] =
    569569                                    &instance->partitions[j];
    570                                
     570
    571571                                log_msg(LOG_DEFAULT, LVL_DEBUG, "Virtual partition: num=%d, start=%d",
    572572                                    instance->partitions[j].number,
     
    574574                                log_msg(LOG_DEFAULT, LVL_DEBUG, "Volume[%" PRIun "]: partition [type %u] "
    575575                                    "found and filled", i, pm2->partition_map_type);
    576                                
     576
    577577                                instance->volumes[i].partition_cnt++;
    578578                                idx += metadata->partition_map_length;
    579579                                continue;
    580580                        }
    581                        
     581
    582582                        /* Not type 1 nor type 2 */
    583583                        udf_general_type_t *pm = (udf_general_type_t *) idx;
    584                        
     584
    585585                        log_msg(LOG_DEFAULT, LVL_DEBUG, "Volume[%" PRIun "]: partition [type %u] "
    586586                            "found and skipped", i, pm->partition_map_type);
    587                        
     587
    588588                        idx += pm->partition_map_lenght;
    589589                }
    590590        }
    591        
     591
    592592        return EOK;
    593593}
     
    608608        if (rc != EOK)
    609609                return rc;
    610        
     610
    611611        aoff64_t pos = addr.location;
    612612        aoff64_t end = pos + (addr.length / instance->sector_size) - 1;
    613        
     613
    614614        if (pos == end)
    615615                return EINVAL;
    616        
     616
    617617        size_t max_descriptors = ALL_UP(addr.length, instance->sector_size);
    618        
     618
    619619        udf_primary_volume_descriptor_t *pvd = calloc(max_descriptors,
    620620            sizeof(udf_primary_volume_descriptor_t));
    621621        if (pvd == NULL)
    622622                return ENOMEM;
    623        
     623
    624624        udf_logical_volume_descriptor_t *lvd = calloc(max_descriptors,
    625625            instance->sector_size);
     
    628628                return ENOMEM;
    629629        }
    630        
     630
    631631        udf_partition_descriptor_t *pd = calloc(max_descriptors,
    632632            sizeof(udf_partition_descriptor_t));
     
    636636                return ENOMEM;
    637637        }
    638        
     638
    639639        size_t pvd_cnt = 0;
    640640        size_t lvd_cnt = 0;
    641641        size_t pd_cnt = 0;
    642        
     642
    643643        while (pos <= end) {
    644644                block_t *block = NULL;
     
    650650                        return rc;
    651651                }
    652                
     652
    653653                udf_volume_descriptor_t *vol =
    654654                    (udf_volume_descriptor_t *) block->data;
    655                
     655
    656656                switch (FLE16(vol->common.tag.id)) {
    657657                /* One sector size descriptors */
    658658                case UDF_TAG_PVD:
    659659                        log_msg(LOG_DEFAULT, LVL_DEBUG, "Volume: Primary volume descriptor found");
    660                        
     660
    661661                        if (!udf_check_prevailing_pvd(pvd, pvd_cnt, &vol->volume)) {
    662662                                memcpy(&pvd[pvd_cnt], &vol->volume,
     
    664664                                pvd_cnt++;
    665665                        }
    666                        
     666
    667667                        pos++;
    668668                        break;
    669                        
     669
    670670                case UDF_TAG_VDP:
    671671                        log_msg(LOG_DEFAULT, LVL_DEBUG, "Volume: Volume descriptor pointer found");
    672672                        pos++;
    673673                        break;
    674                        
     674
    675675                case UDF_TAG_IUVD:
    676676                        log_msg(LOG_DEFAULT, LVL_DEBUG,
     
    678678                        pos++;
    679679                        break;
    680                        
     680
    681681                case UDF_TAG_PD:
    682682                        log_msg(LOG_DEFAULT, LVL_DEBUG, "Volume: Partition descriptor found");
     
    688688                            FLE32(vol->partition.starting_location),
    689689                            FLE32(vol->partition.length));
    690                        
     690
    691691                        if (!udf_check_prevailing_pd(pd, pd_cnt, &vol->partition)) {
    692692                                memcpy(&pd[pd_cnt], &vol->partition,
     
    694694                                pd_cnt++;
    695695                        }
    696                        
     696
    697697                        udf_partition_header_descriptor_t *phd =
    698698                            (udf_partition_header_descriptor_t *) vol->partition.contents_use;
     
    702702                                    FLE32(phd->unallocated_space_table.length),
    703703                                    FLE32(phd->unallocated_space_table.position));
    704                                
     704
    705705                                instance->space_type = SPACE_TABLE;
    706706                                instance->uaspace_start =
     
    710710                                    FLE32(phd->unallocated_space_table.length);
    711711                        }
    712                        
     712
    713713                        if (FLE32(phd->unallocated_space_bitmap.length)) {
    714714                                log_msg(LOG_DEFAULT, LVL_DEBUG,
     
    716716                                    FLE32(phd->unallocated_space_bitmap.length),
    717717                                    FLE32(phd->unallocated_space_bitmap.position));
    718                                
     718
    719719                                instance->space_type = SPACE_BITMAP;
    720720                                instance->uaspace_start =
     
    724724                                    FLE32(phd->unallocated_space_bitmap.length);
    725725                        }
    726                        
     726
    727727                        pos++;
    728728                        break;
    729                        
     729
    730730                /* Relative size descriptors */
    731731                case UDF_TAG_LVD:
    732732                        log_msg(LOG_DEFAULT, LVL_DEBUG, "Volume: Logical volume descriptor found");
    733                        
     733
    734734                        aoff64_t sct =
    735735                            ALL_UP((sizeof(udf_logical_volume_descriptor_t) +
     
    738738                        pos += sct;
    739739                        char tmp[130];
    740                        
     740
    741741                        udf_to_unix_name(tmp, 129,
    742742                            (char *) vol->logical.logical_volume_id, 128,
    743743                            &vol->logical.charset);
    744                        
     744
    745745                        log_msg(LOG_DEFAULT, LVL_DEBUG, "Logical Volume ID: '%s', "
    746746                            "logical block size: %" PRIu32 " (bytes)", tmp,
     
    750750                            FLE32(vol->logical.map_table_length),
    751751                            FLE32(vol->logical.number_of_partitions_maps));
    752                        
     752
    753753                        if (!udf_check_prevailing_lvd(lvd, lvd_cnt, &vol->logical)) {
    754754                                memcpy(&lvd[lvd_cnt], &vol->logical,
     
    757757                                lvd_cnt++;
    758758                        }
    759                        
     759
    760760                        break;
    761                        
     761
    762762                case UDF_TAG_USD:
    763763                        log_msg(LOG_DEFAULT, LVL_DEBUG, "Volume: Unallocated space descriptor found");
    764                        
     764
    765765                        sct = ALL_UP((sizeof(udf_unallocated_space_descriptor_t) +
    766766                            FLE32(vol->unallocated.allocation_descriptors_num)*
     
    774774                                return ENOMEM;
    775775                        }
    776                        
     776
    777777                        memcpy(instance->uasd, block->data, instance->sector_size);
    778778                        pos += sct;
    779779                        break;
    780                        
     780
    781781                case UDF_TAG_LVID:
    782782                        log_msg(LOG_DEFAULT, LVL_DEBUG,
    783783                            "Volume: Logical volume integrity descriptor found");
    784                        
     784
    785785                        pos++;
    786786                        break;
    787                        
     787
    788788                case UDF_TAG_TD:
    789789                        log_msg(LOG_DEFAULT, LVL_DEBUG, "Volume: Terminating descriptor found");
    790                        
     790
    791791                        /* Found terminating descriptor. Exiting */
    792792                        pos = end + 1;
    793793                        break;
    794                        
     794
    795795                default:
    796796                        pos++;
    797797                }
    798                
     798
    799799                rc = block_put(block);
    800800                if (rc != EOK) {
     
    805805                }
    806806        }
    807        
     807
    808808        /* Fill the instance */
    809809        udf_fill_volume_info(lvd, lvd_cnt, pd, pd_cnt, instance);
    810        
     810
    811811        for (size_t i = 0; i < lvd_cnt; i++) {
    812812                pos = udf_long_ad_to_pos(instance,
    813813                    (udf_long_ad_t *) &lvd[i].logical_volume_conents_use);
    814                
     814
    815815                block_t *block = NULL;
    816816                rc = block_get(&block, instance->service_id, pos,
     
    820820                        return rc;
    821821                }
    822                
     822
    823823                udf_descriptor_tag_t *desc = block->data;
    824                
     824
    825825                log_msg(LOG_DEFAULT, LVL_DEBUG, "First tag ID=%" PRIu16, desc->id);
    826                
     826
    827827                if (desc->checksum != udf_tag_checksum((uint8_t *) desc)) {
    828828                        // FIXME: Memory leak, cleanup missing
    829829                        return EINVAL;
    830830                }
    831                
     831
    832832                udf_prepare_tag(desc);
    833                
     833
    834834                udf_fileset_descriptor_t *fd = block->data;
    835835                memcpy((uint8_t *) &instance->charset,
    836836                    (uint8_t *) &fd->fileset_charset, sizeof(fd->fileset_charset));
    837                
     837
    838838                instance->volumes[i].root_dir = udf_long_ad_to_pos(instance,
    839839                    &fd->root_dir_icb);
    840840        }
    841        
     841
    842842        free(pvd);
    843843        free(lvd);
Note: See TracChangeset for help on using the changeset viewer.