Changeset a35b458 in mainline for uspace/srv/fs


Ignore:
Timestamp:
2018-03-02T20:10:49Z (8 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f1380b7
Parents:
3061bc1
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
Message:

style: Remove trailing whitespace on _all_ lines, including empty ones, for particular file types.

Command used: tools/srepl '\s\+$' '' -- *.c *.h *.py *.sh *.s *.S *.ag

Currently, whitespace on empty lines is very inconsistent.
There are two basic choices: Either remove the whitespace, or keep empty lines
indented to the level of surrounding code. The former is AFAICT more common,
and also much easier to do automatically.

Alternatively, we could write script for automatic indentation, and use that
instead. However, if such a script exists, it's possible to use the indented
style locally, by having the editor apply relevant conversions on load/save,
without affecting remote repository. IMO, it makes more sense to adopt
the simpler rule.

Location:
uspace/srv/fs
Files:
33 edited

Legend:

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

    r3061bc1 ra35b458  
    6060{
    6161        printf("%s: HelenOS cdfs file system server\n", NAME);
    62        
     62
    6363        if (argc == 3) {
    6464                if (!str_cmp(argv[1], "--instance"))
     
    7474                return -1;
    7575        }
    76        
     76
    7777        async_sess_t *vfs_sess = service_connect_blocking(SERVICE_VFS,
    7878            INTERFACE_VFS_DRIVER, 0);
     
    8181                return -1;
    8282        }
    83        
     83
    8484        errno_t rc = fs_register(vfs_sess, &cdfs_vfs_info, &cdfs_ops,
    8585            &cdfs_libfs_ops);
     
    8888                return rc;
    8989        }
    90        
     90
    9191        printf("%s: Accepting connections\n", NAME);
    9292        task_retval(0);
    9393        async_manager();
    94        
     94
    9595        /* Not reached */
    9696        return 0;
  • uspace/srv/fs/cdfs/cdfs_ops.c

    r3061bc1 ra35b458  
    9292        uint8_t mon[2];
    9393        uint8_t day[2];
    94        
     94
    9595        uint8_t hour[2];
    9696        uint8_t min[2];
    9797        uint8_t sec[2];
    9898        uint8_t msec[2];
    99        
     99
    100100        uint8_t offset;
    101101} __attribute__((packed)) cdfs_datetime_t;
     
    105105        uint8_t mon;
    106106        uint8_t day;
    107        
     107
    108108        uint8_t hour;
    109109        uint8_t min;
    110110        uint8_t sec;
    111        
     111
    112112        uint8_t offset;
    113113} __attribute__((packed)) cdfs_timestamp_t;
     
    121121        uint8_t length;
    122122        uint8_t ea_length;
    123        
     123
    124124        uint32_t_lb lba;
    125125        uint32_t_lb size;
    126        
     126
    127127        cdfs_timestamp_t timestamp;
    128128        uint8_t flags;
     
    130130        uint8_t gap_size;
    131131        uint16_t_lb sequence_nr;
    132        
     132
    133133        uint8_t name_length;
    134134        uint8_t name[];
     
    139139        uint8_t length;
    140140        uint8_t ea_length;
    141        
     141
    142142        uint32_t_lb lba;
    143143        uint32_t_lb size;
    144        
     144
    145145        cdfs_timestamp_t timestamp;
    146146        uint8_t flags;
     
    148148        uint8_t gap_size;
    149149        uint16_t_lb sequence_nr;
    150        
     150
    151151        uint8_t name_length;
    152152        uint8_t name[1];
     
    155155typedef struct {
    156156        uint8_t flags; /* reserved in primary */
    157        
     157
    158158        uint8_t system_ident[32];
    159159        uint8_t ident[32];
    160        
     160
    161161        uint64_t res1;
    162162        uint32_t_lb lba_size;
    163        
     163
    164164        uint8_t esc_seq[32]; /* reserved in primary */
    165165        uint16_t_lb set_size;
    166166        uint16_t_lb sequence_nr;
    167        
     167
    168168        uint16_t_lb block_size;
    169169        uint32_t_lb path_table_size;
    170        
     170
    171171        uint32_t path_table_lsb;
    172172        uint32_t opt_path_table_lsb;
    173173        uint32_t path_table_msb;
    174174        uint32_t opt_path_table_msb;
    175        
     175
    176176        cdfs_root_dir_t root_dir;
    177177        uint8_t pad0;
    178        
     178
    179179        uint8_t set_ident[128];
    180180        uint8_t publisher_ident[128];
    181181        uint8_t preparer_ident[128];
    182182        uint8_t app_ident[128];
    183        
     183
    184184        uint8_t copyright_file_ident[37];
    185185        uint8_t abstract_file_ident[37];
    186186        uint8_t biblio_file_ident[37];
    187        
     187
    188188        cdfs_datetime_t creation;
    189189        cdfs_datetime_t modification;
    190190        cdfs_datetime_t expiration;
    191191        cdfs_datetime_t effective;
    192        
     192
    193193        uint8_t fs_version;
    194194} __attribute__((packed)) cdfs_vol_desc_prisec_t;
     
    236236        fs_index_t index;         /**< Node index */
    237237        cdfs_t *fs;               /**< File system */
    238        
     238
    239239        ht_link_t nh_link;        /**< Nodes hash table link */
    240240        cdfs_dentry_type_t type;  /**< Dentry type */
    241        
     241
    242242        unsigned int lnkcnt;      /**< Link count */
    243243        uint32_t size;            /**< File size if type is CDFS_FILE */
    244        
     244
    245245        list_t cs_list;           /**< Child's siblings list */
    246246        cdfs_lba_t lba;           /**< LBA of data on disk */
     
    301301        cdfs_node_t *node = hash_table_get_inst(item, cdfs_node_t, nh_link);
    302302        ht_key_t *key = (ht_key_t*)k;
    303        
     303
    304304        return key->service_id == node->fs->service_id && key->index == node->index;
    305305}
     
    308308{
    309309        cdfs_node_t *node = hash_table_get_inst(item, cdfs_node_t, nh_link);
    310        
     310
    311311        if (node->type == CDFS_DIRECTORY) {
    312312                link_t *link;
     
    317317                }
    318318        }
    319        
     319
    320320        free(node->fs_node);
    321321        free(node);
     
    338338                .service_id = service_id
    339339        };
    340        
     340
    341341        ht_link_t *link = hash_table_find(&nodes, &key);
    342342        if (link) {
    343343                cdfs_node_t *node =
    344344                    hash_table_get_inst(link, cdfs_node_t, nh_link);
    345                
     345
    346346                *rfn = FS_NODE(node);
    347347        } else
    348348                *rfn = NULL;
    349        
     349
    350350        return EOK;
    351351}
     
    367367        node->processed = false;
    368368        node->opened = 0;
    369        
     369
    370370        list_initialize(&node->cs_list);
    371371}
     
    375375{
    376376        assert((lflag & L_FILE) ^ (lflag & L_DIRECTORY));
    377        
     377
    378378        cdfs_node_t *node = malloc(sizeof(cdfs_node_t));
    379379        if (!node)
    380380                return ENOMEM;
    381        
     381
    382382        cdfs_node_initialize(node);
    383        
     383
    384384        node->fs_node = malloc(sizeof(fs_node_t));
    385385        if (!node->fs_node) {
     
    387387                return ENOMEM;
    388388        }
    389        
     389
    390390        fs_node_initialize(node->fs_node);
    391391        node->fs_node->data = node;
    392        
     392
    393393        fs_node_t *rootfn;
    394394        errno_t rc = cdfs_root_get(&rootfn, fs->service_id);
    395        
     395
    396396        assert(rc == EOK);
    397        
     397
    398398        if (!rootfn)
    399399                node->index = CDFS_SOME_ROOT;
    400400        else
    401401                node->index = index;
    402        
     402
    403403        node->fs = fs;
    404        
     404
    405405        if (lflag & L_DIRECTORY)
    406406                node->type = CDFS_DIRECTORY;
    407407        else
    408408                node->type = CDFS_FILE;
    409        
     409
    410410        /* Insert the new node into the nodes hash table. */
    411411        hash_table_insert(&nodes, &node->nh_link);
    412        
     412
    413413        *rfn = FS_NODE(node);
    414414        nodes_cached++;
    415        
     415
    416416        return EOK;
    417417}
     
    421421        cdfs_node_t *parent = CDFS_NODE(pfn);
    422422        cdfs_node_t *node = CDFS_NODE(fn);
    423        
     423
    424424        assert(parent->type == CDFS_DIRECTORY);
    425        
     425
    426426        /* Check for duplicate entries */
    427427        list_foreach(parent->cs_list, link, cdfs_dentry_t, dentry) {
     
    429429                        return EEXIST;
    430430        }
    431        
     431
    432432        /* Allocate and initialize the dentry */
    433433        cdfs_dentry_t *dentry = malloc(sizeof(cdfs_dentry_t));
    434434        if (!dentry)
    435435                return ENOMEM;
    436        
     436
    437437        /* Populate and link the new dentry */
    438438        dentry->name = str_dup(name);
     
    441441                return ENOMEM;
    442442        }
    443        
     443
    444444        link_initialize(&dentry->link);
    445445        dentry->index = node->index;
    446        
     446
    447447        node->lnkcnt++;
    448448        list_append(&dentry->link, &parent->cs_list);
    449        
     449
    450450        return EOK;
    451451}
     
    463463        char *str;
    464464        uint16_t *buf;
    465        
     465
    466466        switch (enc) {
    467467        case enc_ascii:
     
    476476                if (buf == NULL)
    477477                        return NULL;
    478                
     478
    479479                size_t i;
    480480                for (i = 0; i < dsize / sizeof(uint16_t); i++) {
     
    482482                            ((unaligned_uint16_t *)data)[i]);
    483483                }
    484                
     484
    485485                size_t dstr_size = dsize / sizeof(uint16_t) * 4 + 1;
    486486                str = malloc(dstr_size);
    487487                if (str == NULL)
    488488                        return NULL;
    489                
     489
    490490                rc = utf16_to_str(str, dstr_size, buf);
    491491                free(buf);
    492                
     492
    493493                if (rc != EOK)
    494494                        return NULL;
     
    498498                str = NULL;
    499499        }
    500        
     500
    501501        return str;
    502502}
     
    516516        char *dot;
    517517        char *scolon;
    518        
     518
    519519        name = cdfs_decode_str(data, dsize, enc);
    520520        if (name == NULL)
    521521                return NULL;
    522        
     522
    523523        if (dtype == CDFS_DIRECTORY)
    524524                return name;
    525        
     525
    526526        dot = str_chr(name, '.');
    527        
     527
    528528        if (dot != NULL) {
    529529                scolon = str_chr(dot, ';');
     
    532532                        *scolon = '\0';
    533533                }
    534        
     534
    535535                /* If the extension is an empty string, trim the dot separator. */
    536536                if (dot[1] == '\0')
    537537                        *dot = '\0';
    538538        }
    539        
     539
    540540        return name;
    541541}
     
    552552        char *ident;
    553553        size_t i;
    554        
     554
    555555        ident = cdfs_decode_str(data, dsize, enc);
    556556        if (ident == NULL)
    557557                return NULL;
    558        
     558
    559559        /* Trim trailing spaces */
    560560        i = str_size(ident);
     
    562562                --i;
    563563        ident[i] = '\0';
    564        
     564
    565565        return ident;
    566566}
     
    570570        cdfs_node_t *node = CDFS_NODE(fs_node);
    571571        assert(node);
    572        
     572
    573573        if (node->processed)
    574574                return EOK;
    575        
     575
    576576        uint32_t blocks = node->size / BLOCK_SIZE;
    577577        if ((node->size % BLOCK_SIZE) != 0)
    578578                blocks++;
    579        
     579
    580580        for (uint32_t i = 0; i < blocks; i++) {
    581581                block_t *block;
     
    583583                if (rc != EOK)
    584584                        return rc;
    585                
     585
    586586                cdfs_dir_t *dir;
    587                
     587
    588588                for (size_t offset = 0; offset < BLOCK_SIZE;
    589589                    offset += dir->length) {
     
    595595                                break;
    596596                        }
    597                        
     597
    598598                        cdfs_dentry_type_t dentry_type;
    599599                        if (dir->flags & DIR_FLAG_DIRECTORY)
     
    601601                        else
    602602                                dentry_type = CDFS_FILE;
    603                        
     603
    604604                        /* Skip special entries */
    605                        
     605
    606606                        if (dir->name_length == 1 &&
    607607                            dir->name[0] == CDFS_NAME_CURDIR)
     
    610610                            dir->name[0] == CDFS_NAME_PARENTDIR)
    611611                                continue;
    612                        
     612
    613613                        // FIXME: hack - indexing by dentry byte offset on disc
    614                        
     614
    615615                        fs_node_t *fn;
    616616                        errno_t rc = create_node(&fn, fs, dentry_type,
     
    620620
    621621                        assert(fn != NULL);
    622                        
     622
    623623                        cdfs_node_t *cur = CDFS_NODE(fn);
    624624                        cur->lba = uint32_lb(dir->lba);
    625625                        cur->size = uint32_lb(dir->size);
    626                        
     626
    627627                        char *name = cdfs_decode_name(dir->name,
    628628                            dir->name_length, node->fs->enc, dentry_type);
    629629                        if (name == NULL)
    630630                                return EIO;
    631                        
     631
    632632                        // FIXME: check return value
    633                        
     633
    634634                        link_node(fs_node, fn, name);
    635635                        free(name);
    636                        
     636
    637637                        if (dentry_type == CDFS_FILE)
    638638                                cur->processed = true;
    639639                }
    640                
     640
    641641                block_put(block);
    642642        }
    643        
     643
    644644        node->processed = true;
    645645        return EOK;
     
    650650        cdfs_lba_t lba = index / BLOCK_SIZE;
    651651        size_t offset = index % BLOCK_SIZE;
    652        
     652
    653653        block_t *block;
    654654        errno_t rc = block_get(&block, fs->service_id, lba, BLOCK_FLAGS_NONE);
    655655        if (rc != EOK)
    656656                return NULL;
    657        
     657
    658658        cdfs_dir_t *dir = (cdfs_dir_t *) (block->data + offset);
    659        
     659
    660660        cdfs_dentry_type_t dentry_type;
    661661        if (dir->flags & DIR_FLAG_DIRECTORY)
     
    663663        else
    664664                dentry_type = CDFS_FILE;
    665        
     665
    666666        fs_node_t *fn;
    667667        rc = create_node(&fn, fs, dentry_type, index);
    668668        if ((rc != EOK) || (fn == NULL))
    669669                return NULL;
    670        
     670
    671671        cdfs_node_t *node = CDFS_NODE(fn);
    672672        node->lba = uint32_lb(dir->lba);
    673673        node->size = uint32_lb(dir->size);
    674674        node->lnkcnt = 1;
    675        
     675
    676676        if (dentry_type == CDFS_FILE)
    677677                node->processed = true;
    678        
     678
    679679        block_put(block);
    680680        return fn;
     
    687687                .service_id = fs->service_id
    688688        };
    689        
     689
    690690        ht_link_t *link = hash_table_find(&nodes, &key);
    691691        if (link) {
     
    694694                return FS_NODE(node);
    695695        }
    696        
     696
    697697        return get_uncached_node(fs, index);
    698698}
     
    701701{
    702702        cdfs_node_t *parent = CDFS_NODE(pfn);
    703        
     703
    704704        if (!parent->processed) {
    705705                errno_t rc = cdfs_readdir(parent->fs, pfn);
     
    707707                        return rc;
    708708        }
    709        
     709
    710710        list_foreach(parent->cs_list, link, cdfs_dentry_t, dentry) {
    711711                if (str_cmp(dentry->name, component) == 0) {
     
    714714                }
    715715        }
    716        
     716
    717717        *fn = NULL;
    718718        return EOK;
     
    722722{
    723723        cdfs_node_t *node = CDFS_NODE(fn);
    724        
     724
    725725        if (!node->processed)
    726726                cdfs_readdir(node->fs, fn);
    727        
     727
    728728        node->opened++;
    729729        return EOK;
     
    763763{
    764764        cdfs_node_t *node = CDFS_NODE(fn);
    765        
     765
    766766        if ((node->type == CDFS_DIRECTORY) && (!node->processed))
    767767                cdfs_readdir(node->fs, fn);
    768        
     768
    769769        *has_children = !list_empty(&node->cs_list);
    770770        return EOK;
     
    809809{
    810810        *size = BLOCK_SIZE;
    811        
     811
    812812        return EOK;
    813813}
     
    816816{
    817817        *count = 0;
    818        
     818
    819819        return EOK;
    820820}
     
    823823{
    824824        *count = 0;
    825        
     825
    826826        return EOK;
    827827}
     
    855855        size_t i, j, k;
    856856        bool match;
    857        
     857
    858858        i = 0;
    859859        while (i + ucs2_esc_seq_len <= 32) {
    860860                if (seq[i] == 0)
    861861                        break;
    862                
     862
    863863                for (j = 0; j < ucs2_esc_seq_no; j++) {
    864864                        match = true;
     
    870870                        }
    871871                }
    872                
     872
    873873                if (!match)
    874874                        return EINVAL;
    875                
     875
    876876                i += ucs2_esc_seq_len;
    877877        }
    878        
     878
    879879        while (i < 32) {
    880880                if (seq[i] != 0)
     
    882882                ++i;
    883883        }
    884        
     884
    885885        return EOK;
    886886}
     
    905905                if (rc != EOK)
    906906                        break;
    907                
     907
    908908                cdfs_vol_desc_t *vol_desc = (cdfs_vol_desc_t *) block->data;
    909                
     909
    910910                if (vol_desc->type == VOL_DESC_SET_TERMINATOR) {
    911911                        block_put(block);
    912912                        break;
    913913                }
    914                
     914
    915915                if ((vol_desc->type != VOL_DESC_SUPPLEMENTARY) ||
    916916                    (memcmp(vol_desc->standard_ident, CDFS_STANDARD_IDENT, 5) != 0) ||
     
    919919                        continue;
    920920                }
    921                
     921
    922922                uint16_t set_size = uint16_lb(vol_desc->data.prisec.set_size);
    923923                if (set_size > 1) {
     
    929929                         */
    930930                }
    931                
     931
    932932                uint16_t sequence_nr = uint16_lb(vol_desc->data.prisec.sequence_nr);
    933933                if (sequence_nr != 1) {
     
    939939                        continue;
    940940                }
    941                
     941
    942942                uint16_t block_size = uint16_lb(vol_desc->data.prisec.block_size);
    943943                if (block_size != BLOCK_SIZE) {
     
    945945                        continue;
    946946                }
    947                
     947
    948948                rc = cdfs_verify_joliet_esc_seq(vol_desc->data.prisec.esc_seq);
    949949                if (rc != EOK)
     
    958958                return EOK;
    959959        }
    960        
     960
    961961        return ENOENT;
    962962}
     
    971971        if (rc != EOK)
    972972                return rc;
    973        
     973
    974974        cdfs_vol_desc_t *vol_desc = (cdfs_vol_desc_t *) block->data;
    975        
     975
    976976        /*
    977977         * Test for primary volume descriptor
     
    984984                return ENOTSUP;
    985985        }
    986        
     986
    987987        uint16_t set_size = uint16_lb(vol_desc->data.prisec.set_size);
    988988        if (set_size > 1) {
     
    994994                 */
    995995        }
    996        
     996
    997997        uint16_t sequence_nr = uint16_lb(vol_desc->data.prisec.sequence_nr);
    998998        if (sequence_nr != 1) {
     
    10041004                return ENOTSUP;
    10051005        }
    1006        
     1006
    10071007        uint16_t block_size = uint16_lb(vol_desc->data.prisec.block_size);
    10081008        if (block_size != BLOCK_SIZE) {
     
    10101010                return ENOTSUP;
    10111011        }
    1012        
     1012
    10131013        // TODO: implement path table support
    1014        
     1014
    10151015        /* Search for Joliet SVD */
    1016        
     1016
    10171017        uint32_t jrlba;
    10181018        uint32_t jrsize;
    1019        
     1019
    10201020        rc = cdfs_find_joliet_svd(sid, altroot, &jrlba, &jrsize, vol_ident);
    10211021        if (rc == EOK) {
     
    10311031                    32, enc_ascii);
    10321032        }
    1033        
     1033
    10341034        block_put(block);
    10351035        return EOK;
     
    10401040{
    10411041        cdfs_node_t *node = CDFS_NODE(rfn);
    1042        
     1042
    10431043        errno_t rc = iso_read_vol_desc(fs->service_id, altroot, &node->lba,
    10441044            &node->size, &fs->enc, &fs->vol_ident);
    10451045        if (rc != EOK)
    10461046                return rc;
    1047        
     1047
    10481048        return cdfs_readdir(fs, rfn);
    10491049}
     
    10601060        if (fs == NULL)
    10611061                goto error;
    1062        
     1062
    10631063        fs->service_id = sid;
    1064        
     1064
    10651065        /* Create root node */
    10661066        errno_t rc = create_node(&rfn, fs, L_DIRECTORY, cdfs_index++);
    1067        
     1067
    10681068        if ((rc != EOK) || (!rfn))
    10691069                goto error;
    1070        
     1070
    10711071        /* FS root is not linked */
    10721072        CDFS_NODE(rfn)->lnkcnt = 0;
    10731073        CDFS_NODE(rfn)->lba = 0;
    10741074        CDFS_NODE(rfn)->processed = false;
    1075        
     1075
    10761076        /* Check if there is cdfs in given session */
    10771077        if (iso_readfs(fs, rfn, altroot) != EOK)
    10781078                goto error;
    1079        
     1079
    10801080        list_append(&fs->link, &cdfs_instances);
    10811081        return fs;
     
    10941094        if (rc != EOK)
    10951095                return rc;
    1096        
     1096
    10971097        cdfs_lba_t altroot = 0;
    1098        
     1098
    10991099        /*
    11001100         * Read TOC multisession information and get the start address
     
    11061106        if (rc == EOK && (uint16_t_be2host(toc.toc_len) == 10))
    11071107                altroot = uint32_t_be2host(toc.ftrack_lsess.start_addr);
    1108        
     1108
    11091109        /* Initialize the block cache */
    11101110        rc = block_cache_init(service_id, BLOCK_SIZE, 0, CACHE_MODE_WT);
     
    11131113                return rc;
    11141114        }
    1115        
     1115
    11161116        /* Check if this device is not already mounted */
    11171117        fs_node_t *rootfn;
     
    11231123                return EOK;
    11241124        }
    1125        
     1125
    11261126        /* Read volume descriptors */
    11271127        uint32_t rlba;
     
    11351135                return rc;
    11361136        }
    1137        
     1137
    11381138        str_cpy(info->label, FS_LABEL_MAXLEN + 1, vol_ident);
    11391139        free(vol_ident);
    1140        
     1140
    11411141        block_cache_fini(service_id);
    11421142        block_fini(service_id);
     
    11511151        if (rc != EOK)
    11521152                return rc;
    1153        
     1153
    11541154        cdfs_lba_t altroot = 0;
    1155        
     1155
    11561156        if (str_lcmp(opts, "altroot=", 8) == 0) {
    11571157                /* User-defined alternative root on a multi-session disk */
     
    11691169                        altroot = uint32_t_be2host(toc.ftrack_lsess.start_addr);
    11701170        }
    1171        
     1171
    11721172        /* Initialize the block cache */
    11731173        rc = block_cache_init(service_id, BLOCK_SIZE, 0, CACHE_MODE_WT);
     
    11761176                return rc;
    11771177        }
    1178        
     1178
    11791179        /* Check if this device is not already mounted */
    11801180        fs_node_t *rootfn;
     
    11841184                block_cache_fini(service_id);
    11851185                block_fini(service_id);
    1186                
     1186
    11871187                return EEXIST;
    11881188        }
    1189        
     1189
    11901190        /* Create cdfs instance */
    11911191        if (cdfs_fs_create(service_id, altroot) == NULL) {
    11921192                block_cache_fini(service_id);
    11931193                block_fini(service_id);
    1194                
     1194
    11951195                return ENOMEM;
    11961196        }
    1197        
     1197
    11981198        rc = cdfs_root_get(&rootfn, service_id);
    11991199        assert(rc == EOK);
    1200        
     1200
    12011201        cdfs_node_t *root = CDFS_NODE(rootfn);
    12021202        *index = root->index;
    12031203        *size = root->size;
    1204        
     1204
    12051205        return EOK;
    12061206}
     
    12101210        service_id_t service_id = *(service_id_t*)arg;
    12111211        cdfs_node_t *node = hash_table_get_inst(item, cdfs_node_t, nh_link);
    1212        
     1212
    12131213        if (node->fs->service_id == service_id) {
    12141214                hash_table_remove_item(&nodes, &node->nh_link);
    12151215        }
    1216        
     1216
    12171217        return true;
    12181218}
     
    12341234                        return fs;
    12351235        }
    1236        
     1236
    12371237        return NULL;
    12381238}
     
    12451245        if (fs == NULL)
    12461246                return ENOENT;
    1247        
     1247
    12481248        cdfs_fs_destroy(fs);
    12491249        return EOK;
     
    12571257                .service_id = service_id
    12581258        };
    1259        
     1259
    12601260        ht_link_t *link = hash_table_find(&nodes, &key);
    12611261        if (link == NULL)
    12621262                return ENOENT;
    1263        
     1263
    12641264        cdfs_node_t *node =
    12651265            hash_table_get_inst(link, cdfs_node_t, nh_link);
    1266        
     1266
    12671267        if (!node->processed) {
    12681268                errno_t rc = cdfs_readdir(node->fs, FS_NODE(node));
     
    12701270                        return rc;
    12711271        }
    1272        
     1272
    12731273        ipc_callid_t callid;
    12741274        size_t len;
     
    12771277                return EINVAL;
    12781278        }
    1279        
     1279
    12801280        if (node->type == CDFS_FILE) {
    12811281                if (pos >= node->size) {
     
    12851285                        cdfs_lba_t lba = pos / BLOCK_SIZE;
    12861286                        size_t offset = pos % BLOCK_SIZE;
    1287                        
     1287
    12881288                        *rbytes = min(len, BLOCK_SIZE - offset);
    12891289                        *rbytes = min(*rbytes, node->size - pos);
    1290                        
     1290
    12911291                        block_t *block;
    12921292                        errno_t rc = block_get(&block, service_id, node->lba + lba,
     
    12961296                                return rc;
    12971297                        }
    1298                        
     1298
    12991299                        async_data_read_finalize(callid, block->data + offset,
    13001300                            *rbytes);
     
    13091309                        return ENOENT;
    13101310                }
    1311                
     1311
    13121312                cdfs_dentry_t *dentry =
    13131313                    list_get_instance(link, cdfs_dentry_t, link);
    1314                
     1314
    13151315                *rbytes = 1;
    13161316                async_data_read_finalize(callid, dentry->name,
    13171317                    str_size(dentry->name) + 1);
    13181318        }
    1319        
     1319
    13201320        return EOK;
    13211321}
     
    13281328         * the operation is not supported.
    13291329         */
    1330        
     1330
    13311331        return ENOTSUP;
    13321332}
     
    13391339         * the operation is not supported.
    13401340         */
    1341        
     1341
    13421342        return ENOTSUP;
    13431343}
     
    13461346{
    13471347        size_t *premove_cnt = (size_t*)arg;
    1348        
     1348
    13491349        /* Some nodes were requested to be removed from the cache. */
    13501350        if (0 < *premove_cnt) {
     
    13531353                if (!node->opened) {
    13541354                        hash_table_remove_item(&nodes, item);
    1355                        
     1355
    13561356                        --nodes_cached;
    13571357                        --*premove_cnt;
    13581358                }
    13591359        }
    1360        
     1360
    13611361        /* Only continue if more nodes were requested to be removed. */
    13621362        return 0 < *premove_cnt;
     
    13671367        if (nodes_cached > NODE_CACHE_SIZE) {
    13681368                size_t remove_cnt = nodes_cached - NODE_CACHE_SIZE;
    1369                
     1369
    13701370                if (0 < remove_cnt)
    13711371                        hash_table_apply(&nodes, cache_remove_closed, &remove_cnt);
     
    13781378        if (index == 0)
    13791379                return EOK;
    1380        
     1380
    13811381        ht_key_t key = {
    13821382                .index = index,
    13831383                .service_id = service_id
    13841384        };
    1385        
     1385
    13861386        ht_link_t *link = hash_table_find(&nodes, &key);
    13871387        if (link == 0)
    13881388                return ENOENT;
    1389        
     1389
    13901390        cdfs_node_t *node =
    13911391            hash_table_get_inst(link, cdfs_node_t, nh_link);
    1392        
     1392
    13931393        assert(node->opened > 0);
    1394        
     1394
    13951395        node->opened--;
    13961396        cleanup_cache(service_id);
    1397        
     1397
    13981398        return EOK;
    13991399}
     
    14051405         * the operation is not supported.
    14061406         */
    1407        
     1407
    14081408        return ENOTSUP;
    14091409}
     
    14151415         * the sync operation is a no-op.
    14161416         */
    1417        
     1417
    14181418        return EOK;
    14191419}
     
    14381438        if (!hash_table_create(&nodes, 0, 0, &nodes_ops))
    14391439                return false;
    1440        
     1440
    14411441        return true;
    14421442}
  • uspace/srv/fs/exfat/exfat.c

    r3061bc1 ra35b458  
    8282                return -1;
    8383        }
    84        
     84
    8585        rc = fs_register(vfs_sess, &exfat_vfs_info, &exfat_ops, &exfat_libfs_ops);
    8686        if (rc != EOK) {
     
    8888                goto err;
    8989        }
    90        
     90
    9191        printf(NAME ": Accepting connections\n");
    9292        task_retval(0);
  • uspace/srv/fs/exfat/exfat.h

    r3061bc1 ra35b458  
    133133        /** Back pointer to the FS node. */
    134134        fs_node_t               *bp;
    135        
     135
    136136        fibril_mutex_t          lock;
    137137        exfat_node_type_t       type;
  • uspace/srv/fs/exfat/exfat_bitmap.c

    r3061bc1 ra35b458  
    5959
    6060        clst -= EXFAT_CLST_FIRST;
    61        
     61
    6262        rc = exfat_bitmap_get(&fn, service_id);
    6363        if (rc != EOK)
    6464                return rc;
    6565        bitmapp = EXFAT_NODE(fn);
    66        
     66
    6767        aoff64_t offset = clst / 8;
    6868        rc = exfat_block_get(&b, bs, bitmapp, offset / BPS(bs), BLOCK_FLAGS_NONE);
     
    9999
    100100        clst -= EXFAT_CLST_FIRST;
    101        
     101
    102102        rc = exfat_bitmap_get(&fn, service_id);
    103103        if (rc != EOK)
    104104                return rc;
    105105        bitmapp = EXFAT_NODE(fn);
    106        
     106
    107107        aoff64_t offset = clst / 8;
    108108        rc = exfat_block_get(&b, bs, bitmapp, offset / BPS(bs), BLOCK_FLAGS_NONE);
     
    120120                return rc;
    121121        }
    122        
     122
    123123        return exfat_node_put(fn);
    124124}
     
    134134
    135135        clst -= EXFAT_CLST_FIRST;
    136        
     136
    137137        rc = exfat_bitmap_get(&fn, service_id);
    138138        if (rc != EOK)
    139139                return rc;
    140140        bitmapp = EXFAT_NODE(fn);
    141        
     141
    142142        aoff64_t offset = clst / 8;
    143143        rc = exfat_block_get(&b, bs, bitmapp, offset / BPS(bs),
     
    156156                return rc;
    157157        }
    158        
     158
    159159        return exfat_node_put(fn);
    160160}
  • uspace/srv/fs/exfat/exfat_directory.c

    r3061bc1 ra35b458  
    9191{
    9292        errno_t rc = EOK;
    93        
     93
    9494        if (di->b) {
    9595                rc = block_put(di->b);
    9696                di->b = NULL;
    9797        }
    98        
     98
    9999        return rc;
    100100}
     
    141141        if (rc != EOK)
    142142                di->pos -= 1;
    143        
     143
    144144        return rc;
    145145}
     
    148148{
    149149        errno_t rc = EOK;
    150        
     150
    151151        if (di->pos > 0) {
    152152                di->pos -= 1;
     
    154154        } else
    155155                return ENOENT;
    156        
     156
    157157        if (rc != EOK)
    158158                di->pos += 1;
    159        
     159
    160160        return rc;
    161161}
     
    170170        if (rc != EOK)
    171171                di->pos = _pos;
    172        
     172
    173173        return rc;
    174174}
     
    177177{
    178178        errno_t rc;
    179        
     179
    180180        rc = exfat_directory_block_load(di);
    181181        if (rc == EOK) {
     
    183183                *d = ((exfat_dentry_t *)di->b->data) + o;
    184184        }
    185        
     185
    186186        return rc;
    187187}
     
    197197                        return ENOENT;
    198198        } while (exfat_directory_next(di) == EOK);
    199        
     199
    200200        return ENOENT;
    201201}
     
    222222        size_t offset = 0;
    223223        aoff64_t start_pos = 0;
    224        
     224
    225225        rc = exfat_directory_find(di, EXFAT_DENTRY_FILE, &d);
    226226        if (rc != EOK)
     
    238238                return ENOENT;
    239239        *ds  = d->stream;
    240        
     240
    241241        if (ds->name_size > size)
    242242                return EOVERFLOW;
     
    470470                di->b->dirty = true;
    471471        }
    472        
     472
    473473        return exfat_directory_seek(di, pos);
    474474}
     
    486486                return rc;
    487487        count = de->file.count + 1;
    488        
     488
    489489        while (count) {
    490490                rc = exfat_directory_get(di, &de);
     
    517517        di->nodep->dirty = true;                /* need to sync node */
    518518        di->blocks = di->nodep->size / BPS(di->bs);
    519        
     519
    520520        return EOK;
    521521}
  • uspace/srv/fs/exfat/exfat_fat.c

    r3061bc1 ra35b458  
    516516        blocks = ROUND_UP(nodep->size, BPS(bs))/BPS(bs);
    517517        count = BPS(bs);
    518        
     518
    519519        for (i = 0; i < blocks; i++) {
    520520                rc = exfat_block_get(&b, bs, nodep, i, BLOCK_FLAGS_NOREAD);
  • uspace/srv/fs/exfat/exfat_idx.c

    r3061bc1 ra35b458  
    120120{
    121121        pos_key_t *pos = (pos_key_t*)key;
    122        
     122
    123123        size_t hash = 0;
    124124        hash = hash_combine(pos->pfc, pos->pdi);
     
    129129{
    130130        exfat_idx_t *fidx = hash_table_get_inst(item, exfat_idx_t, uph_link);
    131        
     131
    132132        pos_key_t pkey = {
    133133                .service_id = fidx->service_id,
     
    135135                .pdi = fidx->pdi,
    136136        };
    137        
     137
    138138        return pos_key_hash(&pkey);
    139139}
     
    143143        pos_key_t *pos = (pos_key_t*)key;
    144144        exfat_idx_t *fidx = hash_table_get_inst(item, exfat_idx_t, uph_link);
    145        
     145
    146146        return pos->service_id == fidx->service_id
    147147                && pos->pdi == fidx->pdi
     
    184184        exfat_idx_t *fidx = hash_table_get_inst(item, exfat_idx_t, uih_link);
    185185        idx_key_t *key = (idx_key_t*)key_arg;
    186        
     186
    187187        return key->index == fidx->index && key->service_id == fidx->service_id;
    188188}
     
    207207{
    208208        unused_t *u;
    209        
     209
    210210        assert(index);
    211211        u = unused_find(service_id, true);
     
    339339                return ENOSPC;
    340340        }
    341                
     341
    342342        fibril_mutex_initialize(&fidx->lock);
    343343        fidx->service_id = service_id;
     
    361361                return rc;
    362362        }
    363                
     363
    364364        hash_table_insert(&ui_hash, &fidx->uih_link);
    365365        fibril_mutex_lock(&fidx->lock);
     
    374374{
    375375        exfat_idx_t *fidx;
    376        
     376
    377377        pos_key_t pos_key = {
    378378                .service_id = service_id,
     
    393393                        return NULL;
    394394                }
    395                
     395
    396396                fidx->pfc = pfc;
    397397                fidx->pdi = pdi;
     
    515515                hash_table_remove_item(&up_hash, item);
    516516        }
    517        
     517
    518518        return true;
    519519}
     
    527527                hash_table_remove_item(&ui_hash, item);
    528528        }
    529        
     529
    530530        return true;
    531531}
  • uspace/srv/fs/exfat/exfat_ops.c

    r3061bc1 ra35b458  
    519519        service_id = parentp->idx->service_id;
    520520        fibril_mutex_unlock(&parentp->idx->lock);
    521        
     521
    522522        exfat_directory_t di;
    523523        rc = exfat_directory_open(parentp, &di);
     
    803803        assert(childp->lnkcnt == 1);
    804804        fibril_mutex_lock(&childp->idx->lock);
    805        
     805
    806806        exfat_directory_t di;
    807807        rc = exfat_directory_open(parentp,&di);
     
    929929        bs = block_bb_get(service_id);
    930930        *count = DATA_CNT(bs);
    931        
     931
    932932        return EOK;
    933933}
  • uspace/srv/fs/ext4fs/ext4fs.c

    r3061bc1 ra35b458  
    5656{
    5757        printf("%s: HelenOS ext4 file system server\n", NAME);
    58        
     58
    5959        if (argc == 3) {
    6060                if (!str_cmp(argv[1], "--instance"))
     
    6565                }
    6666        }
    67        
     67
    6868        async_sess_t *vfs_sess = service_connect_blocking(SERVICE_VFS,
    6969            INTERFACE_VFS_DRIVER, 0);
     
    7272                return 2;
    7373        }
    74        
     74
    7575        errno_t rc = ext4_global_init();
    7676        if (rc != EOK) {
     
    7878                return rc;
    7979        }
    80        
     80
    8181        rc = fs_register(vfs_sess, &ext4fs_vfs_info, &ext4_ops,
    8282            &ext4_libfs_ops);
     
    8585                return rc;
    8686        }
    87        
     87
    8888        printf("%s: Accepting connections\n", NAME);
    8989        task_retval(0);
    9090        async_manager();
    91        
     91
    9292        /* Not reached */
    9393        return 0;
  • uspace/srv/fs/fat/fat.c

    r3061bc1 ra35b458  
    6262{
    6363        printf(NAME ": HelenOS FAT file system server\n");
    64        
     64
    6565        if (argc == 3) {
    6666                if (!str_cmp(argv[1], "--instance"))
     
    7575        if (rc != EOK)
    7676                goto err;
    77        
     77
    7878        async_sess_t *vfs_sess = service_connect_blocking(SERVICE_VFS,
    7979            INTERFACE_VFS_DRIVER, 0);
     
    8282                return -1;
    8383        }
    84        
     84
    8585        rc = fs_register(vfs_sess, &fat_vfs_info, &fat_ops, &fat_libfs_ops);
    8686        if (rc != EOK) {
     
    8888                goto err;
    8989        }
    90        
     90
    9191        printf(NAME ": Accepting connections\n");
    9292        task_retval(0);
    9393        async_manager();
    94        
     94
    9595        /* Not reached */
    9696        return 0;
    97        
     97
    9898err:
    9999        printf(NAME ": Failed to register file system: %s\n", str_error(rc));
  • uspace/srv/fs/fat/fat.h

    r3061bc1 ra35b458  
    213213        /** Back pointer to the FS node. */
    214214        fs_node_t               *bp;
    215        
     215
    216216        fibril_mutex_t          lock;
    217217        fat_node_type_t         type;
  • uspace/srv/fs/fat/fat_dentry.c

    r3061bc1 ra35b458  
    8181{
    8282        unsigned int i;
    83        
     83
    8484        for (i = 0; i < FAT_NAME_LEN; i++) {
    8585                if (d->name[i] == FAT_PAD)
    8686                        break;
    87                
     87
    8888                if (d->name[i] == FAT_DENTRY_E5_ESC)
    8989                        *buf++ = 0xe5;
     
    9595                }
    9696        }
    97        
     97
    9898        if (d->ext[0] != FAT_PAD)
    9999                *buf++ = '.';
    100        
     100
    101101        for (i = 0; i < FAT_EXT_LEN; i++) {
    102102                if (d->ext[i] == FAT_PAD) {
     
    104104                        return;
    105105                }
    106                
     106
    107107                if (d->ext[i] == FAT_DENTRY_E5_ESC)
    108108                        *buf++ = 0xe5;
     
    114114                }
    115115        }
    116        
     116
    117117        *buf = '\0';
    118118}
     
    124124        bool lower_name = true;
    125125        bool lower_ext = true;
    126        
     126
    127127        for (i = 0; i < FAT_NAME_LEN; i++) {
    128128                switch ((uint8_t) *name) {
     
    140140                                        lower_name = false;
    141141                        }
    142                        
     142
    143143                        d->name[i] = toupper(*name++);
    144144                        break;
    145145                }
    146146        }
    147        
     147
    148148        if (*name++ != '.')
    149149                name = fake_ext;
    150        
     150
    151151        for (i = 0; i < FAT_EXT_LEN; i++) {
    152152                switch ((uint8_t) *name) {
     
    163163                                        lower_ext = false;
    164164                        }
    165                        
     165
    166166                        d->ext[i] = toupper(*name++);
    167167                        break;
    168168                }
    169169        }
    170        
     170
    171171        if (lower_name)
    172172                d->lcase |= FAT_LCASE_LOWER_NAME;
    173173        else
    174174                d->lcase &= ~FAT_LCASE_LOWER_NAME;
    175        
     175
    176176        if (lower_ext)
    177177                d->lcase |= FAT_LCASE_LOWER_EXT;
     
    183183{
    184184        unsigned int i;
    185        
     185
    186186        for (i = 0; i < FAT_NAME_LEN; i++) {
    187187                if (d->name[i] == FAT_PAD)
    188188                        break;
    189                
     189
    190190                if (d->name[i] == FAT_DENTRY_E5_ESC)
    191191                        *buf++ = 0xe5;
     
    193193                        *buf++ = d->name[i];
    194194        }
    195        
     195
    196196        for (i = 0; i < FAT_EXT_LEN; i++) {
    197197                if (d->ext[i] == FAT_PAD) {
     
    199199                        return;
    200200                }
    201                
     201
    202202                if (d->ext[i] == FAT_DENTRY_E5_ESC)
    203203                        *buf++ = 0xe5;
     
    205205                        *buf++ = d->ext[i];
    206206        }
    207        
     207
    208208        *buf = '\0';
    209209}
     
    291291{
    292292        size_t size = 0;
    293        
     293
    294294        size += fat_lfn_str_nlength(FAT_LFN_PART1(d), FAT_LFN_PART1_SIZE);
    295295        size += fat_lfn_str_nlength(FAT_LFN_PART2(d), FAT_LFN_PART2_SIZE);
    296296        size += fat_lfn_str_nlength(FAT_LFN_PART3(d), FAT_LFN_PART3_SIZE);
    297        
     297
    298298        return size;
    299299}
     
    354354        d->lfn.type = 0;
    355355        d->lfn.firstc_lo = 0;
    356        
     356
    357357        return *offset;
    358358}
     
    363363        size_t off = 0;
    364364        size_t i = 0;
    365        
     365
    366366        while (i < count) {
    367367                if ((ch = str_decode(src, &off, STR_NO_LIMIT)) != 0) {
     
    384384        size_t offset=0;
    385385        bool result = true;
    386        
     386
    387387        while ((ch = str_decode(name, &offset, STR_NO_LIMIT)) != 0) {
    388388                if (str_chr(FAT_STOP_CHARS, ch) != NULL) {
  • uspace/srv/fs/fat/fat_dentry.h

    r3061bc1 ra35b458  
    6060#define FAT_ATTR_LFN \
    6161    (FAT_ATTR_RDONLY | FAT_ATTR_HIDDEN | FAT_ATTR_SYSTEM | FAT_ATTR_VOLLABEL)
    62    
     62
    6363#define FAT_LCASE_LOWER_NAME    0x08
    6464#define FAT_LCASE_LOWER_EXT     0x10
  • uspace/srv/fs/fat/fat_directory.c

    r3061bc1 ra35b458  
    6565{
    6666        errno_t rc = EOK;
    67        
     67
    6868        if (di->b)
    6969                rc = block_put(di->b);
    70        
     70
    7171        return rc;
    7272}
     
    106106        if (rc != EOK)
    107107                di->pos -= 1;
    108        
     108
    109109        return rc;
    110110}
     
    113113{
    114114        errno_t rc = EOK;
    115        
     115
    116116        if (di->pos > 0) {
    117117                di->pos -= 1;
     
    119119        } else
    120120                return ENOENT;
    121        
     121
    122122        if (rc != EOK)
    123123                di->pos += 1;
    124        
     124
    125125        return rc;
    126126}
     
    135135        if (rc != EOK)
    136136                di->pos = _pos;
    137        
     137
    138138        return rc;
    139139}
     
    142142{
    143143        errno_t rc;
    144        
     144
    145145        rc = fat_directory_block_load(di);
    146146        if (rc == EOK) {
     
    148148                *d = ((fat_dentry_t *)di->b->data) + o;
    149149        }
    150        
     150
    151151        return rc;
    152152}
     
    168168        assert(rc == EOK);
    169169        instance = (fat_instance_t *) data;
    170        
     170
    171171        do {
    172172                rc = fat_directory_get(di, &d);
     
    220220                        } else
    221221                                fat_dentry_name_get(d, name);
    222                                
     222
    223223                        *de = d;
    224224                        return EOK;
     
    232232                }
    233233        } while (fat_directory_next(di) == EOK);
    234        
     234
    235235        return ENOENT;
    236236}
     
    250250        d->name[0] = FAT_DENTRY_ERASED;
    251251        di->b->dirty = true;
    252        
     252
    253253        while (!flag && fat_directory_prev(di) == EOK) {
    254254                if (fat_directory_get(di, &d) == EOK &&
     
    276276        assert(rc == EOK);
    277277        instance = (fat_instance_t *) data;
    278        
     278
    279279        if (fat_valid_short_name(name)) {
    280280                /*
     
    296296                uint16_t wname[FAT_LFN_NAME_LEN];
    297297                size_t lfn_size, lfn_offset;
    298                
     298
    299299                rc = str_to_utf16(wname, FAT_LFN_NAME_LEN, name);
    300300                if (rc != EOK)
    301301                        return rc;
    302                
     302
    303303                lfn_size = utf16_wsize(wname);
    304304                long_entry_count = lfn_size / FAT_LFN_ENTRY_SIZE;
     
    440440        di->nodep->dirty = true;                /* need to sync node */
    441441        di->blocks = di->nodep->size / BPS(di->bs);
    442        
     442
    443443        return EOK;
    444444}
     
    450450        aoff64_t pos;
    451451        errno_t rc;
    452        
     452
    453453        do {
    454454                found = 0;
  • uspace/srv/fs/fat/fat_fat.c

    r3061bc1 ra35b458  
    344344        else
    345345                *value = (*value) & FAT12_MASK;
    346        
     346
    347347        rc = block_put(b);
    348348
     
    463463        if (offset / BPS(bs) >= SF(bs))
    464464                return ERANGE;
    465        
     465
    466466        rc = block_get(&b, service_id, RSCNT(bs) + SF(bs) * fatno +
    467467            offset / BPS(bs), BLOCK_FLAGS_NONE);
     
    687687        if (!lifo)
    688688                return ENOMEM;
    689        
     689
    690690        /*
    691691         * Search FAT1 for unused clusters.
  • uspace/srv/fs/fat/fat_idx.c

    r3061bc1 ra35b458  
    120120{
    121121        pos_key_t *pos = (pos_key_t*)key;
    122        
     122
    123123        size_t hash = 0;
    124124        hash = hash_combine(pos->pfc, pos->pdi);
     
    129129{
    130130        fat_idx_t *fidx = hash_table_get_inst(item, fat_idx_t, uph_link);
    131        
     131
    132132        pos_key_t pkey = {
    133133                .service_id = fidx->service_id,
     
    135135                .pdi = fidx->pdi,
    136136        };
    137        
     137
    138138        return pos_key_hash(&pkey);
    139139}
     
    143143        pos_key_t *pos = (pos_key_t*)key;
    144144        fat_idx_t *fidx = hash_table_get_inst(item, fat_idx_t, uph_link);
    145        
     145
    146146        return pos->service_id == fidx->service_id
    147147                && pos->pdi == fidx->pdi
     
    184184        fat_idx_t *fidx = hash_table_get_inst(item, fat_idx_t, uih_link);
    185185        idx_key_t *key = (idx_key_t*)key_arg;
    186        
     186
    187187        return key->index == fidx->index && key->service_id == fidx->service_id;
    188188}
     
    207207{
    208208        unused_t *u;
    209        
     209
    210210        assert(index);
    211211        u = unused_find(service_id, true);
     
    339339                return ENOSPC;
    340340        }
    341                
     341
    342342        fibril_mutex_initialize(&fidx->lock);
    343343        fidx->service_id = service_id;
     
    361361                return rc;
    362362        }
    363                
     363
    364364        hash_table_insert(&ui_hash, &fidx->uih_link);
    365365        fibril_mutex_lock(&fidx->lock);
     
    393393                        return NULL;
    394394                }
    395                
     395
    396396                fidx->pfc = pfc;
    397397                fidx->pdi = pdi;
     
    514514                hash_table_remove_item(&up_hash, item);
    515515        }
    516        
     516
    517517        return true;
    518518}
     
    526526                hash_table_remove_item(&ui_hash, item);
    527527        }
    528        
     528
    529529        return true;
    530530}
  • uspace/srv/fs/fat/fat_ops.c

    r3061bc1 ra35b458  
    381381        service_id = parentp->idx->service_id;
    382382        fibril_mutex_unlock(&parentp->idx->lock);
    383        
     383
    384384        fat_directory_t di;
    385385        rc = fat_directory_open(parentp, &di);
     
    716716        assert(childp->lnkcnt == 1);
    717717        fibril_mutex_lock(&childp->idx->lock);
    718        
     718
    719719        fat_directory_t di;
    720720        rc = fat_directory_open(parentp, &di);
     
    856856{
    857857        fat_bs_t *bs;
    858        
     858
    859859        bs = block_bb_get(service_id);
    860860        *count = (SPC(bs)) ? TS(bs) / SPC(bs) : 0;
     
    883883        }
    884884        *count = block_count;
    885        
     885
    886886        return EOK;
    887887}
     
    13301330        int flags = BLOCK_FLAGS_NONE;
    13311331        errno_t rc;
    1332        
     1332
    13331333        rc = fat_node_get(&fn, service_id, index);
    13341334        if (rc != EOK)
  • uspace/srv/fs/locfs/locfs.c

    r3061bc1 ra35b458  
    6363{
    6464        printf("%s: HelenOS Device Filesystem\n", NAME);
    65        
     65
    6666        if (argc == 3) {
    6767                if (!str_cmp(argv[1], "--instance"))
     
    7878                return -1;
    7979        }
    80        
     80
    8181        async_sess_t *vfs_sess = service_connect_blocking(SERVICE_VFS,
    8282            INTERFACE_VFS_DRIVER, 0);
     
    8585                return -1;
    8686        }
    87        
     87
    8888        errno_t rc = fs_register(vfs_sess, &locfs_vfs_info, &locfs_ops,
    8989            &locfs_libfs_ops);
     
    9292                return rc;
    9393        }
    94        
     94
    9595        printf("%s: Accepting connections\n", NAME);
    9696        task_retval(0);
    9797        async_manager();
    98        
     98
    9999        /* Not reached */
    100100        return 0;
  • uspace/srv/fs/locfs/locfs_ops.c

    r3061bc1 ra35b458  
    109109                return ENOMEM;
    110110        }
    111        
     111
    112112        *rfn = (fs_node_t *) malloc(sizeof(fs_node_t));
    113113        if (*rfn == NULL) {
     
    116116                return ENOMEM;
    117117        }
    118        
     118
    119119        fs_node_initialize(*rfn);
    120120        node->type = type;
    121121        node->service_id = service_id;
    122        
     122
    123123        (*rfn)->data = node;
    124124        return EOK;
     
    134134        locfs_node_t *node = (locfs_node_t *) pfn->data;
    135135        errno_t ret;
    136        
     136
    137137        if (node->service_id == 0) {
    138138                /* Root directory */
    139                
     139
    140140                loc_sdesc_t *nspaces;
    141141                size_t count = loc_get_namespaces(&nspaces);
    142                
     142
    143143                if (count > 0) {
    144144                        size_t pos;
     
    147147                                if (str_cmp(nspaces[pos].name, "") == 0)
    148148                                        continue;
    149                                
     149
    150150                                if (str_cmp(nspaces[pos].name, component) == 0) {
    151151                                        ret = locfs_node_get_internal(rfn, LOC_OBJECT_NAMESPACE, nspaces[pos].id);
     
    154154                                }
    155155                        }
    156                        
     156
    157157                        free(nspaces);
    158158                }
    159                
     159
    160160                /* Search root namespace */
    161161                service_id_t namespace;
     
    163163                if (loc_namespace_get_id("", &namespace, 0) == EOK) {
    164164                        count = loc_get_services(namespace, &svcs);
    165                        
     165
    166166                        if (count > 0) {
    167167                                size_t pos;
     
    173173                                        }
    174174                                }
    175                                
     175
    176176                                free(svcs);
    177177                        }
    178178                }
    179                
     179
    180180                *rfn = NULL;
    181181                return EOK;
    182182        }
    183        
     183
    184184        if (node->type == LOC_OBJECT_NAMESPACE) {
    185185                /* Namespace directory */
    186                
     186
    187187                loc_sdesc_t *svcs;
    188188                size_t count = loc_get_services(node->service_id, &svcs);
     
    196196                                }
    197197                        }
    198                        
     198
    199199                        free(svcs);
    200200                }
    201                
     201
    202202                *rfn = NULL;
    203203                return EOK;
    204204        }
    205        
     205
    206206        *rfn = NULL;
    207207        return EOK;
     
    216216{
    217217        locfs_node_t *node = (locfs_node_t *) fn->data;
    218        
     218
    219219        if (node->service_id == 0) {
    220220                /* Root directory */
    221221                return EOK;
    222222        }
    223        
     223
    224224        loc_object_type_t type = loc_id_probe(node->service_id);
    225        
     225
    226226        if (type == LOC_OBJECT_NAMESPACE) {
    227227                /* Namespace directory */
    228228                return EOK;
    229229        }
    230        
     230
    231231        if (type == LOC_OBJECT_SERVICE) {
    232232                /* Device node */
    233                
     233
    234234                fibril_mutex_lock(&services_mutex);
    235235                ht_link_t *lnk;
     
    242242                                return ENOMEM;
    243243                        }
    244                        
     244
    245245                        dev->service_id = node->service_id;
    246                        
     246
    247247                        /* Mark as incomplete */
    248248                        dev->sess = NULL;
    249249                        dev->refcount = 1;
    250250                        fibril_condvar_initialize(&dev->cv);
    251                        
     251
    252252                        /*
    253253                         * Insert the incomplete device structure so that other
     
    256256                         */
    257257                        hash_table_insert(&services, &dev->link);
    258                        
     258
    259259                        /*
    260260                         * Drop the mutex to allow recursive locfs requests.
    261261                         */
    262262                        fibril_mutex_unlock(&services_mutex);
    263                        
     263
    264264                        async_sess_t *sess = loc_service_connect(node->service_id,
    265265                            INTERFACE_FS, 0);
    266                        
     266
    267267                        fibril_mutex_lock(&services_mutex);
    268                        
     268
    269269                        /*
    270270                         * Notify possible waiters about this device structure
     
    272272                         */
    273273                        fibril_condvar_broadcast(&dev->cv);
    274                        
     274
    275275                        if (!sess) {
    276276                                /*
     
    280280                                hash_table_remove(&services, &node->service_id);
    281281                                fibril_mutex_unlock(&services_mutex);
    282                                
     282
    283283                                return ENOENT;
    284284                        }
    285                        
     285
    286286                        /* Set the correct session. */
    287287                        dev->sess = sess;
    288288                } else {
    289289                        service_t *dev = hash_table_get_inst(lnk, service_t, link);
    290                        
     290
    291291                        if (!dev->sess) {
    292292                                /*
     
    303303                        dev->refcount++;
    304304                }
    305                
     305
    306306                fibril_mutex_unlock(&services_mutex);
    307                
    308                 return EOK;
    309         }
    310        
     307
     308                return EOK;
     309        }
     310
    311311        return ENOENT;
    312312}
     
    322322{
    323323        assert((lflag & L_FILE) ^ (lflag & L_DIRECTORY));
    324        
     324
    325325        *rfn = NULL;
    326326        return ENOTSUP;
     
    345345{
    346346        locfs_node_t *node = (locfs_node_t *) fn->data;
    347        
     347
    348348        if (node->service_id == 0) {
    349349                size_t count = loc_count_namespaces();
     
    352352                        return EOK;
    353353                }
    354                
     354
    355355                /* Root namespace */
    356356                service_id_t namespace;
     
    362362                        }
    363363                }
    364                
     364
    365365                *has_children = false;
    366366                return EOK;
    367367        }
    368        
     368
    369369        if (node->type == LOC_OBJECT_NAMESPACE) {
    370370                size_t count = loc_count_services(node->service_id);
     
    373373                        return EOK;
    374374                }
    375                
     375
    376376                *has_children = false;
    377377                return EOK;
    378378        }
    379        
     379
    380380        *has_children = false;
    381381        return EOK;
     
    396396{
    397397        locfs_node_t *node = (locfs_node_t *) fn->data;
    398        
     398
    399399        if (node->service_id == 0)
    400400                return 0;
    401        
     401
    402402        return 1;
    403403}
     
    406406{
    407407        locfs_node_t *node = (locfs_node_t *) fn->data;
    408        
     408
    409409        return ((node->type == LOC_OBJECT_NONE) || (node->type == LOC_OBJECT_NAMESPACE));
    410410}
     
    413413{
    414414        locfs_node_t *node = (locfs_node_t *) fn->data;
    415        
     415
    416416        return (node->type == LOC_OBJECT_SERVICE);
    417417}
     
    420420{
    421421        locfs_node_t *node = (locfs_node_t *) fn->data;
    422        
     422
    423423        if (node->type == LOC_OBJECT_SERVICE)
    424424                return node->service_id;
    425        
     425
    426426        return 0;
    427427}
     
    451451        if (!hash_table_create(&services, 0,  0, &services_ops))
    452452                return false;
    453        
     453
    454454        return true;
    455455}
     
    484484                        return EINVAL;
    485485                }
    486                
     486
    487487                loc_sdesc_t *desc;
    488488                size_t count = loc_get_namespaces(&desc);
    489                
     489
    490490                /* Get rid of root namespace */
    491491                size_t i;
     
    494494                                if (pos >= i)
    495495                                        pos++;
    496                                
     496
    497497                                break;
    498498                        }
    499499                }
    500                
     500
    501501                if (pos < count) {
    502502                        async_data_read_finalize(callid, desc[pos].name, str_size(desc[pos].name) + 1);
     
    505505                        return EOK;
    506506                }
    507                
     507
    508508                free(desc);
    509509                pos -= count;
    510                
     510
    511511                /* Search root namespace */
    512512                service_id_t namespace;
    513513                if (loc_namespace_get_id("", &namespace, 0) == EOK) {
    514514                        count = loc_get_services(namespace, &desc);
    515                        
     515
    516516                        if (pos < count) {
    517517                                async_data_read_finalize(callid, desc[pos].name, str_size(desc[pos].name) + 1);
     
    520520                                return EOK;
    521521                        }
    522                        
     522
    523523                        free(desc);
    524524                }
    525                
     525
    526526                async_answer_0(callid, ENOENT);
    527527                return ENOENT;
    528528        }
    529        
     529
    530530        loc_object_type_t type = loc_id_probe(index);
    531        
     531
    532532        if (type == LOC_OBJECT_NAMESPACE) {
    533533                /* Namespace directory */
     
    538538                        return EINVAL;
    539539                }
    540                
     540
    541541                loc_sdesc_t *desc;
    542542                size_t count = loc_get_services(index, &desc);
    543                
     543
    544544                if (pos < count) {
    545545                        async_data_read_finalize(callid, desc[pos].name, str_size(desc[pos].name) + 1);
     
    548548                        return EOK;
    549549                }
    550                
     550
    551551                free(desc);
    552552                async_answer_0(callid, ENOENT);
    553553                return ENOENT;
    554554        }
    555        
     555
    556556        if (type == LOC_OBJECT_SERVICE) {
    557557                /* Device node */
    558                
     558
    559559                fibril_mutex_lock(&services_mutex);
    560560                service_id_t service_index = index;
     
    564564                        return ENOENT;
    565565                }
    566                
     566
    567567                service_t *dev = hash_table_get_inst(lnk, service_t, link);
    568568                assert(dev->sess);
    569                
     569
    570570                ipc_callid_t callid;
    571571                if (!async_data_read_receive(&callid, NULL)) {
     
    574574                        return EINVAL;
    575575                }
    576                
     576
    577577                /* Make a request at the driver */
    578578                async_exch_t *exch = async_exchange_begin(dev->sess);
    579                
     579
    580580                ipc_call_t answer;
    581581                aid_t msg = async_send_4(exch, VFS_OUT_READ, service_id,
    582582                    index, LOWER32(pos), UPPER32(pos), &answer);
    583                
     583
    584584                /* Forward the IPC_M_DATA_READ request to the driver */
    585585                async_forward_fast(callid, exch, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);
    586                
     586
    587587                async_exchange_end(exch);
    588                
     588
    589589                fibril_mutex_unlock(&services_mutex);
    590                
     590
    591591                /* Wait for reply from the driver. */
    592592                errno_t rc;
     
    596596                if ((errno_t) rc == EHANGUP)
    597597                        rc = ENOTSUP;
    598                
     598
    599599                *rbytes = IPC_GET_ARG1(answer);
    600600                return rc;
    601601        }
    602        
     602
    603603        return ENOENT;
    604604}
     
    610610        if (index == 0)
    611611                return ENOTSUP;
    612        
     612
    613613        loc_object_type_t type = loc_id_probe(index);
    614        
     614
    615615        if (type == LOC_OBJECT_NAMESPACE) {
    616616                /* Namespace directory */
    617617                return ENOTSUP;
    618618        }
    619        
     619
    620620        if (type == LOC_OBJECT_SERVICE) {
    621621                /* Device node */
    622                
     622
    623623                fibril_mutex_lock(&services_mutex);
    624624                service_id_t service_index = index;
     
    628628                        return ENOENT;
    629629                }
    630                
     630
    631631                service_t *dev = hash_table_get_inst(lnk, service_t, link);
    632632                assert(dev->sess);
    633                
     633
    634634                ipc_callid_t callid;
    635635                if (!async_data_write_receive(&callid, NULL)) {
     
    638638                        return EINVAL;
    639639                }
    640                
     640
    641641                /* Make a request at the driver */
    642642                async_exch_t *exch = async_exchange_begin(dev->sess);
    643                
     643
    644644                ipc_call_t answer;
    645645                aid_t msg = async_send_4(exch, VFS_OUT_WRITE, service_id,
    646646                    index, LOWER32(pos), UPPER32(pos), &answer);
    647                
     647
    648648                /* Forward the IPC_M_DATA_WRITE request to the driver */
    649649                async_forward_fast(callid, exch, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);
    650                
     650
    651651                async_exchange_end(exch);
    652                
     652
    653653                fibril_mutex_unlock(&services_mutex);
    654                
     654
    655655                /* Wait for reply from the driver. */
    656656                errno_t rc;
     
    660660                if ((errno_t) rc == EHANGUP)
    661661                        rc = ENOTSUP;
    662                
     662
    663663                *wbytes = IPC_GET_ARG1(answer);
    664664                *nsize = 0;
    665665                return rc;
    666666        }
    667        
     667
    668668        return ENOENT;
    669669}
     
    679679        if (index == 0)
    680680                return EOK;
    681        
     681
    682682        loc_object_type_t type = loc_id_probe(index);
    683        
     683
    684684        if (type == LOC_OBJECT_NAMESPACE) {
    685685                /* Namespace directory */
    686686                return EOK;
    687687        }
    688        
     688
    689689        if (type == LOC_OBJECT_SERVICE) {
    690                
     690
    691691                fibril_mutex_lock(&services_mutex);
    692692                service_id_t service_index = index;
     
    696696                        return ENOENT;
    697697                }
    698                
     698
    699699                service_t *dev = hash_table_get_inst(lnk, service_t, link);
    700700                assert(dev->sess);
    701701                dev->refcount--;
    702                
     702
    703703                if (dev->refcount == 0) {
    704704                        async_hangup(dev->sess);
     
    706706                        hash_table_remove(&services, &service_index);
    707707                }
    708                
     708
    709709                fibril_mutex_unlock(&services_mutex);
    710                
    711                 return EOK;
    712         }
    713        
     710
     711                return EOK;
     712        }
     713
    714714        return ENOENT;
    715715}
     
    719719        if (index == 0)
    720720                return EOK;
    721        
     721
    722722        loc_object_type_t type = loc_id_probe(index);
    723        
     723
    724724        if (type == LOC_OBJECT_NAMESPACE) {
    725725                /* Namespace directory */
    726726                return EOK;
    727727        }
    728        
     728
    729729        if (type == LOC_OBJECT_SERVICE) {
    730730
     
    736736                        return ENOENT;
    737737                }
    738                
     738
    739739                service_t *dev = hash_table_get_inst(lnk, service_t, link);
    740740                assert(dev->sess);
    741                
     741
    742742                /* Make a request at the driver */
    743743                async_exch_t *exch = async_exchange_begin(dev->sess);
    744                
     744
    745745                ipc_call_t answer;
    746746                aid_t msg = async_send_2(exch, VFS_OUT_SYNC, service_id,
    747747                    index, &answer);
    748                
     748
    749749                async_exchange_end(exch);
    750                
     750
    751751                fibril_mutex_unlock(&services_mutex);
    752                
     752
    753753                /* Wait for reply from the driver */
    754754                errno_t rc;
    755755                async_wait_for(msg, &rc);
    756                
     756
    757757                return rc;
    758758        }
    759        
     759
    760760        return  ENOENT;
    761761}
  • uspace/srv/fs/mfs/mfs_ops.c

    r3061bc1 ra35b458  
    617617                .index = index
    618618        };
    619        
     619
    620620        ht_link_t *already_open = hash_table_find(&open_nodes, &key);
    621621
     
    974974                if (r != EOK)
    975975                        goto out_err;
    976                
     976
    977977                r = mfs_write_map(mnode, pos, block, &dummy);
    978978                if (r != EOK) {
     
    12021202        if (NULL == inst)
    12031203                return ENOENT;
    1204        
     1204
    12051205        *size = inst->sbi->block_size;
    12061206
     
    12131213        struct mfs_instance *inst;
    12141214        errno_t rc;
    1215        
     1215
    12161216        rc = mfs_instance_get(service_id, &inst);
    12171217        if (rc != EOK)
     
    12201220        if (NULL == inst)
    12211221                return ENOENT;
    1222        
     1222
    12231223        *count = (uint64_t) MFS_BMAP_SIZE_BITS(inst->sbi, BMAP_ZONE);
    12241224
     
    12301230{
    12311231        uint32_t block_free;
    1232        
     1232
    12331233        struct mfs_instance *inst;
    12341234        errno_t rc = mfs_instance_get(service_id, &inst);
  • uspace/srv/fs/mfs/mfs_rw.c

    r3061bc1 ra35b458  
    249249
    250250        mfs_version_t fs_version = sbi->fs_version;
    251        
     251
    252252        assert(new_size <= ino_i->i_size);
    253253
  • uspace/srv/fs/tmpfs/tmpfs.c

    r3061bc1 ra35b458  
    7575                }
    7676        }
    77        
     77
    7878        if (!tmpfs_init()) {
    7979                printf(NAME ": failed to initialize TMPFS\n");
    8080                return -1;
    8181        }
    82        
     82
    8383        async_sess_t *vfs_sess = service_connect_blocking(SERVICE_VFS,
    8484            INTERFACE_VFS_DRIVER, 0);
     
    8787                return -1;
    8888        }
    89        
     89
    9090        errno_t rc = fs_register(vfs_sess, &tmpfs_vfs_info, &tmpfs_ops,
    9191            &tmpfs_libfs_ops);
     
    9494                return rc;
    9595        }
    96        
     96
    9797        printf(NAME ": Accepting connections\n");
    9898        task_retval(0);
    9999        async_manager();
    100        
     100
    101101        /* Not reached */
    102102        return 0;
  • uspace/srv/fs/tmpfs/tmpfs_dump.c

    r3061bc1 ra35b458  
    6464        libfs_ops_t *ops = &tmpfs_libfs_ops;
    6565        errno_t rc;
    66        
     66
    6767        do {
    6868                char *fname;
     
    7070                tmpfs_node_t *nodep;
    7171                uint32_t size;
    72                
     72
    7373                if (block_seqread(dsid, tmpfs_buf, bufpos, buflen, pos, &entry,
    7474                    sizeof(entry)) != EOK)
    7575                        return false;
    76                
     76
    7777                entry.len = uint32_t_le2host(entry.len);
    78                
     78
    7979                switch (entry.type) {
    8080                case TMPFS_NONE:
     
    8484                        if (fname == NULL)
    8585                                return false;
    86                        
     86
    8787                        rc = ops->create(&fn, dsid, L_FILE);
    8888                        if (rc != EOK || fn == NULL) {
     
    9090                                return false;
    9191                        }
    92                        
     92
    9393                        if (block_seqread(dsid, tmpfs_buf, bufpos, buflen, pos, fname,
    9494                            entry.len) != EOK) {
     
    9898                        }
    9999                        fname[entry.len] = 0;
    100                        
     100
    101101                        rc = ops->link(pfn, fn, fname);
    102102                        if (rc != EOK) {
     
    106106                        }
    107107                        free(fname);
    108                        
     108
    109109                        if (block_seqread(dsid, tmpfs_buf, bufpos, buflen, pos, &size,
    110110                            sizeof(size)) != EOK)
    111111                                return false;
    112                        
     112
    113113                        size = uint32_t_le2host(size);
    114                        
     114
    115115                        nodep = TMPFS_NODE(fn);
    116116                        nodep->data = malloc(size);
    117117                        if (nodep->data == NULL)
    118118                                return false;
    119                        
     119
    120120                        nodep->size = size;
    121121                        if (block_seqread(dsid, tmpfs_buf, bufpos, buflen, pos, nodep->data,
    122122                            size) != EOK)
    123123                                return false;
    124                        
     124
    125125                        break;
    126126                case TMPFS_DIRECTORY:
     
    128128                        if (fname == NULL)
    129129                                return false;
    130                        
     130
    131131                        rc = ops->create(&fn, dsid, L_DIRECTORY);
    132132                        if (rc != EOK || fn == NULL) {
     
    134134                                return false;
    135135                        }
    136                        
     136
    137137                        if (block_seqread(dsid, tmpfs_buf, bufpos, buflen, pos, fname,
    138138                            entry.len) != EOK) {
     
    150150                        }
    151151                        free(fname);
    152                        
     152
    153153                        if (!tmpfs_restore_recursion(dsid, bufpos, buflen, pos,
    154154                            fn))
    155155                                return false;
    156                        
     156
    157157                        break;
    158158                default:
     
    160160                }
    161161        } while (entry.type != TMPFS_NONE);
    162        
     162
    163163        return true;
    164164}
     
    173173        if (rc != EOK)
    174174                return false;
    175        
     175
    176176        size_t bufpos = 0;
    177177        size_t buflen = 0;
    178178        aoff64_t pos = 0;
    179        
     179
    180180        char tag[6];
    181181        if (block_seqread(dsid, tmpfs_buf, &bufpos, &buflen, &pos, tag, 5) != EOK)
    182182                goto error;
    183        
     183
    184184        tag[5] = 0;
    185185        if (str_cmp(tag, "TMPFS") != 0)
    186186                goto error;
    187        
     187
    188188        rc = ops->root_get(&fn, dsid);
    189189        if (rc != EOK)
     
    192192        if (!tmpfs_restore_recursion(dsid, &bufpos, &buflen, &pos, fn))
    193193                goto error;
    194                
     194
    195195        block_fini(dsid);
    196196        return true;
    197        
     197
    198198error:
    199199        block_fini(dsid);
  • uspace/srv/fs/tmpfs/tmpfs_ops.c

    r3061bc1 ra35b458  
    163163        tmpfs_node_t *node = hash_table_get_inst(item, tmpfs_node_t, nh_link);
    164164        node_key_t *key = (node_key_t *)key_arg;
    165        
     165
    166166        return key->service_id == node->service_id && key->index == node->index;
    167167}
     
    220220        if (!hash_table_create(&nodes, 0, 0, &nodes_ops))
    221221                return false;
    222        
     222
    223223        return true;
    224224}
     
    228228        fs_node_t *rfn;
    229229        errno_t rc;
    230        
     230
    231231        rc = tmpfs_create_node(&rfn, service_id, L_DIRECTORY);
    232232        if (rc != EOK || !rfn)
     
    240240        service_id_t sid = *(service_id_t*)arg;
    241241        tmpfs_node_t *node = hash_table_get_inst(item, tmpfs_node_t, nh_link);
    242        
     242
    243243        if (node->service_id == sid) {
    244244                hash_table_remove_item(&nodes, &node->nh_link);
     
    273273                .index = index
    274274        };
    275        
     275
    276276        ht_link_t *lnk = hash_table_find(&nodes, &key);
    277        
     277
    278278        if (lnk) {
    279279                tmpfs_node_t *nodep;
     
    338338{
    339339        tmpfs_node_t *nodep = TMPFS_NODE(fn);
    340        
     340
    341341        assert(!nodep->lnkcnt);
    342342        assert(list_empty(&nodep->cs_list));
    343        
     343
    344344        hash_table_remove_item(&nodes, &nodep->nh_link);
    345345
     
    406406        if (!childp)
    407407                return ENOENT;
    408                
     408
    409409        if ((childp->lnkcnt == 1) && !list_empty(&childp->cs_list))
    410410                return ENOTEMPTY;
     
    432432        fs_node_t *rootfn;
    433433        errno_t rc;
    434        
     434
    435435        /* Check if this device is not already mounted. */
    436436        rc = tmpfs_root_get(&rootfn, service_id);
     
    474474                .index = index
    475475        };
    476        
     476
    477477        ht_link_t *hlp = hash_table_find(&nodes, &key);
    478478        if (!hlp)
    479479                return ENOENT;
    480        
     480
    481481        tmpfs_node_t *nodep = hash_table_get_inst(hlp, tmpfs_node_t, nh_link);
    482        
     482
    483483        /*
    484484         * Receive the read request.
     
    499499                tmpfs_dentry_t *dentryp;
    500500                link_t *lnk;
    501                
     501
    502502                assert(nodep->type == TMPFS_DIRECTORY);
    503                
     503
    504504                /*
    505505                 * Yes, we really use O(n) algorithm here.
     
    508508                 */
    509509                lnk = list_nth(&nodep->cs_list, pos);
    510                
     510
    511511                if (lnk == NULL) {
    512512                        async_answer_0(callid, ENOENT);
     
    536536                .index = index
    537537        };
    538        
     538
    539539        ht_link_t *hlp = hash_table_find(&nodes, &key);
    540        
     540
    541541        if (!hlp)
    542542                return ENOENT;
    543        
     543
    544544        tmpfs_node_t *nodep = hash_table_get_inst(hlp, tmpfs_node_t, nh_link);
    545545
     
    599599                .index = index
    600600        };
    601        
     601
    602602        ht_link_t *hlp = hash_table_find(&nodes, &key);
    603        
     603
    604604        if (!hlp)
    605605                return ENOENT;
    606606        tmpfs_node_t *nodep = hash_table_get_inst(hlp, tmpfs_node_t, nh_link);
    607        
     607
    608608        if (size == nodep->size)
    609609                return EOK;
    610        
     610
    611611        if (size > SIZE_MAX)
    612612                return ENOMEM;
    613        
     613
    614614        void *newdata = realloc(nodep->data, size);
    615615        if (!newdata)
    616616                return ENOMEM;
    617        
     617
    618618        if (size > nodep->size) {
    619619                size_t delta = size - nodep->size;
    620620                memset(newdata + nodep->size, 0, delta);
    621621        }
    622        
     622
    623623        nodep->size = size;
    624624        nodep->data = newdata;
     
    637637                .index = index
    638638        };
    639        
     639
    640640        ht_link_t *hlp = hash_table_find(&nodes, &key);
    641641        if (!hlp)
  • uspace/srv/fs/udf/udf.c

    r3061bc1 ra35b458  
    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 ra35b458  
    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 ra35b458  
    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 ra35b458  
    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 ra35b458  
    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 ra35b458  
    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 ra35b458  
    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 ra35b458  
    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.